Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SchemaLibraryImpl.java')
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SchemaLibraryImpl.java157
1 files changed, 0 insertions, 157 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SchemaLibraryImpl.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SchemaLibraryImpl.java
deleted file mode 100644
index 66c88c7232..0000000000
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/SchemaLibraryImpl.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jaxb.core.internal;
-
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.jaxb.core.JaxbProject;
-import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
-import org.eclipse.jpt.jaxb.core.SchemaEntry;
-import org.eclipse.jpt.jaxb.core.SchemaLibrary;
-import org.eclipse.jpt.jaxb.core.internal.validation.DefaultValidationMessages;
-import org.eclipse.jpt.jaxb.core.internal.validation.JaxbValidationMessages;
-import org.eclipse.jpt.jaxb.core.xsd.XsdSchema;
-import org.eclipse.jpt.jaxb.core.xsd.XsdUtil;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-public class SchemaLibraryImpl
- implements SchemaLibrary {
-
- private JaxbProject project;
-
- private final List<SchemaEntryImpl> schemaEntries;
-
- private final Map<String, SchemaEntryImpl> impliedEntries;
-
-
- SchemaLibraryImpl(JaxbProject project) {
- this.project = project;
- this.schemaEntries = new Vector<SchemaEntryImpl>();
- this.impliedEntries = new Hashtable<String, SchemaEntryImpl>();
- readProjectPreferences();
- }
-
-
- public List<SchemaEntry> getSchemaEntries() {
- return Collections.<SchemaEntry>unmodifiableList(this.schemaEntries);
- }
-
- public List<String> getSchemaLocations() {
- return Collections.unmodifiableList(
- CollectionTools.list(
- new TransformationIterable<SchemaEntry, String>(this.schemaEntries) {
- @Override
- protected String transform(SchemaEntry o) {
- return o.getLocation();
- }
- }));
- }
-
- public void setSchemaLocations(List<String> schemaLocations) {
- for (SchemaEntryImpl entry : this.schemaEntries) {
- entry.dispose();
- }
- this.schemaEntries.clear();
- JptJaxbCorePlugin.setSchemaLocations(this.project.getProject(), schemaLocations);
- readProjectPreferences();
- }
-
- public XsdSchema getSchema(String namespace) {
- for (SchemaEntry entry : this.schemaEntries) {
- if (StringTools.stringsAreEqual(namespace, entry.getNamespace())) {
- return entry.getXsdSchema(namespace);
- }
- }
-
- if (! this.impliedEntries.containsKey(namespace)) {
- if (! StringTools.stringsAreEqual(XsdUtil.getResolvedUri(namespace), namespace)) {
- // the namespace itself resolves to a location. add it as an implied entry
- this.impliedEntries.put(namespace, new SchemaEntryImpl(namespace));
- }
- else {
- return null;
- }
- }
-
- return this.impliedEntries.get(namespace).getXsdSchema(namespace);
- }
-
- protected void readProjectPreferences() {
- List<String> schemas = JptJaxbCorePlugin.getSchemaLocations(this.project.getProject());
- for (String schemaLocation : schemas) {
- SchemaEntryImpl entry = new SchemaEntryImpl(schemaLocation);
- this.schemaEntries.add(entry);
- }
- }
-
- public void refreshSchema(String namespace) {
- for (SchemaEntryImpl entry : this.schemaEntries) {
- if (StringTools.stringsAreEqual(namespace, entry.getNamespace())) {
- entry.refresh();
- }
- }
- }
-
- public void refreshAllSchemas() {
- for (SchemaEntryImpl entry : this.schemaEntries) {
- entry.refresh();
- }
- }
-
- void dispose() {
- for (SchemaEntryImpl entry : this.schemaEntries) {
- entry.dispose();
- }
- for (SchemaEntryImpl entry : this.impliedEntries.values()) {
- entry.dispose();
- }
-
- this.schemaEntries.clear();
- this.impliedEntries.clear();
- }
-
- public void validate(List<IMessage> messages) {
- Bag<String> namespaces = new HashBag<String>();
-
- for (SchemaEntry entry : this.schemaEntries) {
- namespaces.add(entry.getNamespace());
-
- if (! entry.isLoaded()) {
- messages.add(
- DefaultValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.PROJECT__UNRESOLVED_SCHEMA,
- new String[] { entry.getLocation() },
- this.project));
- }
- }
-
- for (Iterator<String> stream = namespaces.uniqueIterator(); stream.hasNext(); ) {
- String namespace = stream.next();
- if (namespaces.count(namespace) > 1) {
- messages.add(
- DefaultValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JaxbValidationMessages.PROJECT__DUPLICATE_NAMESPACE,
- new String[] { namespace },
- this.project));
- }
- }
- }
-}

Back to the top