diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common')
211 files changed, 0 insertions, 24935 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/JSFCommonPlugin.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/JSFCommonPlugin.java deleted file mode 100644 index 83e040791..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/JSFCommonPlugin.java +++ /dev/null @@ -1,332 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.emf.common.EMFPlugin; -import org.eclipse.emf.common.util.ResourceLocator; -import org.eclipse.jst.jsf.context.symbol.source.AbstractContextSymbolFactory; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolSourceProvider; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolSourceProviderFactory; -import org.osgi.framework.Bundle; - -/** - * This is the central singleton for the My edit plugin. - * <!-- begin-user-doc --> - * This class is not API. - * <!-- end-user-doc --> - * @generated - */ -public final class JSFCommonPlugin extends EMFPlugin { - - /** - * Plugin id - */ - public static final String PLUGIN_ID = "org.eclipse.jst.jsf.common"; //$NON-NLS-1$ - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright 2006 Oracle"; //$NON-NLS-1$ - - private static List<ISymbolSourceProviderFactory> registeredSymbolSourceProviders; - private static Map<String,AbstractContextSymbolFactory> registeredSymbolFactories; - - private final static String FACTORY_ATTRIBUTE_NAME = "factory"; //$NON-NLS-1$ - private final static String FACTORY_ATTRIBUTE_ID_NAME = "factoryId"; //$NON-NLS-1$ - private final static String SYMBOL_SOURCE_ID = "symbolSourceId"; //$NON-NLS-1$ - private final static String CONTEXT_SYMBOL_FACTORY = "contextSymbolFactory"; //$NON-NLS-1$ - /** - * Keep track of the singleton. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final JSFCommonPlugin INSTANCE = new JSFCommonPlugin(); - - /** - * Keep track of the singleton. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static Implementation plugin; - - /** - * Create the instance. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public JSFCommonPlugin() { - super - (new ResourceLocator [] { - }); - } - - /** - * Returns the singleton instance of the Eclipse plugin. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the singleton instance. - * @generated - */ - public ResourceLocator getPluginResourceLocator() { - return plugin; - } - - /** - * Returns the singleton instance of the Eclipse plugin. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the singleton instance. - * @generated - */ - public static Implementation getPlugin() { - return plugin; - } - - /** - * @param e - * @param msg - */ - public static void log(final Exception e, final String msg) { - final ILog log = getPlugin().getLog(); - - log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, e)); - } - - /** - * Logs using the default ILog implementation provided by getLog(). - * - * @param severity Severity (IStatus constant) of log entry - * @param message Human-readable message describing log entry - * @param ex Throwable instance (can be null) - */ - public static void log(int severity, String message, Throwable ex) { - getPlugin().getLog().log(new Status(severity, PLUGIN_ID, IStatus.OK, message, ex)); - } - - /** - * Logs using the default ILog implementation provided by getLog(). - * - * @param severity Severity (IStatus constant) of log entry - * @param message Human-readable message describing log entry - */ - public static void log(int severity, String message) { - log(severity, message, null); - } - /** - * @return all registered symbol source providers - */ - public static ISymbolSourceProvider[] getSymbolSourceProvider() - { - return registeredSymbolSourceProviders.toArray(new ISymbolSourceProvider[0]); - } - - /** - * @return all registered symbol source providers - */ - public synchronized static List<ISymbolSourceProviderFactory> getSymbolSourceProviders() - { - if (registeredSymbolSourceProviders == null) - { - registerProviders(); - if (registeredSymbolSourceProviders == null) - { - throw new AssertionError("registerProviders failed"); //$NON-NLS-1$ - } - } - return Collections.unmodifiableList(registeredSymbolSourceProviders); - } - - private static void registerProviders() - { - final IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(plugin.getBundle().getSymbolicName(), Implementation.SYMBOL_SOURCE_EXT_ID); - final IExtension[] extensions = point.getExtensions(); - registeredSymbolSourceProviders = new ArrayList<ISymbolSourceProviderFactory>(extensions.length); - - for (int i = 0; i < extensions.length; i++) - { - final IExtension extension = extensions[i]; - final IConfigurationElement[] elements = - extension.getConfigurationElements(); - final String bundleId = extension.getContributor().getName(); - - for (int j = 0; j < elements.length; j++) - { - final IConfigurationElement element = elements[j]; - if (SYMBOL_SOURCE_ID.equals(element.getName()) - && element.getAttribute(FACTORY_ATTRIBUTE_NAME) != null) - { - String factoryClassName = element.getAttribute(FACTORY_ATTRIBUTE_NAME); - final Bundle bundle = Platform.getBundle(bundleId); - - if (bundle != null) - { - try - { - Class factoryClass = bundle.loadClass(factoryClassName); - - ISymbolSourceProviderFactory factory = - (ISymbolSourceProviderFactory) factoryClass.newInstance(); - - registeredSymbolSourceProviders.add(factory); - } - catch (Exception e) - { - plugin.log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), 0, "Error loading symbol provider extension point",e)); //$NON-NLS-1$ - } - } - } - } - } - } - - /** - * @return the list of registed symbol factories - */ - public synchronized static Map<String, AbstractContextSymbolFactory> getSymbolFactories() - { - if (registeredSymbolFactories == null) - { - registerSymbolFactories(); - if (registeredSymbolFactories == null) - { - throw new AssertionError("registerProviders failed"); //$NON-NLS-1$ - } - } - return Collections.unmodifiableMap(registeredSymbolFactories); - } - - private static void registerSymbolFactories() - { - final IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(plugin.getBundle().getSymbolicName(), Implementation.SYMBOL_FACTORY_EXT_ID); - final IExtension[] extensions = point.getExtensions(); - registeredSymbolFactories = new HashMap<String, AbstractContextSymbolFactory>(extensions.length); - - for (int i = 0; i < extensions.length; i++) - { - final IExtension extension = extensions[i]; - final IConfigurationElement[] elements = - extension.getConfigurationElements(); - final String bundleId = extension.getContributor().getName(); - - for (int j = 0; j < elements.length; j++) - { - final IConfigurationElement element = elements[j]; - if (CONTEXT_SYMBOL_FACTORY.equals(element.getName()) - && element.getAttribute(FACTORY_ATTRIBUTE_NAME) != null) - { - final String factoryClassName = element.getAttribute(FACTORY_ATTRIBUTE_NAME); - final String factoryId = element.getAttribute(FACTORY_ATTRIBUTE_ID_NAME); - final Bundle bundle = Platform.getBundle(bundleId); - - if (bundle != null) - { - try { - Class factoryClass = bundle.loadClass(factoryClassName); - - AbstractContextSymbolFactory factory = - (AbstractContextSymbolFactory) factoryClass.newInstance(); - registeredSymbolFactories.put(factoryId, factory); - } catch (InstantiationException e) { - plugin.log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), 0, "Error loading symbol factory extension point",e)); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - plugin.log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), 0, "Error loading symbol factory extension point",e)); //$NON-NLS-1$ - } catch (ClassNotFoundException e) { - plugin.log(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), 0, "Error loading symbol factory extension point",e)); //$NON-NLS-1$ - } - } - } - } - } - } - - /** - * Logs an exception in this plugin to the error log - * - * @param t - */ - public static void log(Throwable t) - { - ILog log = getPlugin().getLog(); - IStatus status = new Status(IStatus.ERROR, getPlugin().getSymbolicName(), 0, "Caught exception", t); //$NON-NLS-1$ - log.log(status); - } - - /** - * The actual implementation of the Eclipse <b>Plugin</b>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static class Implementation extends EclipsePlugin - { - /** - * Name of the symbolSourceProvider ext point - */ - public static final String SYMBOL_SOURCE_EXT_ID = "symbolSourceProvider"; //$NON-NLS-1$ - /** - * Local identifier for the symbol factory extension point - */ - public static final String SYMBOL_FACTORY_EXT_ID = "contextSymbolFactory"; //$NON-NLS-1$ - /** - * Creates an instance. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Implementation() { - super(); - - // Remember the static instance. - // - plugin = this; - } - } - - - /** - * Utility method returning class from class name using classloader from specified bundle - * @param className - * @param bundleId - * @return Class - */ - public static Class<?> loadClass(String className, String bundleId) { - Class<?> aClass = null; - try { - if (bundleId != null){ - Bundle bundle = Platform.getBundle(bundleId); - if (bundle != null){ - aClass = bundle.loadClass(className); - } - } - } catch (ClassNotFoundException e) { - log(e); - } - return aClass; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/AttrDOMAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/AttrDOMAdapter.java deleted file mode 100644 index ec51032f6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/AttrDOMAdapter.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.dom; - -import org.w3c.dom.Node; - -/** - * Generic adapter for DOM attribute structures. - * - * @author cbateman - * - * <p> - * <b>Provisional API - subject to change</b> - * </p> - */ -public abstract class AttrDOMAdapter extends DOMAdapter -{ - - private AttributeIdentifier _attributeId; // lazily instantiated. - private final ElementDOMAdapter _owner; - - /** - * @param owner - */ - protected AttrDOMAdapter(final ElementDOMAdapter owner) - { - _owner = owner; - } - - /** - * The default implementation always returns the owner specified in the - * constructor. - * - * @return the element that owns this attribute - */ - public ElementDOMAdapter getOwningElement() - { - return _owner; - } - - /** - * @return the value of the attribute. May return null if the attribute has - * no value. - */ - public abstract String getValue(); - - @Override - public final short getNodeType() - { - return Node.ATTRIBUTE_NODE; - } - - /** - * @return the attribute identifier - */ - public final AttributeIdentifier getAttributeIdentifier() - { - synchronized (this) - { - if (_attributeId == null) - { - _attributeId = new MyAttributeIdentifier(); - } - } - return _attributeId; - } - - private class MyAttributeIdentifier extends AttributeIdentifier - { - - @Override - public String getName() - { - return AttrDOMAdapter.this.getLocalName(); - } - - @Override - public TagIdentifier getTagIdentifier() - { - return getOwningElement().getTagId(); - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/AttributeIdentifier.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/AttributeIdentifier.java deleted file mode 100644 index 2bf163efc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/AttributeIdentifier.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.dom; - -/** - * Uniquely identifies a named attribute on a tag usint TagIdentifier as a way - * to uniquely identify the host tag. All instances should be considered - * immutable and idempotent. Factories may cache copies as transparent - * singletons for unique TagIdentifier/attribute. - * - * THIS CLASS IS NOT API AND SHOULD NOT BE USED - * - * @author cbateman - * - */ -public abstract class AttributeIdentifier -{ - /** - * @return the attribute name (local name, namespace prefix is currently ignored) - */ - public abstract String getName(); - - /** - * @return the tag identifier - */ - public abstract TagIdentifier getTagIdentifier(); - - public final boolean equals(Object compareTo) - { - if (compareTo instanceof AttributeIdentifier) - { - return isSameAttributeType((AttributeIdentifier) compareTo); - } - return false; - } - - public final int hashCode() - { - // use toLowerCase to ensure equals matches - int hashCode = getName().toLowerCase().hashCode(); - - int tagCode = getTagIdentifier().hashCode(); - - hashCode = hashCode ^ tagCode; - - return hashCode; - } - - /** - * @param attributeId - * @return true if attributeId represents the same attribute as this. - */ - public final boolean isSameAttributeType(AttributeIdentifier attributeId) - { - // if same object, always true - if (attributeId == this) - { - return true; - } - - - // if tag identifiers not same, then always false. - if (!getTagIdentifier().isSameTagType(attributeId.getTagIdentifier())) - { - return false; - } - - // if tag id is the same, the tag name must be too. - return getName().toLowerCase().equals(attributeId.getName().toLowerCase()); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/DOMAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/DOMAdapter.java deleted file mode 100644 index fb3c43b75..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/DOMAdapter.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.dom; - -/** - * A generic adapter that can adapt some non-DOM - * things to a dom-like structure like an IRegion to a DOM-like structure. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public abstract class DOMAdapter -{ - /** - * @return the node type. Conforms to Node.getNodeType. - */ - public abstract short getNodeType(); - - /** - * @return the name prefix. Conforms to W3C Node.getPrefix() - */ - public abstract String getPrefix(); - - /** - * @return the local part of the name. Conforms to W3C Node.getLocalName() - */ - public abstract String getLocalName(); - - /** - * @return the name of the node. Conforms the W3C Node.getNodeName interface - */ - public abstract String getNodeName(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/ElementDOMAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/ElementDOMAdapter.java deleted file mode 100644 index 4d0ad5d91..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/ElementDOMAdapter.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.dom; - -import java.util.Map; - -import org.w3c.dom.Node; - -/** - * T - * @author cbateman - * - * <p><b>Provisional API - subject to change</b></p> - * - */ -public abstract class ElementDOMAdapter extends DOMAdapter -{ - private TagIdentifier _tagIdentifier; // lazily initialized - - /** - * Map should be considered immutable and may throw exceptions if - * mutations are attempted. - * - * @return a nodeName keyed map of attributes belonging to this element - */ - public abstract Map<String, ? extends AttrDOMAdapter> getAttributes(); - - @Override - public final short getNodeType() - { - return Node.ELEMENT_NODE; - } - - /** - * @return the namespace uri for element or null if not applicable (i.e. HTML). - */ - public abstract String getNamespace(); - - /** - * @return the tag identifier for this attribute - */ - public final TagIdentifier getTagId() - { - synchronized(this) - { - if (_tagIdentifier == null) - { - _tagIdentifier = new MyTagIdentifier(); - } - } - return _tagIdentifier; - } - - private final class MyTagIdentifier extends TagIdentifier - { - @Override - public String getTagName() - { - return getLocalName(); - } - - @Override - public String getUri() - { - return getNamespace(); - } - - @Override - public boolean isJSPTag() - { - // shouldn't be called - throw new UnsupportedOperationException("jsp flag not supported on this identifier"); //$NON-NLS-1$ - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/TagIdentifier.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/TagIdentifier.java deleted file mode 100644 index 3d675a69d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/TagIdentifier.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.dom; - -import javax.xml.namespace.QName; - - -/** - * Creates an abstraction for a tag. A tag is defined as a DOM Element whose - * namespace uri may be defined outside of the DOM, such as in a JSP tag library - * declaration. This allows tags to be abstracted from actual DOM elements, which - * is useful in situations like palette creation drops where the construction information - * is known, but we are not ready to create and add a node to the document yet. - * - * All tag TagIdentifier<i>s</i> should be considered immutable and idempotent. - * TagIdentifier instances may be cached by the factory. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public abstract class TagIdentifier -{ - /** - * @return the uri that uniquely identifies the tag. - * - * i.e. - * - * If the tag is defined by an XML namespace, then that uri string will be returned. - * If the tag is defined by a JSP tag library, then the tag library uri should - * be returned. - */ - public abstract String getUri(); - - /** - * @return the local name of the tag (without namespace prefix) - */ - public abstract String getTagName(); - - /** - * @return true if this tag is a JSP tag - */ - public abstract boolean isJSPTag(); - - public final boolean equals(Object compareTo) - { - if (compareTo instanceof TagIdentifier) - { - return isSameTagType((TagIdentifier) compareTo); - } - return false; - } - - public final int hashCode() - { - // use toLowerCase to ensure equals matches - int hashCode = getTagName().toLowerCase().hashCode(); - - String uri = getUri(); - if (uri != null) - { - hashCode ^= uri.hashCode(); - } - return hashCode; - } - - /** - * @param tagWrapper - * @return true if tagWrapper represents the same tag as this. - */ - public final boolean isSameTagType(TagIdentifier tagWrapper) - { - if (tagWrapper == this) - { - return true; - } - - final String uri = tagWrapper.getUri(); - - if (uri == null) - { - if (getUri() != null) - { - return false; - } - } - else if (uri.equals(getUri())) - { - final String tagName = tagWrapper.getTagName(); - - if (tagName == null) - { - if(getTagName() != null) - { - return false; - } - } - else - { - // uri and tag name must both the same for it to be the same type - // TODO: the ignore case thing is dependent on the type of container document - // Use toLower instead of equalsIgnoreCase to ensure that hashCode generates - // a hashCode that guarantees x.equals(y) => x.hashCode == y.hashCode - if (tagName.toLowerCase().equals((getTagName().toLowerCase()))) - { - return true; - } - } - } - - // fall-through, not same - return false; - } - - /** - * @return the QName equivalent. Returns a new object on every invocation. - */ - public final QName asQName() - { - return new QName(getUri(), getTagName()); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/package-info.java deleted file mode 100644 index af4d45aef..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/dom/package-info.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle Corporation. - * 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 - * - ********************************************************************************/ - -/** - * API for manipulating DOM-based objects. - * - * <p><b>Provisional API - subject to change</b></p> - */ -package org.eclipse.jst.jsf.common.dom; diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/Messages.java deleted file mode 100644 index 99706d58c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/Messages.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. - */ - - -package org.eclipse.jst.jsf.common.facet; - - -import org.eclipse.osgi.util.NLS; - - -/** - * Resource bundle - * - * @author Debajit Adhikary - */ -public class Messages extends NLS -{ - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.common.facet.messages"; //$NON-NLS-1$ - - /** - * see messages.properties - */ - public static String UserLibraryVersionValidator_cannotReadLibraryVersion; - - /** - * see messages.properties - */ - public static String UserLibraryVersionValidator_versionMismatch; - - static - { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - - private Messages () - { - // - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/libraryprovider/UserLibraryVersionValidator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/libraryprovider/UserLibraryVersionValidator.java deleted file mode 100644 index 765d8d496..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/libraryprovider/UserLibraryVersionValidator.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.facet.libraryprovider; - -import java.io.File; -import java.io.IOException; -import java.util.Enumeration; -import java.util.jar.Attributes; -import java.util.jar.JarFile; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jst.common.project.facet.core.libprov.user.KeyClassesValidator; -import org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryProviderInstallOperationConfig; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.facet.Messages; -import org.eclipse.osgi.util.NLS; - - -/** - * Checks that a user library is version-compatible with the facet. - * - * @author Debajit Adhikary - * - */ -public abstract class UserLibraryVersionValidator extends KeyClassesValidator -{ - private static final String MANIFEST_SPECIFICATION_VERSION = "Specification-Version"; //$NON-NLS-1$ - private static final String MANIFEST_IMPLEMENTATION_VERSION = "Implementation-Version"; //$NON-NLS-1$ - - private final String classNameIdentifyingImplementationJar; - - - /** - * @param classNameIdentifyingImplementationJar - */ - public UserLibraryVersionValidator (final String classNameIdentifyingImplementationJar) - { - this.classNameIdentifyingImplementationJar = classNameIdentifyingImplementationJar; - } - - - @Override - public IStatus validate (final UserLibraryProviderInstallOperationConfig config) - { - // Check super validator - final IStatus status = super.validate(config); - if (status.getSeverity() != IStatus.OK) - return status; - - // Superclass validated this lib successfully. - // Check user library version now. - final String facetVersion = getFacetVersion(config); - final String libraryVersion = getLibraryVersion(config); - return validateVersionStrings(facetVersion, libraryVersion); - } - - - /** - * @param facetVersion - * @param libraryVersion - * @return the diagnostic for whether the facetVersion and libraryVersion - * match. - */ - protected IStatus validateVersionStrings (final String facetVersion, - final String libraryVersion) - { - if (facetVersion == null) - throw new IllegalArgumentException("Cannot read facet version"); //$NON-NLS-1$ - - if (libraryVersion == null) - return new Status(IStatus.WARNING, JSFCommonPlugin.PLUGIN_ID, Messages.UserLibraryVersionValidator_cannotReadLibraryVersion); - - if (isLibraryFacetCompatible(facetVersion, libraryVersion)) - return Status.OK_STATUS; - - final String errorMessage = NLS.bind(Messages.UserLibraryVersionValidator_versionMismatch, libraryVersion, facetVersion); - return new Status(IStatus.ERROR, JSFCommonPlugin.PLUGIN_ID, errorMessage); - } - - - private boolean isLibraryFacetCompatible (final String facetVersion, - final String libraryVersion) - { - return libraryVersion.startsWith(facetVersion); - } - - - private String getFacetVersion (final UserLibraryProviderInstallOperationConfig config) - { - return config.getProjectFacetVersion().getVersionString(); - } - - - private String getLibraryVersion (final UserLibraryProviderInstallOperationConfig config) - { - String libraryVersion = null; - - try - { - for (final IClasspathEntry cpe : config.resolve()) - { - if (isLibrary(cpe)) - { - final File libraryFile = cpe.getPath().toFile(); - - if (libraryFile.exists() && isCorrectLibraryJar(cpe, this.classNameIdentifyingImplementationJar)) - { - JarFile jarFile = null; - try - { - jarFile = new JarFile(libraryFile); - libraryVersion = getLibraryVersion(jarFile); - } - finally - { - if (jarFile != null) - jarFile.close(); - } - } - } - } - } - catch (final IOException e) - { - JSFCommonPlugin.log(e, e.getLocalizedMessage()); - } - - return libraryVersion; - } - - - private boolean isLibrary (final IClasspathEntry cpe) - { - return cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY; - } - - - private boolean isCorrectLibraryJar (final IClasspathEntry cpe, - final String classNameIdentifyingJar) - throws IOException - { - final File libraryFile = cpe.getPath().toFile(); - - if (!libraryFile.exists()) - return false; - - ZipFile zipFile = null; - - try - { - zipFile = new ZipFile(libraryFile); - - for (final Enumeration<? extends ZipEntry> entries = zipFile.entries(); entries.hasMoreElements();) - { - final ZipEntry entry = entries.nextElement(); - final String entryName = entry.getName(); - if (entryName.equals(classNameIdentifyingJar)) - return true; - } - } - finally - { - if (zipFile != null) - zipFile.close(); - } - - return false; - } - - - /** - * @param jarFile - * Library jar file to read - * - * @return Version of the specified Jar. Uses the manifest - * Specification-Version entry. If that is not available, then uses - * the Implementation-Version entry. - * - * @throws IOException - */ - protected String getLibraryVersion (final JarFile jarFile) - throws IOException - { - final Manifest manifest = jarFile.getManifest(); - - if (manifest == null) - return null; - - final Attributes attributes = manifest.getMainAttributes(); - - final String specificationVersion = attributes.getValue(MANIFEST_SPECIFICATION_VERSION); - if (specificationVersion != null) - return specificationVersion; - - final String implementationVersion = manifest.getMainAttributes().getValue(MANIFEST_IMPLEMENTATION_VERSION); - return implementationVersion; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/libraryprovider/jsf/JsfLibraryUtil.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/libraryprovider/jsf/JsfLibraryUtil.java deleted file mode 100644 index e55cdf0e0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/libraryprovider/jsf/JsfLibraryUtil.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.facet.libraryprovider.jsf; - -import java.io.File; -import java.io.IOException; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipException; -import java.util.zip.ZipFile; - -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jst.common.project.facet.core.libprov.user.UserLibraryProviderInstallOperationConfig; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - - -/** - * Utility methods for JSF libraries. - * - * @author Debajit Adhikary - * - */ -public class JsfLibraryUtil -{ - /** - * JSF library vendor type - */ - public static enum JsfLibraryVendorType - { - /** Unknown JSF library type */ - UNKNOWN, - - /** Apache MyFaces JSF library */ - MYFACES, - - /** Sun-RI JSF library */ - SUN_RI - } - - - /** - * @param libConfig UserLibraryProviderInstallOperationConfig - * @return JsfLibraryVendorType - */ - public static JsfLibraryVendorType getJsfLibraryVendorType (final UserLibraryProviderInstallOperationConfig libConfig) - { - final String MYFACES_IDENTIFYING_CLASS = "org/apache/myfaces/el/VariableResolverImpl.class"; //$NON-NLS-1$ - final String SUNRI_IDENTIFYING_CLASS = "com/sun/faces/el/VariableResolverImpl.class"; //$NON-NLS-1$ - - - for (final IClasspathEntry cpe : libConfig.resolve()) - { - if (isLibrary(cpe)) - { - final File libraryFile = cpe.getPath().toFile(); - - if (!libraryFile.exists()) - continue; - - ZipFile zipFile = null; - - try - { - zipFile = new ZipFile(libraryFile); - - for (final Enumeration<? extends ZipEntry> entries = zipFile.entries(); entries.hasMoreElements();) - { - final ZipEntry entry = entries.nextElement(); - final String entryName = entry.getName(); - - if (entryName.equals(MYFACES_IDENTIFYING_CLASS)) - return JsfLibraryVendorType.MYFACES; - - if (entryName.equals(SUNRI_IDENTIFYING_CLASS)) - return JsfLibraryVendorType.SUN_RI; - } - } - catch (final ZipException e) - { - JSFCommonPlugin.log(e, e.getLocalizedMessage()); - } - catch (final IOException e) - { - JSFCommonPlugin.log(e, e.getLocalizedMessage()); - } - finally - { - try - { - if (zipFile != null) - zipFile.close(); - } - catch (final IOException e) - { - JSFCommonPlugin.log(e, e.getLocalizedMessage()); - } - } - } - } - - return JsfLibraryVendorType.UNKNOWN; - } - - - /** - * @param cpe - * @return True if the classpath entry is a library. - */ - public static boolean isLibrary (final IClasspathEntry cpe) - { - return cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/messages.properties deleted file mode 100644 index aace54dbd..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/facet/messages.properties +++ /dev/null @@ -1,2 +0,0 @@ -UserLibraryVersionValidator_cannotReadLibraryVersion=Could not read version for selected library. The library may not be correct for this facet version. -UserLibraryVersionValidator_versionMismatch=Incorrect library version: The selected library version ({0}) does not match the facet version ({1})
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/ITestTracker.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/ITestTracker.java deleted file mode 100644 index 259d90921..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/ITestTracker.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal; - -/** - * An injection interface that allows classes to selectively report test progress. - * - * @author cbateman - * - */ -public interface ITestTracker -{ - /** - * Event types - * - */ - public enum Event - { - /** - * Signals that tracking should begin on the eventLabel - * The seqId must be repeated on the STOP_TRACKING event - * for the same event. - */ - START_TRACKING, - /** - * Signals that tracking should stop on the named event - * for the seqId that was passed first in the START_TRACKING. - * - */ - STOP_TRACKING - } - - /** - * Fires the event of type event, a unique instance tracking seqId - * and a label called eventLabel. - * - * @param event - * @param seqId - * @param eventLabel - */ - void fireEvent(Event event, long seqId, String eventLabel); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/JSPUtil.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/JSPUtil.java deleted file mode 100644 index 37e7a9999..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/JSPUtil.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.core.runtime.content.IContentTypeManager; - -/** - * Utility JSP methods - * @author cbateman - * - */ -public final class JSPUtil -{ - private final static String CTYPE_JSPSOURCE = - "org.eclipse.jst.jsp.core.jspsource"; //$NON-NLS-1$ - private final static String CTYPE_JSPFRAGMENTSOURCE = - "org.eclipse.jst.jsp.core.jspfragmentsource"; //$NON-NLS-1$ - /** - * @param contentType - * @return true if contentType is one of the content types registered - * for JSP files - */ - public static boolean isJSPContentType(final String contentType) - { - return CTYPE_JSPSOURCE.equals(contentType) - || CTYPE_JSPFRAGMENTSOURCE.equals(contentType); - } - - /** - * @param file - * @return true if file is associated with a JSP or JSP fragment content type - */ - public static boolean isJSPContentType(final IFile file) - { - final boolean isJSPSource = isJSPSource(file); - if (isJSPSource) - { - return true; - } - - final boolean isJSPFragment = isJSPFragment(file); - - if (isJSPFragment) - { - return true; - } - - return false; - } - - private JSPUtil() - { - // no instantiation - } - - /** - * @param file - * @return true if file is associated with the JSP source content type - * (returns if JSP fragment) - */ - public static boolean isJSPSource(IFile file) { - return isAssociatedWithContentType(file, CTYPE_JSPSOURCE); - } - - /** - * @param file - * @return true if the file is associated with the JSP fragment content type - */ - public static boolean isJSPFragment(IFile file) { - return isAssociatedWithContentType(file, CTYPE_JSPFRAGMENTSOURCE); - } - - private static boolean isAssociatedWithContentType(final IFile file, final String contentType) - { - final IContentTypeManager typeManager = Platform.getContentTypeManager(); - IContentType jspContentType = - typeManager.getContentType(contentType); - if (jspContentType != null - && jspContentType.isAssociatedWith(file.getName())) - { - return true; - } - - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/RunOnCompletionPattern.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/RunOnCompletionPattern.java deleted file mode 100644 index 6ae5a195a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/RunOnCompletionPattern.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.jobs.IJobChangeEvent; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * A pattern that runs a Job and either joins on the job's completion - * or runs some completion behaviour. - * - * @author cbateman - * - */ -public class RunOnCompletionPattern implements Runnable -{ - private final Job _job; - private final Runnable _runAfter; - - /** - * @param job - * @param runAfter - */ - public RunOnCompletionPattern(Job job, Runnable runAfter) - { - _job = job; - _runAfter = runAfter; - } - - public void run() - { - if (_runAfter != null) - { - _job.addJobChangeListener(new JobChangeAdapter() - { - - @Override - public void done(IJobChangeEvent event) - { - if (event.getResult().getSeverity() != IStatus.ERROR) - { - _runAfter.run(); - } - } - - }); - } - - _job.schedule(); - - if (_runAfter == null) - { - try - { - _job.join(); - } - catch (InterruptedException e) - { - JSFCommonPlugin.log(e, "Joining on job"); //$NON-NLS-1$ - } - } - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/AbstractLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/AbstractLocator.java deleted file mode 100644 index 240657a97..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/AbstractLocator.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.locator; - -import java.util.concurrent.CopyOnWriteArrayList; - -import org.eclipse.jst.jsf.common.internal.locator.ILocatorChangeListener.LocatorChangeEvent; - -/** - * The abstract base class of all ILocator implementations. - * - * @author cbateman - * - * @param <LOCATORTYPE> - * @param <CONTEXTTYPE> - * @param <IDTYPE> - */ -public abstract class AbstractLocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE> - implements ILocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE> -{ - /** - * The default value used for "no result". - */ - protected static final Object DEFAULT_NO_RESULT_VALUE = null; - - private final CopyOnWriteArrayList<ILocatorChangeListener> _listeners; - private final LOCATORTYPE _noResultValue; - private final IDTYPE _id; - private final String _displayName; - private boolean _isStarted; - - /** - * Available for sub-classes that want to use reasonable defaults and only provide - * mandatory data. - * - * No result value is null. - * A new instance of CopyOnWriteArrayList is used and held private. - * - * @param id - * @param displayName - * - */ - public AbstractLocator(final IDTYPE id, final String displayName) - { - this(id, - displayName, - null, - new CopyOnWriteArrayList<ILocatorChangeListener>()); - } - - /** - * Available for sub-classes to manually inject dependencies. - * - * @param id - * @param displayName - * @param noResultValue - * @param mutableListenerList - */ - protected AbstractLocator( - final IDTYPE id, - final String displayName, - final LOCATORTYPE noResultValue, - final CopyOnWriteArrayList<ILocatorChangeListener> mutableListenerList) - { - _id = id; - _displayName = displayName; - _listeners = mutableListenerList; - _noResultValue = noResultValue; - } - - public final LOCATORTYPE perform(final CONTEXTTYPE context) - throws Exception - { - return locate(context); - } - - public LOCATORTYPE getNoResult() - { - return _noResultValue; - } - - public IDTYPE getId() - { - return _id; - } - - public String getDisplayName() - { - return _displayName; - } - - public LOCATORTYPE locate(final CONTEXTTYPE context) - { - if (isStarted()) - { - return doLocate(context); - } - throw new IllegalArgumentException("Locator not started"); //$NON-NLS-1$ - } - - - /** - * @param context - * @return the located type. - */ - protected abstract LOCATORTYPE doLocate(CONTEXTTYPE context); - - public void start(final CONTEXTTYPE initialContext) - { - // set the started flag - setStarted(true); - } - - public void stop() - { - // set the started flag - setStarted(false); - } - - /** - * @param listener - */ - public void addListener(final ILocatorChangeListener listener) - { - _listeners.addIfAbsent(listener); - } - - /** - * @param listener - */ - public void removeListener(final ILocatorChangeListener listener) - { - _listeners.remove(listener); - } - - /** - * @param event - */ - protected void fireChangeEvent(final LocatorChangeEvent event) - { - for (final ILocatorChangeListener listener : _listeners) - { - listener.changed(event); - } - } - - public final boolean isStarted() - { - return _isStarted; - } - - public boolean canStart() - { - if (isStarted()) - { - return false; - } - return true; - } - - /** - * @param newValue - */ - protected final void setStarted(final boolean newValue) - { - _isStarted = newValue; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/CompositeLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/CompositeLocator.java deleted file mode 100644 index 65658e89d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/CompositeLocator.java +++ /dev/null @@ -1,154 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.locator; - -import java.util.Iterator; - -import org.eclipse.jst.jsf.common.internal.policy.IIteratorPolicy; -import org.eclipse.jst.jsf.common.internal.strategy.IteratorPolicyBasedStrategyComposite; - -/** - * @author cbateman - * - * @param <LOCATORTYPE> - * @param <COMPOSITETYPE> - * @param <CONTEXTTYPE> - * @param <IDTYPE> - */ -public abstract class CompositeLocator<LOCATORTYPE, COMPOSITETYPE, CONTEXTTYPE, IDTYPE> extends -IteratorPolicyBasedStrategyComposite<CONTEXTTYPE, LOCATORTYPE, COMPOSITETYPE, IDTYPE, ILocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE>> -implements ILocator<COMPOSITETYPE, CONTEXTTYPE, IDTYPE>, ILocatorChangeListener -{ - private DefaultComposingLocatorDelegate<LOCATORTYPE, COMPOSITETYPE, CONTEXTTYPE, IDTYPE> _delegate; - private final COMPOSITETYPE _noResultValue; - - /** - * @param id - * @param displayName - * @param policy - * @param noResultValue - * @param compositionStrategy - */ - public CompositeLocator( - final IDTYPE id, - final String displayName, - final IIteratorPolicy<IDTYPE> policy, - final COMPOSITETYPE noResultValue, - final DefaultCompositionStrategy<CONTEXTTYPE, LOCATORTYPE, COMPOSITETYPE, ILocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE>> compositionStrategy) - { - super(policy, compositionStrategy); - _delegate = new DefaultComposingLocatorDelegate<LOCATORTYPE, COMPOSITETYPE, CONTEXTTYPE, IDTYPE>(id, displayName) - { - @Override - protected COMPOSITETYPE doLocate(final CONTEXTTYPE context) - { - return CompositeLocator.this.doLocate(context); - } - }; - _noResultValue = noResultValue; - } - - /** - * @param context - * @return the located value. - */ - protected abstract COMPOSITETYPE doLocate(CONTEXTTYPE context); - - public final IDTYPE getId() - { - return _delegate.getId(); - } - - public String getDisplayName() - { - return _delegate.getDisplayName(); - } - - public void start(final CONTEXTTYPE initialContext) - { - if (canStart()) - { - final Iterator<ILocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE>> iterator = getIterator(); - while (iterator.hasNext()) - { - - final ILocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE> next = iterator.next(); - next.addListener(this); - next.start(initialContext); - } - _delegate.start(initialContext); - } - throw new IllegalStateException("canStart must be called before calling start"); //$NON-NLS-1$ - } - - public boolean canStart() - { - boolean canStart = true; - final Iterator<ILocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE>> iterator = getIterator(); - while (canStart && iterator.hasNext()) - { - canStart &= iterator.next().canStart(); - } - - return canStart && _delegate.canStart(); - } - - public boolean isStarted() - { - return _delegate.isStarted(); - } - - public void stop() - { - if (!isStarted()) - { - final Iterator<ILocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE>> iterator = getIterator(); - while (iterator.hasNext()) - { - final ILocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE> next = iterator.next(); - next.removeListener(this); - next.stop(); - } - - _delegate.stop(); - } - } - - public COMPOSITETYPE locate(final CONTEXTTYPE context) - { - return _delegate.locate(context); - } - - @Override - public COMPOSITETYPE getNoResult() - { - return _noResultValue; - } - - - public void changed(final LocatorChangeEvent event) - { - _delegate.fireChangeEvent(event); - } - - - public void addListener(final ILocatorChangeListener listener) - { - _delegate.addListener(listener); - } - - - public void removeListener(final ILocatorChangeListener listener) - { - _delegate.removeListener(listener); - } - - /** - * Re-fire events from composed strategies. - * - * @param event - */ - protected void fireChangeEvent(final LocatorChangeEvent event) - { - _delegate.fireChangeEvent(event); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/DefaultComposingLocatorDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/DefaultComposingLocatorDelegate.java deleted file mode 100644 index ac698d342..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/DefaultComposingLocatorDelegate.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.locator; - -import java.util.concurrent.CopyOnWriteArrayList; - -/** - * Default delegatable locator for composing locators. - * - * @author cbateman - * - * @param <LOCATORTYPE> - * @param <COMPOSITETYPE> - * @param <CONTEXTTYPE> - * @param <IDTYPE> - */ -public class DefaultComposingLocatorDelegate<LOCATORTYPE, COMPOSITETYPE, CONTEXTTYPE, IDTYPE> extends - AbstractLocator<COMPOSITETYPE, CONTEXTTYPE, IDTYPE> -{ - - /** - * @param id - * @param displayName - */ - public DefaultComposingLocatorDelegate(IDTYPE id, String displayName) - { - super(id, displayName); - } - - - /** - * @param id - * @param displayName - * @param noResultValue - * @param mutableListenerList - */ - public DefaultComposingLocatorDelegate( - IDTYPE id, - String displayName, - COMPOSITETYPE noResultValue, - CopyOnWriteArrayList<ILocatorChangeListener> mutableListenerList) - { - super(id, displayName, noResultValue, mutableListenerList); - } - - - @Override - protected COMPOSITETYPE doLocate(CONTEXTTYPE context) - { - throw new UnsupportedOperationException("This method is abstract and should not be called"); //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/DefaultLocatorDelegate.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/DefaultLocatorDelegate.java deleted file mode 100644 index 04d8fdb90..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/DefaultLocatorDelegate.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.locator; - -import java.util.concurrent.CopyOnWriteArrayList; - -/** - * Implements the bare minimum of AbstractLocator needed to treat it as a - * sub-class by composition (delegation). - * - * @author cbateman - * @param <LOCATORTYPE> - * @param <CONTEXTTYPE> - * @param <IDTYPE> - * - */ -public class DefaultLocatorDelegate<LOCATORTYPE, CONTEXTTYPE, IDTYPE> extends - AbstractLocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE> -{ - - /** - * @param id - * @param displayName - */ - public DefaultLocatorDelegate(IDTYPE id, String displayName) - { - super(id, displayName); - } - - - /** - * @param id - * @param displayName - * @param noResultValue - * @param mutableListenerList - */ - public DefaultLocatorDelegate( - IDTYPE id, - String displayName, - LOCATORTYPE noResultValue, - CopyOnWriteArrayList<ILocatorChangeListener> mutableListenerList) - { - super(id, displayName, noResultValue, mutableListenerList); - } - - - @Override - protected LOCATORTYPE doLocate(CONTEXTTYPE context) - { - throw new UnsupportedOperationException("This method is abstract and should not be called"); //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/ILocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/ILocator.java deleted file mode 100644 index abf6bade9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/ILocator.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.locator; - -import org.eclipse.jst.jsf.common.internal.strategy.IIdentifiableStrategy; - -/** - * A generic location strategy object. - * - * @author cbateman - * - * @param <LOCATORTYPE> - * the type of object being returned by the locator - * @param <CONTEXTTYPE> - * the type of the context object passed for starting and locating - * @param <IDTYPE> - * the type of the id used to identify a locator - * @noimplement extend AbstractLocator instead - */ -public interface ILocator<LOCATORTYPE, CONTEXTTYPE, IDTYPE> extends - IIdentifiableStrategy<CONTEXTTYPE, LOCATORTYPE, IDTYPE> -{ - /** - * Initialize the locator optionally using initialContext. - * - * Must be called before any other methods. Implementations should throw - * IllegalStateException if this has not been called before anything else. - * - * @param initialContext - */ - void start(CONTEXTTYPE initialContext); - - /** - * Implementations should return false if the system prevents them from - * starting. It must also be checked before a client attempts to restart a - * stopped locator. Must return false if isStarted is true. - * - * @return true if the locator can be started - */ - boolean canStart(); - - /** - * @return true if the start() has been called but stop has not yet been - * called. - */ - boolean isStarted(); - - /** - * Stop the locator. - */ - void stop(); - - /** - * @param listener - */ - void addListener( final ILocatorChangeListener listener); - - /** - * @param listener - */ - void removeListener(final ILocatorChangeListener listener); - - /** - * perform must call this method in any concrete implementation. - * - * @param context - * @return the located type. - */ - LOCATORTYPE locate(CONTEXTTYPE context); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/ILocatorChangeListener.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/ILocatorChangeListener.java deleted file mode 100644 index 0b996dffa..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/locator/ILocatorChangeListener.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.locator; - -import java.util.EventListener; -import java.util.EventObject; - -/** - * @author cbateman - * - */ -public interface ILocatorChangeListener extends EventListener -{ - /** - * @param event - */ - public void changed(final LocatorChangeEvent event); - - /** - * @author cbateman - * - */ - public static class LocatorChangeEvent extends EventObject - { - /** - * @param source - */ - public LocatorChangeEvent(ILocator source) { - super(source); - } - - @Override - public ILocator getSource() { - return (ILocator) super.getSource(); - } - - /** - * - */ - private static final long serialVersionUID = -7930804700395142768L; - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/managedobject/AbstractManagedObject.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/managedobject/AbstractManagedObject.java deleted file mode 100644 index faa337a4b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/managedobject/AbstractManagedObject.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.managedobject; - -/** - * Sub-class for managed objects. - * - */ -public abstract class AbstractManagedObject implements IManagedObject -{ - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.internal.managedobject.IManagedObject#dispose() - */ - public abstract void dispose(); - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.internal.managedobject.IManagedObject#checkpoint() - */ - public abstract void checkpoint(); - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.internal.managedobject.IManagedObject#destroy() - */ - public abstract void destroy(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/managedobject/IManagedObject.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/managedobject/IManagedObject.java deleted file mode 100644 index b4e7e7542..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/managedobject/IManagedObject.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.managedobject; - -/** - * Represents an object that wishes to be managed by the framework. - * - * Clients should not implement: sub-class AbstractManagedObject instead. - * - */ -public interface IManagedObject -{ - /** - * Called by the object client to indicate is finished with the object. - * The object should save any data it may want between sessions, perhaps - * by calling its checkpoint, before cleaning held resources and clearing - * memory references. - */ - void dispose(); - - /** - * Called to indicate that the object should remove all its data from both - * memory and persistent storage. This differentiates it from dispose in - * that it signals that this object and its associated state will never - * again be loaded for associated objects. - */ - void destroy(); - - /** - * Indicates that an object should flush cached data and make durable - * any data it might want between sessions. It does not indicate a - * disposal of the object. - */ - void checkpoint(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/managedobject/ObjectManager.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/managedobject/ObjectManager.java deleted file mode 100644 index f98fe9dda..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/managedobject/ObjectManager.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.managedobject; - -/** - * An abstraction for a manager that manages managed objects based on a KEYTYPE - * - * @author cbateman - * - * @param <T> - * @param <KEYTYPE> - */ -public abstract class ObjectManager<T extends IManagedObject, KEYTYPE> -{ - /** - * A valid instance of T for the key. The instance of T may be unique on - * a per-key basis or may not. - * - * @param key - * @return an instance of the managed object associated with key - * @throws ManagedObjectException if an error occurs during construction - */ - public abstract T getInstance(KEYTYPE key) throws ManagedObjectException; - - /** - * Indicates a problem that occurred during a managed object operation - * @author cbateman - * - */ - public static class ManagedObjectException extends Exception - { - /** - * - */ - private static final long serialVersionUID = -8723548990029368844L; - - /** - * - */ - public ManagedObjectException() - { - super(); - } - - /** - * @param message - * @param cause - */ - public ManagedObjectException(String message, Throwable cause) - { - super(message, cause); - } - - /** - * @param message - */ - public ManagedObjectException(String message) - { - super(message); - } - - /** - * @param cause - */ - public ManagedObjectException(Throwable cause) - { - super(cause); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/pde/AbstractRegistryReader.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/pde/AbstractRegistryReader.java deleted file mode 100644 index 1773efbc8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/pde/AbstractRegistryReader.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.pde; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * A utility base class that simplifies the reading and caching of extension - * point information. - * - * @author cbateman - * @param <T> - * - */ -public abstract class AbstractRegistryReader<T> -{ - private final String _extPtNamespace; - private final String _extPtId; - private List<T> _extensions; - private final AtomicBoolean _isInitialized = new AtomicBoolean(false); - - /** - * @param extPtNamespace - * @param extPtId - */ - protected AbstractRegistryReader(final String extPtNamespace, - final String extPtId) - { - _extPtNamespace = extPtNamespace; - _extPtId = extPtId; - } - - /** - * @return the extensions - */ - public final List<T> getExtensions() - { - synchronized (_isInitialized) - { - if (_isInitialized.compareAndSet(false, true)) - { - initialize(); - } - return _extensions; - } - } - - /** - * @param extensions - */ - protected final void internalSetExtensions(List<T> extensions) - { - if (_extensions != null) - { - throw new IllegalStateException( - "internalSetExtensions should be called exactly once"); //$NON-NLS-1$ - } - _extensions = Collections.unmodifiableList(extensions); - } - - /** - * Called exactly once to initialize the registry. - */ - protected abstract void initialize(); - - /** - * @return the extension point id. see IConfigurationElement.getName - */ - protected final String getExtPtId() - { - return _extPtId; - } - - /** - * @return the namespace of the extension point. see Bundle.getSymbolicName - */ - protected final String getExtPtNamespace() - { - return _extPtNamespace; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/pde/AbstractSimpleClassExtensionRegistryReader.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/pde/AbstractSimpleClassExtensionRegistryReader.java deleted file mode 100644 index 594fa1a38..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/pde/AbstractSimpleClassExtensionRegistryReader.java +++ /dev/null @@ -1,221 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.pde; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * @author cbateman - * @param <T> - * - */ -public abstract class AbstractSimpleClassExtensionRegistryReader<T> extends - AbstractRegistryReader<T> -{ - - private final String _attributeName; - private final String _configElementName; - private final Comparator<SortableExecutableExtension<T>> _comparator; - - /** - * @param extPtNamespace - * @param extPtId - * @param configElementName - * @param attributeName - * @param listComparator - * May be null if no sorting of the extensions list is required. - */ - protected AbstractSimpleClassExtensionRegistryReader( - final String extPtNamespace, final String extPtId, - final String configElementName, final String attributeName, - final Comparator<SortableExecutableExtension<T>> listComparator) - { - super(extPtNamespace, extPtId); - _configElementName = configElementName; - _attributeName = attributeName; - _comparator = listComparator; - } - - @Override - protected final void initialize() - { - final List<SortableExecutableExtension<T>> result = new ArrayList<SortableExecutableExtension<T>>(); - final IExtensionPoint extensionPoint = Platform.getExtensionRegistry() - .getExtensionPoint(getExtPtNamespace(), getExtPtId()); - IExtension[] extensions = extensionPoint.getExtensions(); - for (int i = 0; i < extensions.length; i++) - { - IExtension ext = extensions[i]; - IConfigurationElement[] tagConverter = ext - .getConfigurationElements(); - - for (int j = 0; j < tagConverter.length; j++) - { - final IConfigurationElement element = tagConverter[j]; - - if (element.getName().equals(_configElementName)) - { - element.getAttribute(_attributeName); - try - { - final T obj = (T) element - .createExecutableExtension(_attributeName); - result.add(new SortableExecutableExtension<T>( - _comparator, element.getContributor().getName(), - obj)); - } catch (ClassCastException ce) - { - handleLoadFailure(new CoreException(new Status( - IStatus.ERROR, JSFCommonPlugin.PLUGIN_ID, - "Extension class is not the expected type", ce))); //$NON-NLS-1$ - } catch (CoreException e) - { - handleLoadFailure(e); - } - } - } - } - - if (result.size() > 0) - { - if (_comparator != null) - { - Collections.sort(result, _comparator); - } - } else - { - JSFCommonPlugin.log(IStatus.WARNING, String.format( - "No extensions found for: %s.%s", //$NON-NLS-1$ - getExtPtNamespace(), getExtPtId())); - } - final List<T> finalExtensions = new ArrayList<T>(); - for (final SortableExecutableExtension<T> sortable : result) - { - finalExtensions.add(sortable.getExtensionObject()); - } - internalSetExtensions(finalExtensions); - } - - /** - * Called by initialize when an error occurs trying to load a class from an - * extension point. Sub-class should implement to handle the failure, - * typically to log it using their bundle id. - * - * @param ce - */ - protected abstract void handleLoadFailure(final CoreException ce); - - /** - * A comparator that sorts canonically by extension namespace and id, but - * can make exceptions for certain prefices. - * - * @param <T> - * - */ - protected abstract static class CanonicalComparatorWithPrefixExceptions<T> - implements Comparator<SortableExecutableExtension<T>> - { - - public int compare(SortableExecutableExtension<T> o1, - SortableExecutableExtension<T> o2) - { - int result = prefixSort(o1, o2); - - // if the prefix sort doesn't distinguish a sort order, then - // compare it canonically - if (result == 0) - { - result = o1.getContributorId().compareTo(o2.getContributorId()); - } - - return result; - } - - /** - * @param o1 - * @param o2 - * @return -1 if o1 should sort before o2 based on prefix. 1 if o2 - * should sort before o1 or 0 if there is sort preference based - * on prefix. - */ - protected abstract int prefixSort(SortableExecutableExtension<T> o1, - SortableExecutableExtension<T> o2); - } - - /** - * Used to sort extensions before locking down the list. - * - * @param <T> - */ - protected final static class SortableExecutableExtension<T> implements - Comparable<SortableExecutableExtension> - { - private final Comparator _comparator; - private final String _contributorId; - private final T _extensionObject; - - private SortableExecutableExtension(final Comparator comparator, - final String contributorId, final T extensionObject) - { - if (comparator == null) - { - _comparator = new Comparator<T>() - { - public int compare(T o1, T o2) - { - // always return equal. - return 0; - } - }; - } else - { - _comparator = comparator; - } - _contributorId = contributorId; - _extensionObject = extensionObject; - } - - public int compareTo(SortableExecutableExtension o) - { - return _comparator.compare(this, o); - } - - @Override - public boolean equals(Object obj) - { - return _comparator.compare(this, obj) == 0; - } - - @Override - public int hashCode() - { - return _contributorId.hashCode() ^ _extensionObject.hashCode(); - } - - /** - * @return the id of the bundle that contributed this extension - */ - public String getContributorId() - { - return _contributorId; - } - - /** - * @return the extension object - */ - public T getExtensionObject() - { - return _extensionObject; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/CanonicallyOrderedIteratorPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/CanonicallyOrderedIteratorPolicy.java deleted file mode 100644 index 24ba27d82..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/CanonicallyOrderedIteratorPolicy.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.policy; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -/** - * An iterator policy that sorts a comparable iterator type canonically. This - * policy takes a private copy of the collectin passed in getIterator. The - * cost of the sort is incurred when getIterator() is called under the - * assumption that the iterator will normally be used immediately after - * construction, so there is little value in deferring. - * - * @author cbateman - * - * @param <ITERATORTYPE> - */ -public class CanonicallyOrderedIteratorPolicy<ITERATORTYPE extends Comparable<ITERATORTYPE>> - implements IIteratorPolicy<ITERATORTYPE> -{ - - public Iterator<ITERATORTYPE> getIterator( - Collection<ITERATORTYPE> forCollection) - { - return new CanonicalIterator<ITERATORTYPE>(forCollection); - } - - private final static class CanonicalIterator<ITERATORTYPE extends Comparable> implements Iterator<ITERATORTYPE> - { - private final Iterator<ITERATORTYPE> _sortedIterator; - private CanonicalIterator(final Collection<ITERATORTYPE> source) - { - List<ITERATORTYPE> sortable = new ArrayList<ITERATORTYPE>(source); - Collections.sort(sortable); - _sortedIterator = sortable.iterator(); - } - - public boolean hasNext() - { - return _sortedIterator.hasNext(); - } - - public ITERATORTYPE next() - { - return _sortedIterator.next(); - } - public void remove() - { - throw new UnsupportedOperationException(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/IIdentifiable.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/IIdentifiable.java deleted file mode 100644 index 6e6368def..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/IIdentifiable.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.policy; - -/** - * An object with an unique identity - * @author cbateman - * @param <IDTYPE> - * - */ -public interface IIdentifiable<IDTYPE> -{ - /** - * @return the unique identifier - */ - IDTYPE getId(); - - /** - * @return a human-readable name for this identifier. - */ - String getDisplayName(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/IIteratorPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/IIteratorPolicy.java deleted file mode 100644 index 6b567f368..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/IIteratorPolicy.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.policy; - -import java.util.Collection; -import java.util.Iterator; - -/** - * A policy that allows a strategy composite to change the order in which - * it queries it's list of strategies. - * - * @author cbateman - * @param <ITERATORTYPE> - * - */ -public interface IIteratorPolicy<ITERATORTYPE> -{ - /** - * @param forCollection - * @return an iterator that controls the ordering through forCollection - * in a policy directed way. The policy may take a copy of the collection - * or may choose to iterate in place. - */ - Iterator<ITERATORTYPE> getIterator(Collection<ITERATORTYPE> forCollection); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/IdentifierOrderedIteratorPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/IdentifierOrderedIteratorPolicy.java deleted file mode 100644 index a566af0c7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/IdentifierOrderedIteratorPolicy.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.policy; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; - -/** - * An iterator policy that creates Iterators that traverse a target collection - * by returning items in the order they are in the policyOrder object pased at - * construction. The target collection passed to getIterator is copied, so the - * iterator will not be effected by subsequent changes to the target. - * - * NOTE: the policyOrder iterable collection should not be modified after it is - * passed to the constructor. - * - * The class is thread-safe, however the iterators are not. That is, more than - * one thread can safely call any of the public methods, however each Iterator - * returned by getIterator can only be used safely by a single thread. - * - * @author cbateman - * - * @param <ITERATORTYPE> - */ -public class IdentifierOrderedIteratorPolicy<ITERATORTYPE> implements - IIteratorPolicy<ITERATORTYPE> -{ - private final Iterable<ITERATORTYPE> _policyOrder; - // controls whether the policy iterator will return items that are - // not explicitly listed in policyOrder. - private volatile boolean _excludeNonExplicitValues = false; - - /** - * @param policyOrder - */ - public IdentifierOrderedIteratorPolicy(final Iterable<ITERATORTYPE> policyOrder) - { - _policyOrder = policyOrder; - } - - /** - * Default value is <b>false</b>. - * - * @return if true, the iterator will not return values in the forCollection - * passed to getIterator whose identifier are not explicitly listed in - * the policyOrder, If false, these values will be return after all - * the policyOrder values have been returned. - */ - public boolean isExcludeNonExplicitValues() - { - return _excludeNonExplicitValues; - } - - /** - * @param excludeNonExplicitValues - */ - public void setExcludeNonExplicitValues(boolean excludeNonExplicitValues) - { - _excludeNonExplicitValues = excludeNonExplicitValues; - } - - public Iterator<ITERATORTYPE> getIterator( - final Collection<ITERATORTYPE> forCollection) - { - final boolean excludeNonExplicitValues = _excludeNonExplicitValues; - return new MyIterator<ITERATORTYPE>(forCollection, excludeNonExplicitValues, _policyOrder); - } - - private static class MyIterator<ITERATORTYPE> implements Iterator<ITERATORTYPE> - { - private final List<ITERATORTYPE> _items; - private final Iterator<ITERATORTYPE> _policyIterator; - private ITERATORTYPE _next; - - MyIterator(final Collection<ITERATORTYPE> collection, - final boolean excludeNonExplicitValues, - final Iterable<ITERATORTYPE> policyOrder) - { - _items = new ArrayList(); - _items.addAll(collection); - - _policyIterator = policyOrder.iterator(); - _next = findNext(); - } - - public boolean hasNext() - { - return _next != null; - } - - public ITERATORTYPE next() - { - if (_next != null) - { - ITERATORTYPE next = _next; - //calculate next one before returning - _next = findNext(); - return next; - } - - throw new NoSuchElementException("No more elements"); //$NON-NLS-1$ - } - - public void remove() - { - throw new UnsupportedOperationException(); - } - - private ITERATORTYPE findNext() - { - while (_policyIterator.hasNext()) - { - ITERATORTYPE next = _policyIterator.next(); - if (_items.contains(next)) - { - _items.remove(next); - return next; - } - } - - // we have exhausted the _items that are in the policy iterator - // now return any further _items in the order they are in the list - if (_items.size() > 0) - { - return _items.remove(0); - } - - return null; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/OrderedListProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/OrderedListProvider.java deleted file mode 100644 index 75407553e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/policy/OrderedListProvider.java +++ /dev/null @@ -1,178 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.policy; - -import java.util.List; - -/** - * Provides a list of order, enablement-modifiable objects. - * - * @author cbateman - * - */ -public abstract class OrderedListProvider -{ - private List<OrderableObject> _orderableObjects; - - /** - * - * @return the list of ordered objects - */ - public final List<OrderableObject> getOrderedObjects() - { - if (_orderableObjects == null) - { - _orderableObjects = createAndPopulateOrderedObjects(); - } - return _orderableObjects; - } - - /** - * <p>Clears the orderableObjects collection so that the next call - * of getOrderedObjects() </p> - */ - public final void resetOrderedObjects() - { - _orderableObjects = null; - } - - /** - * Move the object one toward the front of the list - * - * @param object - */ - public final void moveUp(final OrderableObject object) - { - final List<OrderableObject> list = getOrderedObjects(); - final int index = list.indexOf(object); - if (index > 0) - { - OrderableObject item = list.remove(index); - list.add(index - 1, item); - } - } - - /** - * Move the object one toward the end - * @param object - */ - public final void moveDown(final OrderableObject object) - { - final List<OrderableObject> list = getOrderedObjects(); - int index = list.indexOf(object); - if (index < list.size() - 1) - { - OrderableObject item = list.remove(index); - list.add(index + 1, item); - } - } - - /** - * @return a new list orderable objects populate in their initial order - * The list must be modifiable. - */ - protected abstract List<OrderableObject> createAndPopulateOrderedObjects(); - - /** - * Proxy object for ordering in list - * - * @author cbateman - * - */ - public static class OrderableObject implements Cloneable - { - private boolean _enabled; - private Object _object; - - /** - * @param object - * @param enabled - */ - public OrderableObject(final Object object, final boolean enabled) - { - _object = object; - _enabled = enabled; - } - - private OrderableObject(final OrderableObject copyMe) - { - _object = copyMe._object; - _enabled = copyMe._enabled; - } - - /** - * @return true if this object is enabled - */ - public boolean isEnabled() - { - return _enabled; - } - - /** - * @param enabled - */ - public void setEnabled(boolean enabled) - { - _enabled = enabled; - } - - /** - * @return the object in the ordered list - */ - public Object getObject() - { - return _object; - } - - /** - * @param object - */ - public void setObject(Object object) - { - _object = object; - } - - @Override - public OrderableObject clone() - { - return new OrderableObject(this); - } - - @Override - public boolean equals(Object obj) - { - if (obj instanceof OrderableObject) - { - if (_enabled == ((OrderableObject)obj)._enabled) - { - Object other = ((OrderableObject)obj)._object; - if (other != null) - { - return other.equals(_object); - } - return _object == null; - } - } - return false; - } - - @Override - public int hashCode() - { - int enabledCode = _enabled ? 0xcccccccc : 0x33333333; - if (_object == null) - { - return enabledCode; - } - return _object.hashCode() ^ enabledCode; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/IResourceLifecycleListener.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/IResourceLifecycleListener.java deleted file mode 100644 index 70e0e9591..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/IResourceLifecycleListener.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.resource; - -/** - * Listener can register for events ona particular LifecycleListener - * - * @author cbateman - * - */ -public interface IResourceLifecycleListener -{ - /** - * Listener accepts the resource lifecycle event - * - * @param event - * @return the result of accepting the event - */ - EventResult acceptEvent(ResourceLifecycleEvent event); - - /** - * @author cbateman - * - */ - public static class EventResult - { - private static EventResult DEFAULT; - - /** - * @return an event result with defaults initialized - */ - public synchronized static EventResult getDefaultEventResult() - { - if (DEFAULT == null) - { - DEFAULT = new EventResult() - { - @Override - protected void setDisposeAfterEvent(final boolean disposeAfterEvent) - { - throw new UnsupportedOperationException(); - } - }; - } - return DEFAULT; - } - - private static EventResult DISPOSE_AFTER_EVENT; - - /** - * @return an event result with default except dispose after - * is set - */ - public synchronized static EventResult getDisposeAfterEventResult() - { - if (DISPOSE_AFTER_EVENT == null) - { - DISPOSE_AFTER_EVENT = new EventResult() - { - /** - * @return the remove listener flag - */ - @Override - public boolean getDisposeAfterEvent() - { - return true; - } - - /** - * @param disposeAfterEvent - */ - @Override - protected void setDisposeAfterEvent(final boolean disposeAfterEvent) { - _disposeAfterEvent = disposeAfterEvent; - } - - }; - } - return DISPOSE_AFTER_EVENT; - } - - /** - * set to true if after the current event is finished firing, the source - * should be disposed. If self-disposal is not applicable, the flag is ignored - */ - protected boolean _disposeAfterEvent; - - /** - * @return the remove listener flag - */ - public boolean getDisposeAfterEvent() - { - return _disposeAfterEvent; - } - - /** - * @param disposeAfterEvent - */ - protected void setDisposeAfterEvent(final boolean disposeAfterEvent) { - _disposeAfterEvent = disposeAfterEvent; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ImmutableLifecycleListener.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ImmutableLifecycleListener.java deleted file mode 100644 index 86140832a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ImmutableLifecycleListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.resource; - - -/** - * A lifecycle listener abstraction that cannot have its resources modified. - * Clients may only register and deregister for events. - * - * @author cbateman - * - */ -public abstract class ImmutableLifecycleListener -{ - - /** - * Adds listener to the list of objects registered to receive - * lifecycle events for this resource. Only adds the listener - * if it is not already in the list. - * - * Method is thread-safe and may block the caller - * - * Throws {@link IllegalStateException} if isDisposed() == true - * - * @param listener - */ - public abstract void addListener(final IResourceLifecycleListener listener); - - /** - * Removes listener from the list of registered listeners - * - * Method is thread-safe and may block the caller - * - * Throws {@link IllegalStateException} if isDisposed() == true - * - * @param listener - */ - public abstract void removeListener(final IResourceLifecycleListener listener); -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/LifecycleListener.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/LifecycleListener.java deleted file mode 100644 index 7655cf2a4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/LifecycleListener.java +++ /dev/null @@ -1,395 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.resource; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jst.jsf.common.internal.ITestTracker; -import org.eclipse.jst.jsf.common.internal.ITestTracker.Event; -import org.eclipse.jst.jsf.common.internal.resource.IResourceLifecycleListener.EventResult; -import org.eclipse.jst.jsf.common.internal.resource.ResourceLifecycleEvent.EventType; -import org.eclipse.jst.jsf.common.internal.resource.ResourceLifecycleEvent.ReasonType; - -/** - * Listens to resource changes and fires lifecycle events - * - * @author cbateman - * - */ -public class LifecycleListener extends ImmutableLifecycleListener implements - IResourceChangeListener -{ - private static boolean ENABLE_TEST_TRACKING = false; - private static long _seqId; - - private final CopyOnWriteArrayList<IResource> _resources; - final CopyOnWriteArrayList<IResourceLifecycleListener> _listeners; - private AtomicBoolean _isDisposed = new AtomicBoolean( - false); - private ITestTracker _testTracker; // == - // null; - // initialized - // by - // setter - // injection - - /** - * Initialize an inactive lifecycle listener. A workspace listener will not - * be installed by this constructor. The object created using this - * constructor will not fire any events until addResource is called at least - * once to add a target resource - */ - public LifecycleListener() - { - _resources = new CopyOnWriteArrayList<IResource>(); - _listeners = new CopyOnWriteArrayList<IResourceLifecycleListener>(); - } - - /** - * Create a new lifecycle listener for the res - * - * @param res - */ - public LifecycleListener(final IResource res) - { - this(); - _resources.add(res); - ResourcesPlugin.getWorkspace().addResourceChangeListener(this); - } - - /** - * @param resources - */ - public LifecycleListener(final List<IResource> resources) - { - this(); - _resources.addAll(resources); - ResourcesPlugin.getWorkspace().addResourceChangeListener(this); - } - - /** - * @param testTracker - */ - public final void setTestTracker(final ITestTracker testTracker) - { - _testTracker = testTracker; - } - - /** - * @param newValue - */ - protected final void setEnableTracing(final boolean newValue) - { - ENABLE_TEST_TRACKING = newValue; - } - /** - * Adds listener to the list of objects registered to receive lifecycle - * events for this resource. Only adds the listener if it is not already in - * the list. - * - * Method is thread-safe and may block the caller - * - * Throws {@link IllegalStateException} if isDisposed() == true - * - * @param listener - */ - public void addListener(final IResourceLifecycleListener listener) - { - if (isDisposed()) - { - throw new IllegalStateException(); - } - _listeners.addIfAbsent(listener); - } - - /** - * Removes listener from the list of registered listeners - * - * Method is thread-safe and may block the caller - * - * Throws {@link IllegalStateException} if isDisposed() == true - * - * @param listener - */ - public void removeListener(final IResourceLifecycleListener listener) - { - if (isDisposed()) - { - throw new IllegalStateException(); - } - _listeners.remove(listener); - } - - /** - * @param res - */ - public void addResource(final IResource res) - { - synchronized (_resources) - { - // don't add any resources if we've disposed before acquiring the - // lock - if (isDisposed()) - { - return; - } - - final int preSize = _resources.size(); - if (!_resources.contains(res)) - { - _resources.add(res); - } - - // if the size of the array was 0 - // and is now greater, make sure the listener is added - if (preSize == 0 && _resources.size() > 0) - { - ResourcesPlugin.getWorkspace().addResourceChangeListener(this); - } - } - } - - /** - * If there are no longer resources being targeted, the resource change - * listener will be removed. - * - * @param res - */ - public void removeResource(final IResource res) - { - synchronized (_resources) - { - // don't bother with this stuff if we're disposed. - if (isDisposed()) - { - return; - } - _resources.remove(res); - - // if there are no longer target resources, - // remove the workspace listener - if (_resources.size() == 0) - { - ResourcesPlugin.getWorkspace().removeResourceChangeListener( - this); - } - } - } - - /** - * Release the resource change listener - */ - public void dispose() - { - if (_isDisposed.compareAndSet(false, true)) - { - // ensure that add/removeResource don't cause races to add or - // remove the resource listener - synchronized (_resources) - { - // remove first to minimize the chance that the listener will - // be triggered during the remainder of dispose - ResourcesPlugin.getWorkspace().removeResourceChangeListener( - this); - _resources.clear(); - } - } - } - - /** - * @return true if the listener has been disposed - */ - public boolean isDisposed() - { - return _isDisposed.get(); - } - - public void resourceChanged(final IResourceChangeEvent event) - { - final long seqId = _seqId++; - - if (_testTracker != null && ENABLE_TEST_TRACKING) - { - _testTracker.fireEvent(Event.START_TRACKING, seqId, - "trackMethod_resourceChanged"); //$NON-NLS-1$ - } - - assert (!isDisposed()); - - switch (event.getType()) - { - case IResourceChangeEvent.PRE_CLOSE: - { - final IProject proj = (IProject) event.getResource(); - - // must use iterator to ensure copy on write behaviour - for (final IResource res : _resources) - { - if (proj == res || proj == res.getProject()) - { - fireLifecycleEvent(new ResourceLifecycleEvent(res, - EventType.RESOURCE_INACCESSIBLE, - ReasonType.RESOURCE_PROJECT_CLOSED)); - } - } - } - break; - - case IResourceChangeEvent.PRE_DELETE: - { - final IProject proj = (IProject) event.getResource(); - - // must use iterator to ensure copy on write behaviour - for (final IResource res : _resources) - { - // if the resource being tracked is the resource being - // deleted, - // then fire a resource delete event - if (proj == res) - { - fireLifecycleEvent(new ResourceLifecycleEvent(res, - EventType.RESOURCE_INACCESSIBLE, - ReasonType.RESOURCE_DELETED)); - } - // if the resource being tracked is a resource in the - // project being - // deleted, then fire a project deleted event - else if (proj == res.getProject()) - { - fireLifecycleEvent(new ResourceLifecycleEvent(res, - EventType.RESOURCE_INACCESSIBLE, - ReasonType.RESOURCE_PROJECT_DELETED)); - } - } - } - break; - - case IResourceChangeEvent.POST_CHANGE: - { - for (final IResource res : _resources) - { - IResourceDelta delta = event.getDelta(); - - // long seqId2 = _seqId++; - // if (ENABLE_TEST_TRACKING && _testTracker != null) - // { - // _testTracker.fireEvent(Event.START_TRACKING, seqId2, - // "testFindMember"); - // } - // only care about post change events to resources - // that we are tracking - delta = delta.findMember(res.getFullPath()); - - if (delta != null) - { - visit(delta); - } - - // if (ENABLE_TEST_TRACKING && _testTracker != null) - // { - // _testTracker.fireEvent(Event.STOP_TRACKING, seqId2, - // "testFindMember"); - // } - } - } - break; - - default: - // do nothing - // we only handle these three - } - - if (ENABLE_TEST_TRACKING && _testTracker != null) - { - _testTracker.fireEvent(Event.STOP_TRACKING, seqId, - "trackMethod_resourceChanged"); //$NON-NLS-1$ - } - } - - private void fireLifecycleEvent(final ResourceLifecycleEvent event) - { - boolean disposeAfter = false; - - // NOTE: must use iterator through _listeners so that - // CopyOnWriteArrayList protects us from concurrent modification - for (final IResourceLifecycleListener listener : _listeners) - { - final EventResult result = listener.acceptEvent(event); - disposeAfter |= result.getDisposeAfterEvent(); - } - - if (disposeAfter) - { - dispose(); - } - } - - private void visit(final IResourceDelta delta) - { - assert (!isDisposed()); - - final IResource res = delta.getResource(); - - // the wkspace root is a special case since even though - // it is registered as the target resource, we are interested - // in new projects created in the root - if (res.getType() == IResource.ROOT) - { - handleWorkspaceRoot(delta); - } - - switch (delta.getKind()) - { - case IResourceDelta.CHANGED: - { - // the contents of the file have changed - if ((delta.getFlags() & IResourceDelta.CONTENT) != 0) - { - fireLifecycleEvent(new ResourceLifecycleEvent(res, - EventType.RESOURCE_CHANGED, - ReasonType.RESOURCE_CHANGED_CONTENTS)); - } - } - break; - case IResourceDelta.REMOVED: - { - fireLifecycleEvent(new ResourceLifecycleEvent(res, - EventType.RESOURCE_INACCESSIBLE, - ReasonType.RESOURCE_DELETED)); - } - break; - } - } - - private void handleWorkspaceRoot(final IResourceDelta delta) - { - for (final IResourceDelta childDelta : delta - .getAffectedChildren(IResourceDelta.ADDED)) - { - final IResource res = childDelta.getResource(); - if ((childDelta.getFlags() & IResourceDelta.OPEN) != 0 && - // project was just opened - res.getType() == IResource.PROJECT) - { - fireLifecycleEvent(new ResourceLifecycleEvent(res, - EventType.RESOURCE_ADDED, ReasonType.PROJECT_OPENED)); - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceLifecycleEvent.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceLifecycleEvent.java deleted file mode 100644 index 1484382a7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceLifecycleEvent.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.resource; - -import org.eclipse.core.resources.IResource; - -/** - * @author cbateman - * - */ -public class ResourceLifecycleEvent -{ - /** - * the type of lifecycle event - * this enum is not closed and may add new fields in the future - */ - public enum EventType - { - /** - * Indicates that the resource is no longer accessible (as testable with - * IResource.isAccessible). The reasonType will indicate why. - */ - RESOURCE_INACCESSIBLE, - - /** - * Indicates that the resource being tracked has changed in some - * way, use ReasonType to determine specifics - */ - RESOURCE_CHANGED, - - /** - * Indicates that the resource being tracked hass been added. Use - * ReasonType to determine specifics. - */ - RESOURCE_ADDED; - } - - /** - * encodes the cause of the event if the event type provides one - * this enum is not closed and may add new fields in the future - */ - public enum ReasonType - { - /** - * The resource was deleted from the workspace, - * this event is pre change if the event is project - * and post change otherwise - */ - RESOURCE_DELETED, - /** - * The resource's project was deleted. This event is - * pre-change. Note that if the tracked resource is - * a project, RESOURCE_DELETED will be fired, not this - * event. - */ - RESOURCE_PROJECT_DELETED, - /** - * The resource's project was closed. This event is pre-change - */ - RESOURCE_PROJECT_CLOSED, - /** - * Occurs when the contents of a non-project resource has changed - */ - RESOURCE_CHANGED_CONTENTS, - - /** - * Occurs when a project resource is added - */ - PROJECT_OPENED, - /** - * Occurs when a non-project resource is added. - */ - RESOURCE_ADDED - } - - private final IResource _affectedResource; - private final EventType _eventType; - private final ReasonType _reasonType; - - /** - * @param affectedResource - * @param eventType - * @param reasonType - */ - public ResourceLifecycleEvent(IResource affectedResource, EventType eventType, ReasonType reasonType) - { - _affectedResource = affectedResource; - _eventType = eventType; - _reasonType = reasonType; - } - - /** - * @return the affected resource - */ - public IResource getAffectedResource() { - return _affectedResource; - } - - /** - * @return the event that has occurred - */ - public EventType getEventType() { - return _eventType; - } - - /** - * @return the cause of the event - */ - public ReasonType getReasonType() { - return _reasonType; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceSingletonObjectManager.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceSingletonObjectManager.java deleted file mode 100644 index 903acc128..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/resource/ResourceSingletonObjectManager.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.resource; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jst.jsf.common.internal.managedobject.IManagedObject; -import org.eclipse.jst.jsf.common.internal.managedobject.ObjectManager; -import org.eclipse.jst.jsf.common.internal.resource.ResourceLifecycleEvent.EventType; -import org.eclipse.jst.jsf.common.internal.resource.ResourceLifecycleEvent.ReasonType; - -/** - * An object manager that manages a single instanceof an IManagedObject per - * resource. The manager takes care of ensuring that a managed object is - * properly disposed when a resource lifecycle event renders it inaccessible - * (i.e file is deleted, project is closed or delete). - * - * @author cbateman - * - * @param <RESOURCE> - * @param <MANAGEDOBJECT> - */ -public abstract class ResourceSingletonObjectManager<MANAGEDOBJECT extends IManagedObject, RESOURCE extends IResource> - extends ObjectManager<MANAGEDOBJECT, RESOURCE> -{ - // lazily initialized - private LifecycleListener _lifecycleListener; - private final Map<RESOURCE, ManagedResourceObject> _perResourceObjects; - - /** - * Default constructor - */ - protected ResourceSingletonObjectManager() - { - _perResourceObjects = new HashMap<RESOURCE, ManagedResourceObject>(); - } - - @Override - public final MANAGEDOBJECT getInstance(final RESOURCE key) - throws ManagedObjectException - { - synchronized(this) - { - runBeforeGetInstance(key); - ManagedResourceObject managedResObject = _perResourceObjects.get(key); - - if (managedResObject == null) - { - final MANAGEDOBJECT managedObject = createNewInstance(key); - - if (managedObject == null) - { - throw new ManagedObjectException( - "No object available for resource"); //$NON-NLS-1$ - } - managedResObject = manageResource(key, managedObject); - } - - runAfterGetInstance(key); - return managedResObject.getManagedObject(); - } - } - - /** - * @param resource - * @return a new instance of T associated with S. This operation must not - * cache T: a brand new instance is always required. getInstance - * will perform caching and resource listening. - */ - protected abstract MANAGEDOBJECT createNewInstance(RESOURCE resource); - - /** - * @param resource - */ - protected void runBeforeGetInstance(final RESOURCE resource) - { - // do nothing by default - } - - /** - * @param resource - */ - protected void runAfterGetInstance(final RESOURCE resource) - { - // do nothing by default - } - - /** - * @param resource - * @return true if there already exists a managed object associated with - * the resource - */ - public synchronized boolean isInstance(RESOURCE resource) - { - return _perResourceObjects.containsKey(resource); - } - - /** - * @return a copy of the current set of RESOURCE object keys that we - * are managing singletons for. Collection is mutable, but as a copy, - * changes to it do not effect thie object manager. - */ - public synchronized Collection<RESOURCE> getManagedResources() - { - final Set resources = new HashSet(_perResourceObjects.keySet()); - return resources; - } - /** - * Should be called by concrete classes to indicate they have created a new - * managed object for resource, for which they want to track lifecycle - * changes. - * - * @param resource - * @param managedObject - */ - private synchronized ManagedResourceObject manageResource(final RESOURCE resource, - final MANAGEDOBJECT managedObject) - { - final LifecycleListener listener = lazilyGetLifecycleListener(); - listener.addResource(resource); - final MyLifecycleEventListener eventListener = new MyLifecycleEventListener( - managedObject, resource); - listener.addListener(eventListener); - - final ManagedResourceObject managedResourceObject = new ManagedResourceObject( - managedObject, eventListener); - _perResourceObjects.put(resource, managedResourceObject); - return managedResourceObject; - } - - /** - * Stop managing the resource. If resource is the last one, the resource - * change listener will be removed (it will be added again when next - * manageResource is called). - * - * @param resource - */ - protected final synchronized void unmanageResource(final RESOURCE resource) - { - final ManagedResourceObject managedResourceObject = - _perResourceObjects.remove(resource); - final LifecycleListener listener = lazilyGetLifecycleListener(); - - if (managedResourceObject != null) - { - listener.removeListener(managedResourceObject.getEventListener()); - } - - listener.removeResource(resource); - } - - /** - * Call to register a listener - * - * @param listener - */ - protected final void addLifecycleEventListener( - final IResourceLifecycleListener listener) - { - final LifecycleListener lifecycleListener = lazilyGetLifecycleListener(); - lifecycleListener.addListener(listener); - } - - /** - * Call to remove a listener - * - * @param listener - */ - protected final void removeLifecycleEventListener( - final IResourceLifecycleListener listener) - { - final LifecycleListener lifecycleListener = lazilyGetLifecycleListener(); - lifecycleListener.removeListener(listener); - } - - private synchronized LifecycleListener lazilyGetLifecycleListener() - { - if (_lifecycleListener == null) - { - _lifecycleListener = new LifecycleListener(); - } - return _lifecycleListener; - } - - private class ManagedResourceObject - { - private final MANAGEDOBJECT _managedObject; - private final MyLifecycleEventListener _eventListener; - - private ManagedResourceObject(final MANAGEDOBJECT managedObject, - final MyLifecycleEventListener eventListener) - { - _managedObject = managedObject; - _eventListener = eventListener; - } - - public MANAGEDOBJECT getManagedObject() - { - return _managedObject; - } - - public MyLifecycleEventListener getEventListener() - { - return _eventListener; - } - } - - private class MyLifecycleEventListener implements - IResourceLifecycleListener - { - private final RESOURCE _resource; - private final MANAGEDOBJECT _managedObject; - - private MyLifecycleEventListener(final MANAGEDOBJECT managedObject, - final RESOURCE resource) - { - _resource = resource; - _managedObject = managedObject; - } - - public EventResult acceptEvent(final ResourceLifecycleEvent event) - { - final EventResult result = EventResult.getDefaultEventResult(); - - // not interested - if (!_resource.equals(event.getAffectedResource())) - { - return EventResult.getDefaultEventResult(); - } - - if (event.getEventType() == EventType.RESOURCE_INACCESSIBLE) - { - try - { - if (event.getReasonType() == ReasonType.RESOURCE_DELETED - || event.getReasonType() == ReasonType.RESOURCE_PROJECT_DELETED) - { - _managedObject.destroy(); - } - else - { - _managedObject.dispose(); - } - } - // dispose is external code out our control, so make sure - // unmanage gets called if it blows up. - finally - { - unmanageResource(_resource); - } - } - return result; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/AbstractIdentifiableStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/AbstractIdentifiableStrategy.java deleted file mode 100644 index 0de9778f4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/AbstractIdentifiableStrategy.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.strategy; - -/** - * Abstract base implementation for identifiable strategies. - * - * @author cbateman - * - * @param <INPUT> - * @param <OUTPUT> - * @param <IDTYPE> - */ -public abstract class AbstractIdentifiableStrategy<INPUT, OUTPUT, IDTYPE> implements - IIdentifiableStrategy<INPUT, OUTPUT, IDTYPE> -{ - private final IDTYPE _id; - private final OUTPUT _noResultValue; - private final String _displayName; - - /** - * @param id - * @param displayName - * @param noResultValue - */ - public AbstractIdentifiableStrategy(final IDTYPE id, final String displayName, - final OUTPUT noResultValue) - { - _id = id; - _noResultValue = noResultValue; - _displayName = displayName; - } - - public abstract OUTPUT perform(INPUT input) throws Exception; - - public OUTPUT getNoResult() - { - return _noResultValue; - } - - public IDTYPE getId() - { - return _id; - } - - public String getDisplayName() - { - return _displayName; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/IIdentifiableStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/IIdentifiableStrategy.java deleted file mode 100644 index 94cf53d92..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/IIdentifiableStrategy.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.strategy; - -import org.eclipse.jst.jsf.common.internal.policy.IIdentifiable; - - -/** - * A simple strategy that is identifiable - * - * @author cbateman - * - * @param <INPUT> - * @param <OUTPUT> - * @param <IDTYPE> - */ -public interface IIdentifiableStrategy<INPUT, OUTPUT, IDTYPE> - extends ISimpleStrategy<INPUT, OUTPUT>, IIdentifiable<IDTYPE> -{ - // nothing added. -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/ISimpleStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/ISimpleStrategy.java deleted file mode 100644 index 787a31090..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/ISimpleStrategy.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.strategy; - -/** - * A strategy that takes an INPUT, performs a calculation on it, and returns - * an OUTPUT - * @author cbateman - * - * @param <INPUT> - * @param <OUTPUT> - */ -public interface ISimpleStrategy<INPUT, OUTPUT> -{ - /** - * Perform the algorithm on input and return OUTPUT. This type of - * operation should avoid side-effects, but may throw exceptions. - * - * @param input - * @return the result of the strategy algorithm - * @throws Exception implementers should narrow what exceptions are thrown. - */ - public OUTPUT perform(INPUT input) throws Exception; - - /** - * @return the single value that perform will return if it cannot calculate - * a meaningful result for an input. The value must be unique, the same - * for all inputs and must be testable using the '==' operator. - */ - public OUTPUT getNoResult(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/IteratorPolicyBasedStrategyComposite.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/IteratorPolicyBasedStrategyComposite.java deleted file mode 100644 index 189db814f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/IteratorPolicyBasedStrategyComposite.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.strategy; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.internal.policy.IIteratorPolicy; - -/** - * A strategy composite that uses an iterator policy to provide the iterator - * used to decide what order to execute the strategy in. - * - * This composite represents a grouping of strategies which represent N ways - * to perform a particular calculation and which any number for those N ways - * may be applicable to any particular situation given the policy in place. - * - * By default, the first such strategy in policy order to provide the calculation - * wins and it's result is returned. You can modify the way the result is composed - * by providing your own composition strategy using the two-arg constructor. - * - * - * - * @author cbateman - * - * @param <INPUT> - * @param <OUTPUT> - * @param <RESULTTYPE> - * @param <IDTYPE> - * @param <STRATEGYTYPE> - */ -public abstract class IteratorPolicyBasedStrategyComposite<INPUT, OUTPUT, RESULTTYPE, IDTYPE, STRATEGYTYPE extends IIdentifiableStrategy<INPUT, OUTPUT, IDTYPE>> - extends StrategyComposite<INPUT, OUTPUT, RESULTTYPE, IDTYPE, STRATEGYTYPE> -{ - private final Map<IDTYPE, STRATEGYTYPE> _strategies; - private IIteratorPolicy<IDTYPE> _policy; - private final Object _changeLock = new Object(); - - /** - * @param policy - */ - protected IteratorPolicyBasedStrategyComposite(final IIteratorPolicy<IDTYPE> policy) - { - super(); - _policy = policy; - _strategies = new HashMap<IDTYPE, STRATEGYTYPE>(); - } - - /** - * @param policy - * @param compositionStrategy - */ - protected IteratorPolicyBasedStrategyComposite(final IIteratorPolicy<IDTYPE> policy, AbstractCompositionStrategy<INPUT, OUTPUT, RESULTTYPE, STRATEGYTYPE> compositionStrategy) - { - super(compositionStrategy); - _policy = policy; - _strategies = new HashMap<IDTYPE, STRATEGYTYPE>(); - } - - /** - * Add strategy if not already present. - * - * @param strategy - */ - public final void addStrategy(final STRATEGYTYPE strategy) - { - synchronized(_changeLock) - { - _strategies.put(strategy.getId(), strategy); - } - } - - /** - * @param strategy - */ - public final void removeStrategy(final STRATEGYTYPE strategy) - { - synchronized(_changeLock) - { - _strategies.remove(strategy.getId()); - } - } - - /** - * Change the active policy used to select the order in which the composite - * calls it's child strategies. - * - * If the policy is not set, then strategies are called in - * - * @param policy - */ - public final void setPolicy(final IIteratorPolicy<IDTYPE> policy) - { - // policy may not be null - if (policy == null) - { - JSFCommonPlugin.log(new Exception("stack trace only"), "Policy can't be null"); //$NON-NLS-1$ //$NON-NLS-2$ - return; - } - - // protect access in case getIterator is being called simulataneously - synchronized(_changeLock) - { - _policy = policy; - } - } - - @Override - public final Iterator<STRATEGYTYPE> getIterator() - { - IIteratorPolicy<IDTYPE> policy = null; - Map<IDTYPE, STRATEGYTYPE> strategies = Collections.emptyMap(); - - synchronized(_changeLock) - { - policy = _policy; - strategies = Collections.unmodifiableMap(new HashMap<IDTYPE, STRATEGYTYPE>(_strategies)); - } - - final Iterator<IDTYPE> iterator = policy.getIterator(strategies.keySet()); - return new StrategyIterator<IDTYPE, STRATEGYTYPE>(strategies, iterator); - } - - @Override - public abstract RESULTTYPE getNoResult(); - - private static class StrategyIterator<IDTYPE, STRATEGYTYPE> implements - Iterator<STRATEGYTYPE> - { - private final Map<IDTYPE, STRATEGYTYPE> _map; - private final Iterator<IDTYPE> _policyIterator; - - private StrategyIterator(final Map<IDTYPE, STRATEGYTYPE> map, - final Iterator<IDTYPE> policyIterator) - { - _map = map; - _policyIterator = policyIterator; - } - - public boolean hasNext() - { - return _policyIterator.hasNext(); - } - - public STRATEGYTYPE next() - { - IDTYPE id = _policyIterator.next(); - return _map.get(id); - } - - public void remove() - { - throw new UnsupportedOperationException(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/MergingCompositionStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/MergingCompositionStrategy.java deleted file mode 100644 index 4e8cb428b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/MergingCompositionStrategy.java +++ /dev/null @@ -1,213 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.strategy; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.jst.jsf.common.internal.strategy.StrategyComposite.AbstractCompositionStrategy; -import org.eclipse.jst.jsf.common.internal.strategy.StrategyComposite.CompositionArguments; - -/** - * A composition strategy that merges the result of all composed strategies. The - * merge policy is left to concrete implementations. Three concrete impls are - * provided: one that uses compose all (List) and one that uses compose unique - * (Set) and a third that uses Map. - * - * @author cbateman - * - * @param <INPUT> - * @param <MERGETYPE> - * @param <STRATEGY> - */ -/** - * @author cbateman - * - * @param <INPUT> - * @param <OUTPUT> - * @param <MERGETYPE> - * @param <STRATEGY> - */ -public abstract class MergingCompositionStrategy<INPUT, OUTPUT, MERGETYPE, STRATEGY extends ISimpleStrategy<INPUT, OUTPUT>> -extends AbstractCompositionStrategy<INPUT, OUTPUT, MERGETYPE, STRATEGY> -{ - /** - * The result of the merge. - */ - protected final MERGETYPE _composedResult; - - /** - * @param composedResult - * @param noResultValue - */ - public MergingCompositionStrategy(final MERGETYPE composedResult, - final MERGETYPE noResultValue) - { - super(); - _composedResult = composedResult; - } - - @Override - public boolean compose(final CompositionArguments<INPUT, OUTPUT, STRATEGY> args) - throws Exception - { - final OUTPUT result = args.getStrategy().perform(args.getInput()); - if (result != args.getStrategy().getNoResult()) - { - doCompose(result); - } - // never stop composing early - return false; - } - - /** - * Sub-classes must implement to do the detail composition for their result - * type. - * - * @param result - */ - protected abstract void doCompose(OUTPUT result); - - @Override - public MERGETYPE getComposedResult() - { - return _composedResult; - } - - @Override - public abstract void reset(); - - /** - * An implementation that uses a List to implement the list policy. The - * result is to add all results from all composed strategies to a single - * list. Duplicates may occur. - * - * @param <INPUT> - * @param <OUTPUT> - * @param <MERGETYPE> - * @param <STRATEGY> - * ` - */ - public static class ListMergingCompositionStrategy<INPUT, OUTPUT, MERGETYPE extends List, STRATEGY extends ISimpleStrategy<INPUT, OUTPUT>> - extends - MergingCompositionStrategy<INPUT, OUTPUT, MERGETYPE, STRATEGY> - { - /** - * @param composedResult - * @param noResultValue - */ - public ListMergingCompositionStrategy(final MERGETYPE composedResult, - final MERGETYPE noResultValue) - { - super(composedResult, noResultValue); - } - - @Override - protected void doCompose(final OUTPUT result) - { - if (result instanceof Collection) - { - _composedResult.addAll((Collection) result); - } else - { - _composedResult.add(result); - } - } - - @Override - public void reset() - { - _composedResult.clear(); - } - } - - /** - * An implementation that uses a List to implement the list policy. The - * result is to add all results from all composed strategies to a single - * list. Duplicates will not occur. - * - * @param <INPUT> - * @param <OUTPUT> - * @param <MERGETYPE> - * @param <STRATEGY> - */ - public static class SetMergingCompositionStrategy<INPUT, OUTPUT, MERGETYPE extends Set, STRATEGY extends ISimpleStrategy<INPUT, OUTPUT>> - extends - MergingCompositionStrategy<INPUT, OUTPUT, MERGETYPE, STRATEGY> - { - /** - * @param composedResult - * @param noResultValue - */ - public SetMergingCompositionStrategy(final MERGETYPE composedResult, - final MERGETYPE noResultValue) - { - super(composedResult, noResultValue); - } - - @Override - protected void doCompose(final OUTPUT result) - { - if (result instanceof Collection) - { - _composedResult.addAll((Collection) result); - } else - { - _composedResult.add(result); - } - } - - @Override - public void reset() - { - _composedResult.clear(); - } - } - - /** - * @author cbateman - * - * @param <INPUT> - * @param <OUTPUT> - * @param <MERGETYPE> - * @param <STRATEGY> - */ - public abstract static class MapMergingCompositionStrategy<INPUT, OUTPUT, MERGETYPE extends Map, STRATEGY extends ISimpleStrategy<INPUT, OUTPUT>> - extends - MergingCompositionStrategy<INPUT, OUTPUT, MERGETYPE, STRATEGY> - { - /** - * @param composedResult - * @param noResultValue - */ - public MapMergingCompositionStrategy(final MERGETYPE composedResult, - final MERGETYPE noResultValue) - { - super(composedResult, noResultValue); - } - - @Override - protected void doCompose(final OUTPUT result) - { - if (result instanceof Map) - { - _composedResult.putAll((Map) result); - } else - { - _composedResult.put(calculateKey(result), result); - } - } - - /** - * @param result - * @return the key to be used for result in any composed map. - */ - protected abstract Object calculateKey(final OUTPUT result); - - @Override - public void reset() - { - _composedResult.clear(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/SimpleStrategyComposite.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/SimpleStrategyComposite.java deleted file mode 100644 index 25c567af7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/SimpleStrategyComposite.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.eclipse.jst.jsf.common.internal.strategy; - -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; - -/** - * A simple concrete implementation that uses a constructor provided values - * to implement abstract methods. - * - * @author cbateman - * - * @param <INPUT> - * @param <OUTPUT> - * @param <RESULTTYPE> - * @param <IDTYPE> - * @param <STRATEGYTYPE> - */ -public class SimpleStrategyComposite<INPUT, OUTPUT, RESULTTYPE, IDTYPE, STRATEGYTYPE extends IIdentifiableStrategy<INPUT,OUTPUT,IDTYPE>> extends -StrategyComposite<INPUT, OUTPUT, RESULTTYPE, IDTYPE, STRATEGYTYPE> -{ - - private final RESULTTYPE _noResultValue; - private final Collection<STRATEGYTYPE> _strategies; - - /** - * Use the list of strategies and null as the no result value. - * @param strategies - */ - public SimpleStrategyComposite(final Collection<STRATEGYTYPE> strategies) - { - this(strategies, (RESULTTYPE) null); - } - /** - * Use the list of strategies and the provided no result value. - * @param strategies - * @param noResultValue - */ - public SimpleStrategyComposite(final Collection<STRATEGYTYPE> strategies, final RESULTTYPE noResultValue) - { - super(); - _strategies = strategies; - _noResultValue = noResultValue; - } - - /** - * Use the provided strategies, composition strategy and null for the no result value - * @param strategies - * @param compositionStrategy - */ - public SimpleStrategyComposite(final Collection<STRATEGYTYPE> strategies, - final AbstractCompositionStrategy<INPUT, OUTPUT, RESULTTYPE, STRATEGYTYPE> compositionStrategy) - { - this(strategies, null, compositionStrategy); - } - - /** - * Use the provided strategies, composition strategy and null for the no result value - * @param strategies - * @param noResultValue - * @param compositionStrategy - */ - public SimpleStrategyComposite(final Collection<STRATEGYTYPE> strategies, final RESULTTYPE noResultValue, - final AbstractCompositionStrategy<INPUT, OUTPUT, RESULTTYPE, STRATEGYTYPE> compositionStrategy) - { - super(compositionStrategy); - _strategies = strategies; - _noResultValue = noResultValue; - } - - @Override - public RESULTTYPE getNoResult() - { - return _noResultValue; - } - - @Override - public Iterator<STRATEGYTYPE> getIterator() - { - return Collections.unmodifiableCollection(_strategies).iterator(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/StrategyComposite.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/StrategyComposite.java deleted file mode 100644 index c7842c038..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/strategy/StrategyComposite.java +++ /dev/null @@ -1,240 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.strategy; - -import java.util.Iterator; - -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * A composite strategy whos role is to iterate through a number of child - * stategies until one returns a valid value for an input. - * - * @author cbateman - * - * @param <INPUT> - * @param <OUTPUT> - * @param <RESULTOUTPUT> - * @param <IDTYPE> - * @param <STRATEGYTYPE> - */ -public abstract class StrategyComposite<INPUT, OUTPUT, RESULTOUTPUT, IDTYPE, STRATEGYTYPE extends IIdentifiableStrategy<INPUT, OUTPUT, IDTYPE>> -implements ISimpleStrategy<INPUT, RESULTOUTPUT> -{ - private final AbstractCompositionStrategy<INPUT, OUTPUT, RESULTOUTPUT, STRATEGYTYPE> _compositionStrategy; - - /** - * @param compositionStrategy - */ - protected StrategyComposite( - final AbstractCompositionStrategy<INPUT, OUTPUT, RESULTOUTPUT, STRATEGYTYPE> compositionStrategy) - { - _compositionStrategy = compositionStrategy; - } - - /** - * Default constructor: composite returns the first value found. - */ - protected StrategyComposite() - { - // by default, the composition strategy selects the first value - this( - new DefaultCompositionStrategy<INPUT, OUTPUT, RESULTOUTPUT, STRATEGYTYPE>()); - } - - public final RESULTOUTPUT perform(final INPUT input) - { - final Iterator<STRATEGYTYPE> sIt = getIterator(); - - RESULTOUTPUT result = getNoResult(); - boolean finishedComposing = false; - - EXECUTE_LOOP: while (sIt.hasNext()) - { - final STRATEGYTYPE strategy = sIt.next(); - try - { - finishedComposing = _compositionStrategy - .compose(new CompositionArguments<INPUT, OUTPUT, STRATEGYTYPE>( - strategy, input)); - // returns true if we are done composing - if (finishedComposing) - { - result = _compositionStrategy.getComposedResult(); - break EXECUTE_LOOP; - } - } catch (final Exception e) - { - JSFCommonPlugin.log(e); - } - } - - if (finishedComposing) - { - return result; - } - return getNoResult(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.jst.jsf.common.internal.strategy.ISimpleStrategy#getNoResult - * () - */ - public abstract RESULTOUTPUT getNoResult(); - - /** - * @return an iterator that will return the next strategy to be executed - */ - public abstract Iterator<STRATEGYTYPE> getIterator(); - - /** - * @author cbateman - * @param <INPUT> - * @param <OUTPUT> - * @param <RESULTOUTPUT> - * @param <STRATEGY> - */ - public abstract static class AbstractCompositionStrategy<INPUT, OUTPUT, RESULTOUTPUT, STRATEGY extends ISimpleStrategy<INPUT, OUTPUT>> - implements ISimpleStrategy<CompositionArguments<INPUT, OUTPUT, STRATEGY>, Boolean> - { - private final Boolean _noResultValue; - - /** - * - */ - protected AbstractCompositionStrategy() - { - _noResultValue = null; - reset(); - } - - /** - * @param input - * @return true if composing is finished based on the input, false - * otherwise - * @throws Exception - */ - public abstract boolean compose(CompositionArguments<INPUT, OUTPUT, STRATEGY> input) throws Exception; - - @SuppressWarnings("boxing") - public final Boolean perform(final CompositionArguments<INPUT, OUTPUT, STRATEGY> input) throws Exception - { - return compose(input); - } - - /** - * @return the result of composing. - */ - public abstract RESULTOUTPUT getComposedResult(); - - public Boolean getNoResult() - { - return _noResultValue; - } - - /** - * Clear any composed result and make strategy reusable as if it were - * newly constructed. This method is only called automatically at construction. - * - * Owners should call to control the contents of their result list. - */ - public abstract void reset(); - } - - /** - * The default composition strategy. This causes the first strategy that returns - * a non-NoResult value to have it's value returned. - * - * @param <INPUT> - * @param <OUTPUT> - * @param <RESULTOUTPUT> - * @param <STRATEGY> - */ - public final static class DefaultCompositionStrategy<INPUT, OUTPUT, RESULTOUTPUT, STRATEGY extends ISimpleStrategy<INPUT, OUTPUT>> - extends AbstractCompositionStrategy<INPUT, OUTPUT, RESULTOUTPUT, STRATEGY> - { - private RESULTOUTPUT _result; - - /** - * - */ - public DefaultCompositionStrategy() - { - super(); - } - - @Override - public boolean compose(final CompositionArguments<INPUT, OUTPUT, STRATEGY> arg) throws Exception - { - final OUTPUT result = arg.getStrategy().perform(arg.getInput()); - if (result != arg.getStrategy().getNoResult()) - { - _result = (RESULTOUTPUT)result; - return true; - } - return false; - } - - @Override - public RESULTOUTPUT getComposedResult() - { - return _result; - } - - @Override - public void reset() - { - _result = null; - } - } - - /** - * Bundle values needed by the composing strategies into a single arg object. - * - * @param <INPUT> - * @param <OUTPUT> - * @param <STRATEGY> - */ - public final static class CompositionArguments<INPUT, OUTPUT, STRATEGY extends ISimpleStrategy<INPUT, OUTPUT>> - { - private final STRATEGY _strategy; - private final INPUT _input; - - /** - * @param strategy - * @param input - */ - public CompositionArguments(final STRATEGY strategy, final INPUT input) - { - _strategy = strategy; - _input = input; - } - - /** - * @return the strategy - */ - public STRATEGY getStrategy() - { - return _strategy; - } - - /** - * @return the input - */ - public INPUT getInput() - { - return _input; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/BooleanLiteralType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/BooleanLiteralType.java deleted file mode 100644 index 6055e5f50..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/BooleanLiteralType.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import org.eclipse.jdt.core.Signature; - -/** - * Represents a BooleanLiteral as defined by JSP.2.9 - * - * @author cbateman - * - */ -public class BooleanLiteralType extends LiteralType -{ - /** - * The literal FALSE singleton - */ - public final static BooleanLiteralType FALSE = new BooleanLiteralType(false); - /** - * The literal TRUE singleton - */ - public final static BooleanLiteralType TRUE = new BooleanLiteralType(true); - - private final boolean _literalValue; - - - /** - * @param value - * @return a constant boolean literal type corresponding to value - */ - public static BooleanLiteralType valueOf(boolean value) - { - return value ? TRUE : FALSE; - } - - /** - * @param literalValue - */ - /*package*/BooleanLiteralType(boolean literalValue) - { - super(Signature.SIG_BOOLEAN); - _literalValue = literalValue; - } - - public Number coerceToNumber(Class T) throws TypeCoercionException - { - // illegal to coerce boolean to number per JSP.2.8.3 step 3 - throw new TypeCoercionException("Cannot coerce boolean to number"); //$NON-NLS-1$ - } - - public String getLiteralValue() - { - return Boolean.toString(_literalValue); - } - - public Object getLiteralValueRaw() - { - return Boolean.valueOf(_literalValue); - } - - public Boolean coerceToBoolean() throws TypeCoercionException - { - return Boolean.valueOf(_literalValue); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/CompositeType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/CompositeType.java deleted file mode 100644 index 9069f056d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/CompositeType.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import org.eclipse.jdt.core.Signature; - - -/** - * Encapsulates the runtime type or types of a JSF entity in a - * way that can be compared to other entities - * - * @author cbateman - * - */ -public class CompositeType -{ - private final String[] _signatures; - private final int _assignmentType; - - private boolean[] _isTypeSignature; // = null lazily derived from signatures - // on first access - /** - * @param signatureStrings - * @param assignmentType - */ - public CompositeType(String[] signatureStrings, int assignmentType) - { - if (signatureStrings == null - || signatureStrings.length < 1) - { - throw new AssertionError("Must specify at least one signature string"); //$NON-NLS-1$ - } - - _signatures = new String[signatureStrings.length]; - System.arraycopy(signatureStrings, 0, _signatures, 0, _signatures.length); - _assignmentType = assignmentType; - } - - /** - * Convenience constructor for most common case where composite only - * consistes of a single type signature - * - * @param signatureString - * @param assignmentType - */ - public CompositeType(String signatureString, int assignmentType) - { - this(new String[]{signatureString}, assignmentType); - } - /** - * @return the assignment type mask - */ - public int getAssignmentTypeMask() - { - return _assignmentType; - } - - /** - * @return true if the composite type supports being on the LHS of an - * assignment - */ - public boolean isLHS() - { - return TypeUtil.matchesLHS(_assignmentType); - } - - /** - * @return true if the composite type supports being on the RHS of an - * assignment - */ - public boolean isRHS() - { - return TypeUtil.matchesRHS(_assignmentType); - } - - /** - * @return an array of booleans. The value in each index of the array - * is true if the corresponding position _signatures corresponds to a type - * signature and false if it's a method signature - */ - public boolean[] getIsTypeSignature() - { - return getTypeSignatureFlags(); - } - - /** - * @return the type signatures. Changes to the returned form do not - * affect the internal values - */ - public String[] getSignatures() - { - final String[] copy = new String[_signatures.length]; - System.arraycopy(_signatures, 0, copy, 0, _signatures.length); - return copy; - } - - public String toString() - { - final StringBuffer stringBuffer = new StringBuffer(); - - for (int i = 0; i < _signatures.length; i++) - { - stringBuffer.append(_signatures[i]); - stringBuffer.append(" | "); //$NON-NLS-1$ - } - - return stringBuffer.toString(); - } - - /** - * @return a version of to string with of the type signatures replaced - * with their more Javaeseque names - */ - public String toUserReadableString() - { - final StringBuffer stringBuffer = new StringBuffer(); - - for (int i = 0; i < _signatures.length; i++) - { - final String signature = _signatures[i]; - - if (getTypeSignatureFlags()[i]) - { - stringBuffer.append(Signature.getSignatureSimpleName(signature)); - } - - if (i < _signatures.length -1) - { - stringBuffer.append(", "); //$NON-NLS-1$ - } - } - return stringBuffer.toString(); - } - - private boolean[] getTypeSignatureFlags() - { - if (_isTypeSignature == null) - { - _isTypeSignature = new boolean[_signatures.length]; - - for (int i = 0; i < _signatures.length; i++) - { - try - { - Signature.getTypeSignatureKind(_signatures[i]); - - // if an exception wasn't thrown above, then it - // is some sort of type signature - _isTypeSignature[i] = true; - } - catch (IllegalArgumentException ae) - { - // getTypeSignatureKind threw an exception, so - // this signature is a method - _isTypeSignature[i] = false; - } - } - } - - return _isTypeSignature; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/CompositeTypeCoercer.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/CompositeTypeCoercer.java deleted file mode 100644 index 5f2aff492..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/CompositeTypeCoercer.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - - -/** - * Follows type coercion rules codified in section JSP.2.8 of the - * JSP 2.0 Specification. - * - * This class operates on CompositeType's and returns raw - * Java signatures for the single resulting type coercion. - * - * The rules are stretched a little bit since JSP.2.8 defines how to - * coerce an *instance* A to a type T. But since we have no runtime instances, - * only their types, we approximate by taking what we know about the type of A - * and coercing it T as best we can. - * - * Also, whereas the spec says to throw errors when coercion is not possible, - * we have two cases: - * - * 1) We can determine definitively that there is no coercion - * 2) We cannot determine whether there is or isn't a coercion - * - * In case 1, we always throw an exception. In case 2, we return null to indicate - * "indeterminate" result, rather than error. - * - * @author cbateman - * - */ -public class CompositeTypeCoercer -{ - /** - * This method follows JSP.2.8.3 except that rather than returning a specific - * type that has been coerced to, it determines the most exact possible type - * that typeOfA can be coerced to, to be number compatible. The caller must - * decide what do with the return value compared to the type (N in the spec) - * that they want to coerce to. - * - * @param typeOfA - * @return a new signature for the type of A after being coerced to a Number - * @throws TypeCoercionException if A can definitively not be coerced to - * a number - */ - public static String coerceToNumber(final CompositeType typeOfA) - throws TypeCoercionException - { - String coercedType = null; - boolean errorDetected = true; // assume error: only false if we - // find a member of typeOfA that - // coerces to number - - // JSP.2.8.1 -- auto-box primitives - final CompositeType boxedTypeOfA = - TypeTransformer.transformBoxPrimitives(typeOfA); - final boolean[] typesigs = boxedTypeOfA.getIsTypeSignature(); - - // iterate through all of the signatures that represent types - // and find at least one that can be coerced to a number - for (int i = 0; i < typesigs.length; i++) - { - if (typesigs[i]) - { - try - { - final String testType = - TypeCoercer.coerceToNumber(boxedTypeOfA.getSignatures()[i]); - - if (testType != null) - { - // if we have already found a coercible type, then - // we need to return null, since we have a conflict that - // we don't know how to resolve to a type?????? - if (coercedType != null) - { - return null; - } - - coercedType = testType; - } - errorDetected = false; // we have found a number coercion or indeterminate - } - catch (TypeCoercionException tce) - { - // do nothing: so far error still detected - } - } - } - - // we have three choices: - // 1: if errorDetected was never cleared, we definitely never found - // a coerceable type, so throw exception - if (errorDetected) - { - throw new TypeCoercionException(); - } - - // otherwise the flag was cleared return what we found - if (coercedType != null) - { - // need to unbox per JSP.2.8.1 - coercedType = - TypeTransformer.transformUnboxPrimitives(coercedType); - } - - return coercedType; - } - - -// public static String coerceToBoolean(CompositeType compositeType) -// { -// -// } - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/FloatLiteralType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/FloatLiteralType.java deleted file mode 100644 index 5631b8700..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/FloatLiteralType.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.eclipse.jdt.core.Signature; - -/** - * Represents an FloatLiteral as defined by JSP.2.9 - * @author cbateman - * - */ -public class FloatLiteralType extends NumericTypeLiteral -{ - private final double _literalValue; - - /** - * @param literalValue - */ - public FloatLiteralType(double literalValue) - { - // according to the notes to JSP.2.9, bullet 5, float literals are doubles - super(Signature.SIG_DOUBLE); - _literalValue = literalValue; - } - - protected Number getBoxedValue() - { - return new Double(_literalValue); - } - - public Number coerceToNumber(Class T) throws TypeCoercionException - { - if (T == BigInteger.class) - { - return new BigDecimal(_literalValue).toBigInteger(); - } - else if (T == BigDecimal.class) - { - return new BigDecimal(_literalValue); - } - - Number commonCoercion = super.coerceToNumber(T); - - if (commonCoercion == null) - { - throw new IllegalArgumentException("Not a target numeric type: "+T); //$NON-NLS-1$ - } - - return commonCoercion; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/IAssignable.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/IAssignable.java deleted file mode 100644 index 8b74dfd85..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/IAssignable.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -/** - * Defines the lhs/rhs rules for a type - * @author cbateman - * - */ -public interface IAssignable -{ - /** - * Type is none: it cannot be assigned to. method binding. - */ - public static int ASSIGNMENT_TYPE_NONE = 0x0; - /** - * Type is lhs: it can be assigned to - */ - public static int ASSIGNMENT_TYPE_LHS = 0x1; - - /** - * Type is rhs: it can be assigned from - */ - public static int ASSIGNMENT_TYPE_RHS = 0x2; - - /** - * @return the assigment mask - */ - public int getAssignability(); - - /** - * @return true if ASSIGNMENT_TYPE_LHS is set in getAssignability - */ - public boolean isLHS(); - /** - * @return true if ASSIGNMENT_TYPE_RHS is set in getAssignability - */ - public boolean isRHS(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/IntegerLiteralType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/IntegerLiteralType.java deleted file mode 100644 index d7a3be803..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/IntegerLiteralType.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.eclipse.jdt.core.Signature; - -/** - * Represents a IntegerLiteral as defined by JSP.2.9 - * @author cbateman - * - */ -public class IntegerLiteralType extends NumericTypeLiteral -{ - /** - * A singleton for zero literals - */ - public final static IntegerLiteralType ZERO = new IntegerLiteralType(0); - - private final long _literalValue; - - /** - * @param literalValue - */ - public IntegerLiteralType(long literalValue) - { - // according to the notes to JSP.2.9, bullet 4, integer literals are longs - super(Signature.SIG_LONG); - _literalValue = literalValue; - } - - protected Number getBoxedValue() - { - return Long.valueOf(_literalValue); - } - - /** - * Per JSP.2.8.3, step 5 - * @see org.eclipse.jst.jsf.common.internal.types.LiteralType#coerceToNumber(java.lang.Class) - */ - public Number coerceToNumber(Class T) throws TypeCoercionException - { - if (T == BigInteger.class) - { - return BigInteger.valueOf(_literalValue); - } - else if (T == BigDecimal.class) - { - return BigDecimal.valueOf(_literalValue); - } - - Number commonCoercion = super.coerceToNumber(T); - - if (commonCoercion == null) - { - throw new IllegalArgumentException("Not a target numeric type: "+T); //$NON-NLS-1$ - } - - return commonCoercion; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/LiteralType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/LiteralType.java deleted file mode 100644 index 3ea6de53c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/LiteralType.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - - -/** - * Encodes a type signature and a string that has some literal value based on - * the type signature. The class represents only a value object -- no attempt - * is made to assert that the literalValue is really of the type specified. - * - * @author cbateman - * - */ -public abstract class LiteralType extends ValueType -{ - - /** - * Consider a new literal type - * - * @param signature - */ - protected LiteralType(final String signature) - { - super(signature, IAssignable.ASSIGNMENT_TYPE_RHS); - } - - /** - * @return the literal value string (unparsed) - */ - public abstract String getLiteralValue(); - - /** - * @return the actual untranslated literal value as an object - */ - public abstract Object getLiteralValueRaw(); - - /** - * @return the type signature - */ - public final String getSignature() { - return super.getSignature(); - } - - /** - * @return a type signature for the kind of number this literal will coerce - * into when asked to become a number or null if this cannot be determined - * @throws TypeCoercionException if this literal has no legal coercion into - * a number - */ - public String getNumberCoercion() throws TypeCoercionException - { - // always box before coercion - return - TypeCoercer.coerceToNumber( - TypeTransformer.transformBoxPrimitives(getSignature())); - } - - /** - * @param T - * @return a Number coercion of the literal's value, null if indeterminate - * @throws TypeCoercionException if the coercion is illegal - */ - public abstract Number coerceToNumber(Class T) throws TypeCoercionException; - - /** - * @return a Boolean coercion of the literal's value, null if indeterminate - * @throws TypeCoercionException if the coercion is illegal - */ - public abstract Boolean coerceToBoolean() throws TypeCoercionException; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/Messages.java deleted file mode 100644 index b3db7a5e6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/Messages.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.internal.types; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * Message bundle - * - */ -public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.common.internal.types.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - // no external construction - } - - /** - * @param key - * @return the string for key or !key! if not found - */ - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/MethodType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/MethodType.java deleted file mode 100644 index 38e47b0c6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/MethodType.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -/** - * Signature type for method bindings in an EL expression - * - * @author cbateman - * - */ -public class MethodType implements SignatureBasedType -{ - private final String _methodName; - private final String _signature; - - /** - * @param methodName - * @param signature - */ - public MethodType(final String methodName, final String signature) - { - _methodName = methodName; - _signature = signature; - } - - /** - * @see org.eclipse.jst.jsf.common.internal.types.SignatureBasedType#getSignature() - */ - public String getSignature() - { - return _signature; - } - - /** - * @return the method name signature - */ - public String getMethodName() - { - return _methodName; - } - - public CompositeType toCompositeType() - { - return new CompositeType(_signature, IAssignable.ASSIGNMENT_TYPE_NONE); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/NullLiteralType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/NullLiteralType.java deleted file mode 100644 index eeb43e69d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/NullLiteralType.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import java.math.BigDecimal; -import java.math.BigInteger; - -/** - * Represents a NullLiteralType per JSP.2.9 - * - * @author cbateman - * - */ -public class NullLiteralType extends LiteralType -{ - /** - * The singleton null literal - */ - public final static NullLiteralType SINGLETON = new NullLiteralType(); - - /** - * Construct a new null - */ - private NullLiteralType() - { - super(TypeConstants.TYPE_NULL); // use void to indicate null in this situation - } - - /** - * Per JSP.2.8.5 null is always false - * - * @see org.eclipse.jst.jsf.common.internal.types.LiteralType#coerceToBoolean() - */ - public Boolean coerceToBoolean() throws TypeCoercionException - { - return Boolean.FALSE; - } - - /** - * Per JSP.2.8.3, null is always 0 - * - * @see org.eclipse.jst.jsf.common.internal.types.LiteralType#coerceToNumber(java.lang.Class) - */ - public Number coerceToNumber(Class T) throws TypeCoercionException { - if (T == BigInteger.class) - { - return BigInteger.ZERO; - } - else if (T == BigDecimal.class) - { - return new BigDecimal(0.0); - } - else if (T == Double.class || T == Double.TYPE) - { - return new Double(0.0); - } - else if (T == Float.class || T == Float.TYPE) - { - return new Float(0.0); - } - else if (T == Long.class || T == Long.TYPE) - { - return Long.valueOf(0L); - } - else if (T == Integer.class || T == Integer.TYPE) - { - return Integer.valueOf(0); - } - else if (T == Short.class || T == Short.TYPE) - { - return Short.valueOf((short)0); - } - else if (T == Byte.class || T == Byte.TYPE) - { - return Byte.valueOf((byte)0); - } - else - { - throw new IllegalArgumentException("Not a target numeric type: "+T); //$NON-NLS-1$ - } - } - - /** - * Per JSP.2.8.2 null is always an empty string - * @see org.eclipse.jst.jsf.common.internal.types.LiteralType#getLiteralValue() - */ - public String getLiteralValue() - { - return ""; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.internal.types.LiteralType#getLiteralValueRaw() - */ - public Object getLiteralValueRaw() - { - return null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/NumericTypeLiteral.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/NumericTypeLiteral.java deleted file mode 100644 index 8b6acbe05..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/NumericTypeLiteral.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - - -/** - * Common super-type for Float and Integer literals - * @author cbateman - * - */ -public abstract class NumericTypeLiteral extends LiteralType -{ - /** - * @param signature - */ - protected NumericTypeLiteral(String signature) - { - super(signature); - } - - /** - * @return the boxed form of the numeric literal value - */ - protected abstract Number getBoxedValue(); - - public Number coerceToNumber(Class T) throws TypeCoercionException - { - Number boxedLiteralValue = getBoxedValue(); - - if (T == Double.class || T == Double.TYPE) - { - return new Double(boxedLiteralValue.doubleValue()); - } - else if (T == Float.class || T == Float.TYPE) - { - return new Float(boxedLiteralValue.floatValue()); - } - else if (T == Long.class || T == Long.TYPE) - { - return boxedLiteralValue; - } - else if (T == Integer.class || T == Integer.TYPE) - { - return Integer.valueOf(boxedLiteralValue.intValue()); - } - else if (T == Short.class || T == Short.TYPE) - { - return Short.valueOf(boxedLiteralValue.shortValue()); - } - else if (T == Byte.class || T == Byte.TYPE) - { - return Byte.valueOf(boxedLiteralValue.byteValue()); - } - else - { - return null; - } - } - - public String getLiteralValue() - { - return getBoxedValue().toString(); - } - - public Object getLiteralValueRaw() - { - return getBoxedValue(); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.internal.types.LiteralType#coerceToBoolean() - */ - public Boolean coerceToBoolean() throws TypeCoercionException { - // JSP.2.8.5 does not provide for number -> boolean coercion - throw new TypeCoercionException("Cannot coerce number to boolean"); //$NON-NLS-1$ - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/SignatureBasedType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/SignatureBasedType.java deleted file mode 100644 index 41e2bb482..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/SignatureBasedType.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -/** - * Defines a signature-based type. Signatures must conform to the JVM - * type signature format as defined in the JVM specs and in the JDT Signature - * class - * - * @author cbateman - * - */ -public interface SignatureBasedType -{ - /** - * @return the signature string - */ - public String getSignature(); - - /** - * @return a version of the this type in CompositeType form - */ - public CompositeType toCompositeType(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/StringLiteralType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/StringLiteralType.java deleted file mode 100644 index 2e887fde9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/StringLiteralType.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import java.math.BigDecimal; -import java.math.BigInteger; - -/** - * Represents a StringLiteral as defined by JSP.2.9 - * - * @author cbateman - */ -public class StringLiteralType extends LiteralType -{ - private final String _literalValue; - - /** - * @param value - */ - public StringLiteralType(String value) - { - super(TypeConstants.TYPE_STRING); - _literalValue = value; - } - - public Number coerceToNumber(Class T) throws TypeCoercionException - { - try - { - if (T == BigInteger.class) - { - if ("".equals(_literalValue)) //$NON-NLS-1$ - { - return BigInteger.ZERO; - } - return new BigInteger(_literalValue); - } - else if (T == BigDecimal.class) - { - if ("".equals(_literalValue)) //$NON-NLS-1$ - { - return new BigDecimal(0.0); - } - return new BigDecimal(_literalValue); - } - else if (T == Double.class || T == Double.TYPE) - { - if ("".equals(_literalValue)) //$NON-NLS-1$ - { - return new Double(0.0); - } - - return Double.valueOf(_literalValue); - } - else if (T == Float.class || T == Float.TYPE) - { - if ("".equals(_literalValue)) //$NON-NLS-1$ - { - return new Float(0.0); - } - return Float.valueOf(_literalValue); - } - else if (T == Long.class || T == Long.TYPE) - { - if ("".equals(_literalValue)) //$NON-NLS-1$ - { - return Long.valueOf(0L); - } - return Long.valueOf(_literalValue); - } - else if (T == Integer.class || T == Integer.TYPE) - { - if ("".equals(_literalValue)) //$NON-NLS-1$ - { - return Integer.valueOf(0); - } - return Integer.valueOf(_literalValue); - } - else if (T == Short.class || T == Short.TYPE) - { - if ("".equals(_literalValue)) //$NON-NLS-1$ - { - return Short.valueOf((short)0); - } - return Short.valueOf(_literalValue); - } - else if (T == Byte.class || T == Byte.TYPE) - { - if ("".equals(_literalValue)) //$NON-NLS-1$ - { - return Byte.valueOf((byte)0); - } - return Byte.valueOf(_literalValue); - } - else - { - throw new IllegalArgumentException("Not a target numeric type: "+T); //$NON-NLS-1$ - } - } - catch (NumberFormatException nfe) - { - throw new TypeCoercionException(nfe); - } - } - - public String getLiteralValue() - { - return _literalValue; - } - - public Object getLiteralValueRaw() - { - return _literalValue; - } - - public Boolean coerceToBoolean() throws TypeCoercionException - { - // JSP.2.8.5 - return Boolean.valueOf(_literalValue); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeCoercer.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeCoercer.java deleted file mode 100644 index fa75a12f9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeCoercer.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import org.eclipse.jdt.core.Signature; - -/** - * Coercer for simple type signatures - * - * @author cbateman - * - */ -public class TypeCoercer -{ - - /** - * Based on JSP.2.8.3 in JSP 2.0 specification - * - * @param boxedTypeSignature -- an auto-boxed type signature - * @return the coerced type or null if cannot be resolved. No unboxing - * is performed on the return. - * @throws TypeCoercionException if boxedTypeSignature is - */ - public static String coerceToNumber(final String boxedTypeSignature) - throws TypeCoercionException - { - String boxedTypeSignature_ = boxedTypeSignature; - - // can't coerce arrays to numbers - if (Signature.getTypeSignatureKind(boxedTypeSignature_) - == Signature.ARRAY_TYPE_SIGNATURE) - { - throw new TypeCoercionException("Cannot coerce arrays to numbers"); //$NON-NLS-1$ - } - // if it's character, pre-coerce to short per step 2 - if (TypeConstants.SIGNATURE_BOXED_CHARACTER.equals(boxedTypeSignature)) - { - boxedTypeSignature_ = TypeConstants.TYPE_BOXED_SHORT; - } - - if (TypeCoercer.typeIsNumeric(boxedTypeSignature_) - || TypeCoercer.typeIsNull(boxedTypeSignature_)) - { - return boxedTypeSignature_; - } - else if (typeIsString(boxedTypeSignature_)) - { - // undetermined a string may or not resolve to a number - // depending on its runtime value - return null; - } - else - { - throw new TypeCoercionException(); - } - } - - /** - * @param boxedTypeSignature - * @return true if type can be coerced to boolean; null if indeterminate - */ - public static boolean canCoerceToBoolean(String boxedTypeSignature) - { - // JSP.2.8.5 -- boolean is always boolean; string is converted by Boolean.valueOf(String) - if (typeIsBoolean(boxedTypeSignature) - || typeIsString(boxedTypeSignature) - || typeIsNull(boxedTypeSignature)) - { - return true; - } - // nothing else really convertible besides null - return false; - } - - /** - * @param typeSignature -- boxed type signature - * @return true if the typeSignature is numeric - */ - public static boolean typeIsNumeric(final String typeSignature) - { - return (TypeConstants.TYPE_BOXED_BYTE.equals(typeSignature) || - TypeConstants.TYPE_BOXED_SHORT.equals(typeSignature) || - TypeConstants.TYPE_BOXED_INTEGER.equals(typeSignature) || - TypeConstants.TYPE_BOXED_LONG.equals(typeSignature) || - TypeConstants.TYPE_BOXED_FLOAT.equals(typeSignature) || - TypeConstants.TYPE_BOXED_DOUBLE.equals(typeSignature) || - TypeConstants.TYPE_BIG_INTEGER.equals(typeSignature) || - TypeConstants.TYPE_BIG_DOUBLE.equals(typeSignature)); - } - - /** - * @param typeSignature - * @return true if the typeSignature represents a String - */ - public static boolean typeIsString(final String typeSignature) - { - return (TypeConstants.TYPE_STRING.equals(typeSignature)); - } - - /** - * @param typeSignature -- boxed type signature - * @return true if the typeSignature represents a boxed boolean - */ - public static boolean typeIsBoolean(final String typeSignature) - { - return (TypeConstants.TYPE_BOXED_BOOLEAN.equals(typeSignature)); - } - - /** - * @param typeSignature - * @return true if type is the EL null type - */ - public static boolean typeIsNull(final String typeSignature) - { - return (TypeConstants.TYPE_NULL.equals(typeSignature)); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeCoercionException.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeCoercionException.java deleted file mode 100644 index aa18bbd12..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeCoercionException.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -/** - * @author cbateman - * - */ -public class TypeCoercionException extends Exception -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * @see java.lang.Exception - */ - public TypeCoercionException() { - super(); - } - - /** - * @param message - * @param cause - * @see java.lang.Exception - */ - public TypeCoercionException(String message, Throwable cause) { - super(message, cause); - } - - /** - * @param message - * @see java.lang.Exception - */ - public TypeCoercionException(String message) { - super(message); - } - - /** - * @param cause - * @see java.lang.Exception - */ - public TypeCoercionException(Throwable cause) { - super(cause); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparator.java deleted file mode 100644 index a57a94bed..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparator.java +++ /dev/null @@ -1,292 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jdt.core.Signature; - -/** - * Static utility class used to compare two CompositeTypes for compatability - * - * @author cbateman - * - */ -public final class TypeComparator { - private static class SignatureTestResult { - /** - * the diagnostic - */ - private final Diagnostic diagnostic; - /** - * Measure of the probability that the tested signatures were meant to - * match. Larger value means higher probability. - */ - private final int matchQuality; - - /** - * @param diagnostic - * @param matchQuality - - * Measure of the probability that the tested signatures were - * meant to match. Larger value means higher probability. - */ - public SignatureTestResult(final Diagnostic diagnostic, - final int matchQuality) { - super(); - this.diagnostic = diagnostic; - this.matchQuality = matchQuality; - } - } - - private final TypeComparatorDiagnosticFactory _factory; - - /** - * Default Constructor - * @param factory - */ - public TypeComparator(final TypeComparatorDiagnosticFactory factory) - { - _factory = factory; - } - - /** - * @param firstType - * @param secondType - * @return true if firstType is assignable to secondType or vice-versa, - * depending on their assignment and runtime types - */ - public Diagnostic calculateTypeCompatibility( - final CompositeType firstType, final CompositeType secondType) { - // first, box all primitives - final CompositeType boxedFirstType = TypeTransformer - .transformBoxPrimitives(firstType); - final CompositeType boxedSecondType = TypeTransformer - .transformBoxPrimitives(secondType); - - final String[] mustBeSatisfied = boxedFirstType.getSignatures(); - final String[] testSignatures = boxedSecondType.getSignatures(); - List<String> mustbeMethods = Collections.emptyList(); - List<String> mustbeTypes = Collections.emptyList(); - for (final String mustbeSignature : mustBeSatisfied) { - if (TypeUtil.isMethodSignature(mustbeSignature)) { - if (mustbeMethods.isEmpty()) { - mustbeMethods = new ArrayList<String>(mustbeSignature - .length()); - } - mustbeMethods.add(mustbeSignature); - } else { - if (mustbeTypes.isEmpty()) { - mustbeTypes = new ArrayList<String>(mustbeSignature - .length()); - } - mustbeTypes.add(mustbeSignature); - } - } - final boolean mustbeWriteable = firstType.isLHS(); - SignatureTestResult bestResult = null; - for (final String isSignature : testSignatures) { - SignatureTestResult testResult; - if (TypeUtil.isMethodSignature(isSignature)) { - testResult = checkMethodSignature(isSignature, mustbeTypes, - mustbeMethods); - if (testResult.diagnostic.getSeverity() == Diagnostic.OK) { - return testResult.diagnostic; - } - } else { - testResult = checkTypeSignature(isSignature, mustbeTypes, - mustbeMethods, mustbeWriteable); - if (testResult.diagnostic.getSeverity() == Diagnostic.OK) { - return checkAssignability(firstType, secondType); - } - } - if (bestResult == null - || bestResult.matchQuality < testResult.matchQuality) { - bestResult = testResult; - } - } - // TODO: bestResult empty? (should not happen, but who knows... - return bestResult.diagnostic; - } - - private SignatureTestResult checkTypeSignature( - final String isSignature, final List<String> mustbeTypes, - final List<String> mustbeMethods, final boolean mustbeWriteable) { - if (mustbeTypes.isEmpty()) { - final Diagnostic diag = _factory.create_METHOD_EXPRESSION_EXPECTED(); - return new SignatureTestResult(diag, 0); - } - for (final String mustbeSignature : mustbeTypes) { - if (mustbeSignature.equals(isSignature) - || canCoerce(isSignature, mustbeSignature, mustbeWriteable)) { - final Diagnostic diag = Diagnostic.OK_INSTANCE; - return new SignatureTestResult(diag, 5); - } - } - final String[] params = new String[2]; - params[0] = readableSignatures(mustbeTypes); - params[1] = Signature.toString(isSignature); - final Diagnostic diag = _factory.create_INCOMPATIBLE_TYPES(params); - return new SignatureTestResult(diag, 1); - } - - private SignatureTestResult checkMethodSignature( - final String isSignature, final List<String> mustbeTypes, - final List<String> mustbeMethods) { - if (mustbeMethods.isEmpty()) { - final Diagnostic diag = _factory.create_VALUE_EXPRESSION_EXPECTED(); - return new SignatureTestResult(diag, 0); - } - for (final String mustbeSignature : mustbeMethods) { - if (methodSignaturesMatch(mustbeSignature, isSignature)) { - final Diagnostic diag = Diagnostic.OK_INSTANCE; - return new SignatureTestResult(diag, 5); - } - } - final String[] params = new String[2]; - params[0] = readableSignatures(mustbeMethods); - params[1] = Signature - .toString(isSignature, "method", null, false, true); //$NON-NLS-1$ - final Diagnostic diag = _factory.create_INCOMPATIBLE_METHOD_TYPES(params); - return new SignatureTestResult(diag, 1); - } - - private static String readableSignatures(final List<String> signatures) { - StringBuilder res = null; - for (final String sig : signatures) { - String sigText; - if (TypeUtil.isMethodSignature(sig)) { - sigText = Signature.toString(sig, "method", null, false, true); //$NON-NLS-1$ - } else { - sigText = Signature.toString(sig); - } - if (res == null) { - res = new StringBuilder(sigText); - } else { - res.append(", ").append(sigText); //$NON-NLS-1$ - } - } - return res != null ? res.toString() : "[no signature]"; //$NON-NLS-1$ - } - - private static boolean canCoerce(final String testType, - final String checkType, final boolean checkTypeIsWritable) { - boolean canCoerce = canCoerce(testType, checkType); - - // if the check type is writable, we need to be sure that the - // coercion can work in both directions - if (canCoerce && checkTypeIsWritable) { - // reverse roles: can checkType assign back to test type? - canCoerce &= canCoerce(checkType, testType); - } - - return canCoerce; - } - - private static boolean canCoerce(final String testType, - final String checkType) { - // can always to coerce to string or object - if (TypeCoercer.typeIsString(checkType)/* - || TypeConstants.TYPE_JAVAOBJECT.equals(checkType)*/) - { - return true; - } else if (TypeCoercer.typeIsNumeric(checkType)) { - return canCoerceNumeric(testType); - } else if (TypeCoercer.typeIsBoolean(checkType)) { - return TypeCoercer.canCoerceToBoolean(testType); - } - - // otherwise, no type coercion available - return false; - } - - private static boolean canCoerceNumeric(final String testType) { - try { - TypeCoercer.coerceToNumber(testType); - // TODO: there is a case when coerceToNumber returns - // null meaning "not sure", that we may want to handle - // differently, with a warning - return true; - } catch (final TypeCoercionException tce) { - // outright failure -- can't coerce - return false; - } - } - - private static boolean methodSignaturesMatch(final String firstMethodSig, - final String secondMethodSig) { - // TODO: need to account for primitive type coercions - if (firstMethodSig.equals(secondMethodSig)) { - return true; - } - final String[] firstMethodParams = Signature - .getParameterTypes(firstMethodSig); - final String[] secondMethodParams = Signature - .getParameterTypes(secondMethodSig); - - // fail fast if param count doesn't match - if (firstMethodParams.length != secondMethodParams.length) { - return false; - } - - // now check each parameter - for (int i = 0; i < firstMethodParams.length; i++) { - // need to box primitives before comparing - final String firstMethodParam = TypeTransformer - .transformBoxPrimitives(firstMethodParams[i]); - final String secondMethodParam = TypeTransformer - .transformBoxPrimitives(secondMethodParams[i]); - - if (!firstMethodParam.equals(secondMethodParam)) { - return false; - } - } - - // if we get to here then we need only check the return type - final String firstReturn = TypeTransformer - .transformBoxPrimitives(Signature.getReturnType(firstMethodSig)); - final String secondReturn = TypeTransformer - .transformBoxPrimitives(Signature - .getReturnType(secondMethodSig)); - - if (!firstReturn.equals(secondReturn)) { - return false; - } - - // if we get to here, then everything checks out - return true; - } - - /** - * Precond: both firstType and secondType must represent value bindings. - * - * @param firstType - * @param secondType - * @return a diagnostic validating that the two composite have compatible - * assignability - */ - private Diagnostic checkAssignability(final CompositeType firstType, - final CompositeType secondType) { - if (firstType.isRHS() && !secondType.isRHS()) { - return _factory.create_PROPERTY_NOT_READABLE(); - } - - if (firstType.isLHS() && !secondType.isLHS()) { - return _factory.create_PROPERTY_NOT_WRITABLE(); - } - - return Diagnostic.OK_INSTANCE; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparatorDiagnosticFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparatorDiagnosticFactory.java deleted file mode 100644 index 23d2cccc0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparatorDiagnosticFactory.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.types; - -import org.eclipse.emf.common.util.BasicDiagnostic; -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.osgi.util.NLS; - -/** - * Diagnostic Factory for type comparator diagnostics. - * - * @author cbateman - * - */ -public final class TypeComparatorDiagnosticFactory -{ - /** - * The id used in the source field of all Diagnostic's created by this - * factory to uniquely identify TypeComparator validation as their source - * type. - */ - public final static String SOURCE_IDENTIFIER = "org.eclipse.jst.jsf.common.types.TypeComparator"; //$NON-NLS-1$ - - /** - * A method expression was expected, but something else (i.e. a value - * expression) was provided. - */ - public final static int METHOD_EXPRESSION_EXPECTED_ID = 0; - - /** - * Value expression type was incompatible with the expected type. - */ - public static final int INCOMPATIBLE_TYPES_ID = 1; - - /** - * A value expression was expected, but something else (i.e. a method - * expression) was provided. - */ - public static final int VALUE_EXPRESSION_EXPECTED_ID = 2; - - /** - * Method expression signature did not match what was expected. - */ - public static final int INCOMPATIBLE_METHOD_TYPES_ID = 3; - - /** - * A property was expected to be readable but no getter was found. - */ - public static final int PROPERTY_NOT_READABLE_ID = 4; - - /** - * A property was expected to be writable but no setter was found - */ - public static final int PROPERTY_NOT_WRITABLE_ID = 5; - - /** - * the number of diagnostic ids - */ - public static final int NUM_IDS = 6; - - private final TypeComparatorPreferences _prefs; - - /** - * @param prefs - */ - public TypeComparatorDiagnosticFactory(final TypeComparatorPreferences prefs) - { - _prefs = prefs; - } - // A method expression was supplied as expected, but its signature did - // * not match the expected. - /** - * @return a diagnostic - */ - public Diagnostic create_METHOD_EXPRESSION_EXPECTED() - { - return create(METHOD_EXPRESSION_EXPECTED_ID, Messages - .getString("TypeComparator.Expression.No_Method")); //$NON-NLS-1$ - } - - /** - * @param params - * @return a diagnostic - */ - public Diagnostic create_INCOMPATIBLE_TYPES(final Object[] params) - { - return create( - INCOMPATIBLE_TYPES_ID, - NLS - .bind( - Messages - .getString("TypeComparator.Expression.Incompatible_Value"), params)); //$NON-NLS-1$ - } - - /** - * @return a diagnostic - */ - public Diagnostic create_VALUE_EXPRESSION_EXPECTED() - { - return create(VALUE_EXPRESSION_EXPECTED_ID, Messages - .getString("TypeComparator.Expression.No_Value")); //$NON-NLS-1$ - } - - /** - * @param params - * @return a diagnostic - */ - public Diagnostic create_INCOMPATIBLE_METHOD_TYPES(final Object[] params) - { - return create(INCOMPATIBLE_METHOD_TYPES_ID, NLS.bind(Messages - .getString("TypeComparator.Expression.Incompatible_Method"), //$NON-NLS-1$ - params)); - } - - /** - * @return a diagnostic - */ - public Diagnostic create_PROPERTY_NOT_READABLE() - { - return create(PROPERTY_NOT_READABLE_ID, Messages - .getString("TypeComparator.Expression.Not.Gettable")); //$NON-NLS-1$ - } - - /** - * @return a diagnostic - */ - public Diagnostic create_PROPERTY_NOT_WRITABLE() - { - return create(PROPERTY_NOT_WRITABLE_ID, Messages - .getString("TypeComparator.Expression.Expected.Settable")); //$NON-NLS-1$ - } - - private BasicDiagnostic create(int diagnosticId, String message) - { - final int severity = _prefs.getDefaultSeverity(diagnosticId); - return new BasicDiagnostic(severity, SOURCE_IDENTIFIER, diagnosticId, message, - null); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparatorPreferences.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparatorPreferences.java deleted file mode 100644 index 7428cb19c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeComparatorPreferences.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.types; - -import org.eclipse.emf.common.util.Diagnostic; - -/** - * Preference info for type comparator diagnostics - * - * @author cbateman - * - */ -public class TypeComparatorPreferences -{ - - /** - * @param diagnosticId - * @return the default severity of a diagnostic - */ - public int getDefaultSeverity(final int diagnosticId) - { - switch (diagnosticId) - { - case TypeComparatorDiagnosticFactory.METHOD_EXPRESSION_EXPECTED_ID: - return Diagnostic.ERROR; - case TypeComparatorDiagnosticFactory.INCOMPATIBLE_TYPES_ID: - return Diagnostic.WARNING; - case TypeComparatorDiagnosticFactory.VALUE_EXPRESSION_EXPECTED_ID: - return Diagnostic.ERROR; - case TypeComparatorDiagnosticFactory.INCOMPATIBLE_METHOD_TYPES_ID: - return Diagnostic.ERROR; - case TypeComparatorDiagnosticFactory.PROPERTY_NOT_READABLE_ID: - return Diagnostic.WARNING; - case TypeComparatorDiagnosticFactory.PROPERTY_NOT_WRITABLE_ID: - return Diagnostic.WARNING; - default: - throw new IllegalArgumentException("Diagnostic Id: "+ diagnosticId +" is out of range"); //$NON-NLS-1$ //$NON-NLS-2$ - - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeConstants.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeConstants.java deleted file mode 100644 index 4561f6d3c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeConstants.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -/** - * @author cbateman - * - */ -public class TypeConstants -{ - /** - * we overload "void" to represent null - */ - public final static String TYPE_NULL = "V"; //$NON-NLS-1$ - /** - * unboxed boolean - */ - public final static String TYPE_BOOLEAN = "Z"; //$NON-NLS-1$ - /** - * string type - */ - public final static String TYPE_STRING = "Ljava.lang.String;"; //$NON-NLS-1$ - /** - * big integer - */ - public final static String TYPE_BIG_INTEGER = "Ljava.math.BigInteger;"; //$NON-NLS-1$ - - /** - * big double - */ - public final static String TYPE_BIG_DOUBLE = "Ljava.math.BigDecimal;"; //$NON-NLS-1$ - - /* boxed types */ - /** - * Boxed byte - */ - public final static String TYPE_BOXED_BYTE = "Ljava.lang.Byte;"; //$NON-NLS-1$ - /** - * Boxed short - */ - public final static String TYPE_BOXED_SHORT = "Ljava.lang.Short;"; //$NON-NLS-1$ - /** - * Boxed int - */ - public final static String TYPE_BOXED_INTEGER = "Ljava.lang.Integer;"; //$NON-NLS-1$ - /** - * Boxed long - */ - public final static String TYPE_BOXED_LONG = "Ljava.lang.Long;"; //$NON-NLS-1$ - /** - * Boxed float - */ - public final static String TYPE_BOXED_FLOAT = "Ljava.lang.Float;"; //$NON-NLS-1$ - /** - * Boxed double - */ - public final static String TYPE_BOXED_DOUBLE = "Ljava.lang.Double;"; //$NON-NLS-1$ - /** - * Boxed boolean - */ - public final static String TYPE_BOXED_BOOLEAN = "Ljava.lang.Boolean;"; //$NON-NLS-1$ - /** - * Boxed char - */ - public final static String SIGNATURE_BOXED_CHARACTER = "Ljava.lang.Character"; //$NON-NLS-1$ - /** - * Map type - */ - public final static String TYPE_MAP = "Ljava.util.Map;"; //$NON-NLS-1$ - /** - * Collection type - */ - public final static String TYPE_COLLECTION = "Ljava.util.Collection;"; //$NON-NLS-1$ - /** - * Comparable type - */ - public final static String TYPE_COMPARABLE = "Ljava.lang.Comparable;"; //$NON-NLS-1$ - - /** - * List type - */ - public final static String TYPE_LIST = "Ljava.util.List;"; //$NON-NLS-1$ - - /** - * java.lang.Object type signature - */ - public static final String TYPE_JAVAOBJECT = "Ljava.lang.Object;"; //$NON-NLS-1$ - /** - * Type signature for the JSF Data Model type - */ - public static final String TYPE_DATA_MODEL = "Ljavax.faces.model.DataModel;"; //$NON-NLS-1$ - /** - * Type signature for the Result Set type - */ - public static final String TYPE_RESULT_SET = "Ljava.sql.ResultSet;"; //$NON-NLS-1$ - /** - * Type signature for the JSTL ResultSet type - */ - public static final String TYPE_JAVAX_SERVLET_JSP_JSTL_SQL_RESULT = "Ljavax.servlet.jsp.jstl.sql.Result;"; //$NON-NLS-1$ - /** - * Type signature of the base type of all enum types - */ - public static final String TYPE_ENUM_BASE = "Ljava.lang.Enum;"; //$NON-NLS-1$ -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeInfo.java deleted file mode 100644 index d514f4236..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeInfo.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.types; - -import org.eclipse.jdt.core.IType; -import org.eclipse.jst.jsf.context.symbol.IBeanMethodSymbol; -import org.eclipse.jst.jsf.context.symbol.IBeanPropertySymbol; - -/**This class contains all info that is cached for a given IType. - * @see org.eclipse.jst.jsf.common.internal.types.TypeInfoCache - * - * @author Matthias - */ -class TypeInfo { - - /**Empty String array. Used for the (usual) case when a type has no missing supertypes. - */ - public static String[] NO_NAMES = new String[0]; - - private IBeanMethodSymbol[] methods = null; - private IBeanPropertySymbol[] properties = null; - private IType[] supertypes = null; - private IType[] interfaceTypes = null; - private String[] missingSupertypeNames = null; - - /**Creates an empty TypeInfo object - */ - public TypeInfo() { - super(); - } - - /**Returns the method symbols. Returns <code>null</code> if none have been cached. - * @return the method symbols. May be null. - */ - public IBeanMethodSymbol[] getMethodSymbols() { - return methods; - } - - /**Returns the property symbols. Returns <code>null</code> if none have been cached. - * @return the property symbols. May be null. - */ - public IBeanPropertySymbol[] getPropertySymbols() { - return properties; - } - - /**Sets the methods symbols to be cached. - * @param methods - the method symbols - */ - public void setMethodSymbols(IBeanMethodSymbol[] methods) { - this.methods = methods; - } - - /**Sets the property symbols to be cached. - * @param properties - the property symbols - */ - public void setPropertySymbols(IBeanPropertySymbol[] properties) { - this.properties = properties; - } - - /**Returns the supertypes. Returns <code>null</code> if none have been cached. - * @return the supertypes. May be null. - */ - public IType[] getSupertypes() { - return supertypes; - } - - /**Sets the supertypes to be cached. - * @param superTypes - the property symbols - */ - public void setSupertypes(IType[] superTypes) { - this.supertypes = superTypes; - } - - /**Returns the interface types. Returns <code>null</code> if none have been cached. - * @return the interface types. May be null. - */ - public IType[] getInterfaceTypes() { - return interfaceTypes; - } - - /**Sets the interface types to be cached. - * @param interfaceTypes - the property symbols - */ - public void setInterfaceTypes(IType[] interfaceTypes) { - this.interfaceTypes = interfaceTypes; - } - - /**Returns the names of the missing supertypes. Returns <code>null</code> if none have been cached. - * @return the names of the missing supertypes. May be null. - */ - public String[] getMissingSupertypeNames() { - return missingSupertypeNames; - } - - /**Sets the supertypes to be cached. - * @param missingSupertypeNames - the names of the missing supertypes - */ - public void setMissingSupertypeNames(String[] missingSupertypeNames) { - this.missingSupertypeNames = missingSupertypeNames; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeInfoCache.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeInfoCache.java deleted file mode 100644 index c58f31ce1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeInfoCache.java +++ /dev/null @@ -1,603 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.internal.types; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.core.ElementChangedEvent; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IElementChangedListener; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaElementDelta; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.ITypeRoot; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.context.symbol.IBeanMethodSymbol; -import org.eclipse.jst.jsf.context.symbol.IBeanPropertySymbol; - -/**Provides a cache for java IType properties. It can cache bean property symbols, method symbols, - * supertypes and implemented interfaces per IType. The cache listens to changes in the java model - * and invalidates affected properties, but does not update them. - * - * @author Matthias - */ -public class TypeInfoCache implements IElementChangedListener { - - private static TypeInfoCache instance = null; - - /**Returns the TypeInfoCache instance. This instance is considered - * protected and must not be disposded with disposeInstance. - * - * @return the TypeInfoCache instance - */ - public static synchronized TypeInfoCache getInstance() { - if (instance == null) { - instance = createNewInstance(); - } - return instance; - } - - /** - * Create a new instance of the type cache. - * - * @return a new instance of the type info cache. - */ - public static TypeInfoCache createNewInstance() - { - final TypeInfoCache newCache = new TypeInfoCache(); - JavaCore.addElementChangedListener(newCache, ElementChangedEvent.POST_CHANGE); - return newCache; - } - - /** - * If cache is not the singleton instance acquired with {@link #getInstance()} - * then the cache will be disposed and should not be used. If cache is - * protected instance, then nothing will happen (the singleton instance - * cannot be disposed). - * - * @param cache - */ - public static void disposeInstance(final TypeInfoCache cache) - { - if (cache != null - && cache != instance) - { - JavaCore.removeElementChangedListener(cache); - - synchronized(cache) - { - if (cache.cachedInfo != null) - { - cache.cachedInfo.clear(); - } - - if (cache.cachedTypesByAffectingTypeRoot != null) - { - cache.cachedTypesByAffectingTypeRoot.clear(); - } - - if (cache.cachedTypesByMissingSupertypename != null) - { - cache.cachedTypesByMissingSupertypename.clear(); - } - } - } - } - - private final Map<IType, TypeInfo> cachedInfo; - private final Map<ITypeRoot, Set<IType>> cachedTypesByAffectingTypeRoot; - private final Map<String, Set<IType>> cachedTypesByMissingSupertypename; - - private TypeInfoCache() { - cachedInfo = new HashMap<IType, TypeInfo>(); - cachedTypesByAffectingTypeRoot = new HashMap(); - cachedTypesByMissingSupertypename = new HashMap(10); - } - - public void elementChanged(ElementChangedEvent event) { - updateChangedJavaElement(event.getDelta()); - } - - /**Returns the cached info({@link TypeInfo}) for a given type. Will - * return <code>null</code> if no info has been cached or the the type/something it depends on - * has changed since then. - * - * @param type - the type in question - * @return a TypeInfo instance that contains all cached info for the given type. May be null. - */ - protected TypeInfo getTypeInfo(IType type) { - TypeInfo info = null; - if (type != null) - { - info = cachedInfo.get(type); - } - return info; - } - - /**Returns the cached bean property symbols for a given type. Will return null if no - * bean property symbols have been cached or the type/something it depends on has changed since - * then. - * @param beanType - the bean type in question - * @return the bean property symbols for the given type. May be null. - * @see TypeInfoCache#cachePropertySymbols(IType, IBeanPropertySymbol[]) - */ - public synchronized IBeanPropertySymbol[] getCachedPropertySymbols(IType beanType) { - IBeanPropertySymbol[] props = null; - - if (beanType != null) - { - TypeInfo typeInfo = getTypeInfo(beanType); - if (typeInfo != null) - { - props = typeInfo.getPropertySymbols(); - } - } - return props; - } - - /**Returns the cached method symbols for a given type. Will return null if no - * method symbols have been cached or the type/something it depends on has changed since - * then. - * @param beanType - the bean type in question - * @return the method symbols for the given type. May be null. - * @see TypeInfoCache#cacheMethodSymbols(IType, IBeanMethodSymbol[]) - */ - public synchronized IBeanMethodSymbol[] getCachedMethodSymbols(IType beanType) { - IBeanMethodSymbol[] methods = null; - - if (beanType != null) - { - TypeInfo typeInfo = getTypeInfo(beanType); - if (typeInfo != null) - { - methods = typeInfo.getMethodSymbols(); - } - } - - return methods; - } - - /**Returns the cached supertypes for a given type. Will return null if no supertypes - * have been cached for this type or if the type/something it depends on has changed since - * then. - * @param type - the bean type in question - * @return the supertypes for the given type. May be null. - * @see TypeInfoCache#cacheSupertypesFor(IType) - */ - public synchronized IType[] getCachedSupertypes(IType type) { - IType[] types = null; - - if (type != null) - { - TypeInfo typeInfo = getTypeInfo(type); - if (typeInfo != null) - { - types = typeInfo.getSupertypes(); - } - } - - return types; - } - - /**Returns the cached implemented interfaces for a given type. Will return null if no interfaces - * have been cached for this type or if the type/something it depends on has changed since - * then. - * @param type - the bean type in question - * @return the interface types implemented by the given type. May be null. - * @see TypeInfoCache#cacheInterfaceTypesFor(IType) - */ - public synchronized IType[] getCachedInterfaceTypes(IType type) - { - IType[] types = null; - - if (type != null) - { - TypeInfo typeInfo = getTypeInfo(type); - if (typeInfo != null) - { - types = typeInfo.getInterfaceTypes(); - } - } - - return types; - } - - /**Caches the given method symbols for the given type. - * @param beanType - the type - * @param methods - the method symbols to cache - */ - public synchronized void cacheMethodSymbols(IType beanType, IBeanMethodSymbol[] methods) { - if (beanType != null) - { - TypeInfo typeInfo = getOrCreateTypeInfo(beanType); - if (typeInfo != null) { - typeInfo.setMethodSymbols(methods); - } - } - } - - /**Caches the given property symbols for the given type. - * @param beanType - the type - * @param properties - the property symbols to cache - */ - public synchronized void cachePropertySymbols(IType beanType, IBeanPropertySymbol[] properties) { - if (beanType != null) - { - TypeInfo typeInfo = getOrCreateTypeInfo(beanType); - if (typeInfo != null) { - typeInfo.setPropertySymbols(properties); - } - } - } - - /**Caches the supertypes for the given type. The supertypes will be calculated (and also returned) - * by this method. - * @param type - the type to cache supertypes for - * @return the supertypes of the given type. - */ - public synchronized IType[] cacheSupertypesFor(IType type) - { - IType[] types = null; - - if (type != null) - { - TypeInfo typeInfo = getOrCreateTypeInfo(type); - - if (typeInfo != null) - { - types = typeInfo.getSupertypes(); - } - } - return types; - } - - /**Caches the interface types for the given type. The interface types will be calculated (and also - * returned) by this method. - * @param type - the type to cache interface types for - * @return the interface types implemented by the given type. - */ - public synchronized IType[] cacheInterfaceTypesFor(IType type) - { - IType[] types = null; - - if (type != null) - { - TypeInfo typeInfo = getOrCreateTypeInfo(type); - if (typeInfo != null) - { - types = typeInfo.getInterfaceTypes(); - } - } - return types; - } - - /**Returns the TypeInfo for the given type. If no TypeInfo exists for this type, an empty TypeInfo - * will be created and cached. - * @param type - the type in question - * @return the (modifyable) TypeInfo for the given type - */ - protected TypeInfo getOrCreateTypeInfo(IType type) { - TypeInfo typeInfo = getTypeInfo(type); - if (typeInfo == null) { - try { - final ITypeHierarchy hierarchy = - type.newSupertypeHierarchy(new NullProgressMonitor()); - final IType[] supertypes = hierarchy.getAllSuperclasses(type); - final IType[] interfaceTypes = hierarchy.getAllInterfaces(); - final IType[] rootClasses = hierarchy.getRootClasses(); - List missingSupertypesList = null; - for (int i = 0; i < rootClasses.length; i++) { - String superclassName = rootClasses[i].getSuperclassName(); - if (superclassName != null) { - if (missingSupertypesList == null) { - missingSupertypesList = new ArrayList(1); - } - superclassName = shortTypename(superclassName); - missingSupertypesList.add(superclassName); - } - } - String[] missingSupertypes = null; - if (missingSupertypesList != null) { - missingSupertypes = (String[]) missingSupertypesList.toArray(new String[missingSupertypesList.size()]); - } else { - missingSupertypes = TypeInfo.NO_NAMES; - } - typeInfo = new TypeInfo(); - typeInfo.setSupertypes(supertypes); - typeInfo.setInterfaceTypes(interfaceTypes); - typeInfo.setMissingSupertypeNames(missingSupertypes); - cachedInfo.put(type, typeInfo); - registerCachedType(type, typeInfo); - } catch (JavaModelException e) { - JSFCommonPlugin.log(e); - } - } - return typeInfo; - } - - /**Returns the typename fragment after the last "." (which in most cases is identical to the - * unqualified typename). - * Used only to make sure that if n1 and n2 are names of the same type - * shortname(n1) equals shortname(2) even if one name is qualified and one not. - * @param typename - * @return the typename fragment after the last "." - */ - private String shortTypename(String typename) { - int pos = typename.lastIndexOf('.'); - if (pos >= 0) { - typename = typename.substring(pos + 1); - } - return typename; - } - - /** - * Registers the given type for all ITypeRoot's it depends on, so that it can be uncached if - * one of this ITypeRoot's has changed. The type must be unregistered when it should not be watched - * anymore. - * @param type - the type - * @param typeInfo - TypeInfo of the given type - * @see TypeInfoCache#unregisterCachedType(IType, TypeInfo) - */ - protected void registerCachedType(IType type, TypeInfo typeInfo) { - registerTypeForTypeRoot(type, type.getTypeRoot()); - IType[] supertypes = typeInfo.getSupertypes(); - for (int i = 0; i < supertypes.length; i++) { - registerTypeForTypeRoot(type, supertypes[i].getTypeRoot()); - } - String[] missingSupertypeNames = typeInfo.getMissingSupertypeNames(); - if (missingSupertypeNames != null) { - for (int i = 0; i < missingSupertypeNames.length; i++) { - registerTypeForMissingSupertype(type, missingSupertypeNames[i]); - } - } - } - - private void registerTypeForTypeRoot(IType type, ITypeRoot typeRoot) { - Set dependentTypes = cachedTypesByAffectingTypeRoot.get(typeRoot); - if (dependentTypes == null) { - dependentTypes = new HashSet(5); - cachedTypesByAffectingTypeRoot.put(typeRoot, dependentTypes); - } - dependentTypes.add(type); - } - - private void registerTypeForMissingSupertype(IType type, String supertype) { - Set dependentTypes = cachedTypesByMissingSupertypename.get(supertype); - if (dependentTypes == null) { - dependentTypes = new HashSet(5); - cachedTypesByMissingSupertypename.put(supertype, dependentTypes); - } - dependentTypes.add(type); - } - - /**Unregisters the given type for all ITypeRoot's it depended on. - * @param type - the type - * @param typeInfo - TypeInfo of the given type - */ - protected void unregisterCachedType(IType type, TypeInfo typeInfo) { - unregisterTypeForTypeRoot(type, type.getTypeRoot()); - IType[] supertypes = typeInfo.getSupertypes(); - for (int i = 0; i < supertypes.length; i++) { - unregisterTypeForTypeRoot(type, supertypes[i].getTypeRoot()); - } - String[] missingSupertypeNames = typeInfo.getMissingSupertypeNames(); - if (missingSupertypeNames != null) { - for (int i = 0; i < missingSupertypeNames.length; i++) { - unregisterTypeForMissingSupertype(type, missingSupertypeNames[i]); - } - } - } - - private void unregisterTypeForTypeRoot(IType type, ITypeRoot typeRoot) { - Set dependentTypes = cachedTypesByAffectingTypeRoot.get(typeRoot); - if (dependentTypes != null) { - dependentTypes.remove(type); - if (dependentTypes.isEmpty()) { - cachedTypesByAffectingTypeRoot.remove(typeRoot); - } - } - } - - private void unregisterTypeForMissingSupertype(IType type, String supertype) { - Set dependentTypes = cachedTypesByMissingSupertypename.get(supertype); - if (dependentTypes != null) { - dependentTypes.remove(type); - if (dependentTypes.isEmpty()) { - cachedTypesByMissingSupertypename.remove(supertype); - } - } - } - - /**This will remove all cached info for all types. - */ - protected synchronized void uncacheAllTypes() { - cachedInfo.clear(); - cachedTypesByAffectingTypeRoot.clear(); - cachedTypesByMissingSupertypename.clear(); - } - - /**Removes all cached info for all types that are subtypes of a type of the given ITypeRoot. - * @param typeRoot - */ - protected synchronized void uncacheAffectedTypes(ITypeRoot typeRoot) { - Collection affectedTypes = cachedTypesByAffectingTypeRoot.get(typeRoot); - if (affectedTypes != null && !affectedTypes.isEmpty()) { - List affectedTypesCopy = new ArrayList(affectedTypes); - for (Iterator it = affectedTypesCopy.iterator(); it.hasNext(); ) { - IType cachedType = (IType) it.next(); - TypeInfo typeInfo = cachedInfo.remove(cachedType); - unregisterCachedType(cachedType, typeInfo); - } - } - } - - /**Removes all cached info for all types (or subtypes of types) that specify a supertype - * that has a name similar to the given name. - * @param supertypename - the missing supertype name. May be qualified or not - */ - protected synchronized void uncacheTypesWithMissingSupertype(String supertypename) { - Collection affectedTypes = cachedTypesByMissingSupertypename.get(shortTypename(supertypename)); - if (affectedTypes != null && !affectedTypes.isEmpty()) { - List affectedTypesCopy = new ArrayList(affectedTypes); - for (Iterator it = affectedTypesCopy.iterator(); it.hasNext(); ) { - IType cachedType = (IType) it.next(); - TypeInfo typeInfo = cachedInfo.remove(cachedType); - unregisterCachedType(cachedType, typeInfo); - } - } - } - - /**Removes all cached info that may be affected by the given change. - * @param delta - the change in the java model - */ - protected void updateChangedJavaElement(IJavaElementDelta delta) { - IJavaElement element= delta.getElement(); - switch (element.getElementType()) { - case IJavaElement.JAVA_MODEL: - updateChangedJavaModel(delta, element); - break; - case IJavaElement.JAVA_PROJECT: - updateChangedJavaProject(delta, element); - break; - case IJavaElement.PACKAGE_FRAGMENT_ROOT: - updateChangedPackageFragmentRoot(delta, element); - break; - case IJavaElement.PACKAGE_FRAGMENT: - updateChangedPackageFragment(delta, (IPackageFragment) element); - break; - case IJavaElement.CLASS_FILE: - case IJavaElement.COMPILATION_UNIT: - updateChangedOpenable(delta, element); - break; - } - } - - private void updateChangedChildren(IJavaElementDelta delta) { - if ((delta.getFlags() & IJavaElementDelta.F_CHILDREN) > 0) { - IJavaElementDelta[] children= delta.getAffectedChildren(); - for (int i= 0; i < children.length; i++) { - updateChangedJavaElement(children[i]); - } - } - } - - private void updateChangedJavaModel(IJavaElementDelta delta, IJavaElement element) { - switch (delta.getKind()) { - case IJavaElementDelta.ADDED : - case IJavaElementDelta.REMOVED : - uncacheAllTypes(); - break; - case IJavaElementDelta.CHANGED : - updateChangedChildren(delta); - break; - } - } - - private void updateChangedJavaProject(IJavaElementDelta delta, IJavaElement element) { - int kind = delta.getKind(); - int flags = delta.getFlags(); - if ((flags & IJavaElementDelta.F_OPENED) != 0) { - kind = IJavaElementDelta.ADDED; // affected in the same way - } - if ((flags & IJavaElementDelta.F_CLOSED) != 0) { - kind = IJavaElementDelta.REMOVED; // affected in the same way - } - switch (kind) { - case IJavaElementDelta.ADDED : - case IJavaElementDelta.REMOVED : - uncacheAllTypes(); - break; - case IJavaElementDelta.CHANGED : - updateChangedChildren(delta); - break; - } - } - - private void updateChangedPackageFragment(IJavaElementDelta delta, IPackageFragment element) { - switch (delta.getKind()) { - case IJavaElementDelta.ADDED : - // if the package fragment is in the projects being considered, this could - // introduce new types, changing the hierarchy - case IJavaElementDelta.REMOVED : - // is a change if the package fragment contains supertypes? - uncacheAllTypes(); - break; - case IJavaElementDelta.CHANGED : - // look at the files in the package fragment - updateChangedChildren(delta); - } - } - - private void updateChangedPackageFragmentRoot(IJavaElementDelta delta, IJavaElement element) { - switch (delta.getKind()) { - case IJavaElementDelta.ADDED : - case IJavaElementDelta.REMOVED : - uncacheAllTypes(); - break; - case IJavaElementDelta.CHANGED : - int flags = delta.getFlags(); - if (((flags & IJavaElementDelta.F_ADDED_TO_CLASSPATH) > 0)||(flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) > 0) { - uncacheAllTypes(); - } else { - updateChangedChildren(delta); - } - break; - } - } - - /**Removes all cached info that may be affected by the change in this IOpenable - * @param delta - the change in the java model - * @param element - the (changed) IOpenable considered - */ - protected void updateChangedOpenable(IJavaElementDelta delta, IJavaElement element) { - if (element instanceof ITypeRoot) { - ITypeRoot typeRoot = (ITypeRoot) element; - uncacheAffectedTypes(typeRoot); - // Creates missing superclass for any cached type? - if (delta.getKind() == IJavaElementDelta.ADDED) { - if (typeRoot instanceof ICompilationUnit) { - ICompilationUnit cu = (ICompilationUnit) typeRoot; - try { - IType[] types = cu.getAllTypes(); - for (int i = 0; i < types.length; i++) { - uncacheTypesWithMissingSupertype(types[i].getElementName()); - } - } catch (JavaModelException e) { - if (!e.isDoesNotExist()) - { - JSFCommonPlugin.log(IStatus.INFO, "Unable to get types for compilation unit " + cu, e); //$NON-NLS-1$ - } - uncacheAllTypes(); - } - } else if (typeRoot instanceof IClassFile) { - IClassFile cf = (IClassFile) typeRoot; - IType type = cf.getType(); - uncacheTypesWithMissingSupertype(type.getElementName()); - } - } - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeTransformer.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeTransformer.java deleted file mode 100644 index 4c5718f89..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeTransformer.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.jdt.core.Signature; - -/** - * Transforms one CompositeType to another according to particular - * transform rules. - * - * In general, every transformation should be of the form: - * - * CompositeType transform(CompositeType original, other inputs...); - * - * @author cbateman - * - */ -public class TypeTransformer -{ - private final static Map boxConversions = new HashMap(); - private final static Map unBoxConversions = new HashMap(); - - static - { - // see jdt.core.Signature or JVM link spec for more details - boxConversions.put("B", "Ljava.lang.Byte;"); //$NON-NLS-1$//$NON-NLS-2$ - boxConversions.put("C", "Ljava.lang.Character;"); //$NON-NLS-1$ //$NON-NLS-2$ - boxConversions.put("D", "Ljava.lang.Double;"); //$NON-NLS-1$ //$NON-NLS-2$ - boxConversions.put("F", "Ljava.lang.Float;"); //$NON-NLS-1$ //$NON-NLS-2$ - boxConversions.put("I", "Ljava.lang.Integer;"); //$NON-NLS-1$ //$NON-NLS-2$ - boxConversions.put("J", "Ljava.lang.Long;"); //$NON-NLS-1$ //$NON-NLS-2$ - boxConversions.put("S", "Ljava.lang.Short;"); //$NON-NLS-1$ //$NON-NLS-2$ - boxConversions.put("Z", "Ljava.lang.Boolean;"); //$NON-NLS-1$ //$NON-NLS-2$ - // don't box V - boxConversions.put("V", "V"); //$NON-NLS-1$ //$NON-NLS-2$ - - // invert hte box conversions - for (final Iterator it = boxConversions.keySet().iterator(); it.hasNext();) - { - final String newValue = (String) it.next(); - final String newKey = (String) boxConversions.get(newValue); - if (unBoxConversions.put(newKey, newValue) != null) - { - // if put returns non-null then we have replaced a key - // added on a previous iteration. This implies - // that box mappings are no longer one-to-one - throw new AssertionError("Duplicated boxing value"); //$NON-NLS-1$ - } - } - } - - /** - * @param compositeType - * @return an equivilent form of compositeType with all primitive type - * signatures converted to their fully qualified boxed equivilent but - * otherwise unchanged. - * - * Example: J -> Ljava.lang.Long; - */ - public static CompositeType transformBoxPrimitives(CompositeType compositeType) - { - String[] signatures = compositeType.getSignatures(); - String[] newsignatures = new String[signatures.length]; - - for (int i = 0; i < signatures.length; i++) - { - newsignatures[i] = transformBoxPrimitives(signatures[i]); - } - - return new CompositeType(newsignatures, compositeType.getAssignmentTypeMask()); - } - - /** - * Performs boxing for a single typeSignature string - * @param curSignature - * @return the boxed signature - */ - public static String transformBoxPrimitives(final String curSignature) - { - String newSignature = curSignature; - - // first determine if we have a type or method signature - try - { - int kind = Signature.getTypeSignatureKind(curSignature); - - // interested in base types, since these need boxing - if (kind == Signature.BASE_TYPE_SIGNATURE) - { - // grab the box for the primitive - newSignature = (String) boxConversions.get(curSignature); - } - else if (kind == Signature.ARRAY_TYPE_SIGNATURE) - { - // check if it's array of primitives - final String baseType = Signature.getElementType(curSignature); - - if (Signature.getTypeSignatureKind(baseType) == Signature.BASE_TYPE_SIGNATURE) - { - // it is, so box it - final String newBaseType = (String) boxConversions.get(baseType); - final int numBraces = Signature.getArrayCount(curSignature); - newSignature = ""; //$NON-NLS-1$ - for (int j = 0; j < numBraces; j++) - { - newSignature += "["; //$NON-NLS-1$ - } - - newSignature += newBaseType; - } - } - } - catch (IllegalArgumentException e) - { - // signature was not a type signature, so must be a method sig - // do nothing: don't box method types - } - - return newSignature; - } - - /** - * Performs the exact inverse of transformBoxPrimitives -- takes all - * boxing type signatures and replaces them with their primitive equivilent - * @param compositeType - * @return a new composite with all boxed primitives unboxed - */ - public static CompositeType transformUnboxPrimitives(CompositeType compositeType) - { - String[] signatures = compositeType.getSignatures(); - String[] newsignatures = new String[signatures.length]; - - for (int i = 0; i < signatures.length; i++) - { - newsignatures[i] = transformUnboxPrimitives(signatures[i]); - } - - return new CompositeType(newsignatures, compositeType.getAssignmentTypeMask()); - } - - /** - * Performs unboxing for a single typeSignature string - * - * @param typeSignature - * @return the transformed signature - */ - public static String transformUnboxPrimitives(final String typeSignature) - { - String newSignature = typeSignature; - - // first determine if we have a type or method signature - try - { - int kind = Signature.getTypeSignatureKind(typeSignature); - - // interested in class types, since these need boxing - if (kind == Signature.CLASS_TYPE_SIGNATURE) - { - // grab the box for the primitive - String checkForUnbox = (String) unBoxConversions.get(typeSignature); - - if (checkForUnbox != null) - { - newSignature = checkForUnbox; - } - } - else if (kind == Signature.ARRAY_TYPE_SIGNATURE) - { - // check if it's array of objects - final String baseType = Signature.getElementType(typeSignature); - - if (Signature.getTypeSignatureKind(baseType) == Signature.CLASS_TYPE_SIGNATURE) - { - // it is, so unbox it - final String newBaseTypeCandidate = (String) unBoxConversions.get(baseType); - - if (newBaseTypeCandidate != null) - { - final int numBraces = Signature.getArrayCount(typeSignature); - newSignature = ""; //$NON-NLS-1$ - for (int j = 0; j < numBraces; j++) - { - newSignature += "["; //$NON-NLS-1$ - } - - newSignature += newBaseTypeCandidate; - } - } - } - } - catch (IllegalArgumentException e) - { - // signature was not a type signature, so must be a method sig - // do nothing: don't box method types - } - - return newSignature; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeUtil.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeUtil.java deleted file mode 100644 index a302fc4d6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/TypeUtil.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import org.eclipse.jdt.core.Signature; - -/** - * Package utility class - * @author cbateman - * - */ -/*package*/final class TypeUtil -{ - /** - * @param assignmentType - * @return true if assignmentType has lhs flag set - */ - public static boolean matchesLHS(int assignmentType) - { - return (assignmentType & IAssignable.ASSIGNMENT_TYPE_LHS) != 0; - } - - /** - * @param assignmentType - * @return true if assignmentType has rhs flag set - */ - public static boolean matchesRHS(int assignmentType) - { - return (assignmentType & IAssignable.ASSIGNMENT_TYPE_RHS) != 0; - } - - /** - * @param signature - * @return true if the signature is a method signature - */ - public static boolean isMethodSignature(final String signature) - { - // method signature must start with a "(" - return signature.charAt(0) == Signature.C_PARAM_START; - } - private TypeUtil() {/*not instantiable*/} -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/ValueType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/ValueType.java deleted file mode 100644 index 2d1282586..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/ValueType.java +++ /dev/null @@ -1,238 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.internal.types; - -import org.eclipse.jdt.core.Signature; - -/** - * Value object representing a value binding type by it's type and assignability - * information - * - * @author cbateman - * - */ -public class ValueType implements SignatureBasedType, IAssignable -{ - /** - * A default empty string array - */ - protected final static String[] EMPTY_STRING_ARRAY = new String[0]; - - private final String _signature; - private final String[] _typeArgs; - private final int _assignmentMask; - private final String[] _superTypes; - private final String[] _interfaceTypes; - - private final boolean _isEnumType; - - private String[] _allTypes; // lazy creation on getAllTypes - - /** - * Construct a new ValueType object with the given - * signature - * - * @param signature - * @param typeArgs generic type arguments for signature or empty if none - * @param superTypes - * @param interfaceTypes - * @param isEnumType - * @param assignmentMask - */ - public ValueType(final String signature, - final String[] typeArgs, - final String[] superTypes, - final String[] interfaceTypes, - final boolean isEnumType, - final int assignmentMask) - { - if (signature == null) - { - throw new AssertionError("signature can never be null"); //$NON-NLS-1$ - } - - _signature = signature; - _typeArgs = typeArgs; - _assignmentMask = assignmentMask; - _superTypes = superTypes != null ? superTypes : EMPTY_STRING_ARRAY; - _interfaceTypes = interfaceTypes != null ? interfaceTypes : EMPTY_STRING_ARRAY; - _isEnumType = isEnumType; - } - - /** - * Copy constructor equivilent to - * ValueType(template.getSignature(), template.getSuperTypes(), template.getInterfaceTypes(),assingmentMask, template._isEnumType) - * - * @param template - * @param assignmentMask - */ - public ValueType(final ValueType template, final int assignmentMask) - { - this(template._signature, template._typeArgs, template._superTypes, - template._interfaceTypes, template._isEnumType, assignmentMask); - } - - /** - * Convienence constructor for creating ValueType's with no supertype, type argument - * or interface info. Equivilent to: - * ValueType(signature, new String[0], new String[0], new String[0], false, assignmentMask) - * - * @param signature - * @param assignmentMask - */ - public ValueType(final String signature, final int assignmentMask) - { - this(signature, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY, false, assignmentMask); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.core.internal.types.SignatureBasedType#getSignature() - */ - public String getSignature() - { - return _signature; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.internal.types.IAssignable#getAssignability() - */ - public int getAssignability() { - return _assignmentMask; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.internal.types.IAssignable#isLHS() - */ - public boolean isLHS() { - return TypeUtil.matchesLHS(_assignmentMask); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.internal.types.IAssignable#isRHS() - */ - public boolean isRHS() { - return TypeUtil.matchesRHS(_assignmentMask); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString() - { - return Signature.getSignatureSimpleName - (TypeTransformer.transformBoxPrimitives(_signature)); - } - - /** - * @return an array of all signatures of all super types or empty - * array if there are no super types for this type - * - * Note: if isArray() == true, then these are the super types of - * the base element - */ - public String[] getSuperTypes() - { - return _superTypes; - } - - /** - * @return an array of all interfaces implemented or empty array - * if none - * - * Note: if isArray() == true, then these are the interfacess of - * the base element - */ - public String[] getInterfaceTypes() - { - return _interfaceTypes; - } - - /** - * @return all types including the base type, super types and interface - * types. - * - * Note: if isArray() == true, then these are the super types of - * the base element - - */ - public String[] getAllTypes() - { - if (_allTypes == null) - { - int numberOfTypes = 1 + _superTypes.length + _interfaceTypes.length; - _allTypes = new String[numberOfTypes]; - _allTypes[0] = _signature; - System.arraycopy(_superTypes, 0, _allTypes, 1, _superTypes.length); - System.arraycopy(_interfaceTypes, 0, _allTypes, 1+_superTypes.length, _interfaceTypes.length); - } - return _allTypes; - } - - /** - * @return the type arguments for getSignature() if any or empty array if none - */ - public String[] getTypeArguments() - { - return _typeArgs; - } - - /** - * - */ - public CompositeType toCompositeType() - { - return new CompositeType(getAllTypes(), getAssignability()); - } - - /** - * @param signature - * @return true if an instance of this type would satisfy instanceof signature - * - */ - public boolean isInstanceOf(final String signature) - { - // if this is an array, then the super types are for the base - // type and we can't be an instance of anything but signature - if (isArray()) - { - return getSignature().equals(signature); - } - - final String[] allTypes = getAllTypes(); - - for (int i = 0; i < allTypes.length; i++) - { - if (allTypes[i].equals(signature)) - { - return true; - } - } - - return false; - } - - /** - * @return true if this is an array type - */ - public boolean isArray() - { - return Signature.getArrayCount(getSignature()) > 0; - } - - /** - * @return true if the value type represents a (>=Java5) enum type - */ - public boolean isEnumType() { - return _isEnumType; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/messages.properties deleted file mode 100644 index 3df119baf..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/internal/types/messages.properties +++ /dev/null @@ -1,18 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2007 Oracle Corporation and others. -# 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 Corporation - initial API and implementation -############################################################################### -TypeComparator.Expression.Doesnt.Match.Expected.Types=EL expression does not evaluate to expected types for this attribute -TypeComparator.Expression.Not.Gettable=Expression is not gettable -TypeComparator.Expression.Expected.Settable=Attribute expects settable value, but expression is not settable - -TypeComparator.Expression.No_Method=Expression must be a method expression but is a value expression -TypeComparator.Expression.No_Value=Expression must be a value expression but is a method expression -TypeComparator.Expression.Incompatible_Method=Method must have signature "{0}" but has signature "{1}" -TypeComparator.Expression.Incompatible_Value=Cannot coerce type {1} to {0} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/Entity.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/Entity.java deleted file mode 100644 index 977011abd..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/Entity.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Entity</b></em>'. - * <p><b>Provisional API - subject to change</b></p> - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Entity#getChildEntities <em>Child Entities</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Entity#getTraits <em>Traits</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Entity#getId <em>Id</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Entity#getType <em>Type</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Entity#getIncludeGroups <em>Include Groups</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getEntity() - * @model extendedMetaData="kind='element' name='entity'" - * @generated - */ -public interface Entity extends EObject { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Returns the value of the '<em><b>Child Entities</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.jst.jsf.common.metadata.Entity}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Child Entities</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Child Entities</em>' containment reference list. - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getEntity_ChildEntities() - * @model type="org.eclipse.jst.jsf.common.metadata.Entity" containment="true" - * extendedMetaData="kind='element' name='entity'" - * @generated - */ - EList getChildEntities(); - - /** - * Returns the value of the '<em><b>Traits</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.jst.jsf.common.metadata.Trait}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Traits</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Traits</em>' containment reference list. - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getEntity_Traits() - * @model type="org.eclipse.jst.jsf.common.metadata.Trait" containment="true" - * extendedMetaData="kind='element' name='trait'" - * @generated - */ - EList getTraits(); - - /** - * Returns the value of the '<em><b>Id</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Id</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Id</em>' attribute. - * @see #setId(String) - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getEntity_Id() - * @model id="true" required="true" - * @generated - */ - String getId(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.Entity#getId <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Id</em>' attribute. - * @see #getId() - * @generated - */ - void setId(String value); - - /** - * Returns the value of the '<em><b>Type</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Type</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Type</em>' attribute. - * @see #setType(String) - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getEntity_Type() - * @model - * @generated - */ - String getType(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.Entity#getType <em>Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Type</em>' attribute. - * @see #getType() - * @generated - */ - void setType(String value); - - /** - * Returns the value of the '<em><b>Include Groups</b></em>' reference list. - * The list contents are of type {@link org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Include Groups</em>' reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Include Groups</em>' reference list. - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getEntity_IncludeGroups() - * @model type="org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup" - * extendedMetaData="kind='element' name='include-entity-group'" - * @generated - */ - EList getIncludeGroups(); - - /** - * <!-- begin-user-doc --> - * @param visitor - * <!-- end-user-doc --> - * @model visitorDataType="org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor" - * @generated - */ - void accept(IEntityVisitor visitor); - - /** - * <!-- begin-user-doc --> - * @return Model - * <!-- end-user-doc --> - * @model kind="operation" - * @generated - */ - Model getModel(); - -} // Entity diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/EntityGroup.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/EntityGroup.java deleted file mode 100644 index fd98b48a8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/EntityGroup.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata; - - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Entity Group</b></em>'. - * <p><b>Provisional API - subject to change</b></p> - * <!-- end-user-doc --> - * - * - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getEntityGroup() - * @model - * @generated - */ -public interface EntityGroup extends Entity { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - -} // EntityGroup diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/IncludeEntityGroup.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/IncludeEntityGroup.java deleted file mode 100644 index be4f1463f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/IncludeEntityGroup.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata; - -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Include Entity Group</b></em>'. - * <p><b>Provisional API - subject to change</b></p> - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup#getId <em>Id</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup#getModelUri <em>Model Uri</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getIncludeEntityGroup() - * @model - * @generated - */ -public interface IncludeEntityGroup extends EObject { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Returns the value of the '<em><b>Id</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Id</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Id</em>' attribute. - * @see #setId(String) - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getIncludeEntityGroup_Id() - * @model required="true" - * @generated - */ - String getId(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup#getId <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Id</em>' attribute. - * @see #getId() - * @generated - */ - void setId(String value); - - /** - * Returns the value of the '<em><b>Model Uri</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Model Uri</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Model Uri</em>' attribute. - * @see #setModelUri(String) - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getIncludeEntityGroup_ModelUri() - * @model extendedMetaData="name='uri'" - * @generated - */ - String getModelUri(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup#getModelUri <em>Model Uri</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Model Uri</em>' attribute. - * @see #getModelUri() - * @generated - */ - void setModelUri(String value); - -} // IncludeEntityGroup diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/MetadataFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/MetadataFactory.java deleted file mode 100644 index 8b8ea0c04..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/MetadataFactory.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata; - -import org.eclipse.emf.ecore.EFactory; - -/** - * <!-- begin-user-doc --> - * The <b>Factory</b> for the model. - * It provides a create method for each non-abstract class of the model. - * <p><b>NOT API</b></p> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage - * @generated - */ -public interface MetadataFactory extends EFactory { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The singleton instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - MetadataFactory eINSTANCE = org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataFactoryImpl.init(); - - /** - * Returns a new object of class '<em>Trait</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Trait</em>'. - * @generated - */ - Trait createTrait(); - - /** - * Returns a new object of class '<em>Include Entity Group</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Include Entity Group</em>'. - * @generated - */ - IncludeEntityGroup createIncludeEntityGroup(); - - /** - * Returns a new object of class '<em>Model</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Model</em>'. - * @generated - */ - Model createModel(); - - /** - * Returns a new object of class '<em>Entity</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Entity</em>'. - * @generated - */ - Entity createEntity(); - - /** - * Returns a new object of class '<em>Entity Group</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Entity Group</em>'. - * @generated - */ - EntityGroup createEntityGroup(); - - /** - * Returns the package supported by this factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the package supported by this factory. - * @generated - */ - MetadataPackage getMetadataPackage(); - -} //MetadataFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/MetadataPackage.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/MetadataPackage.java deleted file mode 100644 index 087f6db19..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/MetadataPackage.java +++ /dev/null @@ -1,871 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - -/** - * <!-- begin-user-doc --> - * The <b>Package</b> for the model. - * It contains accessors for the meta objects to represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * <p><b>NOT API</b></p> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.MetadataFactory - * @model kind="package" - * @generated - */ -public interface MetadataPackage extends EPackage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The package name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNAME = "metadata"; //$NON-NLS-1$ - - /** - * The package namespace URI. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNS_URI = "http://org.eclipse.jst.jsf.common.metadata/metadata.ecore"; //$NON-NLS-1$ - - /** - * The package namespace name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNS_PREFIX = "md"; //$NON-NLS-1$ - - /** - * The singleton instance of the package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - MetadataPackage eINSTANCE = org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl.init(); - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.common.metadata.internal.impl.TraitImpl <em>Trait</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.TraitImpl - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getTrait() - * @generated - */ - int TRAIT = 3; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl <em>Entity</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getEntity() - * @generated - */ - int ENTITY = 2; - - /** - * The feature id for the '<em><b>Child Entities</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY__CHILD_ENTITIES = 0; - - /** - * The feature id for the '<em><b>Traits</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY__TRAITS = 1; - - /** - * The feature id for the '<em><b>Id</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY__ID = 2; - - /** - * The feature id for the '<em><b>Type</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY__TYPE = 3; - - /** - * The feature id for the '<em><b>Include Groups</b></em>' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY__INCLUDE_GROUPS = 4; - - /** - * The number of structural features of the '<em>Entity</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY_FEATURE_COUNT = 5; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.common.metadata.internal.impl.ModelImpl <em>Model</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.ModelImpl - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getModel() - * @generated - */ - int MODEL = 0; - - /** - * The feature id for the '<em><b>Child Entities</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int MODEL__CHILD_ENTITIES = ENTITY__CHILD_ENTITIES; - - /** - * The feature id for the '<em><b>Traits</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int MODEL__TRAITS = ENTITY__TRAITS; - - /** - * The feature id for the '<em><b>Id</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int MODEL__ID = ENTITY__ID; - - /** - * The feature id for the '<em><b>Type</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int MODEL__TYPE = ENTITY__TYPE; - - /** - * The feature id for the '<em><b>Include Groups</b></em>' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int MODEL__INCLUDE_GROUPS = ENTITY__INCLUDE_GROUPS; - - /** - * The feature id for the '<em><b>Entity Groups</b></em>' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int MODEL__ENTITY_GROUPS = ENTITY_FEATURE_COUNT + 0; - - /** - * The feature id for the '<em><b>Source Model Provider</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int MODEL__SOURCE_MODEL_PROVIDER = ENTITY_FEATURE_COUNT + 1; - - /** - * The feature id for the '<em><b>Current Model Context</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int MODEL__CURRENT_MODEL_CONTEXT = ENTITY_FEATURE_COUNT + 2; - - /** - * The number of structural features of the '<em>Model</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int MODEL_FEATURE_COUNT = ENTITY_FEATURE_COUNT + 3; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.common.metadata.internal.impl.IncludeEntityGroupImpl <em>Include Entity Group</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.IncludeEntityGroupImpl - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getIncludeEntityGroup() - * @generated - */ - int INCLUDE_ENTITY_GROUP = 4; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityGroupImpl <em>Entity Group</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.EntityGroupImpl - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getEntityGroup() - * @generated - */ - int ENTITY_GROUP = 1; - - /** - * The feature id for the '<em><b>Child Entities</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY_GROUP__CHILD_ENTITIES = ENTITY__CHILD_ENTITIES; - - /** - * The feature id for the '<em><b>Traits</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY_GROUP__TRAITS = ENTITY__TRAITS; - - /** - * The feature id for the '<em><b>Id</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY_GROUP__ID = ENTITY__ID; - - /** - * The feature id for the '<em><b>Type</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY_GROUP__TYPE = ENTITY__TYPE; - - /** - * The feature id for the '<em><b>Include Groups</b></em>' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY_GROUP__INCLUDE_GROUPS = ENTITY__INCLUDE_GROUPS; - - /** - * The number of structural features of the '<em>Entity Group</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int ENTITY_GROUP_FEATURE_COUNT = ENTITY_FEATURE_COUNT + 0; - - /** - * The feature id for the '<em><b>Id</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int TRAIT__ID = 0; - - /** - * The feature id for the '<em><b>Value</b></em>' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int TRAIT__VALUE = 1; - - /** - * The feature id for the '<em><b>Source Model Provider</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int TRAIT__SOURCE_MODEL_PROVIDER = 2; - - /** - * The number of structural features of the '<em>Trait</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int TRAIT_FEATURE_COUNT = 3; - - /** - * The feature id for the '<em><b>Id</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int INCLUDE_ENTITY_GROUP__ID = 0; - - /** - * The feature id for the '<em><b>Model Uri</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int INCLUDE_ENTITY_GROUP__MODEL_URI = 1; - - /** - * The number of structural features of the '<em>Include Entity Group</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int INCLUDE_ENTITY_GROUP_FEATURE_COUNT = 2; - - /** - * The meta object id for the '<em>ITrait Visitor</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getITraitVisitor() - * @generated - */ - int ITRAIT_VISITOR = 5; - - /** - * The meta object id for the '<em>IEntity Visitor</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getIEntityVisitor() - * @generated - */ - int IENTITY_VISITOR = 6; - - /** - * The meta object id for the '<em>IMeta Data Source Model Provider</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getIMetaDataSourceModelProvider() - * @generated - */ - int IMETA_DATA_SOURCE_MODEL_PROVIDER = 7; - - - /** - * The meta object id for the '<em>Model Context</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getModelContext() - * @generated - */ - int MODEL_CONTEXT = 8; - - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.common.metadata.Trait <em>Trait</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Trait</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Trait - * @generated - */ - EClass getTrait(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.Trait#getId <em>Id</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Id</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Trait#getId() - * @see #getTrait() - * @generated - */ - EAttribute getTrait_Id(); - - /** - * Returns the meta object for the containment reference '{@link org.eclipse.jst.jsf.common.metadata.Trait#getValue <em>Value</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference '<em>Value</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Trait#getValue() - * @see #getTrait() - * @generated - */ - EReference getTrait_Value(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.Trait#getSourceModelProvider <em>Source Model Provider</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Source Model Provider</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Trait#getSourceModelProvider() - * @see #getTrait() - * @generated - */ - EAttribute getTrait_SourceModelProvider(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup <em>Include Entity Group</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Include Entity Group</em>'. - * @see org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup - * @generated - */ - EClass getIncludeEntityGroup(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup#getId <em>Id</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Id</em>'. - * @see org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup#getId() - * @see #getIncludeEntityGroup() - * @generated - */ - EAttribute getIncludeEntityGroup_Id(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup#getModelUri <em>Model Uri</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Model Uri</em>'. - * @see org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup#getModelUri() - * @see #getIncludeEntityGroup() - * @generated - */ - EAttribute getIncludeEntityGroup_ModelUri(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.common.metadata.Model <em>Model</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Model</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Model - * @generated - */ - EClass getModel(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.Model#getSourceModelProvider <em>Source Model Provider</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Source Model Provider</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Model#getSourceModelProvider() - * @see #getModel() - * @generated - */ - EAttribute getModel_SourceModelProvider(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.Model#getCurrentModelContext <em>Current Model Context</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Current Model Context</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Model#getCurrentModelContext() - * @see #getModel() - * @generated - */ - EAttribute getModel_CurrentModelContext(); - - /** - * Returns the meta object for the reference list '{@link org.eclipse.jst.jsf.common.metadata.Model#getEntityGroups <em>Entity Groups</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the reference list '<em>Entity Groups</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Model#getEntityGroups() - * @see #getModel() - * @generated - */ - EReference getModel_EntityGroups(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.common.metadata.Entity <em>Entity</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Entity</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Entity - * @generated - */ - EClass getEntity(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.jst.jsf.common.metadata.Entity#getChildEntities <em>Child Entities</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference list '<em>Child Entities</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Entity#getChildEntities() - * @see #getEntity() - * @generated - */ - EReference getEntity_ChildEntities(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.jst.jsf.common.metadata.Entity#getTraits <em>Traits</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference list '<em>Traits</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Entity#getTraits() - * @see #getEntity() - * @generated - */ - EReference getEntity_Traits(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.Entity#getId <em>Id</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Id</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Entity#getId() - * @see #getEntity() - * @generated - */ - EAttribute getEntity_Id(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.Entity#getType <em>Type</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Type</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Entity#getType() - * @see #getEntity() - * @generated - */ - EAttribute getEntity_Type(); - - /** - * Returns the meta object for the reference list '{@link org.eclipse.jst.jsf.common.metadata.Entity#getIncludeGroups <em>Include Groups</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the reference list '<em>Include Groups</em>'. - * @see org.eclipse.jst.jsf.common.metadata.Entity#getIncludeGroups() - * @see #getEntity() - * @generated - */ - EReference getEntity_IncludeGroups(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.common.metadata.EntityGroup <em>Entity Group</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Entity Group</em>'. - * @see org.eclipse.jst.jsf.common.metadata.EntityGroup - * @generated - */ - EClass getEntityGroup(); - - /** - * Returns the meta object for data type '{@link org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor <em>ITrait Visitor</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for data type '<em>ITrait Visitor</em>'. - * @see org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor - * @model instanceClass="org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor" serializable="false" - * @generated - */ - EDataType getITraitVisitor(); - - /** - * Returns the meta object for data type '{@link org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor <em>IEntity Visitor</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for data type '<em>IEntity Visitor</em>'. - * @see org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor - * @model instanceClass="org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor" serializable="false" - * @generated - */ - EDataType getIEntityVisitor(); - - /** - * Returns the meta object for data type '{@link org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider <em>IMeta Data Source Model Provider</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for data type '<em>IMeta Data Source Model Provider</em>'. - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider - * @model instanceClass="org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider" - * @generated - */ - EDataType getIMetaDataSourceModelProvider(); - - /** - * Returns the meta object for data type '{@link org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor <em>Model Context</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for data type '<em>Model Context</em>'. - * @see org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor - * @model instanceClass="org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor" - * @generated - */ - EDataType getModelContext(); - - /** - * Returns the factory that creates the instances of the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the factory that creates the instances of the model. - * @generated - */ - MetadataFactory getMetadataFactory(); - - /** - * <!-- begin-user-doc --> - * Defines literals for the meta objects that represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("hiding") - interface Literals { - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.common.metadata.internal.impl.TraitImpl <em>Trait</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.TraitImpl - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getTrait() - * @generated - */ - EClass TRAIT = eINSTANCE.getTrait(); - - /** - * The meta object literal for the '<em><b>Id</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute TRAIT__ID = eINSTANCE.getTrait_Id(); - - /** - * The meta object literal for the '<em><b>Value</b></em>' containment reference feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference TRAIT__VALUE = eINSTANCE.getTrait_Value(); - - /** - * The meta object literal for the '<em><b>Source Model Provider</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute TRAIT__SOURCE_MODEL_PROVIDER = eINSTANCE.getTrait_SourceModelProvider(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.common.metadata.internal.impl.IncludeEntityGroupImpl <em>Include Entity Group</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.IncludeEntityGroupImpl - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getIncludeEntityGroup() - * @generated - */ - EClass INCLUDE_ENTITY_GROUP = eINSTANCE.getIncludeEntityGroup(); - - /** - * The meta object literal for the '<em><b>Id</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute INCLUDE_ENTITY_GROUP__ID = eINSTANCE.getIncludeEntityGroup_Id(); - - /** - * The meta object literal for the '<em><b>Model Uri</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute INCLUDE_ENTITY_GROUP__MODEL_URI = eINSTANCE.getIncludeEntityGroup_ModelUri(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.common.metadata.internal.impl.ModelImpl <em>Model</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.ModelImpl - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getModel() - * @generated - */ - EClass MODEL = eINSTANCE.getModel(); - - /** - * The meta object literal for the '<em><b>Source Model Provider</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute MODEL__SOURCE_MODEL_PROVIDER = eINSTANCE.getModel_SourceModelProvider(); - - /** - * The meta object literal for the '<em><b>Current Model Context</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute MODEL__CURRENT_MODEL_CONTEXT = eINSTANCE.getModel_CurrentModelContext(); - - /** - * The meta object literal for the '<em><b>Entity Groups</b></em>' reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference MODEL__ENTITY_GROUPS = eINSTANCE.getModel_EntityGroups(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl <em>Entity</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getEntity() - * @generated - */ - EClass ENTITY = eINSTANCE.getEntity(); - - /** - * The meta object literal for the '<em><b>Child Entities</b></em>' containment reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference ENTITY__CHILD_ENTITIES = eINSTANCE.getEntity_ChildEntities(); - - /** - * The meta object literal for the '<em><b>Traits</b></em>' containment reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference ENTITY__TRAITS = eINSTANCE.getEntity_Traits(); - - /** - * The meta object literal for the '<em><b>Id</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute ENTITY__ID = eINSTANCE.getEntity_Id(); - - /** - * The meta object literal for the '<em><b>Type</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute ENTITY__TYPE = eINSTANCE.getEntity_Type(); - - /** - * The meta object literal for the '<em><b>Include Groups</b></em>' reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference ENTITY__INCLUDE_GROUPS = eINSTANCE.getEntity_IncludeGroups(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityGroupImpl <em>Entity Group</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.EntityGroupImpl - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getEntityGroup() - * @generated - */ - EClass ENTITY_GROUP = eINSTANCE.getEntityGroup(); - - /** - * The meta object literal for the '<em>ITrait Visitor</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getITraitVisitor() - * @generated - */ - EDataType ITRAIT_VISITOR = eINSTANCE.getITraitVisitor(); - - /** - * The meta object literal for the '<em>IEntity Visitor</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getIEntityVisitor() - * @generated - */ - EDataType IENTITY_VISITOR = eINSTANCE.getIEntityVisitor(); - - /** - * The meta object literal for the '<em>IMeta Data Source Model Provider</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getIMetaDataSourceModelProvider() - * @generated - */ - EDataType IMETA_DATA_SOURCE_MODEL_PROVIDER = eINSTANCE.getIMetaDataSourceModelProvider(); - - /** - * The meta object literal for the '<em>Model Context</em>' data type. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor - * @see org.eclipse.jst.jsf.common.metadata.internal.impl.MetadataPackageImpl#getModelContext() - * @generated - */ - EDataType MODEL_CONTEXT = eINSTANCE.getModelContext(); - - } - -} //MetadataPackage diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/Model.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/Model.java deleted file mode 100644 index ed4603fad..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/Model.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor; -import org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Model</b></em>'. - * <p><b>Provisional API - subject to change</b></p> - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Model#getEntityGroups <em>Entity Groups</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Model#getSourceModelProvider <em>Source Model Provider</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Model#getCurrentModelContext <em>Current Model Context</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getModel() - * @model extendedMetaData="kind='element' name='metadatamodel'" - * @generated - */ -public interface Model extends Entity { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Returns the value of the '<em><b>Source Model Provider</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Source Model Provider</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Source Model Provider</em>' attribute. - * @see #setSourceModelProvider(IMetaDataSourceModelProvider) - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getModel_SourceModelProvider() - * @model unique="false" dataType="org.eclipse.jst.jsf.common.metadata.IMetaDataSourceModelProvider" transient="true" volatile="true" - * @generated - */ - IMetaDataSourceModelProvider getSourceModelProvider(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.Model#getSourceModelProvider <em>Source Model Provider</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Source Model Provider</em>' attribute. - * @see #getSourceModelProvider() - * @generated - */ - void setSourceModelProvider(IMetaDataSourceModelProvider value); - - /** - * Returns the value of the '<em><b>Current Model Context</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Current Model Context</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Current Model Context</em>' attribute. - * @see #setCurrentModelContext(ModelKeyDescriptor) - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getModel_CurrentModelContext() - * @model dataType="org.eclipse.jst.jsf.common.metadata.ModelContext" transient="true" volatile="true" - * @generated - */ - ModelKeyDescriptor getCurrentModelContext(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.Model#getCurrentModelContext <em>Current Model Context</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Current Model Context</em>' attribute. - * @see #getCurrentModelContext() - * @generated - */ - void setCurrentModelContext(ModelKeyDescriptor value); - - /** - * Returns the value of the '<em><b>Entity Groups</b></em>' reference list. - * The list contents are of type {@link org.eclipse.jst.jsf.common.metadata.EntityGroup}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Entity Groups</em>' reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Entity Groups</em>' reference list. - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getModel_EntityGroups() - * @model type="org.eclipse.jst.jsf.common.metadata.EntityGroup" - * extendedMetaData="kind='element' name='entityGroup'" - * @generated - */ - EList getEntityGroups(); - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param groupId - * @return EntityGroup - * @model - * @generated - */ - EntityGroup findIncludeGroup(String groupId); - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @model visitorDataType="org.eclipse.jst.jsf.common.metadata.IEntityVisitor" - * @generated - */ - void accept(IEntityVisitor visitor); - -} // Model diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/Trait.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/Trait.java deleted file mode 100644 index 4eb1b30c7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/Trait.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Trait</b></em>'. - * <p><b>Provisional API - subject to change</b></p> - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Trait#getId <em>Id</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Trait#getValue <em>Value</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.Trait#getSourceModelProvider <em>Source Model Provider</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getTrait() - * @model extendedMetaData="kind='element' name='trait'" - * @generated - */ -public interface Trait extends EObject { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Returns the value of the '<em><b>Id</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Id</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Id</em>' attribute. - * @see #setId(String) - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getTrait_Id() - * @model id="true" required="true" - * @generated - */ - String getId(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.Trait#getId <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Id</em>' attribute. - * @see #getId() - * @generated - */ - void setId(String value); - - /** - * Returns the value of the '<em><b>Value</b></em>' containment reference. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Value</em>' reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Value</em>' containment reference. - * @see #setValue(EObject) - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getTrait_Value() - * @model containment="true" required="true" - * extendedMetaData="kind='element' namespace='##targetNamespace'" - * @generated - */ - EObject getValue(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.Trait#getValue <em>Value</em>}' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Value</em>' containment reference. - * @see #getValue() - * @generated - */ - void setValue(EObject value); - - /** - * Returns the value of the '<em><b>Source Model Provider</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Source Model Provider</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Source Model Provider</em>' attribute. - * @see #setSourceModelProvider(IMetaDataSourceModelProvider) - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#getTrait_SourceModelProvider() - * @model dataType="org.eclipse.jst.jsf.common.metadata.IMetaDataSourceModelProvider" - * @generated - */ - IMetaDataSourceModelProvider getSourceModelProvider(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.Trait#getSourceModelProvider <em>Source Model Provider</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Source Model Provider</em>' attribute. - * @see #getSourceModelProvider() - * @generated - */ - void setSourceModelProvider(IMetaDataSourceModelProvider value); - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param visitor - * @model visitorDataType="org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor" - * annotation="http://www.eclipse.org/emf/2002/GenModel body='visitor.visit(this);'" - * @generated - */ - void accept(ITraitVisitor visitor); - -} // Trait diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractMetaDataLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractMetaDataLocator.java deleted file mode 100644 index 8719c1891..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractMetaDataLocator.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.HashSet; -import java.util.Set; - -/** - * Convenient abstract class that a source model locator should consider extending. - */ -public abstract class AbstractMetaDataLocator implements IMetaDataLocator, IMetaDataObservable{ - - private IDomainSourceModelType domainSourceModelType; - private Set/*<IMetaDataObserver>*/ observers; - - /** - * Constructor - */ - public AbstractMetaDataLocator(){ - observers = new HashSet(1); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator#getDomainSourceModelType() - */ - public IDomainSourceModelType getDomainSourceModelType() { - return domainSourceModelType; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator#setDomainSourceModelType(org.eclipse.jst.jsf.common.metadata.internal.IDomainSourceModelType) - */ - public void setDomainSourceModelType( - IDomainSourceModelType domainSourceModelType) { - this.domainSourceModelType = domainSourceModelType; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator#addObserver(org.eclipse.jst.jsf.common.metadata.internal.IMetaDataObserver) - */ - public void addObserver(IMetaDataObserver observer) { - observers.add(observer); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator#removeObserver(org.eclipse.jst.jsf.common.metadata.internal.IMetaDataObserver) - */ - public void removeObserver(IMetaDataObserver observer) { - observers.remove(observer); - } - - /** - * @return the set of {@link IMetaDataObserver}s for this instance - */ - public Set/*<IMetaDataObserver>*/ getObservers(){ - return observers; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractTagLibDomainContentModelMetaDataTranslator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractTagLibDomainContentModelMetaDataTranslator.java deleted file mode 100644 index c9a297247..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/AbstractTagLibDomainContentModelMetaDataTranslator.java +++ /dev/null @@ -1,360 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.Iterator; - -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.MetadataFactory; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesFactory; -import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; - -/** - * Abstract class that the taglib domain translators use to - * convert the CM model to a standard meta data model - * - */ -public abstract class AbstractTagLibDomainContentModelMetaDataTranslator { - - /** - * {@link IMetaDataModelMergeAssistant} to use - */ - protected IMetaDataModelMergeAssistant _assistant; - - /** - * Set the assistant to use during the translation. Must be called prior to doTransalate(doc); - * @param assistant - */ - protected void setAssistant(IMetaDataModelMergeAssistant assistant){ - _assistant = assistant; - } - - /** - * Transforms the CMDocument into entities and traits of a standard metadata model - * using the assistant that must be set before this call. - * @param doc - */ - protected void doTranslate(CMDocument doc){ - createTags(doc); - createTagfileTraits(doc); - } - - /** - * @param entity - * @param key - * @param value - */ - protected void createSimpleStringEntityTraitIfNecessary(final Entity entity, final String key, - final String value) { - Trait t = findTraitOnEntityById(entity, key); - if (t == null){ - t = internalCreateTrait(entity, key); - - StringValue val = TraitTypesFactory.eINSTANCE.createStringValue(); - val.setValue(value); - - t.setValue(val); - } - } - - /** - * @param entity - * @param key - * @param value - */ - protected void createSimpleBooleanObjectEntityTraitIfNecessary(final Entity entity, - String key, boolean value) { - - Trait t = findTraitOnEntityById(entity, key); - if (t == null){ - t = internalCreateTrait(entity, key); - - BooleanValue val = TraitTypesFactory.eINSTANCE.createBooleanValue(); - val.setTrue(value); - - t.setValue(val); - } - - } - - /** - * @param entity - * @param key - * @return Trait - */ - protected Trait internalCreateTrait(final Entity entity, final String key) { - Trait t = MetadataFactory.eINSTANCE.createTrait(); - t.setId(key); - t.setSourceModelProvider(_assistant.getSourceModelProvider()); - entity.getTraits().add(t); - return t; - } - - /** - * @param entity - * @param key - * @return Trait - */ - protected Trait findTraitOnEntityById(final Entity entity, final String key) { - for (Iterator it=entity.getTraits().iterator();it.hasNext();){ - Trait t = (Trait)it.next(); - if (key.equals(t.getId())) - return t; - } - return null; - } - - /** - * @param nodeName - * @return Entity - */ - protected Entity findTagEntity(final String nodeName) { - for (Iterator it=getMergedModel().getChildEntities().iterator();it.hasNext();){ - Entity entity = (Entity)it.next(); - if (nodeName.equals(entity.getId())) - return entity; - } - return null; - } - - /** - * @param tag - * @param attributeName - * @return Attribute entity for supplied attribute name and given Tag entity. Will return null if not found. - */ - protected Entity findAttributeEntityForTagEntity(final Entity tag, final String attributeName) { - for (Iterator it=tag.getChildEntities().iterator();it.hasNext();){ - Entity attr = (Entity)it.next(); - if (attributeName.equals(attr.getId())) - return attr; - } - return null; - } - /** - * Create entities for tags - * @param doc - */ - protected void createTags(final CMDocument doc) { - for (Iterator it=doc.getElements().iterator();it.hasNext();){ - CMElementDeclaration tag = (CMElementDeclaration)it.next(); - Entity entity = findTagEntity(tag.getNodeName()); - if (entity == null){ - entity = MetadataFactory.eINSTANCE.createEntity(); - entity.setId(getTagNodeName(tag)); - entity.setType("tag"); //$NON-NLS-1$ - getMergedModel().getChildEntities().add(entity); - } - setTagEntityTraits(tag, entity); - } - - } - - /** - * @param tag - * @return tag node name - */ - protected String getTagNodeName(CMElementDeclaration tag) { - return tag.getNodeName(); - } - - /** - * Sets the standard traits for a tag entity from the element declaration - * @param tag - * @param entity - */ - protected void setTagEntityTraits(CMElementDeclaration tag, Entity entity) { - createSimpleStringEntityTraitIfNecessary(entity, "display-label", getTagDisplayName(tag)); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(entity, "description", getTagDescription(tag)); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(entity, "small-icon", getTagSmallIcon(tag)); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(entity, "large-icon", getTagLargeIcon(tag)); //$NON-NLS-1$ - createSimpleBooleanObjectEntityTraitIfNecessary(entity, "expert", getTagIsExpert(tag)); //$NON-NLS-1$ - createSimpleBooleanObjectEntityTraitIfNecessary(entity, "hidden", getTagIsHidden(tag)); //$NON-NLS-1$ - - createAttributeEntities(entity, tag); - } - - /** - * @param tagEntity - * @param tag - */ - protected void createAttributeEntities(Entity tagEntity, - CMElementDeclaration tag) { - - for (Iterator it=tag.getAttributes().iterator();it.hasNext();){ - CMAttributeDeclaration cmAttr = (CMAttributeDeclaration)it.next(); - Entity attr = findAttributeEntityForTagEntity(tagEntity, cmAttr.getAttrName()); - if (attr == null) { - attr = MetadataFactory.eINSTANCE.createEntity(); - attr.setId(cmAttr.getAttrName()); - tagEntity.getChildEntities().add(attr); - } - createAttributeTraits(attr, cmAttr); - } - - - } - - /** - * @param attr - * @param cmAttr - */ - protected void createAttributeTraits(Entity attr, - CMAttributeDeclaration cmAttr) { - - createSimpleStringEntityTraitIfNecessary(attr, "description", getTagAttributeDescription(cmAttr)); //$NON-NLS-1$ - createSimpleBooleanObjectEntityTraitIfNecessary(attr, "required", getTagAttributeIsRequired(cmAttr)); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(attr, "default-value", getTagAttributeDefaultValue(cmAttr)); //$NON-NLS-1$ - } - - /** - * @param cmAttr - * @return null. subclass should override if CMAttributeDeclaration has the metadata. - */ - protected String getTagAttributeDescription(CMAttributeDeclaration cmAttr) {return null;} - - /** - * @param cmAttr - * @return false. subclass should override if CMAttributeDeclaration has the metadata. - */ - protected boolean getTagAttributeIsRequired(CMAttributeDeclaration cmAttr) {return cmAttr.getUsage() == CMAttributeDeclaration.REQUIRED;} - - /** - * @param cmAttr - * @return null. subclass should override if CMAttributeDeclaration has the metadata. - */ - protected String getTagAttributeDefaultValue(CMAttributeDeclaration cmAttr) {return null;} - - /** - * @param tag - * @return false. subclass should override if CMElementDeclaration has the metadata. - */ - protected boolean getTagIsHidden(CMElementDeclaration tag) {return false;} - - /** - * @param tag - * @return false. subclass should override if CMElementDeclaration has the metadata. - */ - protected boolean getTagIsExpert(CMElementDeclaration tag) {return false;} - - /** - * @param tag - * @return null. subclass should override if CMElementDeclaration has the metadata. - */ - protected String getTagLargeIcon(CMElementDeclaration tag) {return null;} - - /** - * @param tag - * @return null. subclass should override if CMElementDeclaration has the metadata. - */ - protected String getTagSmallIcon(CMElementDeclaration tag) {return null;} - - /** - * @param tag - * @return null. subclass should override if CMElementDeclaration has the metadata. - */ - protected String getTagDescription(CMElementDeclaration tag) {return null;} - - /** - * @param tag - * @return tag.getElementName() - */ - protected String getTagDisplayName(CMElementDeclaration tag) {return tag.getElementName();} - - /** - * Creates standard traits for tag file entity from CMDocument metadata - * @param doc - */ - protected void createTagfileTraits(CMDocument doc) { - Model model = getMergedModel(); - - createSimpleStringEntityTraitIfNecessary(model, "display-label", getURIDisplayLabel()); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(model, "description", getURIDescription()); //$NON-NLS-1$ - createSimpleStringEntityTraitIfNecessary(model, "default-prefix", getURIDefaultPrefix()); //$NON-NLS-1$ - createSimpleBooleanObjectEntityTraitIfNecessary(model, "expert", getURIExpert()); //$NON-NLS-1$ - createSimpleBooleanObjectEntityTraitIfNecessary(model, "hidden", getURIHidden()); //$NON-NLS-1$ - - } - - /** - * @return the display label to use for this model. Subclasses should override if model has the meta data. - */ - protected String getURIDisplayLabel(){ - return getMergedModel().getId(); - } - - /** - * @return default prefix to use for tags. Returns null. Subclasses should override if model has the meta data. - */ - protected String getURIDefaultPrefix(){ - return null; - } - - /** - * @return description to use. Default is the URI. Subclasses should override if model has the meta data. - */ - protected String getURIDescription(){ - return getMergedModel().getId(); - } - - /** - * @return false. Subclasses should override if model has the meta data. - */ - protected boolean getURIExpert() { return false;} - - /** - * @return false. Subclasses should override if model has the meta data. - */ - protected boolean getURIHidden() {return false; } - - /** - * @return a model of all entities and traits - */ - protected Model getMergedModel() { - Model model = (Model)_assistant.getMergedModel().getRoot(); - if (model == null){ - //need to create model key object - Model tld = createTLDModel(); - _assistant.getMergedModel().setRoot(tld); - model = (Model)_assistant.getMergedModel().getRoot(); - } - return model; - } - - /** - * @return new model - */ - protected Model createTLDModel() { - Model entity = getFactory().createModel(); - entity.setId(_assistant.getMergedModel().getModelKey().getUri()); - return entity; - } - - /** - * @return MetadataFactory instance - */ - protected MetadataFactory getFactory(){ - return (MetadataFactory) MetadataPackage.eINSTANCE.getEFactoryInstance(); - } - - /** - * @return CMDocument being used for the current translate call - */ - protected CMDocument getSourceModel() { - return (CMDocument)_assistant.getSourceModelProvider().getSourceModel(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategy.java deleted file mode 100644 index 01a38e61b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategy.java +++ /dev/null @@ -1,193 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * Default class used for loading metadata. - * Loads the source types from extensions defined against the domain. - * - * see org.eclipse.jst.jsf.common.domainLoadingStrategies ext-pt - */ -public class DomainLoadingStrategy implements IDomainLoadingStrategy, IMetaDataObserver { - - /** - * Domain id - */ - protected String domain; - - private MetaDataModel _model; - private List /*<IDomainSourceModelType>*/ _sourceTypes; - private List /*<IMetaDataSourceModelProvider>*/ _sources; - - /** - * Constructor - * @param domain - */ - public DomainLoadingStrategy(String domain){ - this.domain = domain; - } - - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainLoadingStrategy#load(org.eclipse.jst.jsf.common.metadata.internal.MetaDataModel) - */ - public void load(MetaDataModel model) { - this._model = model; - _sourceTypes = loadDomainSourceModelTypes(); - sortSourceTypes(_sourceTypes); - _sources = locateMetaDataSourceInstances(_sourceTypes, model); - mergeModel(model, _sources); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainLoadingStrategy#reload() - */ - public void reload() throws ModelNotSetException { - //System.out.println("reload");//debug //$NON-NLS-1$ - if (_model == null) - throw new ModelNotSetException(); - - removeOldLocatorObservers(); - _sources = locateMetaDataSourceInstances(_sourceTypes, _model); - mergeModel(_model, _sources); - } - - /** - * Responsible for iterating through the sorted list of <code>IMetaDataSourceModelProvider</code> - * and merging the models after first translating the source model as required, into a single mreged model of - * standard metadata Entities and Traits. - * @param model - * @param sources - */ - protected void mergeModel(MetaDataModel model, List/*<IMetaDataSourceModelProvider>*/ sources) { - - StandardModelFactory.debug(">> Begin Merge: "+model.getModelKey()+"("+sources.size()+ " sources)", StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - - IMetaDataModelMergeAssistant assistant = createModelMergeAssistant(model); - for (Iterator/*<IMetaDataSourceModelProvider>*/ it = sources.iterator();it.hasNext();){ - IMetaDataSourceModelProvider mds = (IMetaDataSourceModelProvider)it.next(); - Iterator translators = mds.getLocator().getDomainSourceModelType().getTranslators().iterator(); - while (translators.hasNext()){ - IMetaDataTranslator translator = (IMetaDataTranslator)translators.next(); - if (translator.canTranslate(mds)){ - StandardModelFactory.debug(">>> Merging: "+model.getModelKey()+"::"+mds, StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$//$NON-NLS-2$ - assistant.setSourceModelProvider(mds); - try { - translator.translate(assistant); - } catch (Exception e) { - StandardModelFactory.debug(">>>> Error during translate/merge of: "+model.getModelKey()+": "+mds, StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ //$NON-NLS-2$ - JSFCommonPlugin.log(IStatus.ERROR, "Error during load of: "+mds, e); //$NON-NLS-1$ - } - } - } - } - assistant.setMergeComplete(); - StandardModelFactory.debug(">> End Merge: "+model.getModelKey(),StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ - } - - /** - * @param model - * @return an instance of a IMetaDataModelMergeAssistant to be used while merging source models - */ - protected IMetaDataModelMergeAssistant createModelMergeAssistant(MetaDataModel model){ - return new MetaDataModelMergeAssistantImpl(model); - } - - /** - * Allows for subclasses to override the default mechanism for sorting the source types. - * @param sourceTypes - */ - protected void sortSourceTypes(List/*<IDomainSourceModelType>*/ sourceTypes) { - //allows override - } - - /** - * @return list of <code>IDomainSourceModelType</code>s located in the <code>DomainSourceTypesRegistry</code> - * for the specified uri - */ - protected List/*<IDomainSourceModelType>*/ loadDomainSourceModelTypes() { - return DomainSourceTypesRegistry.getInstance().getDomainSourceTypes(domain); - } - - /** - * @param sourceTypes - * @param model - * @return list of <code>IMetaDataSourceModelProvider</code> instances from the domain source types applicable for - * this domain for this particular uri specified in the model - */ - protected List/*<IMetaDataSourceModelProvider>*/ locateMetaDataSourceInstances(List/*<IDomainSourceModelType>*/ sourceTypes, MetaDataModel model) { - List/*<IMetaDataSourceModelProvider>*/ sources = new ArrayList/*<IMetaDataSourceModelProvider>*/(); - for (Iterator/*<IDomainSourceModelType>*/ it = sourceTypes.iterator();it.hasNext();){ - IDomainSourceModelType sourceType = (IDomainSourceModelType)it.next(); - IMetaDataLocator locator = sourceType.getLocator(model.getModelKey().getProject()); - if (locator != null) { - //We MUST set the sourceType here to associate the handler with locator to use for the source models - locator.setDomainSourceModelType(sourceType); - - List/*<IMetaDataSourceModelProvider>*/ providers = locator.locateMetaDataModelProviders(model.getModelKey().getUri()); - if (providers != null && !providers.isEmpty()){ - for (Iterator mdProviders =providers.iterator();mdProviders.hasNext();){ - IMetaDataSourceModelProvider provider = (IMetaDataSourceModelProvider)mdProviders.next(); - //We MUST set the sourceType here to associate the translators to use for the source models - provider.setLocator(locator); - sources.add(provider); - } - } - //listen for changes - locator.addObserver(this); - } - } - return sources; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataObserver#notifyMetadataChanged(org.eclipse.jst.jsf.common.metadata.internal.IMetaDataChangeNotificationEvent) - */ - public void notifyMetadataChanged(IMetaDataChangeNotificationEvent event) { - //for now, if any event occurs, we need to flush the _model so that it will rebuild - _model.setNeedsRefresh(); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainLoadingStrategy#cleanup() - */ - public void cleanup(){ - removeOldLocatorObservers(); - _sources = null; - _sourceTypes = null; - _model = null; - } - - private void removeOldLocatorObservers(){ - if (_sources != null){ - for (Iterator it= _sources.iterator();it.hasNext();){ - IMetaDataSourceModelProvider provider = (IMetaDataSourceModelProvider)it.next(); - if (provider != null) { - IMetaDataLocator locator = provider.getLocator(); - if (locator != null){ - locator.removeObserver(this); - locator.setDomainSourceModelType(null); - provider.setLocator(null); - } - } - } - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategyRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategyRegistry.java deleted file mode 100644 index 19b603d02..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainLoadingStrategyRegistry.java +++ /dev/null @@ -1,175 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - - -/** - * Registry of strategies used to load domains of metadata. - * Uses the <code>org.eclipse.jst.jsf.common.domainLoadingStrategies</code> ext-pt to load. - * - * see <code>org.eclipse.jst.jsf.common.domainLoadingStrategies</code> ext-pt - */ -public class DomainLoadingStrategyRegistry{ - private static DomainLoadingStrategyRegistry INSTANCE; - - private HashMap/*<String, DomainLoadingStrategyDescriptorImpl>*/ domainLoadingStrategyDescriptors; - -// public static final String TAGLIB_DOMAIN ="TagLibraryDomain"; //this does *not* belong here. FIX ME -// public static final String TAGLIB_DOMAIN_SOURCE_HANDLER_ID = TAGLIB_DOMAIN + "SourceHandler"; -// public static final String TAGLIB_DOMAIN_TRANSLATOR = "com.foo.translators."+TAGLIB_DOMAIN + "Translator"; - - private static final String EXTENSION_POINT_ID = "domainLoadingStrategies"; //$NON-NLS-1$ - - private DomainLoadingStrategyRegistry(){ - init(); - } - - /** - * @return singleton instance of the DomainLoadingStrategyRegistry - */ - public synchronized static DomainLoadingStrategyRegistry getInstance() { - if (INSTANCE == null){ - INSTANCE = new DomainLoadingStrategyRegistry(); - } - return INSTANCE; - } - - /** - * Loads registry with descriptors from the domainLoadingStrategies ext-pt. - */ - synchronized final void init(){ - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint point = extensionRegistry.getExtensionPoint(JSFCommonPlugin.PLUGIN_ID, EXTENSION_POINT_ID ); - if (point != null) { - IConfigurationElement[] elements = point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement element = elements[i]; - DomainLoadingStrategyDescriptorImpl dls = new DomainLoadingStrategyDescriptorImpl(element); - addDomainLoadingStrategyDescriptor(dls); - } - } - } - - /** - * Add domain loading strategy descriptor for a domain to the registry domains - * @param strategy - */ - protected void addDomainLoadingStrategyDescriptor(DomainLoadingStrategyDescriptorImpl strategy){ - getDescriptors().put(strategy.getDomain(), strategy); - } - - /** - * @param domain - * @return an instance of an <code>IDomainLoadingStrategy</code> for the given domain - */ - public IDomainLoadingStrategy getLoadingStrategy(String domain){ - DomainLoadingStrategyDescriptorImpl strategy = (DomainLoadingStrategyDescriptorImpl)getDescriptors().get(domain); - if (strategy == null){ - return createDefaultLoadingStrategy(); - } - return createLoadingStrategy(domain); - } - - - /** - * @return strategy that will only use standard metadata files - */ - private IDomainLoadingStrategy createDefaultLoadingStrategy() { - return new DomainLoadingStrategy(null); - } - - private IDomainLoadingStrategy createLoadingStrategy(String domain){ - return ((DomainLoadingStrategyDescriptorImpl)getDescriptors().get(domain)).newInstance(); - } - - private Map/*<String, DomainLoadingStrategyDescriptorImpl>*/ getDescriptors(){ - if (domainLoadingStrategyDescriptors == null){ - domainLoadingStrategyDescriptors = new HashMap/*<String, DomainLoadingStrategyDescriptorImpl>*/(); - } - return domainLoadingStrategyDescriptors; - } - - /** - * Implementation of a DomainLoadingStrategy descriptor that is responsible for creating instances of the IDomainLoadingStrategy - */ - private static class DomainLoadingStrategyDescriptorImpl { - String domain; - String loadingStrategyClassName; - String bundleId; - Class strategy; - IConfigurationElement element; - - DomainLoadingStrategyDescriptorImpl(IConfigurationElement element){ - this.element = element; - this.init(); - } - - private void init() { - domain = element.getAttribute("domainId"); //$NON-NLS-1$ - bundleId = element.getContributor().getName(); - loadingStrategyClassName = element.getAttribute("domainLoadingStrategy"); //$NON-NLS-1$ - } - - /** - * @return domain id - */ - public String getDomain() { - return domain; - } - - /** - * @return new instance of IDomainLoadingStrategy - */ - public IDomainLoadingStrategy newInstance(){ - try { - Class[] parameterTypes = new Class[]{String.class}; - Object[] initargs = new Object[]{domain}; - Object loader = this.getLoadingStrategy().getConstructor(parameterTypes).newInstance(initargs); - if (loader instanceof IDomainLoadingStrategy) - return (IDomainLoadingStrategy)loader; - } catch (InstantiationException e) { - JSFCommonPlugin.log(IStatus.ERROR, "Unable to instantiate IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - JSFCommonPlugin.log(IStatus.ERROR, "IllegalAccessException during creation of IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } catch (IllegalArgumentException e) { - JSFCommonPlugin.log(IStatus.ERROR, "IllegalArgumentException during creation of IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } catch (SecurityException e) { - JSFCommonPlugin.log(IStatus.ERROR, "SecurityException during creation of IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } catch (InvocationTargetException e) { - JSFCommonPlugin.log(IStatus.ERROR, "InvocationTargetException during creation of IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } catch (NoSuchMethodException e) { - JSFCommonPlugin.log(IStatus.ERROR, "NoSuchMethodException during creation of IDomainLoadingStrategy for: "+ domain,e); //$NON-NLS-1$ - } - return null; - } - - private Class getLoadingStrategy() { - if (strategy == null){ - strategy = JSFCommonPlugin.loadClass(loadingStrategyClassName, bundleId); - } - return strategy; - } - - } - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceModelTypeDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceModelTypeDescriptor.java deleted file mode 100644 index dd623ca5d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceModelTypeDescriptor.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * Implementation of a {@link IDomainSourceModelType} descriptor. - * Responsible for producing instances of {@link IDomainSourceModelType}. - * Also responsible for creating the {@link IMetaDataTranslator} descriptors from the - * <code>com.eclipse.jst.jsf.common.domainSourceModelTypeTranslators</code> ext-pt - */ -public class DomainSourceModelTypeDescriptor { - private static final String TRANSLATORS_EXTENSION_POINT_ID = "domainSourceModelTypeTranslators"; //$NON-NLS-1$ - private static final String STANDARD_FILE_NULL_TRANSLATOR = "org.eclipse.jst.jsf.common.metadata.internal.StandardMetaDataFilesTranslator"; //$NON-NLS-1$ - private String domain = "DEFAULT"; //$NON-NLS-1$ - private String domainSourceModelTypeId; - private String locatorClassName = "org.eclipse.jst.jsf.common.metadata.internal.StandardMetaDataLocator"; //$NON-NLS-1$ - private Set translatorDescriptors; - private String bundleId = JSFCommonPlugin.PLUGIN_ID; - private int ordinal; - - /** - * Constructor - * @param domain - * @param domainSourceModelTypeId - * @param locatorClassName - * @param bundleId - * @param ordinal - */ - public DomainSourceModelTypeDescriptor(String domain, String domainSourceModelTypeId, String locatorClassName, String bundleId, int ordinal){ - this.domain = domain; - this.locatorClassName = locatorClassName; - this.domainSourceModelTypeId = domainSourceModelTypeId; - this.bundleId = bundleId; - this.ordinal = ordinal; - init(); - } - - /** - * Default model type descriptor that will load only standard metadata files - */ - public DomainSourceModelTypeDescriptor(){ -// getTranslatorDescriptors(); - //createTranslatorInstances() will add the standard null translator - } - - private synchronized void init() { - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint point = extensionRegistry.getExtensionPoint(JSFCommonPlugin.PLUGIN_ID, TRANSLATORS_EXTENSION_POINT_ID ); - if (point != null) { - IConfigurationElement[] elements = point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement element = elements[i]; - String srcHdlrId = element.getAttribute("domainSourceModelTypeId"); //$NON-NLS-1$ - if (srcHdlrId.equals(domainSourceModelTypeId)) - addTranslatorDescriptor(element); - } - } - } - - private void addTranslatorDescriptor(IConfigurationElement element) { - String translator = element.getAttribute("translatorClass"); //$NON-NLS-1$ - DomainSourceModelTranslatorDescriptor d = new DomainSourceModelTranslatorDescriptor(translator, element.getContributor().getName()); - getTranslatorDescriptors().add(d); - } - - private Set getTranslatorDescriptors(){ - if (translatorDescriptors == null){ - translatorDescriptors = new HashSet(); - } - return translatorDescriptors; - } - - /** - * @return domain - */ - public String getDomain() { - return domain; - } - - /** - * @return new instance of the {@link IDomainSourceModelType} - */ - public IDomainSourceModelType getInstance(){ - return new DomainSourceModelTypeImpl(); - } - - /** - * Internal class implementing {@link IDomainSourceModelType} - */ - class DomainSourceModelTypeImpl implements IDomainSourceModelType{ - - private Set translators; - private IMetaDataLocator locator; - - DomainSourceModelTypeImpl(){ - // restrict construction to package scope - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainSourceModelType#getDomain() - */ - public String getDomain() { - return domain; - } - - /** - * @return value of ordinal defined by the ext-pt used for ordering source types for a domain - */ - public int getOrdinal(){ - return ordinal; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainSourceModelType#getLocator() - */ - public IMetaDataLocator getLocator(IProject project) { - if (locator == null){ - locator = MetaDataLocatorFactory.getInstance().getLocator(locatorClassName, bundleId, project); - } - - return locator; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IDomainSourceModelType#getTranslators() - */ - public Set getTranslators() { - if (translators == null){ - translators = createTranslatorInstances(); - } - return translators; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public String toString(){ - StringBuffer buf = new StringBuffer("DomainSourceModelTypeImpl"); //$NON-NLS-1$ - buf.append("(domain = "); //$NON-NLS-1$ - buf.append(getDomain()); - buf.append(", locator = "); //$NON-NLS-1$ - buf.append(locator != null ? locator.toString() : "null"); //$NON-NLS-1$ - buf.append(")"); //$NON-NLS-1$ - return buf.toString(); - } - - private Set createTranslatorInstances() { - translators = new HashSet/*<IMetaDataTranslator>*/(); - if (getTranslatorDescriptors().size() == 0){// for TagLibDomain, we are adding null translator via extension (as of 7/16/07) - //would get here if a domain and source type was defined without a domain translator. Should not happen, but - //add Null Translator for now.... - //we could/should raise exception. - //Developers should add a STANDARD_FILE_NULL_TRANSLATOR if using standard metadata format. - Class klass = JSFCommonPlugin.loadClass(STANDARD_FILE_NULL_TRANSLATOR, JSFCommonPlugin.PLUGIN_ID); - try { - translators.add(klass.newInstance()); - return translators; - } catch (InstantiationException e) { - // TODO: other error handling? - JSFCommonPlugin.log(e, "Error in createTranslatorInstances(STANDARD_FILE_NULL_TRANSLATOR)"); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - // TODO: other error handling? - JSFCommonPlugin.log(e, "Error in createTranslatorInstances(STANDARD_FILE_NULL_TRANSLATOR)"); //$NON-NLS-1$ - } - - } - - Iterator/*<DomainSourceModelTranslatorDescriptor>*/it = getTranslatorDescriptors().iterator(); - while (it.hasNext()){ - DomainSourceModelTranslatorDescriptor d = (DomainSourceModelTranslatorDescriptor)it.next(); - Class klass = JSFCommonPlugin.loadClass(d.getTranslator(), d.getBundleId()); - try { - translators.add(klass.newInstance()); - } catch (InstantiationException e) { - // TODO: other error handling? - JSFCommonPlugin.log(e, "Error in createTranslatorInstances"); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - // TODO: other error handling? - JSFCommonPlugin.log(e, "Error in createTranslatorInstances"); //$NON-NLS-1$ - } - } - return translators; - } - - } - - /** - * Internal class implementing a descriptor for DomainSourceModelTranslators - */ - static class DomainSourceModelTranslatorDescriptor { - - private String _translator; - private String _bundleId; - - /** - * Constructor - * @param translator - * @param bundleId - */ - public DomainSourceModelTranslatorDescriptor(String translator, String bundleId) { - this._translator = translator; - this._bundleId = bundleId; - } - - String getTranslator(){ - return _translator; - } - - String getBundleId(){ - return _bundleId; - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceTypesRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceTypesRegistry.java deleted file mode 100644 index 000fdef91..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/DomainSourceTypesRegistry.java +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.internal.DomainSourceModelTypeDescriptor.DomainSourceModelTypeImpl; - -/** - * Registry of Domain Source Types loaded from domainSourceModelTypes ext-pt. - */ -public class DomainSourceTypesRegistry{ - private static final String EXTENSION_POINT_ID = "domainSourceModelTypes"; //$NON-NLS-1$ - private static DomainSourceTypesRegistry INSTANCE; - private Map/*<String, List/*<DomainSourceModelTypeDescriptor>>*/ domainSourceTypeDescriptors; - - private DomainSourceTypesRegistry(){ - init(); - } - - /** - * @return singleton instance of DomainSourceTypesRegistry - */ - public synchronized static DomainSourceTypesRegistry getInstance() { - if (INSTANCE == null){ - INSTANCE = new DomainSourceTypesRegistry(); - } - return INSTANCE; - } - - /** - * @param domain identifier - * @return list of <code>IDomainSourceModelType</code> sorted in descending order by ordinal - */ - public List/*<IDomainSourceModelType>*/ getDomainSourceTypes(String domain){ - List/*<DomainSourceModelTypeDescriptor>*/ list = getDomainSourceModelDescriptors(domain); - List/*<IDomainSourceModelType>*/ types = new ArrayList/*<IDomainSourceModelType>*/(); - for(Iterator/*<DomainSourceModelTypeDescriptor>*/ it=list.iterator();it.hasNext();){ - DomainSourceModelTypeDescriptor d = (DomainSourceModelTypeDescriptor)it.next(); - types.add(d.getInstance()); - } - //default sort descending by ordinal - Collections.sort(types, new Comparator(){ - public int compare(Object o1, Object o2) { - DomainSourceModelTypeImpl desc1 = (DomainSourceModelTypeImpl)o1; - DomainSourceModelTypeImpl desc2 = (DomainSourceModelTypeImpl)o2; - if (desc1.getOrdinal() == desc2.getOrdinal()) - return 0; - if (desc1.getOrdinal() > desc2.getOrdinal()) - return -1; - - return 1; - } - - }); - - return types; - } - - private List getDomainSourceModelDescriptors(String domain) { - List ret = (List)getDescriptors().get(domain); - if (ret != null && ret.size()>0) - return ret; - - return getDefaultSourceModelDescriptor(); - } - - private List getDefaultSourceModelDescriptor() { - List ret = new ArrayList(); - DomainSourceModelTypeDescriptor desc = new DomainSourceModelTypeDescriptor(); - ret.add(desc); - return ret; - } - - private synchronized void init() { - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint point = extensionRegistry.getExtensionPoint(JSFCommonPlugin.PLUGIN_ID, EXTENSION_POINT_ID ); - if (point != null) { - IConfigurationElement[] elements = point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement element = elements[i]; - addDomainSourceTypeDescriptor(element); - } - } - } - - private void addDomainSourceTypeDescriptor(IConfigurationElement element) { - String domainId = element.getAttribute("domainId"); //$NON-NLS-1$ - String srcHdlrId = element.getAttribute("domainSourceModelTypeId"); //$NON-NLS-1$ - String locator = element.getAttribute("locator"); //$NON-NLS-1$ - String ordinalStr = element.getAttribute("ordinal"); //$NON-NLS-1$ - int ordinal = 1; - if (ordinalStr!=null && !ordinalStr.equals("")){ //$NON-NLS-1$ - ordinal = Integer.parseInt(ordinalStr); - } - DomainSourceModelTypeDescriptor d = new DomainSourceModelTypeDescriptor(domainId, srcHdlrId, locator, element.getContributor().getName(), ordinal); - List/*<DomainSourceTypeDescriptor>*/ descs = (List)getDescriptors().get(domainId); - if (descs == null){ - descs = new ArrayList/*<DomainSourceTypeDescriptor>*/(); - getDescriptors().put(domainId, descs); - } - descs.add(d); - } - - private Map/*<String, List/*<DomainSourceTypeDescriptor>>*/ getDescriptors() { - if (domainSourceTypeDescriptors == null){ - domainSourceTypeDescriptors = new HashMap/*<String, List/*<DomainSourceTypeDescriptor>>*/(); - } - return domainSourceTypeDescriptors; - } - -// private Map/*<String, List/*<IDomainSourceModelType>>*/ getDomainSourceTypes() { -// if (domainSourceTypes == null){ -// domainSourceTypes = new HashMap/*<String, List/*<IDomainSourceModelType>>*/(); -// } -// return domainSourceTypes; -// } - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IClassLoaderProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IClassLoaderProvider.java deleted file mode 100644 index 6c8169616..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IClassLoaderProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -/** - * Provides class loading by using the plugin's classloader that defined an item of metadata - */ -public interface IClassLoaderProvider { - /** - * @param className - * @return Class - implementers should eat exceptions and return null whenever class cannot be returned - */ - public Class loadClass(String className); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainLoadingStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainLoadingStrategy.java deleted file mode 100644 index ee21e6249..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainLoadingStrategy.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - - -/** - * Defines a strategy to use for loading a standard metadata model for a certain domain. - * see <code>org.eclipse.jst.jsf.common.domainLoadingStrategies</code> ext-pt - */ -public interface IDomainLoadingStrategy { - - /** - * Create a merged "standard" metadata model. - * @param model to load - * - */ - public void load(MetaDataModel model); - - /** - * Reload a merged "standard" metadata model. - * Allows for some optimization for reload. - * @throws ModelNotSetException - * - */ - public void reload() throws ModelNotSetException; - - - /** - * Opportunity to cleanup and should be called when strategy is being destroyed - */ - public void cleanup(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainSourceModelType.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainSourceModelType.java deleted file mode 100644 index 67ed29214..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IDomainSourceModelType.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.Set; - -import org.eclipse.core.resources.IProject; - -/** - * Binds a domain of metadata to a source model type which is defined by a {@link IMetaDataLocator} - * and set of {@link IMetaDataTranslator}s - * Not intended to be implemented by clients. Created from ext-pts. - */ -public interface IDomainSourceModelType { - /** - * @return domain id - */ - public String getDomain(); - /** - * @param project - may be null - * @return instance of IMetaDataLocator - may return null if the locator cannot operate in the current context - */ - public IMetaDataLocator getLocator(IProject project); -// public int getOrdinal(); - /** - * @return set of {@link IMetaDataTranslator}s for the domain source model type - */ - public Set/*<IMetaDataTranslator>*/ getTranslators(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IImageDescriptorProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IImageDescriptorProvider.java deleted file mode 100644 index 9405a6a64..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IImageDescriptorProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * Provides image descriptors relative to the plugin that provided the image metadata - * - */ -public interface IImageDescriptorProvider { - /** - * @param imagePath - * @return ImageDescriptor - implementers should eat exceptions and return null whenever imageDescriptor cannot be returned - */ - public ImageDescriptor getImageDescriptor(String imagePath); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataChangeNotificationEvent.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataChangeNotificationEvent.java deleted file mode 100644 index 29c6ce13f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataChangeNotificationEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -/** - * Experimental and not used at the moment. - * - */ -public interface IMetaDataChangeNotificationEvent { - //change to enums if we do Java5 - /** - * TODO: - */ - public static final int ADDED = 1; - /** - * TODO: - */ - public static final int REMOVED = 2; - /** - * TODO: - */ - public static final int CHANGED = 3; - - /** - * @return the uri - */ - public String getURI(); - /** - * @return when to the event types above - */ - public int getEventType(); - /** - * @return the meta-data locator - */ - public IMetaDataLocator getLocator(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataLocator.java deleted file mode 100644 index ffdbd62ce..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataLocator.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.List; - -/** - * Locates instances of metadata of a specific source model type - */ -public interface IMetaDataLocator { - /** - * @param uri - * @return a list of <code>IMetaDataModelProvider</code>s for the uri located by this instance - */ - public List/*<IMetaDataModelProvider>*/ locateMetaDataModelProviders(String uri); - - /** - * Opportunity for service to start (add listeners, etc.). - * Framework calls this immediately after construction and all setup should occur at this time. - */ - public void startLocating(); - /** - * Stop looking for instances of metadata model sources. An opportunity to cleanup. - */ - public void stopLocating(); - - /** - * @param observer add a {@link IMetaDataObserver} of this locator - */ - public void addObserver(IMetaDataObserver observer); - /** - * @param observer remove a {@link IMetaDataObserver} of this locator - */ - public void removeObserver(IMetaDataObserver observer); - - /** - * @return IDomainSourceModelType instance that created this locator - */ - public IDomainSourceModelType getDomainSourceModelType(); - /** - * @param domainSourceModelType set the domainSourceModelType instance that created this locator - */ - public void setDomainSourceModelType(IDomainSourceModelType domainSourceModelType); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelMergeAssistant.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelMergeAssistant.java deleted file mode 100644 index 0a6a341be..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataModelMergeAssistant.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.Trait; - - -/** - * Helper class interface to merge source models into a single merged model. - * Not intended to be implemented by clients - * - */ -public interface IMetaDataModelMergeAssistant { - /** - * @return merged model - */ - public MetaDataModel getMergedModel(); - /** - * Method that will first check to see if an entity with the same id exists in the merged model. - * If not, it will add it. The entities includeGroups are then also merged. - * @param entity - * @return the merged model entity - * - */ - public Entity addEntity(Entity entity); - /** - * Method will add an entity if not already existing in the merged model, and then check for an existing trait by id on the merged model's entity. - * @param entity - * @param trait - * @return flag indicating whether or not the traits was new and therefore added to the merged model's entity - */ - public boolean addTrait(Entity entity, Trait trait); - - /** - * Method will add an entityGroup to the model if not already exiting in the merged model (by id). - * @param entityGroup - */ - public void addEntityGroup(EntityGroup entityGroup); - /** - * Signal that the merge is complete so that any post-processing may occur. - * This should be the last call made on the merge assistant and should be done before client calls for the merged model result. - * This should signal that entityGroups processing should begin. - */ - public void setMergeComplete(); - - /** - * @param mds - {@link IMetaDataSourceModelProvider} - */ - public void setSourceModelProvider(IMetaDataSourceModelProvider mds); - /** - * @return {@link IMetaDataSourceModelProvider} for current operation - */ - public IMetaDataSourceModelProvider getSourceModelProvider(); - - /** - * @param queryRoot - * @param entityKey - key relative to queryRoot - * @return entity - will return null if not found - */ - public Entity getMergedEntity(Entity queryRoot, String entityKey); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObservable.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObservable.java deleted file mode 100644 index 69152d34d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObservable.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -/** - * Allows {@link IMetaDataObserver}s to observe changes. - * Experimental. - * - */ -public interface IMetaDataObservable { - /** - * Add the observer to the set of observers. Has no effect if - * the same observer is already registered - * - * @param observer - */ - public void addObserver(IMetaDataObserver observer); - - /** - * Remove the observer from the set of observers. Has no effect - * if observer was not already registered. - * - * @param observer must not be null - */ - public void removeObserver(IMetaDataObserver observer); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObserver.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObserver.java deleted file mode 100644 index 5a138a33a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataObserver.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -/** - * Interface for notification when an {@link IMetaDataObservable} changes - * - */ -public interface IMetaDataObserver { - /** - * Callback to observer when an {@link IMetaDataObservable} throws an event - * @param event - */ - public void notifyMetadataChanged(IMetaDataChangeNotificationEvent event); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataSourceModelProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataSourceModelProvider.java deleted file mode 100644 index 6a19c3bb0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataSourceModelProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import org.eclipse.core.runtime.IAdaptable; - - -/** - * Provides a source of metadata that can be transformed into a merged standard model - * LIKELY TO CHANGE - */ -public interface IMetaDataSourceModelProvider extends IAdaptable{ - /** - * @return the source model - */ - public Object getSourceModel(); - /** - * @return the IMetaDataLocator instance that located this model provider instance - */ - public IMetaDataLocator getLocator(); - /** - * @param locator instance that located this model provider instance - */ - public void setLocator(IMetaDataLocator locator); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataTranslator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataTranslator.java deleted file mode 100644 index 2a7f6e2e9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IMetaDataTranslator.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -/** - * Translate from the source model metadata structure into a standard metadata domain of metadata. - * - */ -public interface IMetaDataTranslator { - /** - * @param assistant perform translation using the IMetaDataModelMergeAssistant - */ - public void translate(IMetaDataModelMergeAssistant assistant); - /** - * @param modelProvider - cannot be null - * @return true if this translator can translate this model source - */ - public boolean canTranslate(IMetaDataSourceModelProvider modelProvider); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IPathSensitiveMetaDataLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IPathSensitiveMetaDataLocator.java deleted file mode 100644 index 0f0ed7125..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IPathSensitiveMetaDataLocator.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import org.eclipse.core.resources.IProject; - -/** - * A <code>IMetaDataLocator</code> that is sensitive to the project context - */ -public interface IPathSensitiveMetaDataLocator extends IMetaDataLocator { - /** - * @param project - */ - public void setProjectContext(IProject project); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceBundleProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceBundleProvider.java deleted file mode 100644 index 640da3540..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceBundleProvider.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.ResourceBundle; - -/** - * Provides the resource bundle from the plugin that defined an item of metadata. - */ -public interface IResourceBundleProvider { - /** - * @return ResourceBundle - implementers should eat exceptions and return null whenever resourceBundle cannot be returned - */ - public ResourceBundle getResourceBundle(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceURLProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceURLProvider.java deleted file mode 100644 index f82d0fbe4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceURLProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - */ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.net.URL; - -/** - * Provides absolute URLs from resource path, which is relative to the plug-in - * with the metadata that specified the resource path. - * - * @author Ian Trimble - Oracle - */ -public interface IResourceURLProvider { - - /** - * Get absolute URL for resource path, which is relative to the plug-in that - * specified the resource metadata. - * - * @param resourcePath Path to resource, relative to metadata plug-in. - * @return Absolute URL for resource path. - */ - public URL getResourceURL(String resourcePath); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IStandardMetaDataSourceInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IStandardMetaDataSourceInfo.java deleted file mode 100644 index 02270a31d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IStandardMetaDataSourceInfo.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - - -/** - * Represents the metadata file defined by the StandardMetaDataFile extension-point - * Not intended to be implemented by clients - */ -public interface IStandardMetaDataSourceInfo { - /** - * @return location of metadata file that the locator class will use - */ - public String getLocation(); - /** - * @return bundle id of plugin defining the metadata file - */ - public String getBundleId(); - /** - * @return class name of the locator that will find the the standard metadata file - */ - public String getLocatorClassname(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/JSPTagLibDomainLoadingStrategy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/JSPTagLibDomainLoadingStrategy.java deleted file mode 100644 index 9aeb8b4b0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/JSPTagLibDomainLoadingStrategy.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.List; - - -/** - * Strategy for loading tag metadata. Extends and uses the default {@link DomainLoadingStrategy}. - * Mainly exists for illustrative purposes. Could be removed.. - */ -public class JSPTagLibDomainLoadingStrategy extends DomainLoadingStrategy { - - /** - * Constructor - * @param domain - */ - public JSPTagLibDomainLoadingStrategy(String domain) { - super(domain); - } - - /*@Override*/ - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.DomainLoadingStrategy#sortSourceTypes(java.util.List) - */ - protected void sortSourceTypes(List/*<IDomainSourceType>*/ sourceTypes) { - //an opportunity to override the priority of the source types... - } - - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/Messages.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/Messages.java deleted file mode 100644 index 74fd0a7b2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/Messages.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Gerry Kessler/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.osgi.util.NLS; - -/** - * Externalized strings for Metadata - */ -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.common.metadata.internal.messages"; //$NON-NLS-1$ - - /** - * Property key not found in bundle - */ - public static String Key_not_found; - - /** - * Missing resource - */ - public static String MissingResource_exception; - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - // no external instantiation - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataChangeNotificationEvent.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataChangeNotificationEvent.java deleted file mode 100644 index 8ecc17df6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataChangeNotificationEvent.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -/** - * Experimental. Subject to change. - * - */ -public class MetaDataChangeNotificationEvent implements - IMetaDataChangeNotificationEvent { - - private String _uri; - private IMetaDataLocator _locator; - private int _type; - - /** - * Constructor - * @param locator - * @param uri - * @param type - */ - public MetaDataChangeNotificationEvent(IMetaDataLocator locator, String uri, int type){ - this._locator = locator; - this._uri = uri; - this._type = type; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataChangeNotificationEvent#getEventType() - */ - public int getEventType() { - return _type; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataChangeNotificationEvent#getLocator() - */ - public IMetaDataLocator getLocator() { - return _locator; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataChangeNotificationEvent#getURI() - */ - public String getURI() { - return _uri; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataLocatorFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataLocatorFactory.java deleted file mode 100644 index a590590ec..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataLocatorFactory.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * Creates instances of IMetaDataLocators and caches them so that there is only one instance of a particular locator - * when client requests one. - */ -public class MetaDataLocatorFactory - implements IResourceChangeListener { - - private static MetaDataLocatorFactory INSTANCE = null; - private Map<String, IMetaDataLocator> _locators; - - private static final boolean DEBUG = false; - /** - * @return singleton instance of the MetaDataLocatorFactory - */ - public synchronized static MetaDataLocatorFactory getInstance(){ - if (INSTANCE == null){ - INSTANCE = new MetaDataLocatorFactory(); - ResourcesPlugin.getWorkspace().addResourceChangeListener(INSTANCE, IResourceChangeEvent.PRE_CLOSE); - } - return INSTANCE; - } - - - - private Map<String, IMetaDataLocator> getLocators() { - if (_locators == null){ - _locators = new HashMap<String, IMetaDataLocator>(); - } - return _locators; - } - - /** - * @param locatorClassName - may NOT be null - * @param bundleId - may NOT be null - * @param project - may be null - * @return shared instance of IMetaDataLocator - * may return null if is IPathSensitiveMetaDataLocator and there is no project context - */ - public IMetaDataLocator getLocator(final String locatorClassName, final String bundleId, final IProject project){ - final Class klass = JSFCommonPlugin.loadClass(locatorClassName, bundleId); - String key = getKey(locatorClassName, bundleId); - IMetaDataLocator locator = null; - try { - IMetaDataLocator tempLocator = (IMetaDataLocator)klass.newInstance(); - if (tempLocator != null) { - if (tempLocator instanceof IPathSensitiveMetaDataLocator) { - if (project == null) - return null; - - key = getKey(locatorClassName, project.getName()); - } - - locator = getLocators().get(key); - if (locator == null) { - locator = tempLocator; - if (locator instanceof IPathSensitiveMetaDataLocator) - ((IPathSensitiveMetaDataLocator)locator).setProjectContext(project); - - if (DEBUG) - System.out.println("Created locator: "+locator.toString()); //$NON-NLS-1$ - - getLocators().put(key, locator); - locator.startLocating(); - } - } - } catch (InstantiationException e) { - JSFCommonPlugin.log(IStatus.ERROR, "Could not instantiate IMetaDataLocator: "+key, e); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - JSFCommonPlugin.log(IStatus.ERROR, "IllegalAccessException while creating IMetaDataLocator: "+key, e); //$NON-NLS-1$ - } - - return locator; - } - - /** - * @param locatorClassName - * @param contextId - this may be the bundleID or the projectName if it is a path sensitive locator - * @return key - */ - private String getKey(final String locatorClassName, final String contextId) { - StringBuffer buf = new StringBuffer(contextId); - buf.append(":"); //$NON-NLS-1$ - buf.append(locatorClassName); - return buf.toString(); - } - - /** - * Stops and disposes all locators - */ - public void dispose(){ - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - for (Iterator it=getLocators().values().iterator();it.hasNext();){ - IMetaDataLocator locator = (IMetaDataLocator)it.next(); - locator.stopLocating(); - } - getLocators().clear(); - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org - * .eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(final IResourceChangeEvent event) { - if (event.getType() == IResourceChangeEvent.PRE_CLOSE - || event.getType() == IResourceChangeEvent.PRE_DELETE) { - // a project is closing - release and cleanup - final IProject aProject = (IProject) event.getResource(); - - if (aProject != null) { - List<String> locatorsToRemove = new ArrayList<String>(); - for (Iterator it=getLocators().keySet().iterator();it.hasNext();){ - String key = (String)it.next(); - if (locatorIsForProject(key, aProject.getName())) { - locatorsToRemove.add(key); - } - } - - if (! locatorsToRemove.isEmpty()) { - for (String key : locatorsToRemove) { - IMetaDataLocator locator = getLocators().get(key); - - if (DEBUG) - System.out.println("Removed locator: "+locator.toString()); //$NON-NLS-1$ - - locator.stopLocating(); - getLocators().remove(key); - } - } - } - } - } - - private boolean locatorIsForProject(final String key, final String projectName) { - StringTokenizer t = new StringTokenizer(key, ":"); //$NON-NLS-1$ - String contextId = t.nextToken(); - if (contextId.equals(projectName)) - return true; - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModel.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModel.java deleted file mode 100644 index ef41dbca9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModel.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.metadata.Model; - -/** - * Responsible for loading and holding onto the standard metadata model using the IDomainLoadingStrategy. - * Wraps the model (root) with the strategy used for loading it, along with the identifying key (modelKeyDescriptor) - */ -public class MetaDataModel { - - private Object root; - private ModelKeyDescriptor modelKeyDescriptor; - private IDomainLoadingStrategy strategy; - private boolean refresh; - - /** - * Constructor - * @param key - * @param strategy - */ - public MetaDataModel(ModelKeyDescriptor key, IDomainLoadingStrategy strategy){ - this.modelKeyDescriptor = key; - this.strategy = strategy; - } - - /** - * @return the root of the model. - */ - public Object getRoot(){ - return root; - } - - /** - * @param root - */ - public void setRoot(Object root){ - this.root = root; - if (root != null) - ((Model)root).setCurrentModelContext(modelKeyDescriptor); - } - - /** - * @return ModelKeyDescriptor for this model - */ - public ModelKeyDescriptor getModelKey(){ - return modelKeyDescriptor; - } - -// public void accept(IEntityVisitor visitor){ -// if (getRoot() instanceof Model) -// visitor.visit((Model)getRoot()); -// } - - /** - * @return true if the model is null or is not, in fact, a {@link Model} - */ - public boolean isEmpty() { - if (root == null || !(root instanceof Model)) - return true; - - return false; - } - - /** - * Load the model. Delegates to the strategy. - */ - public synchronized void load(){ - StandardModelFactory.debug("> Begin Loading: "+getModelKey(), StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ - strategy.load(this); - StandardModelFactory.debug("> End Loading: "+getModelKey(),StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ - } - - /** - * Reloads the model delegating to strategy reload - * @throws ModelNotSetException - */ - public void reload()throws ModelNotSetException{ - setRoot(null); - refresh = false; - strategy.reload(); - } - - /** - * @return flag indicating that the model is stale - */ - public boolean needsRefresh() { - return refresh; - } - - /** - * Flag that model is stale - */ - public void setNeedsRefresh() { - refresh = true; - } - - /** - * Cleans up the model releasing references. - */ - public void cleanup(){ - if (strategy != null) - strategy.cleanup(); - strategy = null; - root = null; - modelKeyDescriptor = null; - } - - public String toString() { - StringBuffer buf = new StringBuffer("MetaDataModel: "); //$NON-NLS-1$ - buf.append(getModelKey()); - return buf.toString(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelContextImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelContextImpl.java deleted file mode 100644 index 03a99fadd..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelContextImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import org.eclipse.jst.jsf.common.metadata.query.IMetaDataModelContext; - -/** - * Simple implementation of {@link IMetaDataModelContext} - * - */ -public class MetaDataModelContextImpl implements IMetaDataModelContext, Cloneable { - private final String _domain; - - /** - * Constructor - * @param domain id - */ - public MetaDataModelContextImpl(final String domain){ - _domain = domain; - } - - public String getDomainID() { - return _domain; - } - - public Object getAdapter(final Class adapter) { - if (IMetaDataModelContext.class.equals(adapter)) - return this; - return null; - } - - @Override - protected Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelManager.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelManager.java deleted file mode 100644 index e5297b657..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelManager.java +++ /dev/null @@ -1,314 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.jface.util.SafeRunnable; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; - -/** - * Singleton instance for each IProject used to manage all standard metdata models for that project. - * - * Manager is responsible for loading and caching MetaDataModels. Models are keyed by URI. - * - * The manager listens for project closing resource events so that the resources can be freed up. - */ -public class MetaDataModelManager implements IResourceChangeListener{ - /** - * Key that is used for the IProject instance's session property that - * holds a MetaDataModelManager instance. Each project will have it's own instance of a model manager. - */ - public static final QualifiedName KEY_SESSIONPROPERTY = - new QualifiedName(null, "MetaDataModelManager"); //$NON-NLS-1$ FIX ME - - private static MetaDataModelManager SHARED_INSTANCE; - - // used to lock all instance calls for getModel - private static final Object GLOBAL_INSTANCE_LOCK = new Object(); - private final ModelMap models; - private final IProject project; - - - /** - * @return instance that is project agnostic. * may get removed * - */ - public synchronized static MetaDataModelManager getSharedInstance(){ - if (SHARED_INSTANCE == null) { - SHARED_INSTANCE = new MetaDataModelManager(null); - } - return SHARED_INSTANCE; - } - - /** - * @param project - * @return instance of the model manager for this project. Shouldn't, but may, return null. - */ - public synchronized static MetaDataModelManager getInstance(final IProject project){ - MetaDataModelManager repo = null; - if (project != null && project.isAccessible()) { - repo = getFromSessionProperty(project); - if (repo == null) { - repo = new MetaDataModelManager(project); - ResourcesPlugin.getWorkspace().addResourceChangeListener( - repo, - (IResourceChangeEvent.PRE_CLOSE - | IResourceChangeEvent.PRE_DELETE)); - } - } - return repo; - } - private MetaDataModelManager(final IProject project) { - this.project = project; - models = new ModelMap(); - setAsSessionProperty(); - } - - /** - * @param project - * @return MetaDataModelManager instance for the project - */ - private static MetaDataModelManager getFromSessionProperty(final IProject project) { - MetaDataModelManager repo = null; - try { - Object obj = project.getSessionProperty(KEY_SESSIONPROPERTY); - if (obj instanceof MetaDataModelManager) { - repo = (MetaDataModelManager)obj; - } - } catch(CoreException ce) { - JSFCommonPlugin.log(IStatus.ERROR, "Internal Error: Unable to recover MetaDataModelManager for: "+project.getName(), ce); //$NON-NLS-1$ - } - return repo; - } - - /** - * Sets this MetaDataModelManager instance as a session property of its - * IProject instance. - */ - private void setAsSessionProperty() { - if (project != null && project.isAccessible()) { - try { - project.setSessionProperty(KEY_SESSIONPROPERTY, this); - } catch(CoreException ce) { - JSFCommonPlugin.log(IStatus.ERROR, "Internal Error: Unable to store MetaDataModelManager for: "+project.getName(), ce); //$NON-NLS-1$ } - } - } - } - - /** - * Releases a project's MetaDataModelManager instance by removing from project session property - * @param aProject - */ - private void removeAsSessionProperty(final IProject aProject){ - try { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - aProject.setSessionProperty(KEY_SESSIONPROPERTY, null); - } catch (CoreException e) { - JSFCommonPlugin.log(e, "Error removing session property"); //$NON-NLS-1$ - } - } - - /** - * Will locate the cached MetaDataModel. Sets the model context in the - * model. - * - * @param modelContext - * @return the MetaDataModel for the given ITaglibDomainMetaDataModelContext - */ - public MetaDataModel getModel( - final ITaglibDomainMetaDataModelContext modelContext) { - synchronized (GLOBAL_INSTANCE_LOCK) { - ModelKeyDescriptor modelKeyDescriptor = StandardModelFactory.getInstance().createModelKeyDescriptor(modelContext); - - StandardModelFactory.debug(">START getModel: "+modelKeyDescriptor, StandardModelFactory.DEBUG_MD_GET); //$NON-NLS-1$ - - MetaDataModel model = models.get(modelKeyDescriptor); - if (model == null) { - // long in = System.currentTimeMillis(); - model = loadMetadata(modelKeyDescriptor); - //System.out.println("Time to load "+modelContext.getURI()+": "+ - // String.valueOf(System.currentTimeMillis() - in)); - } else if (model.needsRefresh()) { - try { - model.reload(); - } catch (ModelNotSetException e) { - // simply load it - should not get here - model = loadMetadata(modelKeyDescriptor); - } - } - if (model != null && model.getRoot() != null) - ((Model) model.getRoot()) - .setCurrentModelContext(modelKeyDescriptor); - - StandardModelFactory.debug(">END getModel: "+modelKeyDescriptor, StandardModelFactory.DEBUG_MD_GET); //$NON-NLS-1$ - return model; - } - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org - * .eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(final IResourceChangeEvent event) { - if (event.getType() == IResourceChangeEvent.PRE_CLOSE - || event.getType() == IResourceChangeEvent.PRE_DELETE) { - // a project is closing - release and cleanup - final IProject aProject = (IProject) event.getResource(); - if (aProject != null && aProject.equals(this.project)) { - SafeRunnable.run(new ISafeRunnable() { - - public void handleException(Throwable exception) { - JSFCommonPlugin.log(exception); - } - - public void run() throws Exception { - models.dispose(); - removeAsSessionProperty(project); - } - }); - } - } - } - - private MetaDataModel loadMetadata(final ModelKeyDescriptor modelKeyDescriptor) { - if (!Thread.holdsLock(GLOBAL_INSTANCE_LOCK)) { - JSFCommonPlugin - .log(IStatus.ERROR, - "Internal Error: loadMetadata must not be called if class lock not held"); //$NON-NLS-1$ - return null; - } - - final IDomainLoadingStrategy strategy = DomainLoadingStrategyRegistry - .getInstance().getLoadingStrategy( - modelKeyDescriptor.getDomain()); - ; - if (strategy == null) { - JSFCommonPlugin - .log( - IStatus.ERROR, - "Internal Error: Unable to locate metadata loading strategy for: " + modelKeyDescriptor.toString()); //$NON-NLS-1$ - return null; - } - final MetaDataModel model = StandardModelFactory.getInstance().createModel( - modelKeyDescriptor, strategy);// new MetaDataModel(modelKey, - // strategy); - model.load(); - addModel(model); - - return model; - } - - private void addModel(final MetaDataModel model) { - if (model != null) - models.put(model); - } - - /** - * Map of models keyed by ModelKeyDescriptor (.toString()) - * - */ - private static class ModelMap - { - private final Map<String, MetaDataModel> map; - private final AtomicBoolean _isDisposed = new AtomicBoolean(false); - - ModelMap() { - map = new HashMap<String, MetaDataModel>(); - } - - /** - * @param model - * adds model to the map using the given key descriptor - */ - public void put(final MetaDataModel model) { - assert !_isDisposed.get(); - final String key = calculateKey(model); - synchronized (this) { - map.put(key, model); - } - } - - /** - * @param modelKeyDescriptor - * @return MetaDataModel for this ModelKeyDescriptor. May return null. - */ - public MetaDataModel get(final ModelKeyDescriptor modelKeyDescriptor) { - assert !_isDisposed.get(); - - final String key = calculateKey(modelKeyDescriptor); - - synchronized (this) - { - return map.get(key); - } - } - -// /** -// * @param model -// * from the map -// */ -// public void remove(final MetaDataModel model) { -// assert !_isDisposed.get(); -// final String key = calculateKey(model); -// synchronized(this) -// { -// map.remove(key); -// } -// } - - public void dispose() { - if (_isDisposed.compareAndSet(false, true)) { - synchronized(this) - { - for (final Iterator<Map.Entry<String, MetaDataModel>> it = map.entrySet().iterator(); it.hasNext();) - { - // System.out.println("kill mmModel: "+model.toString()); - final Map.Entry<String, MetaDataModel> entry = it.next(); - final MetaDataModel model = entry.getValue(); - - if (model != null) - { - model.cleanup(); - } - it.remove(); - } - } - } - } - - private String calculateKey(final MetaDataModel model) - { - return calculateKey(model.getModelKey()); - } - - private String calculateKey(final ModelKeyDescriptor modelKeyDescriptor) - { - return modelKeyDescriptor.toString(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelMergeAssistantImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelMergeAssistantImpl.java deleted file mode 100644 index 0c53521b0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/MetaDataModelMergeAssistantImpl.java +++ /dev/null @@ -1,395 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.Iterator; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.util.EcoreUtil.Copier; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; -import org.eclipse.jst.jsf.common.metadata.query.MetaDataException; -import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper; -import org.eclipse.jst.jsf.common.metadata.query.internal.SearchControl; -import org.eclipse.jst.jsf.common.metadata.query.internal.SimpleEntityQueryVisitorImpl; -import org.eclipse.jst.jsf.common.metadata.query.internal.SimpleResultSet; -import org.eclipse.jst.jsf.common.metadata.query.internal.SimpleTraitQueryVisitorImpl; -import org.eclipse.jst.jsf.common.metadata.query.internal.HierarchicalSearchControl; -/** - * Implements {@link IMetaDataModelMergeAssistant} - * - * Responsible for merging source models into one. The first model in has subsequent - * entities and traits added to it. - * - * TODO - make locating of existing entities and traits in the merged model more efficient - * TODO - refactor out Taglibdomain-only aspects of include-group processing - * - */ -public class MetaDataModelMergeAssistantImpl implements - IMetaDataModelMergeAssistant { - - private MetaDataModel mergedModel; - private SimpleEntityQueryVisitorImpl entityVisitor; - private SimpleTraitQueryVisitorImpl traitVisitor; - private IMetaDataSourceModelProvider provider; - - /** - * Constructor. Queries with search control limited to first found. - * @param model - */ - public MetaDataModelMergeAssistantImpl(final MetaDataModel model) { - this.mergedModel = model; - entityVisitor = new SimpleEntityQueryVisitorImpl(new HierarchicalSearchControl(1, - HierarchicalSearchControl.SCOPE_ALL_LEVELS)); - traitVisitor = new SimpleTraitQueryVisitorImpl(new SearchControl(1)); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#getMergedModel() - */ - public MetaDataModel getMergedModel() { - return mergedModel; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#getSourceModel() - */ - public IMetaDataSourceModelProvider getSourceModelProvider() { - return provider; - } - - public void setSourceModelProvider(final IMetaDataSourceModelProvider provider) { - this.provider = provider; - } - - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#addEntityGroup(org.eclipse.jst.jsf.common.metadata.EntityGroup) - */ - public void addEntityGroup(final EntityGroup entityGroup) { - final Model model = (Model)getMergedModel().getRoot(); - if (!isExistingEntityGroup(model, entityGroup)){ - model.getEntityGroups().add(entityGroup); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#addEntity(org.eclipse.jst.jsf.common.metadata.Entity) - */ - public Entity addEntity(final Entity entity) { - Entity mmEntity = getMergedEntity(entity); - if (mmEntity == null){ - mmEntity = addEntityAsNecessary((Entity)entity.eContainer(), entity); - return mmEntity; - } - addIncludeGroupsAsNecessary(mmEntity, entity); - return mmEntity; - } - - public Entity getMergedEntity(final Entity queryRoot, final String entityKey){ - Entity ret = null; - SimpleResultSet rs = (SimpleResultSet)entityVisitor.findEntities(queryRoot, entityKey); - try { - if (! rs.getResults().isEmpty()) - ret = (Entity)rs.getResults().get(0); - rs.close(); - } catch (MetaDataException e) { - JSFCommonPlugin.log(IStatus.ERROR, "Error in getMergedEntity()", e); //$NON-NLS-1$ - } - return ret; - } - private void addIncludeGroupsAsNecessary(final Entity mmEntity, final Entity entity) { - for (final Iterator it=entity.getIncludeGroups().iterator();it.hasNext();){ - final IncludeEntityGroup grp = (IncludeEntityGroup)it.next(); - boolean found = false; - for (Iterator it2=mmEntity.getIncludeGroups().iterator();it2.hasNext();){ - final IncludeEntityGroup grp2 = (IncludeEntityGroup)it2.next(); - if (grp2.equals(grp)){ - found = true; - break; - } - } - if (!found){//maybe we should clone and add - mmEntity.getIncludeGroups().add(grp); - } - } - } - - /** - * Checks to see if the entity (by id) is present in the mergedModel or not. - * If not, it will perform a copy of the entity and it's attributes using - * EcoreUtil.Copier. - * - * @param parent - * @param entity - * @return - */ - private Entity addEntityAsNecessary(final Entity parent, final Entity entity) { - Entity mmParent = null; - Entity mmEntity = null; - if (parent != null){ - mmParent = getMergedEntity(parent); - if (mmParent == null){ - mmParent = addEntityAsNecessary((Entity)entity.eContainer(), entity); - } - } - if (mmParent != null){ - mmEntity = addEntityInternal(mmParent, entity); - return mmEntity; - } - return mmEntity; - } - - private boolean isExistingEntityGroup(final Model model, final EntityGroup entityGroup) { - boolean found = false; - for(final Iterator it=model.getEntityGroups().iterator();it.hasNext();){ - if (entityGroup.getId().equals(((EntityGroup)it.next()).getId())) - return true; - } - return found; - } - - private Entity getExistingChildEntity(final Entity parent, final Entity entity) { - for(final Iterator it=parent.getChildEntities().iterator();it.hasNext();){ - final Entity foundEntity = (Entity)it.next(); - if (entity.getId().equals(foundEntity.getId())) - return foundEntity; - } - return null; - } - - private /*synchronized*/ Entity addEntityInternal(final Entity parent, final Entity entity) { - final Copier copier = new Copier(); - final Entity mmEntity =(Entity)copier.copy(entity); - copier.copyReferences(); - parent.getChildEntities().add(mmEntity); - return mmEntity; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#addTrait(org.eclipse.jst.jsf.common.metadata.Entity, org.eclipse.jst.jsf.common.metadata.Trait) - */ - public boolean addTrait(final Entity entity, final Trait trait) { - final Entity returnedEntity = getMergedEntity(entity); - if (returnedEntity != null){ - return addTraitAsNecessary(returnedEntity, trait); - } - return false; - } - - - private boolean addTraitAsNecessary(Entity mergedEntity, Trait trait) { - final Trait mmTrait = getMergedTrait(mergedEntity, trait); - if (mmTrait == null){ - addTraitInternal(mergedEntity, trait); - return true; - - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataModelMergeAssistant#setMergeComplete() - */ - public void setMergeComplete() { - final Model model = (Model)getMergedModel().getRoot(); - if (model != null){ - StandardModelFactory.debug(">> Begin processIncludeGroups for: "+getMergedModel().getModelKey(),StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ - - processIncludeGroups(model); - - StandardModelFactory.debug(">> End processIncludeGroups for: "+getMergedModel().getModelKey(),StandardModelFactory.DEBUG_MD_LOAD); //$NON-NLS-1$ - } - } - - /** - * Copies the passed trait and adds it to the merged entity. - * The source model provider of the trait is then set on the trait so that - * the trait can know where it came from. - * - * @param parent - * @param trait - * @return merged Trait - */ - private Trait addTraitInternal(final Entity parent, final Trait trait) { - final Copier copier = new Copier(); - final Trait mmTrait =(Trait)copier.copy(trait); - copier.copyReferences(); - parent.getTraits().add(mmTrait); - //set the model key to know from where the trait came - mmTrait.setSourceModelProvider(trait.getSourceModelProvider()); - return mmTrait; - } - - /** - * Locates the entity in the merged model matching by id only. - * If not located, this method returns null; - * - * @param entity - * @return merged entity - */ - private Entity getMergedEntity(final Entity entity){ - if (entity instanceof Model) - return (Entity)mergedModel.getRoot(); - - Entity ret = null; - final String entityKey = getIdRelativeToRoot(entity); - final SimpleResultSet rs = (SimpleResultSet)entityVisitor.findEntities((Entity)mergedModel.getRoot(), entityKey); - try { - if (! rs.getResults().isEmpty()) - ret = (Entity)rs.getResults().get(0); - rs.close(); - } catch (MetaDataException e) { - JSFCommonPlugin.log(IStatus.ERROR, "Error in getMergedEntity()", e); //$NON-NLS-1$ - } - return ret; - } - - private String getIdRelativeToRoot(final Entity entity) { - Entity e = entity; - final StringBuffer buf = new StringBuffer(); - while (e.eContainer() != null){ - buf.insert(0, e.getId()); - if (e.eContainer()!=null && e.eContainer().eContainer() != null) - buf.insert(0,"/"); //$NON-NLS-1$ - e = (Entity)e.eContainer(); - } - return buf.toString(); - } - - /** - * Locates the trait in the merged model matching by id only. - * If not located, this method returns null; - * - * @param entity - * @param trait - * @return merged Trait - */ - public Trait getMergedTrait(final Entity entity, final Trait trait){ - final SimpleResultSet rs = (SimpleResultSet)traitVisitor.findTraits(entity, trait.getId()); - Trait ret = null; - try { - if (! rs.getResults().isEmpty()) - ret = (Trait)rs.getResults().get(0); - rs.close(); - } catch (MetaDataException e) { - JSFCommonPlugin.log(IStatus.ERROR, "Error in getMergedTrait()", e); //$NON-NLS-1$ - } - return ret; - } - - private void processIncludeGroups(final Model root) { - addEntityGroupReferencesRecursively(root); - } - - private void addEntityGroupReferencesRecursively(final Entity entity) { - doIncludes(entity); - for (int i=0, size=entity.getChildEntities().size();i<size;i++){ - addEntityGroupReferencesRecursively((Entity)entity.getChildEntities().get(i)); - } - } - - private void doIncludes(final Entity entity){ - for (int j=0, groupsSize=entity.getIncludeGroups().size();j<groupsSize; j++){ - final IncludeEntityGroup include = (IncludeEntityGroup)entity.getIncludeGroups().get(j); - if (include.getId() != null){ - //is this a local merge? - if (include.getModelUri() == null|| - (include.getModelUri() - .equals(getMergedModel() - .getModelKey().getUri())) ){ - final EntityGroup eg = ((Model)getMergedModel().getRoot()).findIncludeGroup(include.getId()); - addIncludeRefs(entity, eg); - } else //external model include - addIncludeRefs(entity, include); - } - } - } - /* - * Adds traits and child entities from an external entity group to the passed entity - * @param entity - * @param include - */ - private void addIncludeRefs(final Entity entity, final IncludeEntityGroup include) { - final ITaglibDomainMetaDataModelContext modelContext = new TaglibDomainMetaDataModelContextImpl( - getMergedModel().getModelKey().getDomain(), - getMergedModel().getModelKey().getProject(), - include.getModelUri() - ); - - final Model externalModel = TaglibDomainMetaDataQueryHelper.getModel(modelContext); - if (externalModel != null){ - final EntityGroup entityGroup = externalModel.findIncludeGroup(include.getId()); - addIncludeRefs(entity, entityGroup); - } - else { - JSFCommonPlugin.log(IStatus.ERROR, "Unable to load external metadata model refs for "+modelContext.getURI() //$NON-NLS-1$ - + " into "+ entity.getModel().getCurrentModelContext().getUri()); //$NON-NLS-1$ - } - } - - /* - * Adds traits and child entities from a local entity group to the passed entity if not already present for the entity. - * First - * @param entity - * @param entityGroup - */ - private void addIncludeRefs(final Entity entity, final EntityGroup entityGroup) { - if (entityGroup == null) - return; - - for (int i=0, size=entityGroup.getTraits().size();i<size;i++){ - addTrait(entity, (Trait)entityGroup.getTraits().get(i)); - } - - for (int i=0, size=entityGroup.getChildEntities().size();i<size;i++){ - traverseAndAddIncludes(entity, (Entity)entityGroup.getChildEntities().get(i)); - } - } - - private void traverseAndAddIncludes(final Entity parent, final Entity entity){ - final Entity mergedEntity = addIncludedEntityAsNecessary(parent, entity); - - for (final Iterator/*<Trait>*/ it=entity.getTraits().iterator();it.hasNext();){ - final Trait trait = (Trait)it.next(); - addTraitAsNecessary(mergedEntity, trait); - } - - for (final Iterator/*<EntityKey>*/ it=entity.getChildEntities().iterator();it.hasNext();){ - final Entity e = (Entity)it.next(); - traverseAndAddIncludes(mergedEntity, e);//add as normal - } - - } - - /* - * Checks to see if the entity (by id) is present as a child entity in the parent or not. - * If not, it will add the entity to the childEntities without copying. - * - * @param parent - * @param entity - * @return Entity - */ - private Entity addIncludedEntityAsNecessary(final Entity parent, final Entity entity) { - Entity mergedEntity = getExistingChildEntity(parent, entity); - if (mergedEntity == null){ - mergedEntity = addEntityInternal(parent, entity); - } - return mergedEntity; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelKeyDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelKeyDescriptor.java deleted file mode 100644 index 380d21844..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelKeyDescriptor.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import org.eclipse.core.resources.IProject; - -/** - * Meta data model key descriptor used to lazily load a model when it is required - * - */ -public class ModelKeyDescriptor { - private final IProject project; - private final String domain; - private final String uri; - private final String key; - - /** - * Constructor - * @param project - * @param domain - * @param uri - */ - public ModelKeyDescriptor(final IProject project, final String domain, final String uri){ - this.project = project; - this.domain = domain; - this.uri = fixJSPURIIfNecessary(uri); - final String proj = project != null ? project.getName() : "Null"; //$NON-NLS-1$ - final StringBuffer buf = new StringBuffer(proj); - buf.append(":"); //$NON-NLS-1$ - buf.append(this.domain); - buf.append(":"); //$NON-NLS-1$ - buf.append(this.uri); - key = buf.toString(); - } - - //this is a workaround for issue where jsp "uri" may upper or lower cased - private String fixJSPURIIfNecessary(final String tempuri) { - if (tempuri != null && tempuri.equals("jsp11")) //$NON-NLS-1$ - return tempuri.toUpperCase(); - return tempuri; - } - - /** - * @return domain id - */ - public final String getDomain(){ - return domain; - } - - /** - * @return model uri - */ - public final String getUri(){ - return uri; - } - - /** - * @return project - */ - public final IProject getProject(){ - return project; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public final String toString(){ - return key; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelNotSetException.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelNotSetException.java deleted file mode 100644 index 34b90b125..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ModelNotSetException.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -/** - * Experimental - * - */ -public class ModelNotSetException extends Exception { - private static final long serialVersionUID = 1L; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/PluginRelativeStandardMetaDataSourceFileLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/PluginRelativeStandardMetaDataSourceFileLocator.java deleted file mode 100644 index db7ed2a06..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/PluginRelativeStandardMetaDataSourceFileLocator.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.osgi.framework.Bundle; - -/** - * Default implementation of StandardMetaDataSourceFileLocator that will locate standard metadata files - * and resource bundles relative to the plugin that registered the files using the - * <code>org.eclipse.jst.jsf.common.StandardMetaDataFiles</code> ext-pt. - * - */ -public class PluginRelativeStandardMetaDataSourceFileLocator extends StandardMetaDataSourceFileLocator{ - - private ResourceBundle resourceBundle; - - /* - * Returns InputStream of standard metadata file from plugin relative location. - * - */ - public InputStream getInputStream() throws IOException { - URL url = getURL(); - if (url != null) - return url.openStream(); - - String fileName = Path.fromOSString(fileInfo.getLocation()).toString() + " (Plugin: " + fileInfo.getBundleId()+")" ; //$NON-NLS-1$ //$NON-NLS-2$ - throw new FileNotFoundException("Metadata file not found: "+ fileName); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.StandardMetaDataSourceFileLocator#getURL() - */ - public URL getURL() { - final Bundle bundle = Platform.getBundle(fileInfo.getBundleId()); - if (bundle == null) - { - return null; - } - final IPath fromOSString = Path.fromOSString(fileInfo.getLocation()); - return FileLocator.find(bundle, fromOSString, null); - } - - - /* - * Returns property resource bundle if it exists. May return null. - * This implementation assumes that the basename of the bundle is the same - * as the source file name and in the same directory. - * - */ - public ResourceBundle getResourceBundle() throws IOException, MalformedURLException { - if (resourceBundle == null){ - URL bundleURL = getStandardMetaDataSourceFileBasenameURL(); - if (bundleURL == null) - return null; - - resourceBundle = ResourceBundleHelper.getResourceBundle(bundleURL); - } - return resourceBundle; - } - - private URL getStandardMetaDataSourceFileBasenameURL() { - IPath annotationPath = Path.fromOSString(fileInfo.getLocation()); - IPath annotationFolder = annotationPath.removeLastSegments(1); - IPath propertiesLocation = annotationPath.removeFirstSegments(annotationPath.segmentCount() - 1).removeFileExtension(); - // append location of properties file - IPath propertiesFile = annotationFolder.append(propertiesLocation); - - // append .properties extension if needed - if (propertiesFile.getFileExtension() == null) - propertiesFile = propertiesFile.addFileExtension("properties"); //$NON-NLS-1$ - // create a URL out of the properties file location - return FileLocator.find(Platform.getBundle(fileInfo.getBundleId()), - propertiesFile, null); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ResourceBundleHelper.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ResourceBundleHelper.java deleted file mode 100644 index fc55894db..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ResourceBundleHelper.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * Gerry Kessler/Oracle - copied from org.eclipse.wst.sse.core.internal.encoding.util and modified heavily - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Locale; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; - -/** - * ResourceBundleHelper - * - */ -public final class ResourceBundleHelper { - - /** - * @param resourceURL - * @return ResourceBundle - * @throws MalformedURLException - may return null - * @throws IOException - */ - public static ResourceBundle getResourceBundle(final URL resourceURL) throws MalformedURLException, IOException { - return getResourceBundle(resourceURL, Locale.getDefault()); - } - - /** - * @param resourceURL - * @param targetLocale - * @return ResourceBundle - may return null - * @throws MalformedURLException - * @throws IOException - */ - public static ResourceBundle getResourceBundle(final URL resourceURL, final Locale targetLocale) throws MalformedURLException, IOException { - // try to load bundle from the location specified in the resourceURL - // - final String protocol = resourceURL.getProtocol(); - final String host = resourceURL.getHost(); - final String file = resourceURL.getFile(); - final IPath path = new Path(file); - - String dir = "./"; //$NON-NLS-1$ - final String bundleName = path.removeFileExtension().segment(path.segmentCount() - 1); - if (path.segmentCount() > 1) - { - dir = path.removeLastSegments(1).toString(); - } - - // create a class loader with a class path that points to the resource - // bundle's location - // - final URL[] classpath = new URL[1]; - classpath[0] = FileLocator.resolve(new URL(protocol, host, dir)); - // TODO: does this need to be in a doPrivileged block? - final ClassLoader resourceLoader = new URLClassLoader(classpath, null); - - return ResourceBundle.getBundle(bundleName, targetLocale, resourceLoader); - } - - private ResourceBundleHelper() - { - // no instantiation - } -} - diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileInfo.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileInfo.java deleted file mode 100644 index 25cc1c208..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileInfo.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -/** - * Contains information about annotation files. - */ -public final class StandardMetaDataFileInfo implements IStandardMetaDataSourceInfo{ - - private final String fileLocation; - private final String fileLocatorClassname; - private final String bundleId; - - /** - * Constructor - * @param fileLocation - * @param bundleId - * @param fileLocatorClassname - */ - public StandardMetaDataFileInfo( String fileLocation, String bundleId, String fileLocatorClassname) { - this.fileLocation = fileLocation.trim(); - this.bundleId = bundleId.trim(); - this.fileLocatorClassname = fileLocatorClassname; - } - - /** - * Get the location of the annotation file as originally specified. - * - * @return String - */ - public String getLocation() { - return fileLocation; - } - - /** - * Get the annotation file locator classname that must implement ICMAnnotationSourceFileLocator. - * Can return null or empty string. Caller should provide default. - * - * @return String - */ - public String getLocatorClassname() { - return fileLocatorClassname != null ? fileLocatorClassname.trim() : null; - } - - /** - * Get the bundle id of the plugin where the annotation file is located. - * - * @return String - */ - public String getBundleId() { - return bundleId; - } - - public String toString(){ - StringBuffer buf = new StringBuffer("StandardMetaDataFileInfo"); //$NON-NLS-1$ - buf.append(": "); //$NON-NLS-1$ - buf.append(bundleId); - buf.append("/"); //$NON-NLS-1$ - buf.append(fileLocation); - if (getLocatorClassname() != null){ - buf.append(": "); //$NON-NLS-1$ - buf.append(getLocatorClassname()); - } - return buf.toString(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistry.java deleted file mode 100644 index 11d87e9c6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistry.java +++ /dev/null @@ -1,311 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2006, 2007 IBM Corporation and others. - * 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: - * IBM - Initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * Gerry Kessler/Oracle - code borrowed and repurposed for JSF subproject - * - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper; - - -/** - * Registry of standard metadata files - */ -public final class StandardMetaDataFileRegistry { - private Map/*<String, List<IMetaDataSourceModelProvider>>*/ mdFilesMap = new HashMap/*<String, List<IMetaDataSourceModelProvider>>*/(1); - private List/*<IMetaDataSourceModelProvider>*/ EMPTY_LIST = new ArrayList/*<IMetaDataSourceModelProvider>*/(0); - - private static StandardMetaDataFileRegistry reg; - - /** - * @return the singleton instance of the registry - */ - public static StandardMetaDataFileRegistry getInstance() { - if (reg == null){ - reg = new StandardMetaDataFileRegistry(); - } - return reg; - } - - private StandardMetaDataFileRegistry() { - new StandardMetaDataFileRegistryReader(this).readRegistry(); - } - - /** - * @param uri as String - * @return list of standard metadata sources as <code>IMetaDataSourceModelProvider</code>s. - * Returns empty list of no standard metadata files are registered for the given uri. - */ - public synchronized List/*<IMetaDataSourceModelProvider>*/ getStandardMetaDataModelProviders(String uri) { - List/*<IMetaDataSourceModelProvider>*/ theList = (List)mdFilesMap.get(uri); - return theList != null ? theList : EMPTY_LIST ; - } - - /** - * For use by registry reader only - * @param uri - * @param fileInfo - */ - public synchronized void addStandardMetaDataFileInfo(String uri, IStandardMetaDataSourceInfo fileInfo) { - List/*<IMetaDataSourceModelProvider>*/ providers = (List) mdFilesMap.get(uri); - if (providers == null) { - providers = new ArrayList/*<IStandardMetaDataSourceInfo>*/(); - mdFilesMap.put(uri, providers); - } - providers.add(new StandardMetaDataFilesProvider(fileInfo)); - } - -/** - * Internal implementation of IMetaDataSourceModelProvider for "standard" metadata sources - * - */ -static class StandardMetaDataFilesProvider implements IMetaDataSourceModelProvider { - - private org.eclipse.jst.jsf.common.metadata.internal.IStandardMetaDataSourceInfo info; - private Object model; - private IMetaDataLocator locator; - private StandardMetaDataSourceFileLocator fileLocator = null; - - /** - * Constructor - * @param info - */ - StandardMetaDataFilesProvider(IStandardMetaDataSourceInfo info){ - this.info = info; - } - - private StandardMetaDataSourceFileLocator getFileLocator(){ - if (fileLocator == null){ - if (info.getLocatorClassname() == null){ - fileLocator = new PluginRelativeStandardMetaDataSourceFileLocator(); - } - else { - Class klass = JSFCommonPlugin.loadClass(info.getLocatorClassname(), info.getBundleId()); - try { - fileLocator = (StandardMetaDataSourceFileLocator)klass.newInstance(); - } catch (InstantiationException e) { - JSFCommonPlugin.log(IStatus.ERROR, "InstantiationException: StandardMetaDataFilesProvider.getFileLocator()", e); //$NON-NLS-1$ - } catch (IllegalAccessException e) { - JSFCommonPlugin.log(IStatus.ERROR, "IllegalAccessException: StandardMetaDataFilesProvider.getFileLocator()", e); //$NON-NLS-1$ - } - } - if (fileLocator != null) - fileLocator.setFileInfo(info); - } - return fileLocator; - } - - private InputStream getInputStream() throws IOException { - if (getFileLocator() != null){ - return getFileLocator().getInputStream(); - } - return null; - - } - - private URI getMDFileURI() - { - try - { - StandardMetaDataSourceFileLocator fileLocator2 = getFileLocator(); - if (fileLocator2 != null) - { - final URL url = fileLocator2.getURL(); - if (url == null) - { - JSFCommonPlugin.log(new RuntimeException(), - "Couldn't locate meta-data file for " //$NON-NLS-1$ - + fileLocator2.getFileInfo() - .getLocation()); - return null; - } - - java.net.URI uri = url.toURI(); - return URI.createURI(uri.toString()); - } - } - catch (URISyntaxException e) - { - JSFCommonPlugin.log(IStatus.ERROR, "Metadata File Load Error: " //$NON-NLS-1$ - + getFileLocator().getFileInfo().toString() - + ": URISyntaxException: " + e.getMessage()); //$NON-NLS-1$ - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider#getSourceModel() - */ - public Object getSourceModel() { - if (model != null) - return model; - - InputStream inputStream = null; - try { - URI uri = getMDFileURI(); - inputStream = getInputStream(); - if (inputStream != null && uri != null){ - EList contents = StandardModelFactory.getInstance().loadStandardFileResource(inputStream, this, uri); - //check to see if this is a Model - if (contents != null && !contents.isEmpty() && - contents.get(0) instanceof Model){ - model = contents.get(0); - ((Model)model).setSourceModelProvider(this); - } - } - } catch (FileNotFoundException e){ - JSFCommonPlugin.log(IStatus.ERROR, e.getLocalizedMessage()); - } catch (IOException e) { - JSFCommonPlugin.log(IStatus.ERROR,"IOException(1): StandardMetaDataFilesProvider.getSourceModel():"+getModelName(), e); //$NON-NLS-1$ - } finally { - if (inputStream != null){ - try { - inputStream.close(); - } catch (IOException e) { - JSFCommonPlugin.log( IStatus.ERROR,"IOException (2): StandardMetaDataFilesProvider.getSourceModel():"+getModelName(), e); //$NON-NLS-1$ - } - } - } - return model; - } - - private String getModelName() { - return info.toString(); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider#getLocator() - */ - public IMetaDataLocator getLocator() { - return locator; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider#setLocator(org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator) - */ - public void setLocator(IMetaDataLocator locator) { - this.locator = locator; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider#getResourceBundle() - */ - private ResourceBundle internalGetResourceBundle() { - if (getFileLocator() != null){ - try { - return fileLocator.getResourceBundle(); - } catch (MissingResourceException e) { - JSFCommonPlugin.log(IStatus.ERROR, "InternalGetResourceBundle1", e); //$NON-NLS-1$ - } catch (IOException e) { - JSFCommonPlugin.log(IStatus.ERROR, "InternalGetResourceBundle2", e); //$NON-NLS-1$ - } - } - return null; - } - - public Object getAdapter(Class klass) { - final StandardMetaDataFilesProvider mdp = this; - if (klass == IImageDescriptorProvider.class){ - return new IImageDescriptorProvider(){ - String imageBase; - public ImageDescriptor getImageDescriptor(String imagePath) { - imagePath = appendImageBase(imagePath); - String bundleID = mdp.getFileLocator().getFileInfo().getBundleId(); - URL url = FileLocator.find(Platform.getBundle(bundleID), new Path(imagePath), null); - return ImageDescriptor.createFromURL(url); - } - private String appendImageBase(String imagePath) { - return getImageBase() + imagePath; - } - - private String getImageBase(){ - if (imageBase == null){ - Model aModel = (Model)getSourceModel(); - Trait t = TaglibDomainMetaDataQueryHelper.getTrait(aModel, "images-base-path"); //$NON-NLS-1$ - if (t == null){ - imageBase = ""; //$NON-NLS-1$ - } else { - imageBase = TraitValueHelper.getValueAsString(t); - if (imageBase != null && imageBase.length() > 0){ - imageBase = imageBase +"/"; //$NON-NLS-1$ - } - } - } - return imageBase; - } - - }; - - } else if (klass == IResourceBundleProvider.class) { - return new IResourceBundleProvider(){ - - public ResourceBundle getResourceBundle() { - return mdp.internalGetResourceBundle(); - } - - }; - - } else if (klass == IClassLoaderProvider.class){ - return new IClassLoaderProvider(){ - - public Class loadClass(String className) { - String bundleID = mdp.getFileLocator().getFileInfo().getBundleId(); - try { - return Platform.getBundle(bundleID).loadClass(className); - } catch (ClassNotFoundException e) { - return null; - } - } - - }; - } else if (klass == IResourceURLProvider.class) { - return new IResourceURLProvider() { - - public URL getResourceURL(String resourcePath) { - URL resourceURL = null; - String bundleID = mdp.getFileLocator().getFileInfo().getBundleId(); - try { - resourceURL = FileLocator.resolve(Platform.getBundle(bundleID).getResource(resourcePath)); - } catch (IOException ioe) { - //do nothing, will return null resourceURL - } - return resourceURL; - } - - }; - } - return null; - } - -} -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistryReader.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistryReader.java deleted file mode 100644 index 802481b3c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistryReader.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2006, 2007 IBM Corporation and others. - * 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: - * IBM - Initial API and implementation - * Jens Lukowski/Innoopract - initial renaming/restructuring - * Gerry Kessler/Oracle - code borrowed and repurposed for JSF subproject - * - *******************************************************************************/ -package org.eclipse.jst.jsf.common.metadata.internal; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - - -/** - * This class reads the standardMetaDataFiles extensions adds each specified standard metadata - * file to the StandardMetaDataFileRegistry. - * - * @see StandardMetaDataFileRegistry - * also see StandardMetaDataFile extension-point - */ -public class StandardMetaDataFileRegistryReader { - /** - * EXTENSION POINT ID - */ - protected static final String EXTENSION_POINT_ID = "standardMetaDataFiles"; //$NON-NLS-1$ - /** - * IConfigurationElement element name - */ - protected static final String TAG_NAME = "StandardMetaDataFile"; //$NON-NLS-1$ - /** - * Uri attribute name for IConfigurationElement - */ - protected static final String ATT_URI = "uri"; //$NON-NLS-1$ - /** - * Location attribute name for IConfigurationElement - */ - protected static final String ATT_LOCATION = "location"; //$NON-NLS-1$ - /** - * Locator attribute name for IConfigurationElement - */ - protected static final String ATT_LOCATOR = "locator"; //$NON-NLS-1$ - - private StandardMetaDataFileRegistry annotationFileRegistry; - - /** - * Constructor - * @param registry - */ - public StandardMetaDataFileRegistryReader(StandardMetaDataFileRegistry registry) { - this.annotationFileRegistry = registry; - } - - /** - * read the registery - */ - public void readRegistry() { - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - IExtensionPoint point = extensionRegistry.getExtensionPoint(JSFCommonPlugin.PLUGIN_ID, EXTENSION_POINT_ID); - if (point != null) { - IConfigurationElement[] elements = point.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - readElement(elements[i]); - } - } - } - - private void readElement(IConfigurationElement element) { - if (element.getName().equalsIgnoreCase(TAG_NAME)) { - String uri = element.getAttribute(ATT_URI); - String location = element.getAttribute(ATT_LOCATION); - String locator = element.getAttribute(ATT_LOCATOR); - String bundleId = null; - if (uri != null && location != null) { - try { - bundleId = element.getContributor().getName(); - StandardMetaDataFileInfo fileInfo = new StandardMetaDataFileInfo(location, bundleId, locator); - annotationFileRegistry.addStandardMetaDataFileInfo(uri, fileInfo); - } - catch (Exception e) { - JSFCommonPlugin.log(IStatus.ERROR, "Internal Error: exception occurred while reading StandardMetaDataFile ext-pt: "+location + ":"+uri, e); //$NON-NLS-1$ //$NON-NLS-2$ } - } - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFilesTranslator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFilesTranslator.java deleted file mode 100644 index 6695ec5a1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFilesTranslator.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.Iterator; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.util.EcoreUtil.Copier; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.StandardMetaDataFileRegistry.StandardMetaDataFilesProvider; - - -/** - * A 'null' translation of a metadata file. Entities and traits are not transformed. - * - */ -public class StandardMetaDataFilesTranslator implements IMetaDataTranslator { - - public boolean canTranslate(final IMetaDataSourceModelProvider modelProvider) { - if (modelProvider instanceof StandardMetaDataFilesProvider) - return true; - return false; - } - - public void translate(final IMetaDataModelMergeAssistant assistant) {//TODO: throw proper errors - //null translate - sourceModel object are already Entities and traits - //traverse the tree and add to model - - //temp - throw proper errors - //assert assistant.getSourceModel() instanceof ModelKeyDescriptor; - - final MetaDataModel mm = assistant.getMergedModel(); - final Model mk = (Model)assistant.getSourceModelProvider().getSourceModel(); - if (mm.getRoot() == null) { - //create copy, otherwise source model becomes merged model because of reference - final Copier copier = new Copier(); - final Model newModel = (Model)copier.copy(mk.getModel()); - copier.copyReferences(); - mm.setRoot(newModel); - } - else { - //for each entity and trait call "add". assistant will handle merge. - if (mk != null) {//possible that model was not loaded - traverseAndAdd(assistant, mk); - } else if (StandardModelFactory.DEBUG_MD_LOAD) { - JSFCommonPlugin.log(IStatus.ERROR,"Unable to load source model: "+assistant.getSourceModelProvider()); //$NON-NLS-1$ - } - } - } - - /** - * Add entity and any children - * @param assistant - * @param entity - */ - protected void traverseAndAdd(final IMetaDataModelMergeAssistant assistant, final Entity entity){ - final Entity mmEntity = assistant.addEntity(entity); - - if (entity instanceof Model){ - final Model model = (Model)entity; - for (final Iterator/*EntityGroup*/ it=model.getEntityGroups().iterator();it.hasNext();){ - assistant.addEntityGroup((EntityGroup)it.next()); - } - } - - for (final Iterator/*<Trait>*/ it=entity.getTraits().iterator();it.hasNext();){ - final Trait trait = (Trait)it.next(); - assistant.addTrait(mmEntity, trait); - } - - for (final Iterator/*<EntityKey>*/ it=entity.getChildEntities().iterator();it.hasNext();){ - final Entity e = (Entity)it.next(); - traverseAndAdd(assistant, e); - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataLocator.java deleted file mode 100644 index fd3e3ea4a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataLocator.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.List; - - -/** - * Implementation of IMetaDataLocator for standard metadata sources. - * Uses StandardMetaDataFileRegistry to locate instances. - * - */ -public class StandardMetaDataLocator extends AbstractMetaDataLocator { - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataLocator#locateMetaDataModelProviders(java.lang.String) - */ - public List locateMetaDataModelProviders(String uri) { - return StandardMetaDataFileRegistry.getInstance().getStandardMetaDataModelProviders(uri); - } - - /* - * Does nothing. - */ - public void startLocating() { - //do nothing - } - - /* - * Does nothing. - */ - public void stopLocating() { - //do nothing - } - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataSourceFileLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataSourceFileLocator.java deleted file mode 100644 index e65d0dab2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataSourceFileLocator.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - - -/** - * Used to supply an InputStream to the parser of an annotation - * meta-data file and the URL to the resource bundle for a properties file, if any. - * - * Implementors must provide a zero-argument constructor. - * - * CURRENTLY INTERNAL... WILL BE MADE API AT SOME POINT - * - */ -public abstract class StandardMetaDataSourceFileLocator { - /** - * metadata file to locate - */ - protected IStandardMetaDataSourceInfo fileInfo; - - /** - * Set the <code>IStandardMetaDataSourceInfo</code> for this locator - * @param fileInfo - */ - public final void setFileInfo(IStandardMetaDataSourceInfo fileInfo){ - this.fileInfo = fileInfo; - } - - /** - * @return the <code>IStandardMetaDataSourceInfo</code> for this locator - */ - protected final IStandardMetaDataSourceInfo getFileInfo(){ - return fileInfo; - } - /** - * Return InputStream to the meta-data source file. - * Callers are responsible for closing the stream. - * @return InputStream - * @throws IOException - */ - public abstract InputStream getInputStream() throws IOException; - - /** - * Return URL to the meta-data source file. - - * @return URL or null if cannot find a the file for getFileInfo - */ - public abstract URL getURL(); - - /** - * Return ResourceBundle for the property files if there are any. Return null if not. - * - * @return java.util.ResourceBundle - * @throws IOException - * @throws MissingResourceException - */ - public abstract ResourceBundle getResourceBundle() throws IOException, MissingResourceException; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardModelFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardModelFactory.java deleted file mode 100644 index e0574f61e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardModelFactory.java +++ /dev/null @@ -1,293 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.BasicExtendedMetaData; -import org.eclipse.emf.ecore.util.ExtendedMetaData; -import org.eclipse.emf.ecore.xmi.ClassNotFoundException; -import org.eclipse.emf.ecore.xmi.FeatureNotFoundException; -import org.eclipse.emf.ecore.xmi.IllegalValueException; -import org.eclipse.emf.ecore.xmi.PackageNotFoundException; -import org.eclipse.emf.ecore.xmi.UnresolvedReferenceException; -import org.eclipse.emf.ecore.xmi.XMIException; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.internal.util.MetadataResourceImpl; -import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; - -/** - * Singleton that produces and loads standard metadata models. - * All models are loaded into the same ResourceSet. - * <p> - * All metadata extension models must be registered with org.eclipse.emf.ecore.generated_package extension-point. - * No other mechanism is provided for model uri resolution. - * <p> - * Debug tracing for model loading is available: <code>org.eclipse.jst.jsf.common/debug/metadataload=true</code> - * <p> - * When the /debug/metadataload trace flag is set, and in case extension models are known not to be available, - * and metadata is referencing those models, error logging can be suppressed by launching with the following properties set:<br> - * metadata.package.ignores<br> - * metadata.classname.ignores - * <p> - * eg. Usage for when WPE is not present<p> - * <code> - -Dmetadata.package.ignores=http://org.eclipse.jsf.pagedesigner/dtinfo.ecore,<br>http://org.eclipse.jsf.pagedesigner/QuickEditTabSections.ecore<br> - -Dmetadata.classname.ignores=DTInfo,QuickEditTabSections<br> - * </code> - * <p> - * see {@link Model} - */ -public class StandardModelFactory { - private static StandardModelFactory INSTANCE; - static boolean DEBUG_MD_LOAD = false; - static boolean DEBUG_MD_GET = false; - private ExtendedMetaData extendedMetaData; - private ResourceSet resourceSet; - - - /** - * @return singleton instance of the metadata model factory - */ - public synchronized static StandardModelFactory getInstance(){ - if (INSTANCE == null){ - INSTANCE = new StandardModelFactory(); - INSTANCE.init(); - - if (JSFCommonPlugin.getPlugin().isDebugging()){ - DEBUG_MD_LOAD = Boolean.valueOf(Platform.getDebugOption(JSFCommonPlugin.PLUGIN_ID+"/debug/metadataload")).booleanValue();//$NON-NLS-1$ - DEBUG_MD_GET = Boolean.valueOf(Platform.getDebugOption(JSFCommonPlugin.PLUGIN_ID+"/debug/metadataget")).booleanValue();//$NON-NLS-1$ - } - } - return INSTANCE; - } - - private void init() { - resourceSet = new ResourceSetImpl(); - - extendedMetaData = new BasicExtendedMetaData(resourceSet.getPackageRegistry()); - - // Register the appropriate resource factory to handle all file extensions. - // - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put - (Resource.Factory.Registry.DEFAULT_EXTENSION, - new XMLResourceFactoryImpl()); - - //relying on the org.eclipse.emf.ecore.generated_package ext-pt to register traits - } - - private StandardModelFactory() { - super(); - } - - /** - * Factory method that probably belongs somewhere else! - * @param key - * @param strategy - * @return an empty MetaDataModel - */ - public MetaDataModel createModel(ModelKeyDescriptor key, IDomainLoadingStrategy strategy){ - return new MetaDataModel(key, strategy); - } - - /** - * Factory method that probably belongs somewhere else! - * @param modelContext - * @return a ModelKeyDescriptor for the context - */ - public ModelKeyDescriptor createModelKeyDescriptor(final ITaglibDomainMetaDataModelContext modelContext) { - return new ModelKeyDescriptor(modelContext.getProject(), modelContext.getDomainID(), modelContext.getURI()); - } - - /** - * @param inputStream - * @param provider - * @param uri - * @return the root of the standard model from the resource as an EList - * @throws IOException - */ - public EList loadStandardFileResource(final InputStream inputStream, - final IMetaDataSourceModelProvider provider, - final org.eclipse.emf.common.util.URI uri) throws IOException - { - final XMLResource res = new MetadataResourceImpl(provider); - - debug(String.format( - ">>> Loading standard meta-data file for uri %s", uri), DEBUG_MD_LOAD); //$NON-NLS-1$ - - res.setURI(uri); - resourceSet.getResources().add(res); - setLoadOptions(res); - res.load(inputStream, null); - if (DEBUG_MD_LOAD) - { - reportErrors(res); - } - final EList root = res.getContents(); - return root; - } - - private void reportErrors(Resource res) { - EList<Resource.Diagnostic> errs = res.getErrors(); - if (! errs.isEmpty()){ - for (Iterator<Resource.Diagnostic> it= errs.iterator();it.hasNext();){ - StandardModelErrorMessageFactory.logErrorMessage(it.next()); - } - } - } - - /** - * Sets default load options for the resource - * @param resource - */ - protected void setLoadOptions(XMLResource resource) { - Map options = resource.getDefaultLoadOptions(); -// options.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, true); - options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); - options.put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData); - options.put(XMLResource.OPTION_RESOURCE_HANDLER, resource); - options.put(XMLResource.OPTION_LAX_FEATURE_PROCESSING, Boolean.TRUE); - options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.FALSE);//turning this off so that res.getErrors() has values to check! bizarre that I should need to do this. -// options.put(XMLResource.OPTION_DOM_USE_NAMESPACES_IN_SCOPE, Boolean.TRUE); - -// if (DEBUG_MD_LOAD) -// { -// System.out.println("Using load options: "+options); -// } - } - - - static class StandardModelErrorMessageFactory { - private static List<String> _missingPackageURIs; - private static List<String> _missingClassnames; - - /** - * Simply logs all messages against JSFCommonPlugin, for now. - * @param diagnostic - */ - public static void logErrorMessage(Resource.Diagnostic diagnostic) { - //should be XMIException - if (diagnostic instanceof XMIException) { - XMIException ex = (XMIException)diagnostic; - String msg = createMessage(ex); - if (msg != null) - JSFCommonPlugin.log(IStatus.ERROR, msg); - } - else { - JSFCommonPlugin.log(IStatus.ERROR, diagnostic.toString());//do better??? - } - } - - private static String createMessage(XMIException ex) { - - StringBuffer buf = new StringBuffer("Metadata Load Error: ") //$NON-NLS-1$ - .append(ex.getClass().getSimpleName()).append(": "); //$NON-NLS-1$ - - if (ex instanceof PackageNotFoundException) { - if (shouldIgnore(ex)) - return null; - - buf.append(((PackageNotFoundException)ex).uri()); - } - else if (ex instanceof ClassNotFoundException) { - if (shouldIgnore(ex)) - return null; - - buf.append(((ClassNotFoundException)ex).getName()); - } - else if (ex instanceof FeatureNotFoundException) - buf.append(((FeatureNotFoundException)ex).getName()); - else if (ex instanceof IllegalValueException) - buf.append(((IllegalValueException)ex).getValue().toString()); - else if (ex instanceof UnresolvedReferenceException) - buf.append(((UnresolvedReferenceException)ex).getReference()); - else - buf.append(ex.getMessage()); - - buf.append(" in ").append(ex.getLocation()).append(": Line = ") //$NON-NLS-1$ //$NON-NLS-2$ - .append(ex.getLine()).append(": Column = ").append(ex.getColumn()); //$NON-NLS-1$ - return buf.toString(); - } - - private static boolean shouldIgnore(XMIException ex) { - if (ex instanceof PackageNotFoundException) { - String uri = ((PackageNotFoundException)ex).uri(); - return getMissingPackageURIs().contains(uri); - } - else if (ex instanceof ClassNotFoundException) { - String className = ((ClassNotFoundException)ex).getName(); - return getMissingClassnames().contains(className); - } - return false; - } - - private static List<String> getMissingPackageURIs() { - if (_missingPackageURIs == null) { - _missingPackageURIs = buildList("metadata.package.ignores"); //$NON-NLS-1$ - - } - return _missingPackageURIs; - } - - private static List<String> getMissingClassnames() { - if (_missingClassnames == null) { - _missingClassnames = buildList("metadata.classname.ignores"); //$NON-NLS-1$ - } - return _missingClassnames; - } - - private static List<String> buildList(String propertyName) { - List<String> ret = new ArrayList<String>(); - String ignoreSet = System.getProperty(propertyName); - if (ignoreSet == null )//try env - ignoreSet = System.getenv(propertyName); - - if (ignoreSet != null && !(ignoreSet.equals(""))){ //$NON-NLS-1$ - StringTokenizer st = new StringTokenizer(ignoreSet, ","); //$NON-NLS-1$ - while(st.hasMoreTokens()){ - String uri = st.nextToken(); - if (!(uri.equals(""))) //$NON-NLS-1$ - ret.add(uri); - } - } - - return ret; - } - - } - - /** - * Debug output. The parenthesis shows thread id. - * @param msg - * @param debugFlag - */ - public static void debug(String msg, boolean debugFlag) { - if (debugFlag) - System.out.println(msg + "["+Thread.currentThread().getId()+"]"); //$NON-NLS-1$ //$NON-NLS-2$ - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TaglibDomainMetaDataModelContextImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TaglibDomainMetaDataModelContextImpl.java deleted file mode 100644 index 040c5069d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TaglibDomainMetaDataModelContextImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext; - -/** - * Simple implementation of {@link ITaglibDomainMetaDataModelContext} - */ -public class TaglibDomainMetaDataModelContextImpl extends MetaDataModelContextImpl implements ITaglibDomainMetaDataModelContext, Cloneable -{ - private final IProject _project; - private final String _uri; - - /** - * Constructor - * @param project - * @param domain - * @param uri - */ - public TaglibDomainMetaDataModelContextImpl(final String domain, final IProject project, final String uri){ - super(domain); - this._project = project; - this._uri = uri; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext#getProject() - */ - public IProject getProject() { - return _project; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext#getURI() - */ - public String getURI() { - return _uri; - } - - public Object getAdapter(Class adapter) { - if (adapter.equals(ITaglibDomainMetaDataModelContext.class)) - return this; - - return super.getAdapter(adapter); - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper.java deleted file mode 100644 index a0812fe9e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper.java +++ /dev/null @@ -1,213 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.BasicEObjectImpl; -import org.eclipse.emf.ecore.util.FeatureMap; -import org.eclipse.emf.ecore.xml.type.AnyType; -import org.eclipse.emf.ecore.xml.type.SimpleAnyType; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue; -import org.eclipse.osgi.util.NLS; - -/** - * Experimental/prototype class to assist with decoding trait values. - * This could/should be made API at some point after "hardening". (https://bugs.eclipse.org/bugs/show_bug.cgi?id=192052) - */ -public class TraitValueHelper { - private static final String KEY_NOT_FOUND = Messages.Key_not_found; - /** - * @param trait - * @return EClass of trait value - */ - public static EClass getValueType(final Trait trait){ - if (trait == null) - return null; - if (trait.getValue() != null) - return trait.getValue().eClass(); - return null; - } - - /** - * @param trait - * @return value of trait as String Object. - */ - public static Object getValue(final Trait trait){ - if (trait == null) - return null; - - if (trait.getValue() == null) - return null; - - if (trait.getValue() instanceof StringValue) { - return ((StringValue)trait.getValue()).getValue(); - } - else if (trait.getValue() instanceof SimpleAnyType){ - return ((SimpleAnyType)trait.getValue()).getRawValue(); - } - else if (trait.getValue() instanceof AnyType){ - AnyType any = (AnyType)trait.getValue(); - FeatureMap map = any.getMixed(); - return getTextValueFromFeatureMap(map); - } - else if ( trait.getValue().eIsProxy() && trait.getValue() instanceof BasicEObjectImpl){ - BasicEObjectImpl o = (BasicEObjectImpl)trait.getValue(); - return o.eProxyURI().toString(); - } - return trait.getValue(); - } - - private static String getTextValueFromFeatureMap(final FeatureMap map) { - for (final Iterator it=map.iterator();it.hasNext();){ - final FeatureMap.Entry entry = (FeatureMap.Entry)it.next(); - if (entry.getEStructuralFeature().getName().equals("text")) //$NON-NLS-1$ - return (String)entry.getValue(); - } - return null; - } - - /** - * @param trait - * @return value of trait as String. If externalized, will resolve from resource bundle. - */ - public static String getValueAsString(final Trait trait){ - final Object val = getValue(trait); - if (val instanceof String){ - return getNLSValue(trait, (String)val); - } - else if (val instanceof BooleanValue) - return String.valueOf(((BooleanValue)val).isTrue()); - - return null; - } - - /** - * - * @param trait whose value a {@link ListOfValues} or is a single string - * @return List of Strings. If externalized, will resolve from resource bundle - * using getNLSValue(Trait trait, String rawValue) - */ - public synchronized static List getValueAsListOfStrings(final Trait trait){ - //PROTO ONLY!!! Need to make WAY more robust! - final List ret = new ArrayList(); - if (trait.getValue() instanceof ListOfValues) { - for(final Iterator it=trait.getValue().eContents().iterator();it.hasNext();){ - final Object o = it.next(); - if (o instanceof SimpleAnyType){ - final SimpleAnyType sat = (SimpleAnyType)o; - final String rawValue = getTextValueFromFeatureMap(sat.getMixed()); - final String nlsValue = getNLSValue(trait, rawValue); - - ret.add(nlsValue); - } - } - } - else { - //may be single value - String o = getValueAsString(trait); - if (o != null) - ret.add(o); - } - return ret; - } - - /** - * Looks for '%' (and not '%%') at beginning of rawValue. If found, looks to the - * traits sourceModelProvider for resource bundle to resolve the key after - * stripping the '%' sign. - * @param trait - * @param rawValue of string in from metadata - * @return the NLS Value or rawValue if it cannot be located - */ - public static String getNLSValue(final Trait trait, final String rawValue) { - String result = rawValue; - if (rawValue.startsWith("%") && !rawValue.startsWith("%%")){ //$NON-NLS-1$//$NON-NLS-2$ - final String key = rawValue.substring(1); - result = getNLSPropertyValue(trait, key); - if (result == null){ - result = rawValue; - } - } - return result == null ? null : result.trim(); - } - - //will return null if there is an IOException with ResourceBundle - private static String getNLSPropertyValue(final Trait trait, final String key){ - try{ - IMetaDataSourceModelProvider provider = trait.getSourceModelProvider(); - IResourceBundleProvider resourceBundleProvider = (IResourceBundleProvider)provider.getAdapter(IResourceBundleProvider.class); - if (resourceBundleProvider != null){ - ResourceBundle resourceBundle_ = resourceBundleProvider.getResourceBundle(); - if (resourceBundle_ != null){ - String replVal = resourceBundle_.getString(key); - return replVal; - } - } - //return original string - return key; - - } catch (MissingResourceException e){ - //fall thru - JSFCommonPlugin.log(e, NLS.bind(Messages.MissingResource_exception, new String[]{key})); - } - return key + KEY_NOT_FOUND; - } - - /** - * If trait type is {@link BooleanValue} returns value, otherwise - * it will get the value as a String and attempt to coerce to boolean. - * Will return 'false' if coercion fails, or value was null. - * @param trait - * @return true or false - */ - public static boolean getValueAsBoolean(final Trait trait) { - if (trait != null && trait.getValue() instanceof BooleanValue) { - return ((BooleanValue)trait.getValue()).isTrue(); - } - final String val = getValueAsString(trait); - if (val == null) - return false; - - return Boolean.valueOf(val).booleanValue(); - } - -// /** -// * @param trait -// * @return name of class or primitive datatype that the value is defined as. -// * For SimpleAnyTypes, the getInstanceType().getInstanceClassName() is returned. -// * For AnyType, java.lang.String is always returned. -// * For all others, the class.getName() is returned. -// */ -// public static String getValueInstanceClassName(Trait trait) {String.class.getName(); -// if (trait.getValue() instanceof SimpleAnyType) { -// return ((SimpleAnyType)trait.getValue()).getInstanceType().getInstanceClassName(); -// } -// else if (trait.getValue() instanceof AnyType) { -// return String.class.getName(); -// } -// else { -// return trait.getValue().getClass().getName(); -// } -// -// } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityGroupImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityGroupImpl.java deleted file mode 100644 index eb8ef8b2d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityGroupImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: EntityGroupImpl.java,v 1.6 2008/11/18 22:24:39 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Entity Group</b></em>'. - * <!-- end-user-doc --> - * <p> - * </p> - * - * @generated - */ -@SuppressWarnings("hiding") -public class EntityGroupImpl extends EntityImpl implements EntityGroup { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EntityGroupImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return MetadataPackage.Literals.ENTITY_GROUP; - } - -} //EntityGroupImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityImpl.java deleted file mode 100644 index ab8247dab..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/EntityImpl.java +++ /dev/null @@ -1,432 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: EntityImpl.java,v 1.8 2010/01/27 23:54:32 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.EObjectResolvingEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor; -import org.eclipse.jst.jsf.common.metadata.query.internal.IHierarchicalEntityVisitor; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Entity</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl#getChildEntities <em>Child Entities</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl#getTraits <em>Traits</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl#getId <em>Id</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl#getType <em>Type</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.EntityImpl#getIncludeGroups <em>Include Groups</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class EntityImpl extends EObjectImpl implements Entity { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached value of the '{@link #getChildEntities() <em>Child Entities</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getChildEntities() - * @generated - * @ordered - */ - protected EList childEntities = null; - - /** - * The cached value of the '{@link #getTraits() <em>Traits</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getTraits() - * @generated - * @ordered - */ - protected EList traits = null; - - /** - * The default value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected String id = ID_EDEFAULT; - - /** - * The default value of the '{@link #getType() <em>Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getType() - * @generated - * @ordered - */ - protected static final String TYPE_EDEFAULT = null; - - /** - * The cached value of the '{@link #getType() <em>Type</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getType() - * @generated - * @ordered - */ - protected String type = TYPE_EDEFAULT; - - /** - * The cached value of the '{@link #getIncludeGroups() <em>Include Groups</em>}' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getIncludeGroups() - * @generated - * @ordered - */ - protected EList includeGroups = null; - - /** - * The cached value of the Model - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - private Model _model; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EntityImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return MetadataPackage.Literals.ENTITY; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getChildEntities() { - if (childEntities == null) { - childEntities = new EObjectContainmentEList(Entity.class, this, MetadataPackage.ENTITY__CHILD_ENTITIES); - } - return childEntities; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getTraits() { - if (traits == null) { - traits = new EObjectContainmentEList(Trait.class, this, MetadataPackage.ENTITY__TRAITS); - } - return traits; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getIncludeGroups() { - if (includeGroups == null) { - includeGroups = new EObjectResolvingEList(IncludeEntityGroup.class, this, MetadataPackage.ENTITY__INCLUDE_GROUPS); - } - return includeGroups; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getId() { - return id; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setId(String newId) { - String oldId = id; - id = newId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.ENTITY__ID, oldId, id)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getType() { - return type; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setType(String newType) { - String oldType = type; - type = newType; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.ENTITY__TYPE, oldType, type)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - private boolean accept(final IHierarchicalEntityVisitor visitor) { - if (visitor.visitEnter( this )) { - acceptChildren(visitor); - } - return visitor.visitLeave(this); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public void accept(final IEntityVisitor visitor) { - if (visitor instanceof IHierarchicalEntityVisitor) { - accept((IHierarchicalEntityVisitor)visitor); - } - else { - if (visitor.stopVisiting()) - return; - - visitor.visit(this); - if (visitor.stopVisiting()) - return; - - acceptChildren(visitor); - - visitor.visitCompleted(this); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - private void acceptChildren(final IEntityVisitor visitor) { - if (!getChildEntities().isEmpty()){ - for (final Iterator/*<Entity>*/ it = getChildEntities().iterator(); it.hasNext();){ - final Entity k = (Entity)it.next(); - k.accept(visitor); - if (visitor.stopVisiting()) - return; - } - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public Model getModel() { - if (_model == null){ - EObject parent = this.eContainer(); - while (true){ - if (parent instanceof Model){ - _model = (Model)parent; - break; - } - if (parent != null) - parent = parent.eContainer(); - else - break; - } - } - return _model; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case MetadataPackage.ENTITY__CHILD_ENTITIES: - return ((InternalEList)getChildEntities()).basicRemove(otherEnd, msgs); - case MetadataPackage.ENTITY__TRAITS: - return ((InternalEList)getTraits()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case MetadataPackage.ENTITY__CHILD_ENTITIES: - return getChildEntities(); - case MetadataPackage.ENTITY__TRAITS: - return getTraits(); - case MetadataPackage.ENTITY__ID: - return getId(); - case MetadataPackage.ENTITY__TYPE: - return getType(); - case MetadataPackage.ENTITY__INCLUDE_GROUPS: - return getIncludeGroups(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case MetadataPackage.ENTITY__CHILD_ENTITIES: - getChildEntities().clear(); - getChildEntities().addAll((Collection)newValue); - return; - case MetadataPackage.ENTITY__TRAITS: - getTraits().clear(); - getTraits().addAll((Collection)newValue); - return; - case MetadataPackage.ENTITY__ID: - setId((String)newValue); - return; - case MetadataPackage.ENTITY__TYPE: - setType((String)newValue); - return; - case MetadataPackage.ENTITY__INCLUDE_GROUPS: - getIncludeGroups().clear(); - getIncludeGroups().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case MetadataPackage.ENTITY__CHILD_ENTITIES: - getChildEntities().clear(); - return; - case MetadataPackage.ENTITY__TRAITS: - getTraits().clear(); - return; - case MetadataPackage.ENTITY__ID: - setId(ID_EDEFAULT); - return; - case MetadataPackage.ENTITY__TYPE: - setType(TYPE_EDEFAULT); - return; - case MetadataPackage.ENTITY__INCLUDE_GROUPS: - getIncludeGroups().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case MetadataPackage.ENTITY__CHILD_ENTITIES: - return childEntities != null && !childEntities.isEmpty(); - case MetadataPackage.ENTITY__TRAITS: - return traits != null && !traits.isEmpty(); - case MetadataPackage.ENTITY__ID: - return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); - case MetadataPackage.ENTITY__TYPE: - return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type); - case MetadataPackage.ENTITY__INCLUDE_GROUPS: - return includeGroups != null && !includeGroups.isEmpty(); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (id: "); //$NON-NLS-1$ - result.append(id); - result.append(", type: "); //$NON-NLS-1$ - result.append(type); - result.append(')'); - return result.toString(); - } - -} //EntityImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/IncludeEntityGroupImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/IncludeEntityGroupImpl.java deleted file mode 100644 index 3943823c3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/IncludeEntityGroupImpl.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: IncludeEntityGroupImpl.java,v 1.3 2008/11/18 22:24:39 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Include Entity Group</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.IncludeEntityGroupImpl#getId <em>Id</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.IncludeEntityGroupImpl#getModelUri <em>Model Uri</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class IncludeEntityGroupImpl extends EObjectImpl implements IncludeEntityGroup { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The default value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected String id = ID_EDEFAULT; - - /** - * The default value of the '{@link #getModelUri() <em>Model Uri</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getModelUri() - * @generated - * @ordered - */ - protected static final String MODEL_URI_EDEFAULT = null; - - /** - * The cached value of the '{@link #getModelUri() <em>Model Uri</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getModelUri() - * @generated - * @ordered - */ - protected String modelUri = MODEL_URI_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected IncludeEntityGroupImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return MetadataPackage.Literals.INCLUDE_ENTITY_GROUP; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getId() { - return id; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setId(String newId) { - String oldId = id; - id = newId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.INCLUDE_ENTITY_GROUP__ID, oldId, id)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getModelUri() { - return modelUri; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setModelUri(String newModelUri) { - String oldModelUri = modelUri; - modelUri = newModelUri; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.INCLUDE_ENTITY_GROUP__MODEL_URI, oldModelUri, modelUri)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case MetadataPackage.INCLUDE_ENTITY_GROUP__ID: - return getId(); - case MetadataPackage.INCLUDE_ENTITY_GROUP__MODEL_URI: - return getModelUri(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case MetadataPackage.INCLUDE_ENTITY_GROUP__ID: - setId((String)newValue); - return; - case MetadataPackage.INCLUDE_ENTITY_GROUP__MODEL_URI: - setModelUri((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case MetadataPackage.INCLUDE_ENTITY_GROUP__ID: - setId(ID_EDEFAULT); - return; - case MetadataPackage.INCLUDE_ENTITY_GROUP__MODEL_URI: - setModelUri(MODEL_URI_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case MetadataPackage.INCLUDE_ENTITY_GROUP__ID: - return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); - case MetadataPackage.INCLUDE_ENTITY_GROUP__MODEL_URI: - return MODEL_URI_EDEFAULT == null ? modelUri != null : !MODEL_URI_EDEFAULT.equals(modelUri); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (id: "); //$NON-NLS-1$ - result.append(id); - result.append(", modelUri: "); //$NON-NLS-1$ - result.append(modelUri); - result.append(')'); - return result.toString(); - } - -} //IncludeEntityGroupImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataFactoryImpl.java deleted file mode 100644 index b80967ea5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataFactoryImpl.java +++ /dev/null @@ -1,239 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataFactoryImpl.java,v 1.5 2008/11/18 22:24:39 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.impl.EFactoryImpl; -import org.eclipse.emf.ecore.plugin.EcorePlugin; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataFactory; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor; - - - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Factory</b>. - * <!-- end-user-doc --> - * @generated - */ -public class MetadataFactoryImpl extends EFactoryImpl implements MetadataFactory { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Creates the default factory implementation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return MetadataFactory - * @generated - */ - public static MetadataFactory init() { - try { - MetadataFactory theMetadataFactory = (MetadataFactory)EPackage.Registry.INSTANCE.getEFactory("http://org.eclipse.jst.jsf.common.metadata/metadata.ecore"); //$NON-NLS-1$ - if (theMetadataFactory != null) { - return theMetadataFactory; - } - } - catch (Exception exception) { - EcorePlugin.INSTANCE.log(exception); - } - return new MetadataFactoryImpl(); - } - - /** - * Creates an instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataFactoryImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EObject create(EClass eClass) { - switch (eClass.getClassifierID()) { - case MetadataPackage.MODEL: return createModel(); - case MetadataPackage.ENTITY_GROUP: return createEntityGroup(); - case MetadataPackage.ENTITY: return createEntity(); - case MetadataPackage.TRAIT: return createTrait(); - case MetadataPackage.INCLUDE_ENTITY_GROUP: return createIncludeEntityGroup(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object createFromString(EDataType eDataType, String initialValue) { - switch (eDataType.getClassifierID()) { - case MetadataPackage.IMETA_DATA_SOURCE_MODEL_PROVIDER: - return createIMetaDataSourceModelProviderFromString(eDataType, initialValue); - case MetadataPackage.MODEL_CONTEXT: - return createModelContextFromString(eDataType, initialValue); - default: - throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String convertToString(EDataType eDataType, Object instanceValue) { - switch (eDataType.getClassifierID()) { - case MetadataPackage.IMETA_DATA_SOURCE_MODEL_PROVIDER: - return convertIMetaDataSourceModelProviderToString(eDataType, instanceValue); - case MetadataPackage.MODEL_CONTEXT: - return convertModelContextToString(eDataType, instanceValue); - default: - throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Trait createTrait() { - TraitImpl trait = new TraitImpl(); - return trait; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IncludeEntityGroup createIncludeEntityGroup() { - IncludeEntityGroupImpl includeEntityGroup = new IncludeEntityGroupImpl(); - return includeEntityGroup; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Model createModel() { - ModelImpl model = new ModelImpl(); - return model; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Entity createEntity() { - EntityImpl entity = new EntityImpl(); - return entity; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EntityGroup createEntityGroup() { - EntityGroupImpl entityGroup = new EntityGroupImpl(); - return entityGroup; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param eDataType IMetaDataSourceModelProvider - * @param initialValue - * @return IMetaDataSourceModelProvider - * @generated - */ - public IMetaDataSourceModelProvider createIMetaDataSourceModelProviderFromString(EDataType eDataType, String initialValue) { - return (IMetaDataSourceModelProvider)super.createFromString(eDataType, initialValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param eDataType - * @param instanceValue - * @return String - * @generated - */ - public String convertIMetaDataSourceModelProviderToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param eDataType - * @param initialValue - * @return ModelKeyDescriptor - * @generated - */ - public ModelKeyDescriptor createModelContextFromString(EDataType eDataType, String initialValue) { - return (ModelKeyDescriptor)super.createFromString(eDataType, initialValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param eDataType - * @param instanceValue - * @return String - * @generated - */ - public String convertModelContextToString(EDataType eDataType, Object instanceValue) { - return super.convertToString(eDataType, instanceValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataPackage getMetadataPackage() { - return (MetadataPackage)getEPackage(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return MetadataPackage - * @deprecated - * @generated - */ - public static MetadataPackage getPackage() { - return MetadataPackage.eINSTANCE; - } - -} //MetadataFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataPackageImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataPackageImpl.java deleted file mode 100644 index 52c73c311..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/MetadataPackageImpl.java +++ /dev/null @@ -1,604 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataPackageImpl.java,v 1.7 2008/11/18 22:24:39 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EOperation; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataFactory; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor; -import org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor; -import org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor; - - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Package</b>. - * <!-- end-user-doc --> - * @generated - */ -public class MetadataPackageImpl extends EPackageImpl implements MetadataPackage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass traitEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass includeEntityGroupEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass modelEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass entityEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass entityGroupEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EDataType iTraitVisitorEDataType = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EDataType iEntityVisitorEDataType = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EDataType iMetaDataSourceModelProviderEDataType = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EDataType modelContextEDataType = null; - - /** - * Creates an instance of the model <b>Package</b>, registered with - * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package - * package URI value. - * <p>Note: the correct way to create the package is via the static - * factory method {@link #init init()}, which also performs - * initialization of the package, or returns the registered package, - * if one already exists. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage#eNS_URI - * @see #init() - * @generated - */ - private MetadataPackageImpl() { - super(eNS_URI, MetadataFactory.eINSTANCE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the <b>Package</b> for this - * model, and for any others upon which it depends. Simple - * dependencies are satisfied by calling this method on all - * dependent packages before doing anything else. This method drives - * initialization for interdependent packages directly, in parallel - * with this package, itself. - * <p>Of this package and its interdependencies, all packages which - * have not yet been registered by their URI values are first created - * and registered. The packages are then initialized in two steps: - * meta-model objects for all of the packages are created before any - * are initialized, since one package's meta-model objects may refer to - * those of another. - * <p>Invocation of this method will not affect any packages that have - * already been initialized. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return MetadataPackage - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static MetadataPackage init() { - if (isInited) return (MetadataPackage)EPackage.Registry.INSTANCE.getEPackage(MetadataPackage.eNS_URI); - - // Obtain or create and register package - MetadataPackageImpl theMetadataPackage = (MetadataPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof MetadataPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new MetadataPackageImpl()); - - isInited = true; - - // Create package meta-data objects - theMetadataPackage.createPackageContents(); - - // Initialize created meta-data - theMetadataPackage.initializePackageContents(); - - // Mark meta-data to indicate it can't be changed - theMetadataPackage.freeze(); - - return theMetadataPackage; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getTrait() { - return traitEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getTrait_Value() { - return (EReference)traitEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getTrait_SourceModelProvider() { - return (EAttribute)traitEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getIncludeEntityGroup() { - return includeEntityGroupEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getIncludeEntityGroup_Id() { - return (EAttribute)includeEntityGroupEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getIncludeEntityGroup_ModelUri() { - return (EAttribute)includeEntityGroupEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getTrait_Id() { - return (EAttribute)traitEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getModel() { - return modelEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getModel_SourceModelProvider() { - return (EAttribute)modelEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getModel_CurrentModelContext() { - return (EAttribute)modelEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getModel_EntityGroups() { - return (EReference)modelEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getEntity() { - return entityEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getEntity_ChildEntities() { - return (EReference)entityEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getEntity_Traits() { - return (EReference)entityEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getEntity_Id() { - return (EAttribute)entityEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getEntity_Type() { - return (EAttribute)entityEClass.getEStructuralFeatures().get(3); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getEntity_IncludeGroups() { - return (EReference)entityEClass.getEStructuralFeatures().get(4); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getEntityGroup() { - return entityGroupEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EDataType getITraitVisitor() { - return iTraitVisitorEDataType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EDataType getIEntityVisitor() { - return iEntityVisitorEDataType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EDataType getIMetaDataSourceModelProvider() { - return iMetaDataSourceModelProviderEDataType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EDataType getModelContext() { - return modelContextEDataType; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataFactory getMetadataFactory() { - return (MetadataFactory)getEFactoryInstance(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is - * guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createPackageContents() { - if (isCreated) return; - isCreated = true; - - // Create classes and their features - modelEClass = createEClass(MODEL); - createEReference(modelEClass, MODEL__ENTITY_GROUPS); - createEAttribute(modelEClass, MODEL__SOURCE_MODEL_PROVIDER); - createEAttribute(modelEClass, MODEL__CURRENT_MODEL_CONTEXT); - - entityGroupEClass = createEClass(ENTITY_GROUP); - - entityEClass = createEClass(ENTITY); - createEReference(entityEClass, ENTITY__CHILD_ENTITIES); - createEReference(entityEClass, ENTITY__TRAITS); - createEAttribute(entityEClass, ENTITY__ID); - createEAttribute(entityEClass, ENTITY__TYPE); - createEReference(entityEClass, ENTITY__INCLUDE_GROUPS); - - traitEClass = createEClass(TRAIT); - createEAttribute(traitEClass, TRAIT__ID); - createEReference(traitEClass, TRAIT__VALUE); - createEAttribute(traitEClass, TRAIT__SOURCE_MODEL_PROVIDER); - - includeEntityGroupEClass = createEClass(INCLUDE_ENTITY_GROUP); - createEAttribute(includeEntityGroupEClass, INCLUDE_ENTITY_GROUP__ID); - createEAttribute(includeEntityGroupEClass, INCLUDE_ENTITY_GROUP__MODEL_URI); - - // Create data types - iTraitVisitorEDataType = createEDataType(ITRAIT_VISITOR); - iEntityVisitorEDataType = createEDataType(IENTITY_VISITOR); - iMetaDataSourceModelProviderEDataType = createEDataType(IMETA_DATA_SOURCE_MODEL_PROVIDER); - modelContextEDataType = createEDataType(MODEL_CONTEXT); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void initializePackageContents() { - if (isInitialized) return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Add supertypes to classes - modelEClass.getESuperTypes().add(this.getEntity()); - entityGroupEClass.getESuperTypes().add(this.getEntity()); - - // Initialize classes and features; add operations and parameters - initEClass(modelEClass, Model.class, "Model", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEReference(getModel_EntityGroups(), this.getEntityGroup(), null, "entityGroups", null, 0, -1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEAttribute(getModel_SourceModelProvider(), this.getIMetaDataSourceModelProvider(), "sourceModelProvider", null, 0, 1, Model.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEAttribute(getModel_CurrentModelContext(), this.getModelContext(), "currentModelContext", null, 0, 1, Model.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - EOperation op = addEOperation(modelEClass, this.getEntityGroup(), "findIncludeGroup", 0, 1); //$NON-NLS-1$ - addEParameter(op, ecorePackage.getEString(), "groupId", 0, 1); //$NON-NLS-1$ - - op = addEOperation(modelEClass, null, "accept"); //$NON-NLS-1$ - addEParameter(op, this.getIEntityVisitor(), "visitor", 0, 1); //$NON-NLS-1$ - - initEClass(entityGroupEClass, EntityGroup.class, "EntityGroup", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - - initEClass(entityEClass, Entity.class, "Entity", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEReference(getEntity_ChildEntities(), this.getEntity(), null, "childEntities", null, 0, -1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - getEntity_ChildEntities().getEKeys().add(this.getEntity_Id()); - getEntity_ChildEntities().getEKeys().add(this.getEntity_Type()); - initEReference(getEntity_Traits(), this.getTrait(), null, "traits", null, 0, -1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - getEntity_Traits().getEKeys().add(this.getTrait_Id()); - initEAttribute(getEntity_Id(), ecorePackage.getEString(), "id", null, 1, 1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEAttribute(getEntity_Type(), ecorePackage.getEString(), "type", null, 0, 1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEReference(getEntity_IncludeGroups(), this.getIncludeEntityGroup(), null, "includeGroups", null, 0, -1, Entity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - op = addEOperation(entityEClass, null, "accept"); //$NON-NLS-1$ - addEParameter(op, this.getIEntityVisitor(), "visitor", 0, 1); //$NON-NLS-1$ - - op = addEOperation(entityEClass, this.getModel(), "getModel", 0, 1); //$NON-NLS-1$ - - initEClass(traitEClass, Trait.class, "Trait", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEAttribute(getTrait_Id(), ecorePackage.getEString(), "id", null, 1, 1, Trait.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEReference(getTrait_Value(), ecorePackage.getEObject(), null, "value", null, 1, 1, Trait.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEAttribute(getTrait_SourceModelProvider(), this.getIMetaDataSourceModelProvider(), "sourceModelProvider", null, 0, 1, Trait.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - op = addEOperation(traitEClass, null, "accept"); //$NON-NLS-1$ - addEParameter(op, this.getITraitVisitor(), "visitor", 0, 1); //$NON-NLS-1$ - - initEClass(includeEntityGroupEClass, IncludeEntityGroup.class, "IncludeEntityGroup", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEAttribute(getIncludeEntityGroup_Id(), ecorePackage.getEString(), "id", null, 1, 1, IncludeEntityGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEAttribute(getIncludeEntityGroup_ModelUri(), ecorePackage.getEString(), "modelUri", null, 0, 1, IncludeEntityGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - // Initialize data types - initEDataType(iTraitVisitorEDataType, ITraitVisitor.class, "ITraitVisitor", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEDataType(iEntityVisitorEDataType, IEntityVisitor.class, "IEntityVisitor", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEDataType(iMetaDataSourceModelProviderEDataType, IMetaDataSourceModelProvider.class, "IMetaDataSourceModelProvider", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEDataType(modelContextEDataType, ModelKeyDescriptor.class, "ModelContext", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - - // Create resource - createResource(eNS_URI); - - // Create annotations - // http:///org/eclipse/emf/ecore/util/ExtendedMetaData - createExtendedMetaDataAnnotations(); - // http://www.eclipse.org/emf/2002/GenModel - createGenModelAnnotations(); - } - - /** - * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void createExtendedMetaDataAnnotations() { - String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; //$NON-NLS-1$ - addAnnotation - (modelEClass, - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "metadatamodel" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getModel_EntityGroups(), - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "entityGroup" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (entityEClass, - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "entity" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getEntity_ChildEntities(), - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "entity" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getEntity_Traits(), - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "trait" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getEntity_IncludeGroups(), - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "include-entity-group" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getIncludeEntityGroup_ModelUri(), - source, - new String[] { - "name", "uri" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (traitEClass, - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "trait" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getTrait_Value(), - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "namespace", "##targetNamespace" //$NON-NLS-1$ //$NON-NLS-2$ - }); - } - - /** - * Initializes the annotations for <b>http://www.eclipse.org/emf/2002/GenModel</b>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @SuppressWarnings("cast") - protected void createGenModelAnnotations() { - String source = "http://www.eclipse.org/emf/2002/GenModel"; //$NON-NLS-1$ - addAnnotation - ((EOperation)traitEClass.getEOperations().get(0), - source, - new String[] { - "body", "visitor.visit(this);" //$NON-NLS-1$ //$NON-NLS-2$ - }); - } - -} //MetadataPackageImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/ModelImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/ModelImpl.java deleted file mode 100644 index cfbb83e4d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/ModelImpl.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ModelImpl.java,v 1.8 2010/01/27 23:54:32 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.util.EObjectResolvingEList; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.internal.ModelKeyDescriptor; -import org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Model</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.ModelImpl#getEntityGroups <em>Entity Groups</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.ModelImpl#getSourceModelProvider <em>Source Model Provider</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.internal.impl.ModelImpl#getCurrentModelContext <em>Current Model Context</em>}</li> - * </ul> - * </p> - * - * @generated - */ -@SuppressWarnings("hiding") -public class ModelImpl extends EntityImpl implements Model { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached value of the '{@link #getEntityGroups() <em>Entity Groups</em>}' reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getEntityGroups() - * @generated - * @ordered - */ - protected EList entityGroups = null; - - /** - * The default value of the '{@link #getSourceModelProvider() <em>Source Model Provider</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSourceModelProvider() - * @generated - * @ordered - */ - protected static final IMetaDataSourceModelProvider SOURCE_MODEL_PROVIDER_EDEFAULT = null; - - /** - * The default value of the '{@link #getCurrentModelContext() <em>Current Model Context</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getCurrentModelContext() - * @generated - * @ordered - */ - protected static final ModelKeyDescriptor CURRENT_MODEL_CONTEXT_EDEFAULT = null; - - private IMetaDataSourceModelProvider sourceModelProvider; - - private ModelKeyDescriptor _modelContext; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ModelImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return MetadataPackage.Literals.MODEL; - } - - /** - * <!-- begin-user-doc --> - * May return null. - * <!-- end-user-doc --> - * @generated NOT - */ - public IMetaDataSourceModelProvider getSourceModelProvider() { - return sourceModelProvider; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public void setSourceModelProvider(IMetaDataSourceModelProvider newSourceModelProvider) { - sourceModelProvider = newSourceModelProvider; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public ModelKeyDescriptor getCurrentModelContext() { - return _modelContext; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public void setCurrentModelContext(ModelKeyDescriptor newCurrentModelContext) { - _modelContext = newCurrentModelContext; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getEntityGroups() { - if (entityGroups == null) { - entityGroups = new EObjectResolvingEList(EntityGroup.class, this, MetadataPackage.MODEL__ENTITY_GROUPS); - } - return entityGroups; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case MetadataPackage.MODEL__ENTITY_GROUPS: - return getEntityGroups(); - case MetadataPackage.MODEL__SOURCE_MODEL_PROVIDER: - return getSourceModelProvider(); - case MetadataPackage.MODEL__CURRENT_MODEL_CONTEXT: - return getCurrentModelContext(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case MetadataPackage.MODEL__ENTITY_GROUPS: - getEntityGroups().clear(); - getEntityGroups().addAll((Collection)newValue); - return; - case MetadataPackage.MODEL__SOURCE_MODEL_PROVIDER: - setSourceModelProvider((IMetaDataSourceModelProvider)newValue); - return; - case MetadataPackage.MODEL__CURRENT_MODEL_CONTEXT: - setCurrentModelContext((ModelKeyDescriptor)newValue); - return; - } - super.eSet(featureID, newValue); - } - - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public EntityGroup findIncludeGroup(String groupId){ - EntityGroup ret = null; - for (Iterator it=getEntityGroups().iterator();it.hasNext();){ - EntityGroup entityGroup = (EntityGroup)it.next(); - if (entityGroup.getId().equals(groupId)){ - ret = entityGroup; - break; - } - } - return ret; - } - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case MetadataPackage.MODEL__ENTITY_GROUPS: - getEntityGroups().clear(); - return; - case MetadataPackage.MODEL__SOURCE_MODEL_PROVIDER: - setSourceModelProvider(SOURCE_MODEL_PROVIDER_EDEFAULT); - return; - case MetadataPackage.MODEL__CURRENT_MODEL_CONTEXT: - setCurrentModelContext(CURRENT_MODEL_CONTEXT_EDEFAULT); - return; - } - super.eUnset(featureID); - } - /** - * <!-- begin-user-doc --> - * Due to a mistake in the EMF model, Model is not inheriting accept method from Entity. This should be fixed. - * <!-- end-user-doc --> - * @generated NOT - */ - - public void accept(IEntityVisitor visitor) { - super.accept(visitor); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public Model getModel() { - return this; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case MetadataPackage.MODEL__ENTITY_GROUPS: - return entityGroups != null && !entityGroups.isEmpty(); - case MetadataPackage.MODEL__SOURCE_MODEL_PROVIDER: - return SOURCE_MODEL_PROVIDER_EDEFAULT == null ? getSourceModelProvider() != null : !SOURCE_MODEL_PROVIDER_EDEFAULT.equals(getSourceModelProvider()); - case MetadataPackage.MODEL__CURRENT_MODEL_CONTEXT: - return CURRENT_MODEL_CONTEXT_EDEFAULT == null ? getCurrentModelContext() != null : !CURRENT_MODEL_CONTEXT_EDEFAULT.equals(getCurrentModelContext()); - } - return super.eIsSet(featureID); - } - -} //ModelImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/TraitImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/TraitImpl.java deleted file mode 100644 index 942168c85..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/impl/TraitImpl.java +++ /dev/null @@ -1,330 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TraitImpl.java,v 1.9 2008/11/18 22:24:39 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor; - - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Trait</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link TraitImpl#getValue <em>Value</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class TraitImpl extends EObjectImpl implements Trait { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The default value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = null; - - /** - * The cached value of the '{@link #getId() <em>Id</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getId() - * @generated - * @ordered - */ - protected String id = ID_EDEFAULT; - - /** - * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getValue() - * @generated - * @ordered - */ - protected EObject value = null; - - /** - * The default value of the '{@link #getSourceModelProvider() <em>Source Model Provider</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSourceModelProvider() - * @generated - * @ordered - */ - protected static final IMetaDataSourceModelProvider SOURCE_MODEL_PROVIDER_EDEFAULT = null; - - /** - * The cached value of the '{@link #getSourceModelProvider() <em>Source Model Provider</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSourceModelProvider() - * @generated - * @ordered - */ - protected IMetaDataSourceModelProvider sourceModelProvider = SOURCE_MODEL_PROVIDER_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TraitImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return MetadataPackage.Literals.TRAIT; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EObject getValue() { - return value; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param newValue - * @param msgs - * @return NotificationChain - * @generated - */ - public NotificationChain basicSetValue(EObject newValue, NotificationChain msgs) { - EObject oldValue = value; - value = newValue; - if (eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__VALUE, oldValue, newValue); - if (msgs == null) msgs = notification; else msgs.add(notification); - } - return msgs; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setValue(EObject newValue) { - if (newValue != value) { - NotificationChain msgs = null; - if (value != null) - msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MetadataPackage.TRAIT__VALUE, null, msgs); - if (newValue != null) - msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MetadataPackage.TRAIT__VALUE, null, msgs); - msgs = basicSetValue(newValue, msgs); - if (msgs != null) msgs.dispatch(); - } - else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__VALUE, newValue, newValue)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public IMetaDataSourceModelProvider getSourceModelProvider() { - return sourceModelProvider; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setSourceModelProvider(IMetaDataSourceModelProvider newSourceModelProvider) { - IMetaDataSourceModelProvider oldSourceModelProvider = sourceModelProvider; - sourceModelProvider = newSourceModelProvider; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__SOURCE_MODEL_PROVIDER, oldSourceModelProvider, sourceModelProvider)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getId() { - return id; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setId(String newId) { - String oldId = id; - id = newId; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__ID, oldId, id)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public void accept(ITraitVisitor visitor) { - visitor.visit(this); - visitor.visitCompleted(this); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case MetadataPackage.TRAIT__VALUE: - return basicSetValue(null, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case MetadataPackage.TRAIT__ID: - return getId(); - case MetadataPackage.TRAIT__VALUE: - return getValue(); - case MetadataPackage.TRAIT__SOURCE_MODEL_PROVIDER: - return getSourceModelProvider(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case MetadataPackage.TRAIT__ID: - setId((String)newValue); - return; - case MetadataPackage.TRAIT__VALUE: - setValue((EObject)newValue); - return; - case MetadataPackage.TRAIT__SOURCE_MODEL_PROVIDER: - setSourceModelProvider((IMetaDataSourceModelProvider)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case MetadataPackage.TRAIT__ID: - setId(ID_EDEFAULT); - return; - case MetadataPackage.TRAIT__VALUE: - setValue((EObject)null); - return; - case MetadataPackage.TRAIT__SOURCE_MODEL_PROVIDER: - setSourceModelProvider(SOURCE_MODEL_PROVIDER_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case MetadataPackage.TRAIT__ID: - return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); - case MetadataPackage.TRAIT__VALUE: - return value != null; - case MetadataPackage.TRAIT__SOURCE_MODEL_PROVIDER: - return SOURCE_MODEL_PROVIDER_EDEFAULT == null ? sourceModelProvider != null : !SOURCE_MODEL_PROVIDER_EDEFAULT.equals(sourceModelProvider); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (id: "); //$NON-NLS-1$ - result.append(id); - result.append(", sourceModelProvider: "); //$NON-NLS-1$ - result.append(sourceModelProvider); - result.append(')'); - return result.toString(); - } - - public boolean equals(Object value_){ - if (!(value_ instanceof String)) - return super.equals(value_); - - String key = (String)value_; - if (key.equals(getId())) - return true; - - return false; - } - - @Override - public int hashCode() - { - // try to match convention x.equals(y) => x.hashCode() == y.hashCode() - return getId() != null ? getId().hashCode() : 0xDEADBEEF; - } -} //TraitImpl
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/messages.properties b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/messages.properties deleted file mode 100644 index 5e9fd47a8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/messages.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2007 Oracle Corporation and others. -# 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 Corporation - initial API and implementation -############################################################################### - -MissingResource_exception=MissingResourceException for NLSPropertyValue: {0} -Key_not_found=(key not found) diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataAdapterFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataAdapterFactory.java deleted file mode 100644 index f73a841d7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataAdapterFactory.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataAdapterFactory.java,v 1.5 2008/11/18 22:24:36 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.util; - - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; - - - -/** - * <!-- begin-user-doc --> - * The <b>Adapter Factory</b> for the model. - * It provides an adapter <code>createXXX</code> method for each class of the model. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage - * @generated - */ -public class MetadataAdapterFactory extends AdapterFactoryImpl { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached model package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static MetadataPackage modelPackage; - - /** - * Creates an instance of the adapter factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataAdapterFactory() { - if (modelPackage == null) { - modelPackage = MetadataPackage.eINSTANCE; - } - } - - /** - * Returns whether this factory is applicable for the type of the object. - * <!-- begin-user-doc --> - * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. - * <!-- end-user-doc --> - * @return whether this factory is applicable for the type of the object. - * @generated - */ - public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch the delegates to the <code>createXXX</code> methods. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected MetadataSwitch modelSwitch = - new MetadataSwitch() { - public Object caseModel(Model object) { - return createModelAdapter(); - } - public Object caseEntityGroup(EntityGroup object) { - return createEntityGroupAdapter(); - } - public Object caseEntity(Entity object) { - return createEntityAdapter(); - } - public Object caseTrait(Trait object) { - return createTraitAdapter(); - } - public Object caseIncludeEntityGroup(IncludeEntityGroup object) { - return createIncludeEntityGroupAdapter(); - } - public Object defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * Creates an adapter for the <code>target</code>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param target the object to adapt. - * @return the adapter for the <code>target</code>. - * @generated - */ - public Adapter createAdapter(Notifier target) { - return (Adapter)modelSwitch.doSwitch((EObject)target); - } - - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.Trait <em>Trait</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.Trait - * @generated - */ - public Adapter createTraitAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup <em>Include Entity Group</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup - * @generated - */ - public Adapter createIncludeEntityGroupAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.Model <em>Model</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.Model - * @generated - */ - public Adapter createModelAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.Entity <em>Entity</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.Entity - * @generated - */ - public Adapter createEntityAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.EntityGroup <em>Entity Group</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.EntityGroup - * @generated - */ - public Adapter createEntityGroupAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. - * <!-- begin-user-doc --> - * This default implementation returns null. - * <!-- end-user-doc --> - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} //MetadataAdapterFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceFactoryImpl.java deleted file mode 100644 index 708b72f1e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceFactoryImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataResourceFactoryImpl.java,v 1.3 2008/11/18 22:24:36 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.util; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; -import org.eclipse.emf.ecore.xmi.XMLResource; - -/** - * <!-- begin-user-doc --> - * The <b>Resource Factory</b> associated with the package. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.util.MetadataResourceImpl - * @generated - */ -public class MetadataResourceFactoryImpl extends ResourceFactoryImpl { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Creates an instance of the resource factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataResourceFactoryImpl() { - super(); - } - - /** - * Creates an instance of the resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public Resource createResource(URI uri) { - XMLResource result = new MetadataResourceImpl(uri); - result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - - result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); - return result; - } - -} //MetadataResourceFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceImpl.java deleted file mode 100644 index 2db23d2b8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataResourceImpl.java +++ /dev/null @@ -1,222 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataResourceImpl.java,v 1.12 2008/11/18 22:24:36 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.util; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.xmi.PackageNotFoundException; -import org.eclipse.emf.ecore.xmi.XMLHelper; -import org.eclipse.emf.ecore.xmi.XMLLoad; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler; -import org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl; -import org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl; -import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider; -import org.xml.sax.helpers.DefaultHandler; - -/** - * <!-- begin-user-doc --> - * The <b>Resource </b> associated with the package. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.internal.util.MetadataResourceFactoryImpl - * @generated NOT - */ -public class MetadataResourceImpl extends XMLResourceImpl implements XMLResource.ResourceHandler { - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Oracle inc."; //$NON-NLS-1$ - - /** - * IMetaDataSourceModelProvider - */ - protected IMetaDataSourceModelProvider _provider; - /** - * Creates an instance of the resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param uri the URI of the new resource. - * @generated - */ - public MetadataResourceImpl(URI uri) { - super(uri); - } - - /** - * Constructor - */ - public MetadataResourceImpl() { - super(); - } - - - /** - * Constructor - * @param provider - */ - public MetadataResourceImpl(IMetaDataSourceModelProvider provider){ - super(); - _provider = provider; - } - - /** - * @generated NOT - */ - protected XMLLoad createXMLLoad() { - return new MetadataXMLLoad(createXMLHelper()); - } - /** - * Override createXMLHelper so that MetadataPackage.eINSTANCE is used for the NoNamespace package - * @generated NOT - */ - protected XMLHelper createXMLHelper() { - return new XMLHelperImpl(){ - @Override - public EPackage getNoNamespacePackage() { - return MetadataPackage.eINSTANCE; - } - }; - } - - public void postLoad(XMLResource resource, InputStream inputStream, - Map options) - { - final List<EObject> resContents = resource.getContents(); - - if (resContents.size() > 0) - { - final Object aRoot = resContents.get(0); - if (aRoot instanceof Model) - { - setModelKeyInTraits((Model) aRoot, (Model) aRoot); - } - } - else - { - JSFCommonPlugin.log(IStatus.WARNING, - "No model loaded for "+getURI()); //$NON-NLS-1$ - } - } - - private void setModelKeyInTraits(Model root, Entity currentEntity) { - // TODO: does this have side effect that we care about? nothing is done with the return value - MetadataPackage.eINSTANCE.getTrait_SourceModelProvider(); - for (int i=0;i < currentEntity.getTraits().size();i++){ - ((Trait)currentEntity.getTraits().get(i)).setSourceModelProvider(_provider); - } - for (int j=0;j < currentEntity.getChildEntities().size();j++){ - setModelKeyInTraits(root,(Entity)currentEntity.getChildEntities().get(j)); - } - - if (currentEntity == root){ - for (int k=0;k < root.getEntityGroups().size();k++){ - setModelKeyInTraits(root,(Entity)root.getEntityGroups().get(k)); - } - } - } - - - public void postSave(XMLResource resource, OutputStream outputStream, - Map options) { - // do nothing - } - - public void preLoad(XMLResource resource, InputStream inputStream, - Map options) { - // do nothing - } - - public void preSave(XMLResource resource, OutputStream outputStream, - Map options) { - // do nothing - } - - /** - * Override the handleErrors() method so that resource will load gracefully, and errors reported later - * when appropriate - * - * @generated NOT - */ - private static class MetadataXMLLoad extends XMLLoadImpl { - - public MetadataXMLLoad(XMLHelper helper) { - super(helper); - } - - @Override - protected void handleErrors() throws IOException { - //by doing nothing here, this allows the list of non-fatal errors (res.getErrors()) to be returned - } - - @Override - protected DefaultHandler makeDefaultHandler() { - return new MetadataXMLHandler(resource, helper, options); - } - } - - /** - * Ensures that only EMF extension models registered with the EMF Package Registry are considered. - * @generated NOT - */ - private static class MetadataXMLHandler extends SAXXMLHandler { - - public MetadataXMLHandler(XMLResource xmiResource, XMLHelper helper, - Map<?, ?> options) { - super(xmiResource, helper, options); - } - - @Override - protected EPackage getPackageForURI(String uriString) { - //code taken from super and modified so that only package registry is considered - if (uriString == null) - { - return null; - } - - EPackage ePackage = packageRegistry.getEPackage(uriString); - - if (ePackage != null && ePackage.eIsProxy()) - { - ePackage = null; - } - - if (ePackage == null) - { - ePackage = handleMissingPackage(uriString); - } - - if (ePackage == null) - { - error - (new PackageNotFoundException - (uriString, - getLocation(), - getLineNumber(), - getColumnNumber())); - } - - return ePackage; - } - } -} //MetadataResourceImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataSwitch.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataSwitch.java deleted file mode 100644 index 141be3bab..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataSwitch.java +++ /dev/null @@ -1,233 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataSwitch.java,v 1.7 2008/11/18 22:24:36 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.util; - - -import java.util.List; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.EntityGroup; -import org.eclipse.jst.jsf.common.metadata.IncludeEntityGroup; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; - - - -/** - * <!-- begin-user-doc --> - * The <b>Switch</b> for the model's inheritance hierarchy. - * It supports the call {@link #doSwitch(EObject) doSwitch(object)} - * to invoke the <code>caseXXX</code> method for each class of the model, - * starting with the actual class of the object - * and proceeding up the inheritance hierarchy - * until a non-null result is returned, - * which is the result of the switch. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.MetadataPackage - * @generated - */ -public class MetadataSwitch { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached model package - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static MetadataPackage modelPackage; - - /** - * Creates an instance of the switch. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataSwitch() { - if (modelPackage == null) { - modelPackage = MetadataPackage.eINSTANCE; - } - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param theEObject - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - public Object doSwitch(EObject theEObject) { - return doSwitch(theEObject.eClass(), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param theEClass - * @param theEObject - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected Object doSwitch(EClass theEClass, EObject theEObject) { - if (theEClass.eContainer() == modelPackage) { - return doSwitch(theEClass.getClassifierID(), theEObject); - } - List eSuperTypes = theEClass.getESuperTypes(); - return - eSuperTypes.isEmpty() ? - defaultCase(theEObject) : - doSwitch((EClass)eSuperTypes.get(0), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param classifierID - * @param theEObject - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected Object doSwitch(int classifierID, EObject theEObject) { - switch (classifierID) { - case MetadataPackage.MODEL: { - Model model = (Model)theEObject; - Object result = caseModel(model); - if (result == null) result = caseEntity(model); - if (result == null) result = defaultCase(theEObject); - return result; - } - case MetadataPackage.ENTITY_GROUP: { - EntityGroup entityGroup = (EntityGroup)theEObject; - Object result = caseEntityGroup(entityGroup); - if (result == null) result = caseEntity(entityGroup); - if (result == null) result = defaultCase(theEObject); - return result; - } - case MetadataPackage.ENTITY: { - Entity entity = (Entity)theEObject; - Object result = caseEntity(entity); - if (result == null) result = defaultCase(theEObject); - return result; - } - case MetadataPackage.TRAIT: { - Trait trait = (Trait)theEObject; - Object result = caseTrait(trait); - if (result == null) result = defaultCase(theEObject); - return result; - } - case MetadataPackage.INCLUDE_ENTITY_GROUP: { - IncludeEntityGroup includeEntityGroup = (IncludeEntityGroup)theEObject; - Object result = caseIncludeEntityGroup(includeEntityGroup); - if (result == null) result = defaultCase(theEObject); - return result; - } - default: return defaultCase(theEObject); - } - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Trait</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Trait</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseTrait(Trait object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Include Entity Group</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Include Entity Group</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseIncludeEntityGroup(IncludeEntityGroup object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Model</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Model</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseModel(Model object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Entity</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Entity</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseEntity(Entity object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Entity Group</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Entity Group</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseEntityGroup(EntityGroup object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>EObject</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch, but this is the last case anyway. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpretting the object as an instance of '<em>EObject</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) - * @generated - */ - public Object defaultCase(EObject object) { - return null; - } - -} //MetadataSwitch diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataXMLProcessor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataXMLProcessor.java deleted file mode 100644 index 036ef6b48..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/util/MetadataXMLProcessor.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: MetadataXMLProcessor.java,v 1.4 2008/11/18 22:24:36 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.internal.util; - -import java.util.Map; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.xmi.util.XMLProcessor; -import org.eclipse.jst.jsf.common.metadata.MetadataPackage; - - -/** - * This class contains helper methods to serialize and deserialize XML documents - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class MetadataXMLProcessor extends XMLProcessor { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - - /** - * Public constructor to instantiate the helper. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public MetadataXMLProcessor() { - super((EPackage.Registry.INSTANCE)); - MetadataPackage.eINSTANCE.eClass(); - } - - /** - * Register for "*" and "xml" file extensions the MetadataResourceFactoryImpl factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Map getRegistrations() { - if (registrations == null) { - super.getRegistrations(); - registrations.put(XML_EXTENSION, new MetadataResourceFactoryImpl()); - registrations.put(STAR_EXTENSION, new MetadataResourceFactoryImpl()); - } - return registrations; - } - -} //MetadataXMLProcessor diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/package-info.java deleted file mode 100644 index 836883f01..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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 - * - ********************************************************************************/ - -/** - * EMF interface objects for design-time metadata. - * <p><b>Provisional API - subject to change</b></p> - */ -package org.eclipse.jst.jsf.common.metadata; diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractEntityQueryVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractEntityQueryVisitor.java deleted file mode 100644 index 059169690..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractEntityQueryVisitor.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import org.eclipse.jst.jsf.common.metadata.Entity; - -/** - * Abstract class implementing {@link IEntityQueryVisitor} that concrete subclasses should provide implementations - * <p><b>Provisional API - subject to change</b></p> - */ -public abstract class AbstractEntityQueryVisitor extends AbstractEntityVisitor - implements IEntityQueryVisitor { - - /** - * @return EmptyResultSet. Subclasses should override. - */ - public IResultSet findEntities(Entity initialEntityContext, String entityKey) { - return new EmptyResultSet(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractEntityVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractEntityVisitor.java deleted file mode 100644 index 54e6f0165..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractEntityVisitor.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import org.eclipse.jst.jsf.common.metadata.Entity; - -/** - * Abstract implementation that concrete subclasses should ovveride - * <p><b>Provisional API - subject to change</b></p> - */ -public abstract class AbstractEntityVisitor extends AbstractMetaDataVisitor - implements IEntityVisitor { - - public abstract void visit(Entity entity); - - public void visitCompleted(Entity entity){ - //subclasses should override if needed - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractMetaDataVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractMetaDataVisitor.java deleted file mode 100644 index 15443e5d5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractMetaDataVisitor.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -/** - * Abstract class implementing {@link IMetaDataVisitor} - * <p><b>Provisional API - subject to change</b></p> - */ -public abstract class AbstractMetaDataVisitor implements IMetaDataVisitor { - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.IMetaDataVisitor#stopVisiting() - */ - public boolean stopVisiting() { - return false; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractResultSet.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractResultSet.java deleted file mode 100644 index df733d541..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractResultSet.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import java.util.Collections; -import java.util.List; - -/** - * Abstract implementation of {@link IResultSet} that developers may subclass. - * Users should assume that the results are only valid at the time of the query. This may change in the future. - * <p><b>Provisional API - subject to change</b></p> - */ -public abstract class AbstractResultSet/*<T>*/ implements IResultSet/*<T>*/ { - private List _results; - private boolean _isClosed = false; - - public List getResults() throws MetaDataException { - initIfNecessary(); - return _results; - } - - public final void close() throws MetaDataException { - doClose(); - _isClosed = true; - _results = null; - } - - /** - * Overridable method to close resultset. This is called by close() - * @throws MetaDataException - */ - protected void doClose() throws MetaDataException { - //subclasses to provide override - } - - public final boolean isClosed() { - return _isClosed; - } - - /** - * @return List of results. Null is tolerated. - */ - protected abstract List getInternalResults(); - - private void initIfNecessary() throws MetaDataException { - if (_isClosed) - throw new MetaDataException("Attempt to access a closed resultset."); //$NON-NLS-1$ - - if (_results == null) { - List checkNullResults = getInternalResults(); - if (checkNullResults == null){ - checkNullResults = Collections.EMPTY_LIST; - } - _results = Collections.unmodifiableList(checkNullResults); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractTraitQueryVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractTraitQueryVisitor.java deleted file mode 100644 index ddb894088..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractTraitQueryVisitor.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import org.eclipse.jst.jsf.common.metadata.Entity; - -/** - * Abstract implmentation of {@link ITraitQueryVisitor} that subclasses should use to provide implmentation - * <p><b>Provisional API - subject to change</b></p> - */ -public abstract class AbstractTraitQueryVisitor extends AbstractTraitVisitor implements - ITraitQueryVisitor { - - /** - * @return EmptyResultSet. Subclasses should override. - */ - public IResultSet findTraits(Entity entity, String traitKey) { - return new EmptyResultSet(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractTraitVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractTraitVisitor.java deleted file mode 100644 index 795a473e1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/AbstractTraitVisitor.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import org.eclipse.jst.jsf.common.metadata.Trait; - -/** - * Abstract Trait visitor - * <p><b>Provisional API - subject to change</b></p> - */ -public abstract class AbstractTraitVisitor extends AbstractMetaDataVisitor implements ITraitVisitor{ - - public abstract void visit(final Trait trait); - - public void visitCompleted(final Trait trait) { - //subclasses should override if needed - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/EmptyResultSet.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/EmptyResultSet.java deleted file mode 100644 index 26a1c7653..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/EmptyResultSet.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import java.util.Collections; -import java.util.List; - -/** - * Implementation of an empty result set - * <p><b>Provisional API - subject to change</b></p> - */ -public final class EmptyResultSet implements IResultSet { - private boolean _isClosed = false; - public void close() { - _isClosed = true; - } - - public List getResults() throws MetaDataException{ - if (_isClosed) - throw new MetaDataException("Resultset is closed"); //$NON-NLS-1$ - - return Collections.EMPTY_LIST; - } - - public boolean isClosed() { - return _isClosed; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IEntityQueryVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IEntityQueryVisitor.java deleted file mode 100644 index 7f168c162..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IEntityQueryVisitor.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import org.eclipse.jst.jsf.common.metadata.Entity; - -/** - * Entity querying interface - * <p>NOT to implemented by clients directly. Clients should subclass AbstractEntityQueryVisitor instead. - * <p><b>Provisional API - subject to change</b></p> - */ -public interface IEntityQueryVisitor extends IEntityVisitor{ - /** - * @param initialEntityContext - * @param entityKey to find relative to the passed intialEntityContext - * @return IResultSet of Entities matching the key. IResultSet must NOT be null. Implementers may return {@link EmptyResultSet}. - */ - public IResultSet/*<Entity>*/ findEntities(final Entity initialEntityContext, - final String entityKey); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IEntityVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IEntityVisitor.java deleted file mode 100644 index fcc178381..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IEntityVisitor.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import org.eclipse.jst.jsf.common.metadata.Entity; - -/** - * Visitor interface for Entities - * <p>NOT to implemented by clients directly. Clients should subclass AbstractEntityVisitor instead. - * <p><b>Provisional API - subject to change</b></p> - */ -public interface IEntityVisitor extends IMetaDataVisitor { - /** - * Visit the entity. - * The entity and then it's children are visited - * @param entity - must not be NULL - */ - public void visit(final Entity entity); - /** - * Signal that the entity and all it's children is now completely 'visited'. - * The entity will call this method at the end of the accept method. - * @param entity - must not be NULL - */ - public void visitCompleted(Entity entity); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IMetaDataModelContext.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IMetaDataModelContext.java deleted file mode 100644 index c70cdd981..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IMetaDataModelContext.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import org.eclipse.jst.jsf.context.IModelContext; - -/** - * <p><b>Provisional API - subject to change</b></p> - */ -public interface IMetaDataModelContext extends IModelContext { - /** - * @return domain identifier for this context. - * <p>This must match the domain id from the org.eclipse.jst.jsf.common.DomainLoadingStrategies - */ - public String getDomainID(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IMetaDataVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IMetaDataVisitor.java deleted file mode 100644 index 35a3652a3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IMetaDataVisitor.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -/** - * Common interface for Entity and Trait visitors - * <p>NOT to implemented by clients directly. Clients should subclass AbstractMetaDataVisitor instead. - * <p><b>Provisional API - subject to change</b></p> - */ -public interface IMetaDataVisitor { - /** - * @return true if visitor has recognized that visiting should stop - */ - public boolean stopVisiting(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IResultSet.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IResultSet.java deleted file mode 100644 index 0d0ab4866..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/IResultSet.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import java.util.List; - - - -/** - * Results from a metadata query. The resultset should be considered valid only at the time that the query is performed. - * Once "closed", the resultset should not be accessed again. - * - * <p>Not intended to be implemented directly by clients. Developers should extend {@link AbstractResultSet} instead. - * <p><b>Provisional API - subject to change</b></p> - */ -public interface IResultSet/*<T>*/{ - - /** - * @return unmodifiable List of results. May NOT be null. Implementer must return Collections.EMPTY_LIST instead. - * @throws MetaDataException - */ - public List/*<T>*/ getResults() throws MetaDataException; - - /** - * Signal that the query results are no longer required allowing for any cleanup that may be required - * Once a resultset is closed, a MetaDataException should be thrown if the next() or hasNext() is called. Clients can check isClosed() first. - * @throws MetaDataException - */ - public void close() throws MetaDataException; - - /** - * @return true if this resultset has been closed. - */ - public boolean isClosed(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/ITaglibDomainMetaDataModelContext.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/ITaglibDomainMetaDataModelContext.java deleted file mode 100644 index 17595f9ea..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/ITaglibDomainMetaDataModelContext.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import org.eclipse.core.resources.IProject; - -/** - * Context for determining the Model to locate in the MetaDataManager - * <p>Should NOT be implemented by clients - * <p><b>Provisional API - subject to change</b></p> - */ -public interface ITaglibDomainMetaDataModelContext extends IMetaDataModelContext { - /** - * @return project - */ - public IProject getProject(); - /** - * @return the namespace URI as String - */ - public String getURI(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/ITraitQueryVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/ITraitQueryVisitor.java deleted file mode 100644 index fd96a3721..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/ITraitQueryVisitor.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import org.eclipse.jst.jsf.common.metadata.Entity; - -/** - * Trait querying interface - * <p>NOT to implemented by clients directly. Clients should subclass AbstractTraitQueryVisitor instead. - * <p><b>Provisional API - subject to change</b></p> - */ -public interface ITraitQueryVisitor extends ITraitVisitor{ - /** - * @param entity - * @param traitKey - * @return IResultSet of Traits. IResultSet must NOT be null. Implementers may return {@link EmptyResultSet}. - */ - public IResultSet/*<Trait>*/ findTraits(final Entity entity, - final String traitKey); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/ITraitVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/ITraitVisitor.java deleted file mode 100644 index 9b39a101d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/ITraitVisitor.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import org.eclipse.jst.jsf.common.metadata.Trait; - -/** - * Visitor interface for Traits - * <p>NOT to implemented by clients directly. Clients should subclass AbstractTraitVisitor instead. - * <p><b>Provisional API - subject to change</b></p> - */ -public interface ITraitVisitor extends IMetaDataVisitor { - /** - * Visit the Trait. - * Implementer cannot assume ordering of trait visiting. - * @param trait - must not be null - */ - public void visit(final Trait trait); - - /** - * Signal that the the trait has been completely visited - * @param trait - */ - public void visitCompleted(final Trait trait); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/MetaDataException.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/MetaDataException.java deleted file mode 100644 index 50b314fbe..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/MetaDataException.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -/** - * Exception intended to be superclass of all exceptions thrown while handling metadata during query - * <p><b>Provisional API - subject to change</b></p> - */ -public class MetaDataException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Constructor - */ - public MetaDataException(){ - super(); - } - /** - * Constructor - * @param msg - */ - public MetaDataException(String msg){ - super(msg); - } - - /** - * Constructor - * @param msg - * @param cause - */ - public MetaDataException(String msg, Throwable cause){ - super(msg, cause); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/TaglibDomainMetaDataQueryHelper.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/TaglibDomainMetaDataQueryHelper.java deleted file mode 100644 index 52dd507c9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/TaglibDomainMetaDataQueryHelper.java +++ /dev/null @@ -1,226 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query; - -import javax.xml.namespace.QName; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.Model; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.internal.MetaDataModel; -import org.eclipse.jst.jsf.common.metadata.internal.TaglibDomainMetaDataModelContextImpl; -import org.eclipse.jst.jsf.common.metadata.internal.MetaDataModelManager; -import org.eclipse.jst.jsf.common.metadata.query.internal.SimpleEntityQueryVisitorImpl; -import org.eclipse.jst.jsf.common.metadata.query.internal.SimpleTraitQueryVisitorImpl; -import org.eclipse.jst.jsf.common.metadata.query.internal.HierarchicalSearchControl; - - -/** - * Helper class with static methods to simplify querying of a metadata model. - * - * <p>Steps for use: - * <br>1) Get the ITaglibDomainMetaDataModelContext using createMetaDataModelContext or createTagLibraryDomainMetaDataModelContext - * <br>2) Use appropriate getXXX methods using the ITaglibDomainMetaDataModelContext. - * <p><b>Provisional API - subject to change</b></p> - * @see IResultSet - * @see IEntityQueryVisitor - * @see ITraitQueryVisitor - * @see ITaglibDomainMetaDataModelContext - * @see Model - * @see Entity - * @see Trait - */ -public final class TaglibDomainMetaDataQueryHelper{ - /** - * Domain id for Tag library domain of metatdata - */ - public static final String TAGLIB_DOMAIN = "TagLibraryDomain"; //need better place for this //$NON-NLS-1$ - - /** - * private constructor - */ - private TaglibDomainMetaDataQueryHelper (){ - super(); - } - - /** - * Convenience method for creating {@link ITaglibDomainMetaDataModelContext}s for TAGLIB_DOMAIN - * @param project - * @param uri - * @return ITaglibDomainMetaDataModelContext - */ - public static ITaglibDomainMetaDataModelContext createMetaDataModelContext(IProject project, String uri){ - return new TaglibDomainMetaDataModelContextImpl(TAGLIB_DOMAIN, project, uri); - } - /** - * @param modelContext - * @return Model object for given context. May return null if not located. - */ - public static Model getModel(final ITaglibDomainMetaDataModelContext modelContext) { - MetaDataModel model = getMDModel(modelContext); - //we may want to throw error that model is empty - if (model != null && !model.isEmpty()){ - return (Model)model.getRoot(); - } - return null; - } - - /** - * @param modelContext - * @param entityKey relative to root of the model - * @return the first entity match from the root of the model. May return null. - */ - public static Entity getEntity(final ITaglibDomainMetaDataModelContext modelContext, - final String entityKey) { - IEntityQueryVisitor visitor = new SimpleEntityQueryVisitorImpl(new HierarchicalSearchControl(1, HierarchicalSearchControl.SCOPE_ALL_LEVELS)); - IResultSet/*<Entity>*/ rs = getEntities(modelContext,entityKey, visitor); - Entity e = null; - try { - if (! rs.getResults().isEmpty()){ - e = (Entity)rs.getResults().get(0); - } - rs.close(); - } catch (MetaDataException ex) { - JSFCommonPlugin.log(IStatus.ERROR, "Error in Helper.getEntity() - 1", ex); //$NON-NLS-1$ - } - - return e; - } - - /** - * @param modelContext - * @param entityKey relative to root of model - * @param visitor - * @return an IResultSet of entity objects - */ - public static IResultSet/*<Entity>*/ getEntities(final ITaglibDomainMetaDataModelContext modelContext, - final String entityKey, final IEntityQueryVisitor visitor){ - Model model = getModel(modelContext); - //we may want to throw error that model is empty - return getEntities(model, entityKey, visitor); - - } - - /** - * @param entity - * @param traitKey - * @return a trait or null for the given entity and traitKey using a SimpleEntityQueryVisitorImpl - */ - public static Trait getTrait(final Entity entity, final String traitKey){ - ITraitQueryVisitor visitor = new SimpleTraitQueryVisitorImpl(); - Trait t= null; - IResultSet/*<Trait>*/ rs = getTraits(entity, traitKey, visitor); - try { - if (! rs.getResults().isEmpty()){ - t = (Trait)rs.getResults().get(0); - } - rs.close(); - } catch (MetaDataException ex) { - JSFCommonPlugin.log(IStatus.ERROR, "Error in Helper.getTrait()", ex); //$NON-NLS-1$ - } - - return t; - } - - /** - * @param entity - * @param traitKey - * @param traitQueryVisitor - * @return an IResultSet of trait objects using supplied traitQueryVisitor. IResultSet should NOT be null. - */ - public static IResultSet/*<Trait>*/ getTraits(Entity entity, String traitKey, - ITraitQueryVisitor traitQueryVisitor) { - IResultSet/*<Trait>*/ rs = traitQueryVisitor.findTraits(entity, traitKey); - return rs; - } - - /** - * @param initialEntityContext - * @param entityKey relative to initial passed entity - * @return the first entity located by key using SimpleEntityQueryVisitorImpl - */ - public static Entity getEntity(Entity initialEntityContext, String entityKey) { - IEntityQueryVisitor visitor = new SimpleEntityQueryVisitorImpl(new HierarchicalSearchControl(1, HierarchicalSearchControl.SCOPE_ALL_LEVELS)); - Entity e= null; - IResultSet/*<Entity>*/ rs = getEntities(initialEntityContext, entityKey, visitor); - try { - if (! rs.getResults().isEmpty()){ - e = (Entity)rs.getResults().get(0); - } - rs.close(); - } catch (MetaDataException ex) { - JSFCommonPlugin.log(IStatus.ERROR, "Error in Helper.getEntity() - 0", ex); //$NON-NLS-1$ - } - - return e; - } - - /** - * @param initialEntityContext - * @param entityQuery relative to initial passed entity - * @param entityKeyQueryVisitor - * @return IResultSet of entities located by key using entityQueryVisitor. IResultSet should NOT be null. - */ - public static IResultSet/*<Entity>*/ getEntities(Entity initialEntityContext, String entityQuery, - IEntityQueryVisitor entityKeyQueryVisitor) { - - return entityKeyQueryVisitor.findEntities(initialEntityContext, entityQuery); - } - - - /** - * Retrieve the MetaDataModel from the ModelManager for given key - * @param modelContext - * @return MetaDataModel - */ - private static MetaDataModel getMDModel(final ITaglibDomainMetaDataModelContext modelContext){ - MetaDataModelManager mgr = null; - if (modelContext.getProject() != null) - mgr = MetaDataModelManager.getInstance(modelContext.getProject()); - else //temp(?) - mgr = MetaDataModelManager.getSharedInstance(); - - if (mgr != null) - return mgr.getModel(modelContext); - - return null; - } - - /** - * @param modelContext - * @param entityKey - * @param traitKey - * @return first trait found for entity and trait key starting from root of the model using SimpleMetaDataQueryImpl - */ - public static Trait getTrait(final ITaglibDomainMetaDataModelContext modelContext, - final String entityKey, final String traitKey) { - Entity entity = getEntity(modelContext, entityKey); - Trait t = null; - if (entity != null){ - t = getTrait(entity, traitKey); - } - return t; - } - - /** - * @param tagEntity - * @return QName for tag entity - */ - public static QName getQNameForTagEntity(Entity tagEntity) { - Assert.isTrue(tagEntity != null); - return new QName(tagEntity.getModel().getCurrentModelContext().getUri(), tagEntity.getId()); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/HierarchicalSearchControl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/HierarchicalSearchControl.java deleted file mode 100644 index 36d446e56..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/HierarchicalSearchControl.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query.internal; - -/** - * Sets controls on how a tree of nodes can be searched - */ -public class HierarchicalSearchControl extends SearchControl { - //scope levels - /** - * Do not recurse. - */ - public static final int SCOPE_CURRENT_LEVEL = 0; - /** - * Allow for one level of children to be visited from initial context - */ - public static final int SCOPE_ONE_LEVEL = 1; - /** - * Allow unlimited recursion of children - */ - public static final int SCOPE_ALL_LEVELS = 2; - - private int scope = SCOPE_ALL_LEVELS; - - /** - * Constructor using defaults of COUNT_LIMIT_NONE and SCOPE_ALL_LEVELS - */ - public HierarchicalSearchControl(){ - super(); - } - /** - * Constructor - * @param countLimit - * @param scope - */ - public HierarchicalSearchControl(int countLimit, int scope){ - super(countLimit); - this.scope = scope; - } - - - /** - * @param scope - */ - public void setScope(int scope){ - this.scope= scope; - } - - /** - * @return scope - */ - public int getScope(){ - return scope; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/IHierarchicalEntityVisitor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/IHierarchicalEntityVisitor.java deleted file mode 100644 index b91fd9e42..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/IHierarchicalEntityVisitor.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.eclipse.jst.jsf.common.metadata.query.internal; - -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor; - -/** - * Provides the necessary hierarchical visitor interface methods to - * provide conditional navigation of the entity hierarchy - * - */ -public interface IHierarchicalEntityVisitor extends IEntityVisitor { - /** - * @param entity - * @return true if children should be traversed - */ - boolean visitEnter(Entity entity); - /** - * @param entity - * @return true when coming out of a branch - */ - boolean visitLeave(Entity entity); - - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SearchControl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SearchControl.java deleted file mode 100644 index 43e131752..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SearchControl.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query.internal; - -/** - * Simple class used by {@link SimpleEntityQueryVisitorImpl} allowing some control of a metadata query. - * A query visitor can use this to optimize the query results and signal completion. - */ -public class SearchControl { - - /** - * No limit on query results - */ - public static final int COUNT_LIMIT_NONE = -1; - - //default settings - private int countLimit = COUNT_LIMIT_NONE; - - - /** - * Constructor using defaults of COUNT_LIMIT_NONE - */ - public SearchControl(){ - //use default settings - } - - /** - * Constructor - * @param countLimit - */ - public SearchControl(int countLimit){ - this.countLimit = countLimit; - } - - /** - * @param limit results count limit - */ - public void setCountLimit(int limit){ - this.countLimit = limit; - } - - /** - * @return query results count limit - */ - public int getCountLimit(){ - return countLimit; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SimpleEntityQueryVisitorImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SimpleEntityQueryVisitorImpl.java deleted file mode 100644 index ea68a0140..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SimpleEntityQueryVisitorImpl.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query.internal; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.query.AbstractEntityQueryVisitor; -import org.eclipse.jst.jsf.common.metadata.query.IResultSet; - - -/** - * A simple metadata query visitor implementing {@link org.eclipse.jst.jsf.common.metadata.query.IEntityQueryVisitor} and {@link org.eclipse.jst.jsf.common.metadata.query.ITraitQueryVisitor}.<p> - * - simple find entity and traits by id only <br> - * - does not allow for wild card searchs<br> - * <p> - * TODO - fix for case-sensitivity https://bugs.eclipse.org/bugs/show_bug.cgi?id=212794 - * - */ -public class SimpleEntityQueryVisitorImpl extends AbstractEntityQueryVisitor implements IHierarchicalEntityVisitor { - private HierarchicalSearchControl control; - private boolean _stop; - - private EntityQueryFilterVisitor entityQuery; - private List/*<Entity>*/ _entityResults; - private Entity initialEntityContext; - - /** - * Constructor that also creates a default SearchControl - */ - public SimpleEntityQueryVisitorImpl() { - super(); - control = new HierarchicalSearchControl(); - } - - /** - * Constructor - * @param control - */ - public SimpleEntityQueryVisitorImpl(final HierarchicalSearchControl control) { - super(); - this.control = control; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.IEntityQueryVisitor#findEntities(org.eclipse.jst.jsf.common.metadata.Entity, java.lang.String) - */ - public IResultSet/*<Entity>*/ findEntities(final Entity initialEntity, - final String entityKey) { - - resetQuery(); - - if (initialEntity != null){ - this.initialEntityContext = initialEntity; - entityQuery = new EntityQueryFilterVisitor(initialEntity.getId(), entityKey); - initialEntity.accept(this); - } - - return new SimpleResultSet(getInternalEntityResults()); - } - - private void resetQuery() { - _stop = false; - _entityResults = null; - } - - private List/*<Entity>*/ getInternalEntityResults(){ - if (_entityResults == null){ - _entityResults = new ArrayList/*<Entity>*/(); - } - return _entityResults; - } - - - public boolean visitEnter(final Entity entity) { - - if (entity == initialEntityContext) - return true; - - entityQuery.pushLevel(); - if (entityQuery.canVisit(entity)) - return entityQuery.visit(entity); - - return false; - } - - public boolean visitLeave(Entity entity) { - checkShouldStopVisitingEntities(); - if (entity != initialEntityContext) - entityQuery.popLevel(); - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.IEntityVisitor#visit(org.eclipse.jst.jsf.common.metadata.Entity) - */ - public void visit(final Entity key) { - //do nothing... all work now done in visitEnter/visitLeave - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.IMetaDataVisitor#stopVisiting() - */ - public boolean stopVisiting() { - return _stop; - } - - private void checkShouldStopVisitingEntities(){ - //implement how to set stop to signal to the entity accept() to skip visiting - if (_stop == false - && control.getCountLimit()== getInternalEntityResults().size() - && control.getCountLimit() != SearchControl.COUNT_LIMIT_NONE ) - - _stop = true; - } - - /** - * Visitor that filters and acts upon hierarchical data that compares that an entity's id for with another with case-insensitive compare - */ - private class EntityQueryFilterVisitor { - - private String entityId; - private List<String> entityQueue; - private int curLevel = 0; - - /** - * Constructor - * @param initialContextId - Entity id from which the query is rooted - * @param queryKey - query key which may be compound ("A/B/C") - */ - public EntityQueryFilterVisitor(final String initialContextId, final String queryKey){ - init(initialContextId, queryKey); - } - - private void init(final String initialContextId, final String key) { - entityQueue = new ArrayList<String>(3); - addLevel(initialContextId); - if (key == null || key.trim().equals("") || key.trim().equals("/")){ //$NON-NLS-1$ //$NON-NLS-2$ - addLevel(""); //$NON-NLS-1$ - } - else { - final StringTokenizer st = new StringTokenizer(key, "/"); //$NON-NLS-1$ - String partialKey = st.nextToken(); - addLevel(partialKey); - while (st.hasMoreElements()){ - partialKey = st.nextToken(); - addLevel(partialKey); - } - } - } - - /** - * @param entity - * @return flag indicating that filter was passed and children may be visited - */ - public boolean canVisit(final Entity entity) { - // only one filter rule... does this entity id match the current level's entity id (case-insensitive) - return entityId.compareTo(entity.getId().toUpperCase()) == 0; - } - - /** - * Operates on passed entity and determines if it should be part of the query results - * @param entity - * @return true if children of entity should be visited - */ - public boolean visit(final Entity entity) { - //one operation... if we have found the leaf-most entity in the query, add it to the results and go no deeper - if (curLevel == entityQueue.size() - 1) { - getInternalEntityResults().add(entity); - return false; - } - return true; - } - - private void addLevel(final String key) { - entityQueue.add(key.toUpperCase()); - } - - /** - * Move up one level in the query - */ - public void popLevel(){ - entityId = entityQueue.get(--curLevel); - } - - /** - * Move down one level in the query - */ - public void pushLevel() { - entityId = entityQueue.get(++curLevel); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SimpleResultSet.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SimpleResultSet.java deleted file mode 100644 index a3b2f2ae2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SimpleResultSet.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query.internal; - - -import java.util.Collections; -import java.util.List; - -import org.eclipse.jst.jsf.common.metadata.query.AbstractResultSet; - -/** - * Simple implementation of {@link org.eclipse.jst.jsf.common.metadata.query.IResultSet} by extending AbstractResultSet - * - */ -public final class SimpleResultSet/*<T>*/ extends AbstractResultSet/*<T>*/ { - private List/*<T>*/ results; - - /** - * Constructor passing a list to hold the results - * @param results - */ - public SimpleResultSet(List/*<T>*/ results){ - super(); - this.results = results; - } - - protected List getInternalResults(){ - if (results == null){ - results = Collections.EMPTY_LIST; - } - return results; - } - - -} - diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SimpleTraitQueryVisitorImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SimpleTraitQueryVisitorImpl.java deleted file mode 100644 index 00423648f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/internal/SimpleTraitQueryVisitorImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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.jst.jsf.common.metadata.query.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jst.jsf.common.metadata.Entity; -import org.eclipse.jst.jsf.common.metadata.Trait; -import org.eclipse.jst.jsf.common.metadata.query.AbstractTraitQueryVisitor; -import org.eclipse.jst.jsf.common.metadata.query.IResultSet; - - -/** - * A simple metadata query visitor implementing {@link org.eclipse.jst.jsf.common.metadata.query.ITraitQueryVisitor}. - * - simple find traits by id only - * - Does not allow for wild card searchs - */ -public class SimpleTraitQueryVisitorImpl extends AbstractTraitQueryVisitor { - - private String _traitQuery; - private SearchControl _control; - private boolean _stop; - private List/*<Trait>*/ _traitResults; - - /** - * Constructor that also creates a default SearchControl - */ - public SimpleTraitQueryVisitorImpl() { - super(); - _control = new SearchControl(); - } - - /** - * Constructor - * @param control - */ - public SimpleTraitQueryVisitorImpl(SearchControl control) { - super(); - this._control = control; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.ITraitQueryVisitor#findTraits(org.eclipse.jst.jsf.common.metadata.Entity, java.lang.String) - */ - public IResultSet/*<Trait>*/ findTraits(final Entity entity, final String traitQuery){ - - resetQuery(); - if (entity != null){ - this._traitQuery = traitQuery; - for (Iterator/*<Trait>*/ it=entity.getTraits().iterator();it.hasNext();){ - Trait t = (Trait)it.next(); - t.accept(this); - if (stopVisiting()) - break; - } - } - return new SimpleResultSet(getInternalTraitResults()); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.ITraitVisitor#visit(org.eclipse.jst.jsf.common.metadata.Trait) - */ - public void visit(Trait trait) { - if (trait.equals(_traitQuery)) - getInternalTraitResults().add(trait); - - checkShouldStopVisitingTraits(); - } - - /** - * - */ - private void resetQuery() { - _stop = false; - _traitResults = null; - } - - /** - * @return lazy init of a SimpleResultSet of Traits - */ - private List/*<Trait>*/ getInternalTraitResults(){ - if (_traitResults == null){ - _traitResults = new ArrayList/*<Trait>*/(); - } - return _traitResults; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.metadata.query.IMetaDataVisitor#stopVisiting() - */ - public boolean stopVisiting() { - return _stop; - } - - private void checkShouldStopVisitingTraits(){ - if (_control.getCountLimit()== getInternalTraitResults().size() && _control.getCountLimit() != SearchControl.COUNT_LIMIT_NONE) - _stop = true; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/package-info.java deleted file mode 100644 index bb9019ece..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/query/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle Corporation. - * 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 - * - ********************************************************************************/ - -/** - * Meta-data query interface. - * <p><b>Provisional API - subject to change</b></p> - */ -package org.eclipse.jst.jsf.common.metadata.query; diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/BooleanValue.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/BooleanValue.java deleted file mode 100644 index 9a658b861..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/BooleanValue.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2007 Oracle Corporation - * - * $Id: BooleanValue.java,v 1.1 2010/01/21 00:01:44 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes; - -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Boolean Value</b></em>'. - * - * Only String value of 'true' in xml will result in isTrue() being true. - * All other String values will result in false. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue#isTrue <em>True</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage#getBooleanValue() - * @model extendedMetaData="kind='simple'" - * @generated - */ -public interface BooleanValue extends EObject { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Returns the value of the '<em><b>True</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>True</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>True</em>' attribute. - * @see #setTrue(boolean) - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage#getBooleanValue_True() - * @model required="true" - * extendedMetaData="kind='simple'" - * @generated - */ - boolean isTrue(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue#isTrue <em>True</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>True</em>' attribute. - * @see #isTrue() - * @generated - */ - void setTrue(boolean value); - -} // BooleanValue diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/ListOfValues.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/ListOfValues.java deleted file mode 100644 index 12e92a411..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/ListOfValues.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>List Of Values</b></em>'. - * - * <p><b>Provisional API - subject to change</b></p> - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues#getEntries <em>Entries</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage#getListOfValues() - * @model - * @generated - */ -public interface ListOfValues extends EObject { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Returns the value of the '<em><b>Entries</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.emf.ecore.xml.type.SimpleAnyType}. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Entries</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Entries</em>' containment reference list. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage#getListOfValues_Entries() - * @model type="org.eclipse.emf.ecore.xml.type.SimpleAnyType" containment="true" - * extendedMetaData="kind='element' name='item'" - * @generated - */ - EList getEntries(); - -} // ListOfValues diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/SetGenerator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/SetGenerator.java deleted file mode 100644 index 023ae6f4a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/SetGenerator.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes; - -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Set Generator</b></em>'. - * - * <p><b>Provisional API - subject to change</b></p> - * <!-- end-user-doc --> - * - * - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage#getSetGenerator() - * @model - * @generated - */ -public interface SetGenerator extends EObject { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Returns the value of the '<em><b>Algorithm</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Algorithm</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Algorithm</em>' attribute. - * @see #setAlgorithm(String) - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage#getSetGenerator_Algorithm() - * @model extendedMetaData="kind='element'" - * @generated - */ - String getAlgorithm(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator#getAlgorithm <em>Algorithm</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Algorithm</em>' attribute. - * @see #getAlgorithm() - * @generated - */ - void setAlgorithm(String value); - - /** - * Returns the value of the '<em><b>Expression</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Expression</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Expression</em>' attribute. - * @see #setExpression(String) - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage#getSetGenerator_Expression() - * @model extendedMetaData="kind='element'" - * @generated - */ - String getExpression(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator#getExpression <em>Expression</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Expression</em>' attribute. - * @see #getExpression() - * @generated - */ - void setExpression(String value); - -} // SetGenerator diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/StringValue.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/StringValue.java deleted file mode 100644 index b978ad871..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/StringValue.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2007 Oracle Corporation - * - * $Id: StringValue.java,v 1.1 2010/01/21 00:01:44 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes; - -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>String Value</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue#getValue <em>Value</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage#getStringValue() - * @model extendedMetaData="kind='simple'" - * @generated - */ -public interface StringValue extends EObject { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - String copyright = "Copyright (c) 2007 Oracle Corporation";//$NON-NLS-1$ - - /** - * Returns the value of the '<em><b>Value</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Value</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Value</em>' attribute. - * @see #setValue(String) - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage#getStringValue_Value() - * @model required="true" - * extendedMetaData="kind='simple'" - * @generated - */ - String getValue(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue#getValue <em>Value</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Value</em>' attribute. - * @see #getValue() - * @generated - */ - void setValue(String value); - -} // StringValue diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/TraitTypesFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/TraitTypesFactory.java deleted file mode 100644 index af30b04c7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/TraitTypesFactory.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes; - -import org.eclipse.emf.ecore.EFactory; - -/** - * <!-- begin-user-doc --> - * The <b>Factory</b> for the model. - * It provides a create method for each non-abstract class of the model. - * - * <p><b>Provisional API - subject to change</b></p> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage - * @generated - */ -public interface TraitTypesFactory extends EFactory { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The singleton instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - TraitTypesFactory eINSTANCE = org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.TraitTypesFactoryImpl.init(); - - /** - * Returns a new object of class '<em>List Of Values</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>List Of Values</em>'. - * @generated - */ - ListOfValues createListOfValues(); - - /** - * Returns a new object of class '<em>Set Generator</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Set Generator</em>'. - * @generated - */ - SetGenerator createSetGenerator(); - - /** - * Returns a new object of class '<em>String Value</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>String Value</em>'. - * @generated - */ - StringValue createStringValue(); - - /** - * Returns a new object of class '<em>Boolean Value</em>'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return a new object of class '<em>Boolean Value</em>'. - * @generated - */ - BooleanValue createBooleanValue(); - - /** - * Returns the package supported by this factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the package supported by this factory. - * @generated - */ - TraitTypesPackage getTraitTypesPackage(); - -} //TraitTypesFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/TraitTypesPackage.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/TraitTypesPackage.java deleted file mode 100644 index 81b82fb5a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/TraitTypesPackage.java +++ /dev/null @@ -1,395 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id$ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - -/** - * <!-- begin-user-doc --> - * The <b>Package</b> for the model. - * It contains accessors for the meta objects to represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * - * <p><b>Provisional API - subject to change</b></p> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesFactory - * @model kind="package" - * @generated - */ -@SuppressWarnings("hiding") -public interface TraitTypesPackage extends EPackage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The package name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNAME = "traittypes"; //$NON-NLS-1$ - - /** - * The package namespace URI. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNS_URI = "http://org.eclipse.jst.jsf.common.metadata/metadataTraitTypes.ecore"; //$NON-NLS-1$ - - /** - * The package namespace name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - String eNS_PREFIX = "mdt"; //$NON-NLS-1$ - - /** - * The singleton instance of the package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - TraitTypesPackage eINSTANCE = org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.TraitTypesPackageImpl.init(); - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.ListOfValuesImpl <em>List Of Values</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.ListOfValuesImpl - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.TraitTypesPackageImpl#getListOfValues() - * @generated - */ - int LIST_OF_VALUES = 0; - - /** - * The feature id for the '<em><b>Entries</b></em>' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int LIST_OF_VALUES__ENTRIES = 0; - - /** - * The number of structural features of the '<em>List Of Values</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int LIST_OF_VALUES_FEATURE_COUNT = 1; - - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.SetGeneratorImpl <em>Set Generator</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.SetGeneratorImpl - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.TraitTypesPackageImpl#getSetGenerator() - * @generated - */ - int SET_GENERATOR = 1; - - /** - * The feature id for the '<em><b>Algorithm</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int SET_GENERATOR__ALGORITHM = 0; - - /** - * The feature id for the '<em><b>Expression</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int SET_GENERATOR__EXPRESSION = 1; - - /** - * The number of structural features of the '<em>Set Generator</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int SET_GENERATOR_FEATURE_COUNT = 2; - - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.StringValueImpl <em>String Value</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.StringValueImpl - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.TraitTypesPackageImpl#getStringValue() - * @generated - */ - int STRING_VALUE = 2; - - /** - * The feature id for the '<em><b>Value</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int STRING_VALUE__VALUE = 0; - - /** - * The number of structural features of the '<em>String Value</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int STRING_VALUE_FEATURE_COUNT = 1; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.BooleanValueImpl <em>Boolean Value</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.BooleanValueImpl - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.TraitTypesPackageImpl#getBooleanValue() - * @generated - */ - int BOOLEAN_VALUE = 3; - - /** - * The feature id for the '<em><b>True</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int BOOLEAN_VALUE__TRUE = 0; - - /** - * The number of structural features of the '<em>Boolean Value</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - int BOOLEAN_VALUE_FEATURE_COUNT = 1; - - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues <em>List Of Values</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>List Of Values</em>'. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues - * @generated - */ - EClass getListOfValues(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues#getEntries <em>Entries</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the containment reference list '<em>Entries</em>'. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues#getEntries() - * @see #getListOfValues() - * @generated - */ - EReference getListOfValues_Entries(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator <em>Set Generator</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Set Generator</em>'. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator - * @generated - */ - EClass getSetGenerator(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator#getAlgorithm <em>Algorithm</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Algorithm</em>'. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator#getAlgorithm() - * @see #getSetGenerator() - * @generated - */ - EAttribute getSetGenerator_Algorithm(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator#getExpression <em>Expression</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Expression</em>'. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator#getExpression() - * @see #getSetGenerator() - * @generated - */ - EAttribute getSetGenerator_Expression(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue <em>String Value</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>String Value</em>'. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue - * @generated - */ - EClass getStringValue(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue#getValue <em>Value</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Value</em>'. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue#getValue() - * @see #getStringValue() - * @generated - */ - EAttribute getStringValue_Value(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue <em>Boolean Value</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Boolean Value</em>'. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue - * @generated - */ - EClass getBooleanValue(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue#isTrue <em>True</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>True</em>'. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue#isTrue() - * @see #getBooleanValue() - * @generated - */ - EAttribute getBooleanValue_True(); - - /** - * Returns the factory that creates the instances of the model. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the factory that creates the instances of the model. - * @generated - */ - TraitTypesFactory getTraitTypesFactory(); - - /** - * <!-- begin-user-doc --> - * Defines literals for the meta objects that represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * <!-- end-user-doc --> - * @generated - */ - interface Literals { - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.ListOfValuesImpl <em>List Of Values</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.ListOfValuesImpl - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.TraitTypesPackageImpl#getListOfValues() - * @generated - */ - EClass LIST_OF_VALUES = eINSTANCE.getListOfValues(); - - /** - * The meta object literal for the '<em><b>Entries</b></em>' containment reference list feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EReference LIST_OF_VALUES__ENTRIES = eINSTANCE.getListOfValues_Entries(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.SetGeneratorImpl <em>Set Generator</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.SetGeneratorImpl - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.TraitTypesPackageImpl#getSetGenerator() - * @generated - */ - EClass SET_GENERATOR = eINSTANCE.getSetGenerator(); - - /** - * The meta object literal for the '<em><b>Algorithm</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute SET_GENERATOR__ALGORITHM = eINSTANCE.getSetGenerator_Algorithm(); - - /** - * The meta object literal for the '<em><b>Expression</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute SET_GENERATOR__EXPRESSION = eINSTANCE.getSetGenerator_Expression(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.StringValueImpl <em>String Value</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.StringValueImpl - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.TraitTypesPackageImpl#getStringValue() - * @generated - */ - EClass STRING_VALUE = eINSTANCE.getStringValue(); - - /** - * The meta object literal for the '<em><b>Value</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute STRING_VALUE__VALUE = eINSTANCE.getStringValue_Value(); - - /** - * The meta object literal for the '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.BooleanValueImpl <em>Boolean Value</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.BooleanValueImpl - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.TraitTypesPackageImpl#getBooleanValue() - * @generated - */ - EClass BOOLEAN_VALUE = eINSTANCE.getBooleanValue(); - - /** - * The meta object literal for the '<em><b>True</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - EAttribute BOOLEAN_VALUE__TRUE = eINSTANCE.getBooleanValue_True(); - - } - -} //TraitTypesPackage diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/BooleanValueImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/BooleanValueImpl.java deleted file mode 100644 index 4592f6a91..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/BooleanValueImpl.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * Copyright (c) 2007 Oracle Corporation - * - * $Id: BooleanValueImpl.java,v 1.1 2010/01/21 00:01:44 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Boolean Value</b></em>'. - * - * Only String value of 'true' in xml will result in isTrue() being true. - * All other String values will result in false. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.BooleanValueImpl#isTrue <em>True</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class BooleanValueImpl extends EObjectImpl implements BooleanValue { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The default value of the '{@link #isTrue() <em>True</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isTrue() - * @generated - * @ordered - */ - protected static final boolean TRUE_EDEFAULT = false; - - /** - * The cached value of the '{@link #isTrue() <em>True</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #isTrue() - * @generated - * @ordered - */ - protected boolean true_ = TRUE_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected BooleanValueImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return TraitTypesPackage.Literals.BOOLEAN_VALUE; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean isTrue() { - return true_; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setTrue(boolean newTrue) { - boolean oldTrue = true_; - true_ = newTrue; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, TraitTypesPackage.BOOLEAN_VALUE__TRUE, oldTrue, true_)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case TraitTypesPackage.BOOLEAN_VALUE__TRUE: - return isTrue() ? Boolean.TRUE : Boolean.FALSE; - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case TraitTypesPackage.BOOLEAN_VALUE__TRUE: - setTrue(((Boolean)newValue).booleanValue()); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case TraitTypesPackage.BOOLEAN_VALUE__TRUE: - setTrue(TRUE_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case TraitTypesPackage.BOOLEAN_VALUE__TRUE: - return true_ != TRUE_EDEFAULT; - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (isTrue(): "); //$NON-NLS-1$ - result.append(true_); - result.append(')'); - return result.toString(); - } - -} //BooleanValueImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/ListOfValuesImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/ListOfValuesImpl.java deleted file mode 100644 index 4cbfe03dc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/ListOfValuesImpl.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: ListOfValuesImpl.java,v 1.4 2008/11/18 22:24:38 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.NotificationChain; - -import org.eclipse.emf.common.util.EList; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.InternalEObject; - -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.emf.ecore.util.InternalEList; - -import org.eclipse.emf.ecore.xml.type.SimpleAnyType; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>List Of Values</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.ListOfValuesImpl#getEntries <em>Entries</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class ListOfValuesImpl extends EObjectImpl implements ListOfValues { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached value of the '{@link #getEntries() <em>Entries</em>}' containment reference list. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getEntries() - * @generated - * @ordered - */ - protected EList entries = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected ListOfValuesImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return TraitTypesPackage.Literals.LIST_OF_VALUES; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EList getEntries() { - if (entries == null) { - entries = new EObjectContainmentEList(SimpleAnyType.class, this, TraitTypesPackage.LIST_OF_VALUES__ENTRIES); - } - return entries; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { - switch (featureID) { - case TraitTypesPackage.LIST_OF_VALUES__ENTRIES: - return ((InternalEList)getEntries()).basicRemove(otherEnd, msgs); - } - return super.eInverseRemove(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case TraitTypesPackage.LIST_OF_VALUES__ENTRIES: - return getEntries(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case TraitTypesPackage.LIST_OF_VALUES__ENTRIES: - getEntries().clear(); - getEntries().addAll((Collection)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case TraitTypesPackage.LIST_OF_VALUES__ENTRIES: - getEntries().clear(); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case TraitTypesPackage.LIST_OF_VALUES__ENTRIES: - return entries != null && !entries.isEmpty(); - } - return super.eIsSet(featureID); - } - -} //ListOfValuesImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/SetGeneratorImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/SetGeneratorImpl.java deleted file mode 100644 index d12cb3ceb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/SetGeneratorImpl.java +++ /dev/null @@ -1,222 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: SetGeneratorImpl.java,v 1.3 2008/11/18 22:24:38 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>Set Generator</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.SetGeneratorImpl#getAlgorithm <em>Algorithm</em>}</li> - * <li>{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.SetGeneratorImpl#getExpression <em>Expression</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class SetGeneratorImpl extends EObjectImpl implements SetGenerator { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The default value of the '{@link #getAlgorithm() <em>Algorithm</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getAlgorithm() - * @generated - * @ordered - */ - protected static final String ALGORITHM_EDEFAULT = null; - - /** - * The cached value of the '{@link #getAlgorithm() <em>Algorithm</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getAlgorithm() - * @generated - * @ordered - */ - protected String algorithm = ALGORITHM_EDEFAULT; - - /** - * The default value of the '{@link #getExpression() <em>Expression</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getExpression() - * @generated - * @ordered - */ - protected static final String EXPRESSION_EDEFAULT = null; - - /** - * The cached value of the '{@link #getExpression() <em>Expression</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getExpression() - * @generated - * @ordered - */ - protected String expression = EXPRESSION_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected SetGeneratorImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return TraitTypesPackage.Literals.SET_GENERATOR; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getAlgorithm() { - return algorithm; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setAlgorithm(String newAlgorithm) { - String oldAlgorithm = algorithm; - algorithm = newAlgorithm; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, TraitTypesPackage.SET_GENERATOR__ALGORITHM, oldAlgorithm, algorithm)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getExpression() { - return expression; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setExpression(String newExpression) { - String oldExpression = expression; - expression = newExpression; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, TraitTypesPackage.SET_GENERATOR__EXPRESSION, oldExpression, expression)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case TraitTypesPackage.SET_GENERATOR__ALGORITHM: - return getAlgorithm(); - case TraitTypesPackage.SET_GENERATOR__EXPRESSION: - return getExpression(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case TraitTypesPackage.SET_GENERATOR__ALGORITHM: - setAlgorithm((String)newValue); - return; - case TraitTypesPackage.SET_GENERATOR__EXPRESSION: - setExpression((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case TraitTypesPackage.SET_GENERATOR__ALGORITHM: - setAlgorithm(ALGORITHM_EDEFAULT); - return; - case TraitTypesPackage.SET_GENERATOR__EXPRESSION: - setExpression(EXPRESSION_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case TraitTypesPackage.SET_GENERATOR__ALGORITHM: - return ALGORITHM_EDEFAULT == null ? algorithm != null : !ALGORITHM_EDEFAULT.equals(algorithm); - case TraitTypesPackage.SET_GENERATOR__EXPRESSION: - return EXPRESSION_EDEFAULT == null ? expression != null : !EXPRESSION_EDEFAULT.equals(expression); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (algorithm: "); //$NON-NLS-1$ - result.append(algorithm); - result.append(", expression: "); //$NON-NLS-1$ - result.append(expression); - result.append(')'); - return result.toString(); - } - -} //SetGeneratorImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/StringValueImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/StringValueImpl.java deleted file mode 100644 index 89f502664..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/StringValueImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * Copyright (c) 2007 Oracle Corporation - * - * $Id: StringValueImpl.java,v 1.1 2010/01/21 00:01:44 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl; - -import org.eclipse.emf.common.notify.Notification; - -import org.eclipse.emf.ecore.EClass; - -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage; - -/** - * <!-- begin-user-doc --> - * An implementation of the model object '<em><b>String Value</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl.StringValueImpl#getValue <em>Value</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class StringValueImpl extends EObjectImpl implements StringValue { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The default value of the '{@link #getValue() <em>Value</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getValue() - * @generated - * @ordered - */ - protected static final String VALUE_EDEFAULT = null; - - /** - * The cached value of the '{@link #getValue() <em>Value</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getValue() - * @generated - * @ordered - */ - protected String value = VALUE_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected StringValueImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected EClass eStaticClass() { - return TraitTypesPackage.Literals.STRING_VALUE; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public String getValue() { - return value; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void setValue(String newValue) { - String oldValue = value; - value = newValue; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, TraitTypesPackage.STRING_VALUE__VALUE, oldValue, value)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Object eGet(int featureID, boolean resolve, boolean coreType) { - switch (featureID) { - case TraitTypesPackage.STRING_VALUE__VALUE: - return getValue(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eSet(int featureID, Object newValue) { - switch (featureID) { - case TraitTypesPackage.STRING_VALUE__VALUE: - setValue((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void eUnset(int featureID) { - switch (featureID) { - case TraitTypesPackage.STRING_VALUE__VALUE: - setValue(VALUE_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public boolean eIsSet(int featureID) { - switch (featureID) { - case TraitTypesPackage.STRING_VALUE__VALUE: - return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated NOT - */ - public String toString() { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (value: "); //$NON-NLS-1$ - result.append(value); - result.append(')'); - return result.toString(); - } - -} //StringValueImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/TraitTypesFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/TraitTypesFactoryImpl.java deleted file mode 100644 index c8441843e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/TraitTypesFactoryImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TraitTypesFactoryImpl.java,v 1.8 2010/03/01 18:10:08 cbateman Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; - -import org.eclipse.emf.ecore.impl.EFactoryImpl; - -import org.eclipse.emf.ecore.plugin.EcorePlugin; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.*; - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Factory</b>. - * <!-- end-user-doc --> - * @generated - */ -public class TraitTypesFactoryImpl extends EFactoryImpl implements TraitTypesFactory { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Creates the default factory implementation. - * <!-- begin-user-doc --> - * @return the factory - * <!-- end-user-doc --> - * @generated NOT - */ - public static TraitTypesFactory init() { - try { - TraitTypesFactory theTraitTypesFactory = (TraitTypesFactory)EPackage.Registry.INSTANCE.getEFactory("http://org.eclipse.jst.jsf.common.metadata/metadataTraitTypes.ecore"); //$NON-NLS-1$ - if (theTraitTypesFactory != null) { - return theTraitTypesFactory; - } - } - catch (Exception exception) { - EcorePlugin.INSTANCE.log(exception); - } - return new TraitTypesFactoryImpl(); - } - - /** - * Creates an instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public TraitTypesFactoryImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EObject create(EClass eClass) { - switch (eClass.getClassifierID()) { - case TraitTypesPackage.LIST_OF_VALUES: return createListOfValues(); - case TraitTypesPackage.SET_GENERATOR: return createSetGenerator(); - case TraitTypesPackage.STRING_VALUE: return createStringValue(); - case TraitTypesPackage.BOOLEAN_VALUE: return createBooleanValue(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public ListOfValues createListOfValues() { - ListOfValuesImpl listOfValues = new ListOfValuesImpl(); - return listOfValues; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public SetGenerator createSetGenerator() { - SetGeneratorImpl setGenerator = new SetGeneratorImpl(); - return setGenerator; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public StringValue createStringValue() { - StringValueImpl stringValue = new StringValueImpl(); - return stringValue; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public BooleanValue createBooleanValue() { - BooleanValueImpl booleanValue = new BooleanValueImpl(); - return booleanValue; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public TraitTypesPackage getTraitTypesPackage() { - return (TraitTypesPackage)getEPackage(); - } - - /** - * <!-- begin-user-doc --> - * @return the package - * <!-- end-user-doc --> - * @deprecated - * @generated - */ - public static TraitTypesPackage getPackage() { - return TraitTypesPackage.eINSTANCE; - } - -} //TraitTypesFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/TraitTypesPackageImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/TraitTypesPackageImpl.java deleted file mode 100644 index 80dfaae01..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/impl/TraitTypesPackageImpl.java +++ /dev/null @@ -1,358 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TraitTypesPackageImpl.java,v 1.8 2010/03/01 18:10:07 cbateman Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.impl; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - -import org.eclipse.emf.ecore.impl.EPackageImpl; - -import org.eclipse.emf.ecore.xml.type.XMLTypePackage; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesFactory; -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage; - -/** - * <!-- begin-user-doc --> - * An implementation of the model <b>Package</b>. - * <!-- end-user-doc --> - * @generated - */ -public class TraitTypesPackageImpl extends EPackageImpl implements TraitTypesPackage { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass listOfValuesEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass setGeneratorEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass stringValueEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass booleanValueEClass = null; - - /** - * Creates an instance of the model <b>Package</b>, registered with - * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package - * package URI value. - * <p>Note: the correct way to create the package is via the static - * factory method {@link #init init()}, which also performs - * initialization of the package, or returns the registered package, - * if one already exists. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage#eNS_URI - * @see #init() - * @generated - */ - private TraitTypesPackageImpl() { - super(eNS_URI, TraitTypesFactory.eINSTANCE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. - * - * <p>This method is used to initialize {@link TraitTypesPackage#eINSTANCE} when that field is accessed. - * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. - * <!-- begin-user-doc --> - * @return the package - * <!-- end-user-doc --> - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static TraitTypesPackage init() { - if (isInited) return (TraitTypesPackage)EPackage.Registry.INSTANCE.getEPackage(TraitTypesPackage.eNS_URI); - - // Obtain or create and register package - TraitTypesPackageImpl theTraitTypesPackage = (TraitTypesPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof TraitTypesPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new TraitTypesPackageImpl()); - - isInited = true; - - // Initialize simple dependencies - XMLTypePackage.eINSTANCE.eClass(); - - // Create package meta-data objects - theTraitTypesPackage.createPackageContents(); - - // Initialize created meta-data - theTraitTypesPackage.initializePackageContents(); - - // Mark meta-data to indicate it can't be changed - theTraitTypesPackage.freeze(); - - - // Update the registry and return the package - EPackage.Registry.INSTANCE.put(TraitTypesPackage.eNS_URI, theTraitTypesPackage); - return theTraitTypesPackage; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getListOfValues() { - return listOfValuesEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EReference getListOfValues_Entries() { - return (EReference)listOfValuesEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getSetGenerator() { - return setGeneratorEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getSetGenerator_Algorithm() { - return (EAttribute)setGeneratorEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getSetGenerator_Expression() { - return (EAttribute)setGeneratorEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getStringValue() { - return stringValueEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getStringValue_Value() { - return (EAttribute)stringValueEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EClass getBooleanValue() { - return booleanValueEClass; - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public EAttribute getBooleanValue_True() { - return (EAttribute)booleanValueEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public TraitTypesFactory getTraitTypesFactory() { - return (TraitTypesFactory)getEFactoryInstance(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is - * guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void createPackageContents() { - if (isCreated) return; - isCreated = true; - - // Create classes and their features - listOfValuesEClass = createEClass(LIST_OF_VALUES); - createEReference(listOfValuesEClass, LIST_OF_VALUES__ENTRIES); - - setGeneratorEClass = createEClass(SET_GENERATOR); - createEAttribute(setGeneratorEClass, SET_GENERATOR__ALGORITHM); - createEAttribute(setGeneratorEClass, SET_GENERATOR__EXPRESSION); - - stringValueEClass = createEClass(STRING_VALUE); - createEAttribute(stringValueEClass, STRING_VALUE__VALUE); - - booleanValueEClass = createEClass(BOOLEAN_VALUE); - createEAttribute(booleanValueEClass, BOOLEAN_VALUE__TRUE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public void initializePackageContents() { - if (isInitialized) return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Obtain other dependent packages - XMLTypePackage theXMLTypePackage = (XMLTypePackage)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI); - - // Add supertypes to classes - - // Initialize classes and features; add operations and parameters - initEClass(listOfValuesEClass, ListOfValues.class, "ListOfValues", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEReference(getListOfValues_Entries(), theXMLTypePackage.getSimpleAnyType(), null, "entries", null, 0, -1, ListOfValues.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - initEClass(setGeneratorEClass, SetGenerator.class, "SetGenerator", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEAttribute(getSetGenerator_Algorithm(), ecorePackage.getEString(), "algorithm", null, 0, 1, SetGenerator.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - initEAttribute(getSetGenerator_Expression(), ecorePackage.getEString(), "expression", null, 0, 1, SetGenerator.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - initEClass(stringValueEClass, StringValue.class, "StringValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEAttribute(getStringValue_Value(), ecorePackage.getEString(), "value", null, 1, 1, StringValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - initEClass(booleanValueEClass, BooleanValue.class, "BooleanValue", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - initEAttribute(getBooleanValue_True(), ecorePackage.getEBoolean(), "true", null, 1, 1, BooleanValue.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ - - // Create resource - createResource(eNS_URI); - - // Create annotations - // http:///org/eclipse/emf/ecore/util/ExtendedMetaData - createExtendedMetaDataAnnotations(); - } - - /** - * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected void createExtendedMetaDataAnnotations() { - String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; //$NON-NLS-1$ - addAnnotation - (getListOfValues_Entries(), - source, - new String[] { - "kind", "element", //$NON-NLS-1$ //$NON-NLS-2$ - "name", "item" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getSetGenerator_Algorithm(), - source, - new String[] { - "kind", "element" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getSetGenerator_Expression(), - source, - new String[] { - "kind", "element" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (stringValueEClass, - source, - new String[] { - "kind", "simple" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getStringValue_Value(), - source, - new String[] { - "kind", "simple" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (booleanValueEClass, - source, - new String[] { - "kind", "simple" //$NON-NLS-1$ //$NON-NLS-2$ - }); - addAnnotation - (getBooleanValue_True(), - source, - new String[] { - "kind", "simple" //$NON-NLS-1$ //$NON-NLS-2$ - }); - } - -} //TraitTypesPackageImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesAdapterFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesAdapterFactory.java deleted file mode 100644 index dd1e6533f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesAdapterFactory.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TraitTypesAdapterFactory.java,v 1.6 2010/01/21 00:01:44 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; - -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; - -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.*; - -/** - * <!-- begin-user-doc --> - * The <b>Adapter Factory</b> for the model. - * It provides an adapter <code>createXXX</code> method for each class of the model. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage - * @generated - */ -public class TraitTypesAdapterFactory extends AdapterFactoryImpl { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached model package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static TraitTypesPackage modelPackage; - - /** - * Creates an instance of the adapter factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public TraitTypesAdapterFactory() { - if (modelPackage == null) { - modelPackage = TraitTypesPackage.eINSTANCE; - } - } - - /** - * Returns whether this factory is applicable for the type of the object. - * <!-- begin-user-doc --> - * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model. - * <!-- end-user-doc --> - * @return whether this factory is applicable for the type of the object. - * @generated - */ - public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject)object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch that delegates to the <code>createXXX</code> methods. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected TraitTypesSwitch modelSwitch = - new TraitTypesSwitch() { - public Object caseListOfValues(ListOfValues object) { - return createListOfValuesAdapter(); - } - public Object caseSetGenerator(SetGenerator object) { - return createSetGeneratorAdapter(); - } - public Object caseStringValue(StringValue object) { - return createStringValueAdapter(); - } - public Object caseBooleanValue(BooleanValue object) { - return createBooleanValueAdapter(); - } - public Object defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * Creates an adapter for the <code>target</code>. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param target the object to adapt. - * @return the adapter for the <code>target</code>. - * @generated - */ - public Adapter createAdapter(Notifier target) { - return (Adapter)modelSwitch.doSwitch((EObject)target); - } - - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues <em>List Of Values</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.ListOfValues - * @generated - */ - public Adapter createListOfValuesAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator <em>Set Generator</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.SetGenerator - * @generated - */ - public Adapter createSetGeneratorAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue <em>String Value</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.StringValue - * @generated - */ - public Adapter createStringValueAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue <em>Boolean Value</em>}'. - * <!-- begin-user-doc --> - * This default implementation returns null so that we can easily ignore cases; - * it's useful to ignore a case when inheritance will catch all the cases anyway. - * <!-- end-user-doc --> - * @return the new adapter. - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.BooleanValue - * @generated - */ - public Adapter createBooleanValueAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. - * <!-- begin-user-doc --> - * This default implementation returns null. - * <!-- end-user-doc --> - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} //TraitTypesAdapterFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesResourceFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesResourceFactoryImpl.java deleted file mode 100644 index 2c56283cf..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesResourceFactoryImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TraitTypesResourceFactoryImpl.java,v 1.4 2008/11/18 22:24:43 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.util; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.resource.Resource; - -import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; - -import org.eclipse.emf.ecore.xmi.XMLResource; - -/** - * <!-- begin-user-doc --> - * The <b>Resource Factory</b> associated with the package. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.util.TraitTypesResourceImpl - * @generated - */ -public class TraitTypesResourceFactoryImpl extends ResourceFactoryImpl { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Creates an instance of the resource factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public TraitTypesResourceFactoryImpl() { - super(); - } - - /** - * Creates an instance of the resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public Resource createResource(URI uri) { - XMLResource result = new TraitTypesResourceImpl(uri); - result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - - result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); - return result; - } - -} //TraitTypesResourceFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesResourceImpl.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesResourceImpl.java deleted file mode 100644 index 894006d12..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesResourceImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TraitTypesResourceImpl.java,v 1.4 2008/11/18 22:24:43 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.util; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; - -/** - * <!-- begin-user-doc --> - * The <b>Resource </b> associated with the package. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.util.TraitTypesResourceFactoryImpl - * @generated - */ -public class TraitTypesResourceImpl extends XMLResourceImpl { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * Creates an instance of the resource. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param uri the URI of the new resource. - * @generated - */ - public TraitTypesResourceImpl(URI uri) { - super(uri); - } - -} //TraitTypesResourceImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesSwitch.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesSwitch.java deleted file mode 100644 index 0947b7048..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesSwitch.java +++ /dev/null @@ -1,203 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TraitTypesSwitch.java,v 1.9 2010/03/01 18:10:08 cbateman Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.util; - -import java.util.List; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.*; - -/** - * <!-- begin-user-doc --> - * The <b>Switch</b> for the model's inheritance hierarchy. - * It supports the call {@link #doSwitch(EObject) doSwitch(object)} - * to invoke the <code>caseXXX</code> method for each class of the model, - * starting with the actual class of the object - * and proceeding up the inheritance hierarchy - * until a non-null result is returned, - * which is the result of the switch. - * <!-- end-user-doc --> - * @see org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage - * @generated - */ -public class TraitTypesSwitch { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - /** - * The cached model package - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected static TraitTypesPackage modelPackage; - - /** - * Creates an instance of the switch. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public TraitTypesSwitch() { - if (modelPackage == null) { - modelPackage = TraitTypesPackage.eINSTANCE; - } - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * @param theEObject - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - public Object doSwitch(EObject theEObject) { - return doSwitch(theEObject.eClass(), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * @param theEClass - * @param theEObject - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected Object doSwitch(EClass theEClass, EObject theEObject) { - if (theEClass.eContainer() == modelPackage) { - return doSwitch(theEClass.getClassifierID(), theEObject); - } - List eSuperTypes = theEClass.getESuperTypes(); - return - eSuperTypes.isEmpty() ? - defaultCase(theEObject) : - doSwitch((EClass)eSuperTypes.get(0), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. - * <!-- begin-user-doc --> - * @param classifierID - * @param theEObject - * <!-- end-user-doc --> - * @return the first non-null result returned by a <code>caseXXX</code> call. - * @generated - */ - protected Object doSwitch(int classifierID, EObject theEObject) { - switch (classifierID) { - case TraitTypesPackage.LIST_OF_VALUES: { - ListOfValues listOfValues = (ListOfValues)theEObject; - Object result = caseListOfValues(listOfValues); - if (result == null) result = defaultCase(theEObject); - return result; - } - case TraitTypesPackage.SET_GENERATOR: { - SetGenerator setGenerator = (SetGenerator)theEObject; - Object result = caseSetGenerator(setGenerator); - if (result == null) result = defaultCase(theEObject); - return result; - } - case TraitTypesPackage.STRING_VALUE: { - StringValue stringValue = (StringValue)theEObject; - Object result = caseStringValue(stringValue); - if (result == null) result = defaultCase(theEObject); - return result; - } - case TraitTypesPackage.BOOLEAN_VALUE: { - BooleanValue booleanValue = (BooleanValue)theEObject; - Object result = caseBooleanValue(booleanValue); - if (result == null) result = defaultCase(theEObject); - return result; - } - default: return defaultCase(theEObject); - } - } - - /** - * Returns the result of interpreting the object as an instance of '<em>List Of Values</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>List Of Values</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseListOfValues(ListOfValues object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of '<em>Set Generator</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>Set Generator</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseSetGenerator(SetGenerator object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of '<em>String Value</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>String Value</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseStringValue(StringValue object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of '<em>Boolean Value</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>Boolean Value</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object caseBooleanValue(BooleanValue object) { - return null; - } - - /** - * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. - * <!-- begin-user-doc --> - * This implementation returns null; - * returning a non-null result will terminate the switch, but this is the last case anyway. - * <!-- end-user-doc --> - * @param object the target of the switch. - * @return the result of interpreting the object as an instance of '<em>EObject</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) - * @generated - */ - public Object defaultCase(EObject object) { - return null; - } - -} //TraitTypesSwitch diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesXMLProcessor.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesXMLProcessor.java deleted file mode 100644 index 674a2dd3c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/internal/util/TraitTypesXMLProcessor.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * <copyright> - * </copyright> - * - * $Id: TraitTypesXMLProcessor.java,v 1.5 2008/11/18 22:24:43 gkessler Exp $ - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.internal.util; - -import java.util.Map; - -import org.eclipse.emf.ecore.EPackage; - -import org.eclipse.emf.ecore.xmi.util.XMLProcessor; - -import org.eclipse.jst.jsf.common.metadata.traittypes.traittypes.TraitTypesPackage; - -/** - * This class contains helper methods to serialize and deserialize XML documents - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ -public class TraitTypesXMLProcessor extends XMLProcessor { - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; //$NON-NLS-1$ - - - /** - * Public constructor to instantiate the helper. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public TraitTypesXMLProcessor() { - super((EPackage.Registry.INSTANCE)); - TraitTypesPackage.eINSTANCE.eClass(); - } - - /** - * Register for "*" and "xml" file extensions the TraitTypesResourceFactoryImpl factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected Map getRegistrations() { - if (registrations == null) { - super.getRegistrations(); - registrations.put(XML_EXTENSION, new TraitTypesResourceFactoryImpl()); - registrations.put(STAR_EXTENSION, new TraitTypesResourceFactoryImpl()); - } - return registrations; - } - -} //TraitTypesXMLProcessor diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/package-info.java deleted file mode 100644 index 76e224562..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/traittypes/traittypes/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle Corporation. - * 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 - * - ********************************************************************************/ - -/** - * Common meta-data traits. - * <p><b>Provisional API - subject to change</b></p> - */ -package org.eclipse.jst.jsf.common.metadata.traittypes.traittypes; diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/AxiomaticSet.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/AxiomaticSet.java deleted file mode 100644 index 8bc288141..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/AxiomaticSet.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.sets; - -import java.util.Set; - -/** - * A java.util.Set with the basic mathematic set axioms of - * extensionality (equality), union, intersection, - * relative complement (set subtraction) and empty (already - * supported by Set). - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public interface AxiomaticSet extends Set -{ - /** - * Implementations should aim to provide O(mn) time cost - * where n is the number of elements in this set and - * m is the cost to check membership of an element in this - * set in toSet. When a set is itself a member of a set, - * the implementation must call isEquivalent on those subsets - * recursively. - * - * @param toSet - * - * @return true iff this set is equivalent toSet. Note - * that extensionality holds that two sets are equivalent - * if and only if they contain exactly the same elements. - * - * - */ - boolean isEquivalent(AxiomaticSet toSet); - - /** - * @param set - * @return the axiomatic union of this set with set - */ - AxiomaticSet union(AxiomaticSet set); - - - /** - * @param set - * @return the axiomatic intersection of this set with set - */ - AxiomaticSet intersect(AxiomaticSet set); - - /** - * @param set - * @return convenience method that must be equivalent to - * (this.intersect(set).isEmpty()) - */ - boolean isDisjoint(AxiomaticSet set); - - /** - * The set constructed by the removing the intersection - * of this with set from this. The set will contain all - * elements in this that are not in set. - * - * Eqivalence: this - set - * - * @param set - * @return the relative complement or theoretic difference of - * set from this - */ - AxiomaticSet subtract(AxiomaticSet set); - - /** - * @return the first element in the set. There is no guarantee which element - * will be chosen, but the call should always return the same element of the set - * for multiple invocations on the same set. Generally this is a convience method - * for when the set only contains one element. - * - * @throws java.util.NoSuchElementException if the set is empty. - */ - Object getFirstElement(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/AxiomaticSetUtil.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/AxiomaticSetUtil.java deleted file mode 100644 index baf9f8d7a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/AxiomaticSetUtil.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.sets; - -import java.util.Iterator; -import java.util.Set; - -/** - * Generic (unoptimized) utilities for doing set operations. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public class AxiomaticSetUtil -{ - /** - * Creates the union of firstSet and secondSet in newSet. - * @param newSet - * @param firstSet - * @param secondSet - */ - public static void union(AxiomaticSet newSet, AxiomaticSet firstSet, AxiomaticSet secondSet) - { - newSet.addAll(firstSet); - newSet.addAll(secondSet); - } - - /** - * Creates an intersection of firstSet and secondSet in newSet - * @param newSet - * @param firstSet - * @param secondSet - */ - public static void intersect(AxiomaticSet newSet, AxiomaticSet firstSet, AxiomaticSet secondSet) - { - // minor optimization: always iterate through the smaller of the - // two sets. This way we iterate through the smallest number - // of elements - Iterator it = null; - Set testSet = null; - // if other set smaller, get its iterator - if (secondSet.size() < firstSet.size()) - { - it = secondSet.iterator(); - // test set is other set - testSet = firstSet; - } - // first set is smaller or same - else - { - it = firstSet.iterator(); - testSet = secondSet; - } - - while (it.hasNext()) - { - Object member = it.next(); - if (testSet.contains(member)) - { - newSet.add(member); - } - } - } - - /** - * @param firstSet - * @param secondSet - * @return true firstSet and secondSet have no common elements (their intersection is empty) - */ - public static boolean isDisjoint(AxiomaticSet firstSet, AxiomaticSet secondSet) - { - return firstSet.intersect(secondSet).isEmpty(); - } - - /** - * @param firstOperand - * @param secondOperand - * @return the set formed by removing the intersection of firstOperand and secondOperand - * from firstOperand, leaving only those elements in firstOperand that are not in secondOperand - */ - public static AxiomaticSet subtract( - AxiomaticSet firstOperand, AxiomaticSet secondOperand) - { - ConcreteAxiomaticSet relativeComplement = new ConcreteAxiomaticSet(); - - // iterate through firstOperand and add each element to the result - // set that is not in secondOperand - for (final Iterator it = firstOperand.iterator(); it.hasNext();) - { - Object member = it.next(); - if (!secondOperand.contains(member)) - { - relativeComplement.add(member); - } - } - - return relativeComplement; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/ConcreteAxiomaticSet.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/ConcreteAxiomaticSet.java deleted file mode 100644 index b82c03fd6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/ConcreteAxiomaticSet.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.sets; - -import java.util.HashSet; - -/** - * Implements a simple axiomatic set based on a hashset - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public class ConcreteAxiomaticSet extends HashSet implements AxiomaticSet { - - /** - * serial version id - */ - private static final long serialVersionUID = 7094728081135008203L; - - public AxiomaticSet intersect(AxiomaticSet set) { - AxiomaticSet intersection = new ConcreteAxiomaticSet(); - AxiomaticSetUtil.intersect(intersection, this, set); - return intersection; - } - - public boolean isEquivalent(AxiomaticSet toSet) { - return equals(toSet); - } - - public AxiomaticSet union(AxiomaticSet set) { - AxiomaticSet union = new ConcreteAxiomaticSet(); - AxiomaticSetUtil.union(union, this, set); - return union; - } - - public boolean isDisjoint(AxiomaticSet set) { - return AxiomaticSetUtil.isDisjoint(this, set); - } - - public Object getFirstElement() { - return iterator().next(); - } - - public AxiomaticSet subtract(AxiomaticSet set) { - return AxiomaticSetUtil.subtract(this, set); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/NodeSet.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/NodeSet.java deleted file mode 100644 index 146b83360..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/NodeSet.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.sets; - -import java.util.AbstractSet; -import java.util.Iterator; -import java.util.NoSuchElementException; - -import org.w3c.dom.NodeList; - -/** - * A set backed by a W3C NodeList so as to avoid copying. Note that operations - * that return new sets still invoke a copy. Also, membership operations - * require O(n) time. This should generally used for sets that are assumed to be - * small where O(n) search time will be small compared to doing a full copy. - * - * This set is immutable (mutation methods throw exceptions) - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public class NodeSet extends AbstractSet implements AxiomaticSet -{ - private NodeList _data; - - /** - * @param data -- wrap the actual data source - */ - public NodeSet(NodeList data) - { - _data = data; - } - - public Iterator iterator() { - return new Iterator() - { - private int pos = 0; - - public boolean hasNext() { - return pos < _data.getLength(); - } - - public Object next() { - return _data.item(pos++); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - - }; - } - - public int size() { - return _data.getLength(); - } - - public AxiomaticSet intersect(AxiomaticSet set) { - ConcreteAxiomaticSet newSet = new ConcreteAxiomaticSet(); - AxiomaticSetUtil.intersect(newSet, this, set); - return newSet; - } - - public boolean isEquivalent(AxiomaticSet toSet) { - if (this == toSet) - { - return true; - } - - if (toSet instanceof NodeSet - && ((NodeSet)toSet)._data == this._data) - { - return true; - } - - // if different sizes, false - if (toSet.size() != size()) - { - return false; - } - - // otherwise, compare item by item - // Iterator through me with the hope that look ups - // are more efficent in toSet - for (Iterator it = iterator(); it.hasNext();) - { - Object obj = it.next(); - - if (!toSet.contains(obj)) - { - // fail fase on membership mismatch - return false; - } - } - - // if we get to here then the item by item match succeeded - return true; - } - - public AxiomaticSet union(AxiomaticSet set) { - ConcreteAxiomaticSet newSet = new ConcreteAxiomaticSet(); - AxiomaticSetUtil.union(newSet, this, set); - return newSet; - } - - public boolean isDisjoint(AxiomaticSet set) { - return AxiomaticSetUtil.isDisjoint(this, set); - } - - public Object getFirstElement() { - if (_data.getLength()>0) - { - return _data.item(0); - } - throw new NoSuchElementException("Set is empty"); //$NON-NLS-1$ - } - - public AxiomaticSet subtract(AxiomaticSet set) { - return AxiomaticSetUtil.subtract(this, set); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/constraint/AbstractMemberConstraint.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/constraint/AbstractMemberConstraint.java deleted file mode 100644 index d71ebf020..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/constraint/AbstractMemberConstraint.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.sets.constraint; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.sets.AxiomaticSet; - -/** - * A set constraint that is specific to members of the set. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public class AbstractMemberConstraint extends AbstractSetConstraint { - - public Diagnostic isSatisfied(AxiomaticSet set) { - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/constraint/AbstractSetConstraint.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/constraint/AbstractSetConstraint.java deleted file mode 100644 index f176a3775..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/constraint/AbstractSetConstraint.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.sets.constraint; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.jst.jsf.common.sets.AxiomaticSet; - -/** - * Super-class of all axiomatic set constraints. - * - * A set constraint applies one or more pre-conditions on a set - * and returns a diagnostic that flags whether or not the set - * satisfies that constraint or not. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public abstract class AbstractSetConstraint -{ - /** - * The following post-conditions must hold: - * - * 1) if the set satisfies the constraint with no caveats, - * the returned diagnostic must in turn satisfy - * Diagnostic.getSeverity() == Diagnostic.OK - * - * 2) if the set does not satisfy the constraint, the returned diagnostic - * must satisfy Diagnostic.getSeverity() == Diagnostic.ERROR - * - * 3) if the set strictly satisfies the constraint but the constraint includes - * parameters that can only be heuristically applied, the constraint may choose - * to return a diagnostic where Diagnostic.getSeverity() == Diagnostic.WARNING - * - * The diagnostic returned should _never_ have any other severity but OK, ERROR or WARNING - * - * Algorithmically: - * - * Constraint is satisfied can be tested by Diagnostic.getSeverity() != ERROR - * Constraint is not satisfied can be tested by Diagnostic.getSeverity() == ERROR - * - * @param set - * @return a diagnostic object that contains information about whether - * or not the constraint is satisfied for set. - * <b>MUST NOT RETURN NULL</b> - */ - public abstract Diagnostic isSatisfied(AxiomaticSet set); - - /** - * Convenience method - * - * @param set - * @return true if the constraint is satisfied for set - */ - public final boolean passesConstraint(AxiomaticSet set) - { - return isSatisfied(set).getSeverity() != Diagnostic.ERROR; - } - - /** - * Convenience method - * - * @param set - * @return true if the constraint is <b>not</b> satisfied for set - */ - public final boolean failsConstraint(AxiomaticSet set) - { - return !passesConstraint(set); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/constraint/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/constraint/package-info.java deleted file mode 100644 index 94a901681..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/constraint/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle Corporation. - * 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 - * - ********************************************************************************/ - -/** - * Classes for creating validation constraints on sets. - * <p><b>Provisional API - subject to change</b></p> - */ -package org.eclipse.jst.jsf.common.sets.constraint; diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/AbstractObjectInjectiveSetMapping.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/AbstractObjectInjectiveSetMapping.java deleted file mode 100644 index 8c2d5b53a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/AbstractObjectInjectiveSetMapping.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.sets.mapping; - -import java.util.Iterator; - -import org.eclipse.jst.jsf.common.sets.AxiomaticSet; -import org.eclipse.jst.jsf.common.sets.ConcreteAxiomaticSet; - -/** - * Super-class of all ObjectInjectiveSetMapping. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public abstract class AbstractObjectInjectiveSetMapping implements - ObjectInjectiveSetMapping { - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.sets.mapping.ObjectInjectiveSetMapping#mapIterator(org.eclipse.jst.jsf.common.sets.AxiomaticSet) - */ - public Iterator mapIterator(final AxiomaticSet set) - { - return new Iterator() - { - final Iterator setIterator = set.iterator(); - - public boolean hasNext() - { - return setIterator.hasNext(); - } - - public Object next() - { - return map(setIterator.next()); - } - - public void remove() - { - throw new UnsupportedOperationException("cannot modify iterator"); //$NON-NLS-1$ - } - }; - } - - /** - * @param element - * @return the result object from the mapping on element - */ - public abstract Object map(Object element); - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.common.sets.mapping.AxiomaticSetMapping#map(org.eclipse.jst.jsf.common.sets.AxiomaticSet) - */ - public final AxiomaticSet map(AxiomaticSet set) { - AxiomaticSet resultSet = new ConcreteAxiomaticSet(); - - for (final Iterator it = mapIterator(set); it.hasNext();) - { - resultSet.add(it.next()); - } - - return resultSet; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/AxiomaticSetMapping.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/AxiomaticSetMapping.java deleted file mode 100644 index d6ab1ff51..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/AxiomaticSetMapping.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.sets.mapping; - -import org.eclipse.jst.jsf.common.sets.AxiomaticSet; - -/** - * Defines an axiomatic mapping from set to another. In formal notation, this may - * also be defined as a "function" or a "proposition". - * - * Applying the map method can be seen as being equivalent to: - * - * AxiomaticSetMapping: set -> map(set) - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public interface AxiomaticSetMapping -{ - /** - * @param set - * @return the new set resulting from applying the map to set - */ - AxiomaticSet map(AxiomaticSet set); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/ObjectInjectiveSetMapping.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/ObjectInjectiveSetMapping.java deleted file mode 100644 index ce33eecc3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/ObjectInjectiveSetMapping.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.sets.mapping; - -import java.util.Iterator; - -import org.eclipse.jst.jsf.common.sets.AxiomaticSet; - -/** - * A type of axiomatic set mapping that operates injectively on the input - * set to create its result set. Note that the injection (one-to-oneness) - * of the mapping is based on Java objects and not on the value of the object. - * Therefore, the result set is not guaranteed to be injective on the basis - * of value. - * - * For example, consider a set of integers: - * - * X = {new Integer(4), new Integer(6), new Integer(9)} - * - * an ObjectInjectiveSetMapping may be defined that maps this set - * to a result based on: - * - * map(x) = new Boolean(x < 8) for all x in X - * - * An ObjectiveInjectiveSetMapping result set would look like this: - * - * map(X) = {new Boolean(true), new Boolean(true), new Boolean(false)} - * - * Note that boolean TRUE maps twice, so based on the value of the set members, - * the mapping is not injective. However, each Java object in X maps to a - * distinct Java object in map(X) - * - * This interface should not be implemented by clients. Clients should - * sub-class AbstractObjectInjectiveSetMapping to avoid future API breakage. - * - * <p><b>Provisional API - subject to change</b></p> - * - * @author cbateman - * - */ -public interface ObjectInjectiveSetMapping extends AxiomaticSetMapping -{ - /** - * This method optimizes the case where a client wants to apply some - * mapping or constraint to each element of a set until a particular - * condition applies and then stop. - * - * Mapping's that implement this - * interface should generally implement their map(set) method as: - * - * for (Iterator it = mapIterator(set); it.hasNext();) - * { - * result.add(doMapping(it.next)); - * } - * - * @param set - * @return an iterator that allows a client to apply the mapping - * one element of set at a time. The iterator is immutable and should - * throw UnsupportedOperationException if remove() is called. - */ - public Iterator mapIterator(AxiomaticSet set); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/package-info.java deleted file mode 100644 index 8a7dacc7d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/mapping/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle Corporation. - * 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 - * - ********************************************************************************/ - -/** - * Classes for creating member mappings between sets. - * <p><b>Provisional API - subject to change</b></p> - */ -package org.eclipse.jst.jsf.common.sets.mapping; diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/package-info.java deleted file mode 100644 index 744883704..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/sets/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle Corporation. - * 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 - * - ********************************************************************************/ - -/** - * Axiomatic Sets framework. - * <p><b>Provisional API - subject to change</b></p> - */ -package org.eclipse.jst.jsf.common.sets; diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java deleted file mode 100644 index 5175158cf..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.util; - -import java.beans.Introspector; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.core.Flags; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * A class that does bean introspection on a JDT IType - * - * This functionality is not meant to replace runtime bean - * introspection. Rather, it is meant to provide a - * more "lightweight" (in terms of class loading as well as - * error handling of bean instantiation out of context) way - * to determine a bean's properties at design time. - * - * This class may not be sub-classed by clients. - * - * @author cbateman - * - */ -public class JDTBeanIntrospector -{ - private final static String GET_PREFIX = "get"; //$NON-NLS-1$ - private final static String SET_PREFIX = "set"; //$NON-NLS-1$ - private final static String IS_PREFIX = "is"; //$NON-NLS-1$ - - private final IType _type; - private final HashMap<String, String> _resolvedSignatures; - - /** - * @param type - */ - public JDTBeanIntrospector(IType type) - { - _type = type; - _resolvedSignatures = new HashMap<String, String>(); - } - - /** - * @return an map of all properties with the property names - * as keys and the values being JDTBeanProperty objects representing - * the properties. - */ - public Map<String, JDTBeanProperty> getProperties() - { - _resolvedSignatures.clear(); - - final Map<String, JDTBeanProperty> propertiesWorkingCopy = - new HashMap<String, JDTBeanProperty>(); - final IMethod[] methods = getAllMethods(); - - for (int i = 0; i < methods.length; i++) - { - final IMethod method = methods[i]; - - try - { - processPropertyMethod(method, propertiesWorkingCopy); - } - catch (JavaModelException jme) - { - // log and then proceed to next method - JSFCommonPlugin.log(jme, "Error processing IMethod for bean property info"); //$NON-NLS-1$ - } - } - - final Map properties = new HashMap(); - - for (Entry<String, JDTBeanProperty> entry : propertiesWorkingCopy.entrySet()) - { - final String key = entry.getKey(); - JDTBeanPropertyWorkingCopy wcopy = (JDTBeanPropertyWorkingCopy) entry.getValue(); - properties.put(key, wcopy.toValueObject()); - } - - return properties; - } - - private void processPropertyMethod(IMethod method, Map<String, JDTBeanProperty> properties) throws JavaModelException - { - // to be a bean method, it must not a constructor, must be public - // and must not be static - if (!method.isConstructor() - && ( Flags.isPublic(method.getFlags()) - || _type.isInterface()) - && !Flags.isStatic(method.getFlags())) - { - final String methodName = method.getElementName(); - final String returnType = method.getReturnType(); - - // either starts with get or is boolean and starts with is - - // is access must start with 'is', have a boolean return type and no parameters - final boolean startsWithIs = methodName.startsWith(IS_PREFIX) - && Signature.SIG_BOOLEAN.equals(returnType) - && method.getNumberOfParameters() == 0 - && methodName.length() > IS_PREFIX.length(); - - // get accessor must start with 'get', have no parameters and return non-void - final boolean startsWithGet = (methodName.startsWith(GET_PREFIX) - && method.getNumberOfParameters() == 0) - && !Signature.SIG_VOID.equals(returnType) - && methodName.length() > GET_PREFIX.length(); - - // mutator must start with 'set' and have one parameter and a void return type - final boolean startsWithSet = methodName.startsWith(SET_PREFIX) - && method.getNumberOfParameters() == 1 - && Signature.SIG_VOID.equals(returnType) - && methodName.length() > SET_PREFIX.length(); - - if (startsWithGet || startsWithSet || startsWithIs) - { - final String propertyName = - Introspector.decapitalize(methodName.substring(startsWithIs ? 2 : 3)); - - JDTBeanPropertyWorkingCopy workingCopy = - (JDTBeanPropertyWorkingCopy) properties.get(propertyName); - - if (workingCopy == null) - { - workingCopy = new JDTBeanPropertyWorkingCopy(_type, _resolvedSignatures); - properties.put(propertyName, workingCopy); - } - - if (startsWithIs) - { - workingCopy.setIsGetter(method); - } - else if (startsWithGet) - { - workingCopy.setGetter(method); - } - else if (startsWithSet) - { - workingCopy.addSetter(method); - } - } - } - } - - /** - * @return all methods for the type including inherited ones - */ - public IMethod[] getAllMethods() - { - IMethod[] methods = new IMethod[0]; - - try - { - // type not resolved so don't proceed - if (_type != null) - { - // TODO: type hierarchy is potentially expensive, should - // cache once and listen for changes - ITypeHierarchy hierarchy = _type.newSupertypeHierarchy(new NullProgressMonitor()); - - methods = getAllMethods(hierarchy, _type); - } - } - catch(JavaModelException jme) - { - JSFCommonPlugin.log(jme, "Error getting type information for bean"); //$NON-NLS-1$ - } - - return methods; - } - - /** - * @param typeHierarchy - * @param type - * @return all methods of the type and it's super types - */ - private static IMethod[] getAllMethods(final ITypeHierarchy typeHierarchy, final IType type) - { - final List<IMethod> methods = new ArrayList<IMethod>(); - final IType[] superTypes = typeHierarchy.getAllSuperclasses(type); - final IType[] closure = new IType[superTypes.length+1]; - closure[0] = type; - System.arraycopy(superTypes, 0, closure, 1, superTypes.length); - - for (int i = 0; i < closure.length; i++) - { - try { - final IType superType = closure[i]; - methods.addAll(Arrays.asList(superType.getMethods())); - } catch (JavaModelException e) { - JSFCommonPlugin.log(e, "Error getting super type information for bean"); //$NON-NLS-1$ - } - } - - return methods.toArray(new IMethod[methods.size()]); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanProperty.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanProperty.java deleted file mode 100644 index a43bd72fe..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanProperty.java +++ /dev/null @@ -1,253 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ -package org.eclipse.jst.jsf.common.util; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * Represents a single bean property backed by JDT data - * - * This class may not be sub-classed by clients. - * - * @author cbateman - * - */ -public class JDTBeanProperty -{ - /** - * the IMethod for the accessor (either is or get) - */ - private IMethod _getter; - - /** - * the IMethod for a "set" accessor method - */ - private IMethod _setter; - - /** - * The IType that this property belongs to - */ - protected final IType _type; - - /** - * @param type - */ - protected JDTBeanProperty(IType type) - { - _type = type; - } - - /** - * @return true if this property is readable - */ - public boolean isReadable() - { - return _getter != null; - } - - /** - * @return true if this property is writable - */ - public boolean isWritable() - { - return _setter != null; - } - - - /** - * @return the get accessor IMethod or null if none - */ - public IMethod getGetter() { - return _getter; - } - - - - /** - * Set the get accessor IMethod - * @param getter -- may be null to indicate none - */ - void setGetter(IMethod getter) { - _getter = getter; - } - - - /** - * @return the set mutator IMethod or null if none - */ - public IMethod getSetter() { - return _setter; - } - - /** - * @param setter - */ - void setSetter(IMethod setter) { - _setter = setter; - } - - /** - * @return the IType for this property's type or null if it - * cannot determined. Note that null does not necessarily indicate an error - * since some types like arrays of things do not have corresponding JDT IType's - * If typeSignature represents an array, the base element IType is returned - * if possible - */ - public IType getType() - { - final String typeSignature = Signature.getElementType(getTypeSignature()); - return TypeUtil.resolveType(_type, typeSignature); - } - - /** - * @return the number of array nesting levels in typeSignature. - * Returns 0 if not an array. - */ - public int getArrayCount() - { - final String sig = getTypeSignature(); - if (sig == null) - return 0; - return Signature.getArrayCount(sig); - } - - /** - * @return true if property is an enum type, false otherwise or if cannot be resolved - */ - public boolean isEnumType() - { - return TypeUtil.isEnumType(getType()); - } - - /** - * Fully equivalent to: - * - * getTypeSignature(true) - * - * @return the fully resolved (if possible) type signature for - * the property or null if unable to determine. - * - * NOTE: this is the "type erasure" signature, so any type parameters - * will be removed and only the raw type signature will be returned. - */ - public String getTypeSignature() - { - return getTypeSignature(true); - } - - - /** - * @param eraseTypeParameters if true, the returned type has type parameters - * erased. If false, template types are resolved. - * - * @see org.eclipse.jst.jsf.common.util.TypeUtil#resolveTypeSignature(IType, String, boolean) - * for more information on how specific kinds of unresolved generics are resolved - * - * @return the fully resolved (if possible) type signature for - * the property or null if unable to determine. - */ - public String getTypeSignature(boolean eraseTypeParameters) - { - try - { - String unResolvedSig = getUnresolvedType(); - return TypeUtil.resolveTypeSignature(_type, unResolvedSig, eraseTypeParameters); - } - catch (JavaModelException jme) - { - JSFCommonPlugin.log(jme, "Error resolving bean property type signature"); //$NON-NLS-1$ - return null; - } - } - - /** - * For example, if this property was formed from: List<String> getListOfStrings() - * then the list would consist of the signature "Ljava.lang.String;". All - * nested type paramters are resolved - * - * @see org.eclipse.jst.jsf.common.util.TypeUtil#resolveTypeSignature(IType, String, boolean) - * for more information on how specific kinds of unresolved generics are resolved - * - * @return a list of type signatures (fully resolved if possible) - * of this property's bounding type parameters. - */ - public List<String> getTypeParameterSignatures() - { - List<String> signatures = new ArrayList<String>(); - - try - { - final String[] typeParameters = Signature.getTypeArguments(getUnresolvedType()); - //System.err.println(getUnresolvedType()); - for (String parameter : typeParameters) - { - //System.out.println(parameter); - signatures.add(TypeUtil.resolveTypeSignature(_type, parameter, false)); - } - } - catch (JavaModelException jme) - { - JSFCommonPlugin.log(jme, "Error resolving bean property type signature"); //$NON-NLS-1$ - // fall-through and return empty array - } - - return signatures; - } - -// public Map<String, String> getTypeParameterSignatureMap() -// { -// Map<String, String> signatures = new HashMap<String, String>(); -// -// try -// { -// final String[] typeParameters = Signature.getTypeArguments(getUnresolvedType()); -// -// for (String parameter : typeParameters) -// { -// signatures.add(TypeUtil.resolveTypeSignature(_type, parameter, false)); -// } -// } -// catch (JavaModelException jme) -// { -// JSFCommonPlugin.log(jme, "Error resolving bean property type signature"); //$NON-NLS-1$ -// // fall-through and return empty array -// } -// -// return signatures; -// } - - private String getUnresolvedType() throws JavaModelException - { - String typeSig = null; - - // first decide which method to use; getter always gets precendence - if (_getter != null) - { - typeSig = _getter.getReturnType(); - } - // TODO: if no getter or setter could we have been created? - // use setter - else - { - typeSig = _setter.getParameterTypes()[0]; - } - - return typeSig; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java deleted file mode 100644 index 4179f0901..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java +++ /dev/null @@ -1,193 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.common.util; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; - -/** - * A writable version of the JDTBeanProperty object - * - * This class may not be sub-classed by clients - * - * @author cbateman - * - */ -public class JDTBeanPropertyWorkingCopy extends JDTBeanProperty -{ - private final List _setters; - - /** - * the IMethod for the boolean "is" accessor method - */ - private IMethod _isGetter; - - private final Map<String, String> _resolvedSignatureMap; - - /** - * @param type - * @param resolvedSignatureMap - */ - public JDTBeanPropertyWorkingCopy(IType type, Map<String, String> resolvedSignatureMap) - { - super(type); - _setters = new ArrayList(); - _resolvedSignatureMap = resolvedSignatureMap; - } - /** - * Constructor - * @param type - */ - public JDTBeanPropertyWorkingCopy(IType type) - { - super(type); - _setters = new ArrayList(); - _resolvedSignatureMap = new HashMap<String, String>(); - } - - /** - * @return the bean properties spawned from this working copy - * Normally, there is only one property in the array, however, - * since this working copy represents all properties with the same - * name, there could be multiple properties since setters can - * be overloaded by name and could result in zero or one readable - * properties plus zero or more write-only properties with the same - * name. I can't see anywhere in the spec that covers this - * boundary case - */ - public JDTBeanProperty toValueObject() - { - // if the isGetter is present that it takes precedence - // over the the normal getter - IMethod getter = getIsGetter() != null ? - getIsGetter() : getGetter(); - IMethod matchedSetter = null; - - if (getter != null) - { - matchedSetter = determineMatchedSetter(getter); - } - // if there's no getter than pick any setter: there - // are bigger problem when there's no getter than - // ambiguous setters - else if (_setters.size() > 0) - { - matchedSetter = (IMethod) _setters.get(0); - } - - JDTBeanProperty beanProp = new JDTBeanProperty(_type); - beanProp.setGetter(getter); - beanProp.setSetter(matchedSetter); - return beanProp; - - } - - private IMethod determineMatchedSetter(IMethod getter) - { - IMethod matchedSetter = null; - - // if there are no setters, there is no point in proceeding - if (_setters.size() < 1) - { - return null; - } - - try - { - final String getterSig = getResolvedSignature(_type, getter.getReturnType()); - FIND_MATCHING_SETTER:for - (final Iterator it = _setters.iterator(); it.hasNext();) - { - final IMethod setter = (IMethod) it.next(); - assert (setter.getNumberOfParameters() == 1); - final String paramSig = - getResolvedSignature - (_type,setter.getParameterTypes()[0]); - - if (paramSig.equals(getterSig)) - { - // we've found our match since only one - // setter with the same name as the getter - // can have the same matching type for a - // single arg method - matchedSetter = setter; - break FIND_MATCHING_SETTER; - } - } - } - catch (JavaModelException jme) - { - JSFCommonPlugin.log(jme, "Error determining getter return type, bean properties analysis may be inaccurate"); //$NON-NLS-1$ - } - - return matchedSetter; - } - - //@Override - public void setGetter(IMethod getter) { - super.setGetter(getter); - } - - /** - * @param isGetter - */ - public void setIsGetter(IMethod isGetter) { - _isGetter = isGetter; - } - - /** - * @param setter - */ - public void addSetter(IMethod setter) { - if (setter != null - && setter.getNumberOfParameters() == 1) - { - _setters.add(setter); - } - } - - /** - * Not supported on working copy. This is synthetically generated - * on toValueObject() - * @return nothing; throws exception - */ - public final IMethod getSetter() - { - throw new UnsupportedOperationException("Setter not calculated in working copy. Call toValueObject().getSetter()"); //$NON-NLS-1$ - } - - /** - * @return the "is" getter method or null if not found - */ - public IMethod getIsGetter() { - return _isGetter; - } - - private String getResolvedSignature(final IType type, final String unresolved) - { - String resolved = _resolvedSignatureMap.get(unresolved); - - if (resolved == null) - { - resolved = TypeUtil.resolveTypeSignature(_type, unresolved); - _resolvedSignatureMap.put(unresolved, resolved); - } - return resolved; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/TypeUtil.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/TypeUtil.java deleted file mode 100644 index 8a465d8d3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/TypeUtil.java +++ /dev/null @@ -1,597 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.common.util; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jdt.core.IField; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeParameter; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.common.internal.types.TypeConstants; -import org.eclipse.jst.jsf.common.internal.types.TypeInfoCache; - -/** - * Utility for handling IType's and type signatures - * - * Class is static and cannot be extended or instantiated. - * - * @author cbateman - * - */ -public final class TypeUtil -{ - static IType resolveType(final IType owningType, final String typeSignature) - { - // if type signature is already resolved then simply look it up - if (typeSignature.charAt(0) == Signature.C_RESOLVED - || (Signature.getTypeSignatureKind(typeSignature) == Signature.BASE_TYPE_SIGNATURE) - || (Signature.getTypeSignatureKind(typeSignature) == Signature.ARRAY_TYPE_SIGNATURE - && Signature.getElementType(typeSignature).charAt(0) == Signature.C_RESOLVED)) - { - IType type = null; - - try - { - type = owningType.getJavaProject(). - findType(getFullyQualifiedName(typeSignature)); - } - catch (JavaModelException jme) - { - // do nothing; return type == null; - } - - return type; - } - - - return resolveTypeRelative(owningType, typeSignature); - } - - /** - * Fully equivalent to: - * - * #resolveTypeSignature(owningType, typeSignature, true) - * - * If resolved, type signature has generic type parameters erased (absent). - * - * @param owningType - * @param typeSignature - * @return the resolved type signature for typeSignature in owningType or - * typeSignature unchanged if cannot resolve. - */ - public static String resolveTypeSignature(final IType owningType, final String typeSignature) - { - return resolveTypeSignature(owningType, typeSignature, true); - } - - /** - * Resolve typeSignature in the context of owningType. This method will return - * a type erased signture if eraseTypeParameters == true and will attempt to - * resolve and include parameters if eraseTypeParamters == false - * - * NOTE: special rules apply to the way unresolved type parameters and wildcards - * are resolved: - * - * 1) If a fully unresolved type parameter is found, then it will be replaced with Ljava.lang.Object; - * - * i.e. List<T> -> Ljava.util.List<Ljava.lang.Object;>; for any unresolved T. - * - * 2) Any bounded wildcard will be replaced by the bound: - * - * i.e. List<? extends String> -> Ljava.util.List<Ljava.lang.String;>; - * i.e. List<? super String> -> Ljava.util.List<Ljava.lang.String;>; - * - * Note limitation here: bounds that use 'super' will take the "best case" scenario that the list - * type is of that type. - * - * 3) The unbounded wildcard will be replaced by Ljava.lang.Object; - * - * i.e. List<?> -> Ljava.util.List<Ljava.lang.Object;>; - * - * - * The reason for this substition is to return the most accurate reasonable approximation - * of the type within what is known by owningType - * - * @param owningType - * @param typeSignature - * @param eraseTypeParameters if set to false, type parameters are resolved included - * in the signature - * @return the resolved type signature for typeSignature in owningType or - * typeSignature unchanged if cannot resolve. - */ - public static String resolveTypeSignature(final IType owningType, final String typeSignature, boolean eraseTypeParameters) - { - final int sigKind = Signature.getTypeSignatureKind(typeSignature); - - switch (sigKind) - { - case Signature.BASE_TYPE_SIGNATURE: - return typeSignature; - - case Signature.ARRAY_TYPE_SIGNATURE: - { - final String elementType = Signature.getElementType(typeSignature); - - if (Signature.getTypeSignatureKind(elementType) == Signature.BASE_TYPE_SIGNATURE) - { - return typeSignature; - } - - final String resolvedElementType = resolveSignatureRelative(owningType, elementType, eraseTypeParameters); - String resultType = ""; //$NON-NLS-1$ - for (int i = 0; i < Signature.getArrayCount(typeSignature);i++) - { - resultType+=Signature.C_ARRAY; - } - - return resultType+resolvedElementType; - } - - case Signature.TYPE_VARIABLE_SIGNATURE: - return resolveSignatureRelative(owningType, typeSignature, eraseTypeParameters); - - case Signature.CLASS_TYPE_SIGNATURE: - return resolveSignatureRelative(owningType, typeSignature, eraseTypeParameters); - - case Signature.WILDCARD_TYPE_SIGNATURE: - // strip the wildcard and try again. Too bad Signature doesn't seem to have a method - // for this - if (typeSignature.charAt(0) == Signature.C_STAR) - { - return TypeConstants.TYPE_JAVAOBJECT; - } - return resolveTypeSignature(owningType, typeSignature.substring(1), eraseTypeParameters); - - case Signature.CAPTURE_TYPE_SIGNATURE: - // strip the capture and try again - return resolveTypeSignature(owningType, Signature.removeCapture(typeSignature), eraseTypeParameters); -// case Signature.TYPE_VARIABLE_SIGNATURE: -// resolveSignatureRelative(owningType, typeSignature, eraseTypeParameters); - - default: - return typeSignature; - } - } - - /** - * @param owningType -- type relative to which typeSignature will be resolved - * @param typeSignature -- non-array type signature - * @return the resolved type signature if possible or typeSignature if not - */ - private static String resolveSignatureRelative(final IType owningType, final String typeSignature, final boolean eraseTypeParameters) - { - // if already fully resolved, return the input - if (typeSignature.charAt(0) == Signature.C_RESOLVED) - { - return typeSignature; - } - - List<String> typeParameters = new ArrayList<String>(); - - IType resolvedType = resolveTypeRelative(owningType, typeSignature); - - if (resolvedType != null) - { - if (!eraseTypeParameters) - { - // ensure that type parameters are resolved recursively - for (String typeParam : Signature.getTypeArguments(typeSignature)) - { - typeParam = Signature.removeCapture(typeParam); - // check and remove bound wildcarding (extends/super/?) - if (Signature.getTypeSignatureKind(typeParam) == Signature.WILDCARD_TYPE_SIGNATURE) - { - // convert ? to Object, strip extends/super - if (typeParam.charAt(0) == Signature.C_STAR) - { - typeParam = TypeConstants.TYPE_JAVAOBJECT; - } - else - { - typeParam = typeParam.substring(1); - } - } - final String resolvedParameter = - resolveSignatureRelative( - // use the enclosing type, - // *not* the resolved type because - // we need to resolve in that context - owningType, - typeParam, eraseTypeParameters); - typeParameters.add(resolvedParameter); - } - } - - final String resolvedTypeSignature = - Signature.createTypeSignature - (resolvedType.getFullyQualifiedName(), true); - - - if (typeParameters.size() > 0 && !eraseTypeParameters) - { - StringBuffer sb = new StringBuffer(resolvedTypeSignature); - - if (sb.charAt(sb.length()-1) == ';') - { - sb = sb.delete(sb.length()-1, sb.length()); - } - - sb.append("<"); //$NON-NLS-1$ - for(String param : typeParameters) - { - //System.out.println("type param: "+resolvedType.getTypeParameter(param)); - sb.append(param); - } - - // replace the dangling ',' with the closing ">" - sb.append(">;"); //$NON-NLS-1$ - return sb.toString(); - } - - return resolvedTypeSignature; - } - - if (Signature.getTypeSignatureKind(typeSignature) == - Signature.CLASS_TYPE_SIGNATURE - || Signature.getTypeSignatureKind(typeSignature) - == Signature.TYPE_VARIABLE_SIGNATURE) - { - // if we are unable to resolve, check to see if the owning type has - // a parameter by this name - ITypeParameter typeParam = owningType.getTypeParameter(Signature.getSignatureSimpleName(typeSignature)); - - // if we have a type parameter and it hasn't been resolved to a type, - // then assume it is a method template placeholder (i.e. T in ArrayList). - // at runtime these unresolved parameter variables are effectively - // turned into Object's. For example, think List.add(E o). At runtime, - // E will behave exactly like java.lang.Object in that signature - if (typeParam.exists()) - { - return TypeConstants.TYPE_JAVAOBJECT; - } - - // TODO: is there a better way to handle a failure to resolve - // than just garbage out? - //JSFCommonPlugin.log(new Exception("Failed to resolve type: "+typeSignature), "Failed to resolve type: "+typeSignature); //$NON-NLS-1$ //$NON-NLS-2$ - } - - return typeSignature; - } - - private static IType resolveTypeRelative(final IType owningType, final String typeSignature) - { - final String fullName = getFullyQualifiedName(typeSignature); - - IType resolvedType = null; - - try - { - // TODO: this call is only supported on sourceTypes! - String[][] resolved = owningType.resolveType(fullName); - - if (resolved != null && resolved.length > 0) - { - resolvedType = owningType.getJavaProject().findType(resolved[0][0], resolved[0][1]); - } - else - { - resolvedType = resolveInParents(owningType, fullName); - } - } - catch (JavaModelException jme) - { - // do nothing; newType == null - } - - return resolvedType; - } - - /** - * @param type - * @return a type signature for a type - */ - public static String getSignature(IType type) - { - final String fullyQualifiedName = type.getFullyQualifiedName(); - return Signature.createTypeSignature(fullyQualifiedName, true); - } - - - /** - * @param owner - * @param unresolvedSignature - * @return the resolved method signature for unresolvedSignature in owner - */ - public static String resolveMethodSignature(final IType owner, - final String unresolvedSignature) - { - - final String unresolvedSignatureNormalized = - unresolvedSignature.replaceAll("/", "."); //$NON-NLS-1$ //$NON-NLS-2$ - - // get the list of parameters - final String[] parameters = - Signature.getParameterTypes(unresolvedSignatureNormalized); - - for (int i = 0; i < parameters.length; i++) - { - // try to full resolve the type - parameters[i] = resolveTypeSignature(owner, parameters[i]); - } - - // resolve return type - final String resolvedReturn = - resolveTypeSignature(owner, - Signature.getReturnType(unresolvedSignatureNormalized)); - - return Signature.createMethodSignature(parameters, resolvedReturn); - } - - /** - * @param typeSignature - * @return a fully qualified Java class name from a type signature - * i.e. Ljava.lang.String; -> java.lang.String - */ - public static String getFullyQualifiedName(final String typeSignature) - { - final String packageName = Signature.getSignatureQualifier(typeSignature); - final String typeName = Signature.getSignatureSimpleName(typeSignature); - return "".equals(packageName) ? typeName : packageName + "." + typeName; //$NON-NLS-1$//$NON-NLS-2$ - } - - private static IType resolveInParents(IType childType, String fullyQualifiedName) - throws JavaModelException - { - IType resolvedType = null; - - final TypeInfoCache typeInfoCache = TypeInfoCache.getInstance(); - IType[] superTypes = typeInfoCache.getCachedSupertypes(childType); - if (superTypes == null) { - superTypes = typeInfoCache.cacheSupertypesFor(childType); - } - - String[][] resolved; - - LOOP_UNTIL_FIRST_MATCH: - for (int i = 0; i < superTypes.length; i++) - { - final IType type = superTypes[i]; - - resolved = type.resolveType(fullyQualifiedName); - - if (resolved != null && resolved.length > 0) - { - resolvedType = childType.getJavaProject().findType(resolved[0][0], resolved[0][1]); - break LOOP_UNTIL_FIRST_MATCH; - } - } - - return resolvedType; - } - - /** - * Attempts to get a Java IType for a fully qualified signature. Note that - * generic type arguments are generally ignored by JDT when doing such - * look ups. - * - * @param javaProject the project context inside which to resolve the type - * @param fullyResolvedTypeSignature a fully resolved type signature - * @return the IType if resolved, null otherwise - */ - public static IType resolveType(final IJavaProject javaProject, final String fullyResolvedTypeSignature) - { - String fullyQualifiedName = getFullyQualifiedName(fullyResolvedTypeSignature); - fullyQualifiedName = Signature.getTypeErasure(fullyQualifiedName); - try { - return javaProject.findType(fullyQualifiedName); - } catch (JavaModelException e) { - // accessible problem - JSFCommonPlugin.log(e); - return null; - } - } - - /** - * @param type - * @param typeParamSignature -- must be a Type Variable Signature - * @param typeArguments - * @return the signature for the type argument in typeArguments that matches the - * named typeParamSignature in type. - * @throws IllegalArgumentException if typeParamSignature is not valid - * - * For example, given type for java.util.Map, typeParamSignature == "V" and - * typeArguments = {Ljava.util.String;, Lcom.test.Blah;}, the result would be - * the typeArgument that matches "V", which is "Lcom.test.Blah;} - * - * returns null if the match cannot be found. - */ - public static String matchTypeParameterToArgument(final IType type, final String typeParamSignature, final List<String> typeArguments) - { - if (Signature.getTypeSignatureKind(typeParamSignature) != Signature.TYPE_VARIABLE_SIGNATURE) - { - throw new IllegalArgumentException(); - } - - try - { - ITypeParameter[] typeParams = type.getTypeParameters(); - - for (int pos = 0; pos < typeParams.length; pos++) - { - if (typeParams[pos].getElementName().equals(Signature.getSignatureSimpleName(typeParamSignature))) - { - if (pos < typeArguments.size()) - { - // TODO: should typeArguments.size ever != typeParams.length? - return typeArguments.get(pos); - } - } - } - } - catch (JavaModelException e) - { - JSFCommonPlugin.log(e); - } - - return null; - } - - /** - * @param type - * @param fieldName - * @return true if fieldName is a member of type. Note that if type is java.lang.Enum - * then this will always return true since we cannot know what fields the instance has (it could be any enum) - */ - public static boolean isEnumMember(final IType type, final String fieldName) - { - try - { - if (type == null || !isEnumType(type)) - { - throw new IllegalArgumentException("type must be non-null and isEnum()==true"); //$NON-NLS-1$ - } - - if (fieldName == null) - { - throw new IllegalArgumentException("fieldName must be non-null"); //$NON-NLS-1$ - } - - // if type is the java.lang.Enum, always true - if (TypeConstants.TYPE_ENUM_BASE.equals(Signature.createTypeSignature(type.getFullyQualifiedName(), true))) - { - return true; - } - - final IField field = type.getField(fieldName); - - if (field.exists() && field.isEnumConstant()) - { - return true; - } - } - catch (JavaModelException jme) - { - // fall through and return false - } - - return false; - } - - /** - * @param typeSig1 the type signature of the first enum. Must be non-null, fully resolved enum type. - * @param typeSig2 the type signature of the second enum. Must be non-null, fully resolved enum type. - * - * @return true if typeSig1.compareTo(typeSig2) is a legal operation (won't throw a CCE) - */ - public static boolean isEnumsCompareCompatible(final String typeSig1, final String typeSig2) - { - if (typeSig1 == null || typeSig2 == null) - { - throw new IllegalArgumentException("args must not be null"); //$NON-NLS-1$ - } - - if (Signature.getTypeSignatureKind(typeSig1) != Signature.CLASS_TYPE_SIGNATURE - || Signature.getTypeSignatureKind(typeSig2) != Signature.CLASS_TYPE_SIGNATURE) - { - throw new IllegalArgumentException("args must be resolved class types"); //$NON-NLS-1$ - } - - // if one or the other is the raw enum type, then they *may* be comparable; we don't know - if (TypeConstants.TYPE_ENUM_BASE.equals(typeSig1) - || TypeConstants.TYPE_ENUM_BASE.equals(typeSig2)) - { - return true; - } - - // TODO: support the case of enum base type with generic type argument - - // only comparable if is the same class - return typeSig1.equals(typeSig2); - } - - /** - * @param typeSig1 the type signature of the first enum. Must be non-null, fully resolved enum type. - * @param typeSig2 the type signature of the second enum. Must be non-null, fully resolved enum type. - * @return true if instances typeSig1 and typeSig2 can never be equal due - * their being definitively different enum types - */ - public static boolean canNeverBeEqual(final String typeSig1, final String typeSig2) - { - if (typeSig1 == null || typeSig2 == null) - { - throw new IllegalArgumentException("args must not be null"); //$NON-NLS-1$ - } - - if (Signature.getTypeSignatureKind(typeSig1) != Signature.CLASS_TYPE_SIGNATURE - || Signature.getTypeSignatureKind(typeSig2) != Signature.CLASS_TYPE_SIGNATURE) - { - throw new IllegalArgumentException("args must be resolved class types"); //$NON-NLS-1$ - } - - // if either one is the base enum type, then we can't be sure - if (TypeConstants.TYPE_ENUM_BASE.equals(typeSig1) - || TypeConstants.TYPE_ENUM_BASE.equals(typeSig2)) - { - return false; - } - - // if they are definitely not the same enum types, then their values - // can never be equal - return !typeSig1.equals(typeSig2); - } - - - /** - * NOTE: we diverge from IType.isEnum() because we also return true if the base type - * is a java.lang.Enum since we consider this to be "any enumeration type" whereas JDT considers - * it merely a class since it doesn't use an "enum" keyword declaration. - * @param type - * @return true if type is an enum type or is java.lang.Enum - */ - static boolean isEnumType(IType type) - { - if (type == null) - { - return false; - } - - // check if it's the enumeration base type - if (TypeConstants.TYPE_ENUM_BASE.equals(Signature.createTypeSignature(type.getFullyQualifiedName(), true))) - { - return true; - } - - try - { - return type.isEnum(); - } - catch (JavaModelException jme) - { - // log and fallthrough to return false - JSFCommonPlugin.log(jme, "Problem resolving isEnum"); //$NON-NLS-1$ - } - - // if unresolved assume false - return false; - } - - private TypeUtil() - { - // no external instantiation - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/package-info.java deleted file mode 100644 index 239a12524..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle Corporation. - * 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 - * - ********************************************************************************/ - -/** - * Common utility classes. - */ -package org.eclipse.jst.jsf.common.util; diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUpdater.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUpdater.java deleted file mode 100644 index 629624825..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUpdater.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.jsf.common.webxml.internal.AbstractWebXmlUpdater; -import org.eclipse.jst.jsf.common.webxml.internal.WebXmlUpdaterForJ2EE; -import org.eclipse.jst.jsf.common.webxml.internal.WebXmlUpdaterForJavaEE; - - -/** - * Facade for web.xml updater classes WebXmlUpdaterForJavaEE, - * WebXmlUpdaterForJ2EE, and AbstractWebXmlUpdater. Utility class to make - * editing web.xml easy. - * - * @author Debajit Adhikary - * - */ -public class WebXmlUpdater -{ - private final IProject project; - private final IProgressMonitor monitor; - private final AbstractWebXmlUpdater updater; - private final IModelProvider provider; - - /** - * @param project - * @param monitor - */ - public WebXmlUpdater (final IProject project, - final IProgressMonitor monitor) - { - this.project = project; - this.monitor = monitor; - this.provider = ModelProviderManager.getModelProvider(project); - this.updater = initUpdater(); - } - - - /** - * @return Provider object for the webapp this WebXmlUpdater is associated - * with. This may be used by clients to perform additional complex - * updates to web.xml using getProvider.modify(new Runnable(), ...) - */ - public IModelProvider getProvider() - { - return provider; - } - - - /** - * @return True if this webapp is a Java EE app. - */ - public boolean isJavaEEWebapp () - { - return updater instanceof WebXmlUpdaterForJavaEE; - } - - - /** - * @return True if this webapp is a J2EE app - */ - public boolean isJ2EEWebapp () - { - return updater instanceof WebXmlUpdaterForJ2EE; - } - - - /** - * @param servletName - * @param servletClass - * @param loadOnStartup - */ - public void addServlet (final String servletName, - final String servletClass, - final String loadOnStartup) - { - updater.addServlet(servletName, servletClass, loadOnStartup); - } - - - /** - * @param servletClassName - */ - public void removeServlet (final String servletClassName) - { - updater.removeServlet(servletClassName); - } - - - /** - * @param servletName - * @param servletClass - * @param urlPattern - */ - public void addServletMapping (final String servletName, - final String servletClass, - final String urlPattern) - { - updater.addServletMapping(servletName, servletClass, urlPattern); - } - - - /** - * @param filterName - * @param filterClass - */ - public void addFilter (final String filterName, - final String filterClass) - { - updater.addFilter(filterName, filterClass); - } - - - /** - * @param filterName - */ - public void removeFilter (final String filterName) - { - updater.removeFilter(filterName); - } - - - /** - * @param filterName - * @param filterClass - * @param servletName - */ - public void addFilterMapping (final String filterName, - final String filterClass, - final String servletName) - { - updater.addFilterMapping(filterName, filterClass, servletName); - } - - - /** - * @param paramName - * @param paramValue - * @param description - */ - public void addContextParam (final String paramName, - final String paramValue, - final String description) - { - updater.addContextParam(paramName, paramValue, description); - } - - - /** - * @param listenerClass - */ - public void addListener (final String listenerClass) - { - updater.addListener(listenerClass); - } - - - private AbstractWebXmlUpdater initUpdater() - { - final Object webAppObj = ModelProviderManager.getModelProvider(project).getModelObject(); - - if (webAppObj != null) - { - if (webAppObj instanceof WebApp) // Java EE - return new WebXmlUpdaterForJavaEE(webAppObj, project, getProvider(), monitor); - else if (webAppObj instanceof org.eclipse.jst.j2ee.webapplication.WebApp) // J2EE - return new WebXmlUpdaterForJ2EE(webAppObj, project, getProvider(), monitor); - } - - // Control should never come here - throw new IllegalArgumentException("Unable to resolve WebApp object for updating web.xml"); //$NON-NLS-1$ - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtils.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtils.java deleted file mode 100644 index 48d22505e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; - - -/** - * Web.xml utilities. - * - * @author Debajit Adhikary - * - */ -public class WebXmlUtils -{ - /** - * Path to deployment descriptor of webapp - */ - public static final IPath WEB_XML_PATH = new Path("WEB-INF").append("web.xml"); //$NON-NLS-1$ //$NON-NLS-2$ -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJ2EE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJ2EE.java deleted file mode 100644 index 27676281c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJ2EE.java +++ /dev/null @@ -1,543 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml; - - -import java.util.List; - -import org.eclipse.jst.j2ee.common.CommonFactory; -import org.eclipse.jst.j2ee.common.Description; -import org.eclipse.jst.j2ee.common.Listener; -import org.eclipse.jst.j2ee.common.ParamValue; -import org.eclipse.jst.j2ee.webapplication.Filter; -import org.eclipse.jst.j2ee.webapplication.FilterMapping; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.ServletMapping; -import org.eclipse.jst.j2ee.webapplication.ServletType; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory; -import org.eclipse.jst.j2ee.webapplication.internal.impl.ServletTypeImpl; - - -/** - * Web.xml editing utilities for J2EE (Servlet 2.4 and lower versions). - * - * @author Debajit Adhikary - * - */ -public class WebXmlUtilsForJ2EE -{ - /** - * @param webapp - * @param servletName - * @param servletClass - * @param loadOnStartup - */ - public static void addServlet (final WebApp webapp, - final String servletName, - final String servletClass, - final String loadOnStartup) - { - if (existsServlet(webapp, servletName, servletClass)) - return; - - // Create new servlet - - final Servlet servlet = WebapplicationFactory.eINSTANCE.createServlet(); - servlet.setServletName(servletName); - servlet.setLoadOnStartup(new Integer(loadOnStartup)); - - final ServletType servletType = WebapplicationFactory.eINSTANCE.createServletType(); - servletType.setClassName(servletClass); - servlet.setWebType(servletType); - - webapp.getServlets().add(servlet); - } - - - /** - * @param webapp - * @param servletName - * @param servletClass - * @return true if the specified servlet is declared for use in webapp - */ - public static boolean existsServlet (final WebApp webapp, - final String servletName, - final String servletClass) - { - return findServlet(webapp, servletName, servletClass) != null; - } - - - /** - * @param webapp - * Webapp in which to look for - * @param servletName - * Servlet name - * @param servletClass - * Servlet class - * - * @return The servlet containing the specified servlet-name and - * servlet-class in web.xml - */ - public static Servlet findServlet (final WebApp webapp, - final String servletName, - final String servletClass) - { - for (final Object s : webapp.getServlets()) - { - final Servlet servlet = (Servlet) s; - if (servlet.getServletName().equals(servletName) - && ((ServletType) servlet.getWebType()).getClassName().equals(servletClass)) - { - return servlet; - } - } - - return null; - } - - - /** - * @param webApp - * @param servletClassName - * @return the servlet or null if not found - */ - public static Servlet findServlet (final WebApp webApp, - final String servletClassName) - { - for (final Object servlet : webApp.getServlets()) - { - final org.eclipse.jst.j2ee.webapplication.Servlet j2eeServlet = (org.eclipse.jst.j2ee.webapplication.Servlet) servlet; - final String servletClass = ((ServletTypeImpl) j2eeServlet.getWebType()).getClassName(); - if (servletClass.equals(servletClassName)) - return j2eeServlet; - } - return null; - } - - - /** - * @param webapp - * @param servletName - * @return the servlet or null if not found - */ - public static Servlet findServletByName (final WebApp webapp, - final String servletName) - { - for (final Object s : webapp.getServlets()) - { - final Servlet servlet = (Servlet) s; - if (servlet.getServletName().trim().equals(servletName)) - return servlet; - } - - return null; - } - - - /** - * @param webApp - * @param servlet - */ - public static void removeServlet (final WebApp webApp, - final Servlet servlet) - { - webApp.getServlets().remove(servlet); - } - - - /** - * @param webapp - * @param servletName - * @param servletClass - * @param urlPattern - */ - public static void addServletMapping (final WebApp webapp, - final String servletName, - final String servletClass, - final String urlPattern) - { - if (existsServletMapping(webapp, servletName, urlPattern)) - return; - - final Servlet servlet = findServlet(webapp, servletName, servletClass); - if (servlet == null) - throw new IllegalArgumentException("Cannot create servlet mapping with servlet name \"" //$NON-NLS-1$ - + servletName + "\" and URL pattern \"" //$NON-NLS-1$ - + urlPattern + "\". No corresponding servlet is defined."); //$NON-NLS-1$ - - final ServletMapping servletMapping = WebapplicationFactory.eINSTANCE.createServletMapping(); - servletMapping.setServlet(servlet); - servletMapping.setName(servletName); - servletMapping.setUrlPattern(urlPattern); - - webapp.getServletMappings().add(servletMapping); - } - - - /** - * @param webapp - * @param servletName - * @param urlPattern - * @return true if the servlet mapping exists - */ - public static boolean existsServletMapping (final WebApp webapp, - final String servletName, - final String urlPattern) - { - return findServletMapping(webapp, servletName, urlPattern) != null; - } - - - /** - * @param webapp - * @param servletName - * @param urlPattern - * @return the servlet mapping - */ - public static ServletMapping findServletMapping (final WebApp webapp, - final String servletName, - final String urlPattern) - { - for (final Object mapping : webapp.getServletMappings()) - { - final ServletMapping servletMapping = (ServletMapping) mapping; - if (servletMapping.getName().equals(servletName) - && servletMapping.getUrlPattern().equals(urlPattern)) - { - return servletMapping; - } - } - - return null; - } - - - /** - * @param webApp - * @param servlet - */ - public static void removeServletMappings (final WebApp webApp, - final Servlet servlet) - { - final List mappings = webApp.getServletMappings(); - String servletName = servlet.getServletName(); - - if (servletName != null) - { - servletName = servletName.trim(); - for (int i = mappings.size() - 1; i >= 0; --i) - { - final ServletMapping mapping = (ServletMapping) mappings.get(i); - if (mapping != null && mapping.getServlet().getServletName() != null - && mapping.getServlet().getServletName().trim().equals(servletName)) - { - mappings.remove(mapping); - } - } - } - } - - - /** - * @param webapp - * @param filterName - * @param filterClass - */ - public static void addFilter (final WebApp webapp, - final String filterName, - final String filterClass) - { - if (existsFilter(webapp, filterName, filterClass)) - return; - - webapp.getFilters().add(createFilter(filterName, filterClass)); - } - - - /** - * @param filterName - * @param filterClass - * @return the filter or null if not found. - */ - public static Filter createFilter (final String filterName, - final String filterClass) - { - final Filter filter = WebapplicationFactory.eINSTANCE.createFilter(); - filter.setName(filterName); - filter.setFilterClassName(filterClass); - return filter; - } - - - /** - * @param webapp - * @param filterName - * @param filterClass - * @return true if the filter exists. - */ - public static boolean existsFilter (final WebApp webapp, - final String filterName, - final String filterClass) - { - return findFilter(webapp, filterName, filterClass) != null; - } - - - /** - * @param webapp - * @param filterName - * @param filterClass - * @return the filter or null if not found. - */ - public static Filter findFilter (final WebApp webapp, - final String filterName, - final String filterClass) - { - for (final Object f : webapp.getFilters()) - { - final Filter filter = (Filter) f; - if (filter.getName().trim().equals(filterName) - && filter.getFilterClassName().trim().equals(filterClass)) - { - return filter; - } - } - - return null; - } - - - /** - * @param webApp - * @param filterClassName - * @return the filter or null if not found. - */ - public static Filter findFilter (final WebApp webApp, - final String filterClassName) - { - for (final Object filter : webApp.getFilters()) - { - if (((Filter) filter).getFilterClassName().trim().equals(filterClassName)) - return (Filter) filter; - } - - return null; - } - - - /** - * @param webapp - * @param filterName - * @param filterClass - * @param servletName - */ - public static void addFilterMapping (final WebApp webapp, - final String filterName, - final String filterClass, - final String servletName) - { - if (existsFilterMapping(webapp, filterName, servletName)) - return; - - - // Find corresponding filter - final Filter filter = findFilter(webapp, filterName, filterClass); - if (filter == null) - throw new IllegalArgumentException("Cannot create filter mapping with filter name \"" //$NON-NLS-1$ - + filterName + "\" and servlet name \"" //$NON-NLS-1$ - + servletName + "\". No corresponding filter is defined."); //$NON-NLS-1$ - - - // Find corresponding servlet - final Servlet servlet = findServletByName(webapp, servletName); - if (servlet == null) - throw new IllegalArgumentException("Cannot create filter mapping with filter name \"" //$NON-NLS-1$ - + filterName + "\" and servlet name \"" //$NON-NLS-1$ - + servletName + "\". No corresponding servlet is defined."); //$NON-NLS-1$ - - - // Create new filter mapping - final FilterMapping filterMapping = WebapplicationFactory.eINSTANCE.createFilterMapping(); - filterMapping.setFilter(filter); - filterMapping.setServlet(servlet); - filterMapping.setServletName(servletName); - - webapp.getFilterMappings().add(filterMapping); - } - - - /** - * @param webapp - * @param filterName - * @param servletName - * @return true if the filter mapping exists - */ - public static boolean existsFilterMapping (final WebApp webapp, - final String filterName, - final String servletName) - { - return findFilterMapping(webapp, filterName, servletName) != null; - } - - - /** - * @param webapp - * @param filterName - * @param servletName - * @return the filter mapping or null if it doesn't exist. - */ - public static FilterMapping findFilterMapping (final WebApp webapp, - final String filterName, - final String servletName) - { - for (final Object fm : webapp.getFilterMappings()) - { - final FilterMapping filterMapping = (FilterMapping) fm; - - if (filterMapping.getFilter().getName().trim().equals(filterName) - && filterMapping.getServletName().equals(servletName)) - { - return filterMapping; - } - } - - return null; - } - - - /** - * @param webApp - * @param paramName - * @param paramValue - * @param description - */ - public static void addContextParam (final WebApp webApp, - final String paramName, - final String paramValue, - final String description) - { - if (existsContextParam(webApp, paramName, paramValue)) - return; - - webApp.getContextParams().add(createContextParam(paramName, paramValue, description)); - } - - - /** - * @param paramName - * @param paramValue - * @param descriptionString - * @return the param value or null if doesn't exist - */ - public static ParamValue createContextParam (final String paramName, - final String paramValue, - final String descriptionString) - { - final ParamValue param = CommonFactory.eINSTANCE.createParamValue(); - param.setName(paramName); - param.setValue(paramValue); - - if (descriptionString != null) - { - final Description description = CommonFactory.eINSTANCE.createDescription(); - description.setValue(descriptionString); - param.getDescriptions().add(description); - } - - return param; - } - - - /** - * @param webApp - * @param paramName - * @param paramValue - * @return true if the context param exists. - */ - public static boolean existsContextParam (final WebApp webApp, - final String paramName, - final String paramValue) - { - return findContextParam(webApp, paramName, paramValue) != null; - } - - - /** - * @param webApp - * @param paramName - * @param paramValue - * @return the param value or null if not found - */ - public static ParamValue findContextParam (final WebApp webApp, - final String paramName, - final String paramValue) - { - for (final Object param : webApp.getContextParams()) - { - final ParamValue contextParam = (ParamValue) param; - if (contextParam.getName().equals(paramName) - && contextParam.getValue().equals(paramValue)) - { - return contextParam; - } - } - - return null; - } - - - /** - * @param webapp - * @param listenerClass - */ - public static void addListener (final WebApp webapp, - final String listenerClass) - { - if (existsListener(webapp, listenerClass)) - return; - - // Create new listener - final Listener listener = CommonFactory.eINSTANCE.createListener(); - listener.setListenerClassName(listenerClass); - - webapp.getListeners().add(listener); - } - - - /** - * @param webapp - * @param listenerClass - * @return true if the listener exists - */ - public static boolean existsListener (final WebApp webapp, - final String listenerClass) - { - return findListener(webapp, listenerClass) != null; - } - - - /** - * @param webapp - * @param listenerClass - * @return the listener or null if not found - */ - public static Listener findListener (final WebApp webapp, - final String listenerClass) - { - for (final Object listener : webapp.getListeners()) - if (((Listener) listener).getListenerClassName().equals(listenerClass)) - return (Listener) listener; - - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJavaEE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJavaEE.java deleted file mode 100644 index c6ccd950e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJavaEE.java +++ /dev/null @@ -1,552 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml; - -import java.util.List; - -import org.eclipse.jst.javaee.core.Description; -import org.eclipse.jst.javaee.core.JavaeeFactory; -import org.eclipse.jst.javaee.core.Listener; -import org.eclipse.jst.javaee.core.ParamValue; -import org.eclipse.jst.javaee.core.UrlPatternType; -import org.eclipse.jst.javaee.web.Filter; -import org.eclipse.jst.javaee.web.FilterMapping; -import org.eclipse.jst.javaee.web.Servlet; -import org.eclipse.jst.javaee.web.ServletMapping; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.javaee.web.WebFactory; - - -/** - * Web.xml editing utilities for Java EE. - * - * @author Debajit Adhikary - * - */ -/** - * @author cbateman - * - */ -/** - * @author cbateman - * - */ -/** - * @author cbateman - * - */ -public class WebXmlUtilsForJavaEE -{ - /** - * @param webapp - * @param servletName - * @param servletClass - * @param loadOnStartup - */ - public static void addServlet (final WebApp webapp, - final String servletName, - final String servletClass, - final String loadOnStartup) - { - if (existsServlet(webapp, servletName, servletClass)) - return; - - // Create new servlet - final Servlet servlet = WebFactory.eINSTANCE.createServlet(); - servlet.setServletName(servletName); - servlet.setServletClass(servletClass); - servlet.setLoadOnStartup(loadOnStartup); - - webapp.getServlets().add(servlet); - } - - - /** - * @param webapp - * @param servletName - * @param servletClass - * @return true if the servlet exists. - */ - public static boolean existsServlet (final WebApp webapp, - final String servletName, - final String servletClass) - { - return findServlet(webapp, servletName, servletClass) != null; - } - - - /** - * @param webapp - * @param servletName - * @param servletClass - * @return the servlet or null if not found. - */ - public static Servlet findServlet (final WebApp webapp, - final String servletName, - final String servletClass) - { - for (final Object s : webapp.getServlets()) - { - final Servlet servlet = (Servlet) s; - if (servlet.getServletName().equals(servletName) && servlet.getServletClass().equals(servletClass)) - { - return servlet; - } - } - - return null; - } - - - /** - * @param servletName - * @param webApp - * @return the servlet or null if not found. - */ - public static Servlet findServlet (final String servletName, - final WebApp webApp) - { - for (final Object servlet : webApp.getServlets()) - { - if (((Servlet) servlet).getServletClass().trim().equals(servletName)) - return (Servlet) servlet; - } - - return null; - } - - - /** - * @param webApp - * @param servlet - */ - public static void removeServlet (final WebApp webApp, - final Servlet servlet) - { - webApp.getServlets().remove(servlet); - } - - - /** - * @param webApp - * @param servletName - * @param servletClass - * @param urlPatternString - */ - public static void addServletMapping (final WebApp webApp, - final String servletName, - final String servletClass, - final String urlPatternString) - { - if (existsServletMapping(webApp, servletName, urlPatternString)) - return; - - // Create new servlet mapping. - final ServletMapping servletMapping = WebFactory.eINSTANCE.createServletMapping(); - servletMapping.setServletName(servletName); - servletMapping.getUrlPatterns().add(createUrlPattern(urlPatternString)); - - webApp.getServletMappings().add(servletMapping); - } - - - /** - * @param webApp - * @param servletName - * @param urlPatternString - * @return true if the servlet mapping exists. - */ - public static boolean existsServletMapping (final WebApp webApp, - final String servletName, - final String urlPatternString) - { - return findServletMapping(webApp, servletName, urlPatternString) != null; - } - - - /** - * @param webApp - * @param servletName - * @param urlPatternString - * @return the servlet mapping or null if doesn't exist. - */ - public static ServletMapping findServletMapping (final WebApp webApp, - final String servletName, - final String urlPatternString) - { - for (final Object mapping : webApp.getServletMappings()) - { - final ServletMapping servletMappingToCheck = (ServletMapping) mapping; - if (servletMappingToCheck.getServletName().trim().equals(servletName)) - { - // We found a servlet with the same name. Check for urls - for (final Object pattern : servletMappingToCheck.getUrlPatterns()) - if (((UrlPatternType) pattern).getValue().equals(urlPatternString)) - return servletMappingToCheck; - } - } - - return null; - } - - /** - * @param webApp - * @param servlet - */ - public static void removeServletMappings (final WebApp webApp, - final Servlet servlet) - { - final List mappings = webApp.getServletMappings(); - String servletName = servlet.getServletName(); - - if (servletName != null) - { - servletName = servletName.trim(); - for (int i = mappings.size() - 1; i >= 0; --i) - { - final ServletMapping mapping = (ServletMapping) mappings.get(i); - if (mapping != null && mapping.getServletName() != null && mapping.getServletName().trim().equals(servletName)) - { - mappings.remove(mapping); - } - } - } - } - - - /** - * @param webapp - * @param filterName - * @param filterClass - */ - public static void addFilter (final WebApp webapp, - final String filterName, - final String filterClass) - { - if (existsFilter(webapp, filterName, filterClass)) - return; - - webapp.getFilters().add(createFilter(filterName, filterClass)); - } - - - /** - * @param filterName - * @param filterClass - * @return the filter or null if it doesn't exist. - */ - public static Filter createFilter (final String filterName, - final String filterClass) - { - final Filter filter = WebFactory.eINSTANCE.createFilter(); - filter.setFilterName(filterName); - filter.setFilterClass(filterClass); - return filter; - } - - - /** - * @param webapp - * @param filterName - * @param filterClass - * @return true if the filter exists. - */ - public static boolean existsFilter (final WebApp webapp, - final String filterName, - final String filterClass) - { - return findFilter(webapp, filterName, filterClass) != null; - } - - - /** - * @param webapp - * @param filterName - * @param filterClass - * @return the filter or null if not found. - */ - public static Filter findFilter (final WebApp webapp, - final String filterName, - final String filterClass) - { - for (final Object f : webapp.getFilters()) - { - final Filter filter = (Filter) f; - if (filter.getFilterName().trim().equals(filterName) && filter.getFilterClass().trim().equals(filterClass)) - { - return filter; - } - } - - return null; - } - - - /** - * @param webApp - * @param filterClassName - * @return the filter or null if not found. - */ - public static Filter findFilter (final WebApp webApp, - final String filterClassName) - { - for (final Object filter : webApp.getFilters()) - { - if (((Filter) filter).getFilterClass().trim().equals(filterClassName)) - return (Filter) filter; - } - - return null; - } - - - /** - * @param webApp - * @param filter - */ - public static void removeFilter (final WebApp webApp, - final Filter filter) - { - webApp.getFilters().remove(filter); - } - - - /** - * @param webapp - * @param filterName - * @param servletName - */ - public static void addFilterMapping (final WebApp webapp, - final String filterName, - final String servletName) - { - if (existsFilterMapping(webapp, filterName, servletName)) - return; - - webapp.getFilterMappings().add(createFilterMapping(filterName, servletName)); - } - - - /** - * @param filterName - * @param servletName - * @return the filter mapping or null if not found. - */ - public static FilterMapping createFilterMapping (final String filterName, - final String servletName) - { - final FilterMapping filterMapping = WebFactory.eINSTANCE.createFilterMapping(); - filterMapping.setFilterName(filterName); - filterMapping.getServletNames().add(servletName); - - return filterMapping; - } - - - /** - * @param webapp - * @param filterName - * @param servletName - * @return true if the filter mapping exists. - */ - public static boolean existsFilterMapping (final WebApp webapp, - final String filterName, - final String servletName) - { - return findFilterMapping(webapp, filterName, servletName) != null; - } - - - /** - * @param webapp - * @param filterName - * @param servletName - * @return the filter mapping or null. - */ - public static FilterMapping findFilterMapping (final WebApp webapp, - final String filterName, - final String servletName) - { - for (final Object fm : webapp.getFilterMappings()) - { - final FilterMapping filterMapping = (FilterMapping) fm; - - if (filterMapping.getFilterName().trim().equals(filterName) && filterMapping.getServletNames().contains(servletName)) - { - return filterMapping; - } - } - - return null; - } - - - /** - * @param webApp - * @param filter - */ - public static void removeFilterMappings (final WebApp webApp, - final Filter filter) - { - final List mappings = webApp.getFilterMappings(); - String filterName = filter.getFilterName(); - - if (filterName != null) - { - filterName = filterName.trim(); - for (int i = mappings.size() - 1; i >= 0; --i) - { - final FilterMapping mapping = (FilterMapping) mappings.get(i); - if (mapping != null && mapping.getFilterName() != null && mapping.getFilterName().trim().equals(filterName)) - { - mappings.remove(mapping); - } - } - } - } - - - /** - * @param webApp - * @param paramName - * @param paramValue - * @param description - */ - public static void addContextParam (final WebApp webApp, - final String paramName, - final String paramValue, - final String description) - { - if (existsContextParam(webApp, paramName, paramValue)) - return; - - webApp.getContextParams().add(createContextParam(paramName, paramValue, description)); - } - - - /** - * @param paramName - * @param paramValue - * @param descriptionString - * @return the param value or null if not found. - */ - public static ParamValue createContextParam (final String paramName, - final String paramValue, - final String descriptionString) - { - final ParamValue param = JavaeeFactory.eINSTANCE.createParamValue(); - param.setParamName(paramName); - param.setParamValue(paramValue); - - if (descriptionString != null) - { - final Description description = JavaeeFactory.eINSTANCE.createDescription(); - description.setValue(descriptionString); - param.getDescriptions().add(description); - } - - - return param; - } - - - /** - * @param webApp - * @param paramName - * @param paramValue - * @return true if the context param exists. - */ - public static boolean existsContextParam (final WebApp webApp, - final String paramName, - final String paramValue) - { - return findContextParam(webApp, paramName, paramValue) != null; - } - - - /** - * @param webApp - * @param paramName - * @param paramValue - * @return the param value or null if not found. - */ - public static ParamValue findContextParam (final WebApp webApp, - final String paramName, - final String paramValue) - { - for (final Object param : webApp.getContextParams()) - { - final ParamValue contextParam = (ParamValue) param; - if (contextParam.getParamName().equals(paramName) && contextParam.getParamValue().equals(paramValue)) - return contextParam; - } - - return null; - } - - - /** - * @param webapp - * @param listenerClass - */ - public static void addListener (final WebApp webapp, - final String listenerClass) - { - if (existsListener(webapp, listenerClass)) - return; - - // Create new listener - final Listener listener = JavaeeFactory.eINSTANCE.createListener(); - listener.setListenerClass(listenerClass); - - webapp.getListeners().add(listener); - } - - - /** - * @param webapp - * @param listenerClass - * @return true if the listener exists. - */ - public static boolean existsListener (final WebApp webapp, - final String listenerClass) - { - return findListener(webapp, listenerClass) != null; - } - - - /** - * @param webapp - * @param listenerClass - * @return the listener or null if not found. - */ - public static Listener findListener (final WebApp webapp, - final String listenerClass) - { - for (final Object listener : webapp.getListeners()) - if (((Listener) listener).getListenerClass().equals(listenerClass)) - return (Listener) listener; - - return null; - } - - - /** - * @param urlPatternString - * @return the UrlPattern or null. - */ - public static UrlPatternType createUrlPattern (final String urlPatternString) - { - final UrlPatternType urlPattern = JavaeeFactory.eINSTANCE.createUrlPatternType(); - urlPattern.setValue(urlPatternString); - return urlPattern; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/AbstractWebXmlUpdater.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/AbstractWebXmlUpdater.java deleted file mode 100644 index d16f3d8f5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/AbstractWebXmlUpdater.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.j2ee.model.IModelProvider; - - -/** - * Abstract class to define web-xml editing interface. Users may use the - * WebXmlUpdater facade class for convenient web.xml editing. - * - * @author Debajit Adhikary - * - */ -public abstract class AbstractWebXmlUpdater -{ - /** - * the web app object. JavaEE has own type and J2EE has another. They are not object compatible. - */ - protected final Object webAppObj; - /** - * the project - */ - protected final IProject project; - /** - * the model provider used to modify the model - */ - protected final IModelProvider provider; - /** - * the progress monitor - */ - protected final IProgressMonitor monitor; - - - /** - * @param webAppObj - * @param project - * @param provider - * @param monitor - */ - public AbstractWebXmlUpdater (final Object webAppObj, - final IProject project, - final IModelProvider provider, - final IProgressMonitor monitor) - { - this.webAppObj = webAppObj; - this.project = project; - this.provider = provider; - this.monitor = monitor; - } - - - /** - * @param servletName - * @param servletClass - * @param loadOnStartup - */ - public abstract void addServlet (final String servletName, - final String servletClass, - final String loadOnStartup); - - - /** - * @param servletName - * @param servletClass - * @param urlPattern - */ - public abstract void addServletMapping (final String servletName, - final String servletClass, - final String urlPattern); - - - /** - * Removes a servlet and its associated mappings from web.xml. - * - * @param servletClassName - * Fully qualified classname of servlet class to remove. - */ - public abstract void removeServlet (final String servletClassName); - - - /** - * @param filterName - * @param filterClass - */ - public abstract void addFilter (final String filterName, - final String filterClass); - - - /** - * Removes a filter and its associated mappings from web.xml. - * - * @param filterName - */ - public abstract void removeFilter (final String filterName); - - - /** - * @param filterName - * @param filterClass - * @param servletName - */ - public abstract void addFilterMapping (final String filterName, - final String filterClass, - final String servletName); - - - /** - * @param paramName - * @param paramValue - * @param description - */ - public abstract void addContextParam (final String paramName, - final String paramValue, - final String description); - - - /** - * @param listenerClass - */ - public abstract void addListener (final String listenerClass); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/WebXmlUpdaterForJ2EE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/WebXmlUpdaterForJ2EE.java deleted file mode 100644 index 5cf5f8ff8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/WebXmlUpdaterForJ2EE.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.j2ee.webapplication.Filter; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtils; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJ2EE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.ContextParamAdderForJ2EE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.FilterAdderForJ2EE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.FilterMapperAdderForJ2EE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.FilterRemoverForJavaEE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.ListenerAdderForJ2EE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.ServletAdderForJ2EE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.ServletMappingAdderForJ2EE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.ServletRemoverForJavaEE; - - -/** - * @author Debajit Adhikary - * - */ -public class WebXmlUpdaterForJ2EE extends AbstractWebXmlUpdater -{ - private final WebApp webApp; - - - /** - * @param webAppObj - * @param project - * @param provider - * @param monitor - */ - public WebXmlUpdaterForJ2EE (final Object webAppObj, - final IProject project, - final IModelProvider provider, - final IProgressMonitor monitor) - { - super(webAppObj, project, provider, monitor); - this.webApp = (WebApp) webAppObj; - } - - - @Override - public void addServlet (final String servletName, - final String servletClass, - final String loadOnStartup) - { - provider.modify(new ServletAdderForJ2EE(project, servletName, servletClass, loadOnStartup), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void addServletMapping (final String servletName, - final String servletClass, - final String urlPattern) - { - provider.modify(new ServletMappingAdderForJ2EE(project, servletName, servletClass, urlPattern), WebXmlUtils.WEB_XML_PATH); - } - - // TODO: needs fixing - @Override - public void removeServlet (final String servletClassName) - { - final Servlet servlet = WebXmlUtilsForJ2EE.findServlet(webApp, servletClassName); - if (servlet == null) - throw new IllegalArgumentException("Cannot find servlet named \"" + servletClassName + "\""); //$NON-NLS-1$//$NON-NLS-2$ - - provider.modify(new ServletRemoverForJavaEE(project, servletClassName), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void addFilter (final String filterName, - final String filterClass) - { - provider.modify(new FilterAdderForJ2EE(project, filterName, filterClass), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void removeFilter (final String filterClassName) - { - final Filter filter = WebXmlUtilsForJ2EE.findFilter(webApp, filterClassName); - if (filter == null) - throw new IllegalArgumentException("Cannot find filter named \"" + filterClassName + "\""); //$NON-NLS-1$//$NON-NLS-2$ - - provider.modify(new FilterRemoverForJavaEE(project, filterClassName), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void addFilterMapping (final String filterName, - final String filterClass, - final String servletName) - { - provider.modify(new FilterMapperAdderForJ2EE(project, filterName, filterClass, servletName), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void addContextParam (final String paramName, - final String paramValue, - final String description) - { - provider.modify(new ContextParamAdderForJ2EE(project, paramName, paramValue, description), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void addListener (final String listenerClass) - { - provider.modify(new ListenerAdderForJ2EE(project, listenerClass), WebXmlUtils.WEB_XML_PATH); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/WebXmlUpdaterForJavaEE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/WebXmlUpdaterForJavaEE.java deleted file mode 100644 index 15615c621..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/WebXmlUpdaterForJavaEE.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2009 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal; - -import static org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE.findFilter; -import static org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE.findServlet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jst.j2ee.model.IModelProvider; -import org.eclipse.jst.javaee.web.Filter; -import org.eclipse.jst.javaee.web.Servlet; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtils; -import org.eclipse.jst.jsf.common.webxml.internal.operations.ContextParamAdderForJavaEE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.FilterAdderForJavaEE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.FilterMapperAdderForJavaEE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.FilterRemoverForJavaEE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.ListenerAdderForJavaEE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.ServletAdderForJavaEE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.ServletMappingAdderForJavaEE; -import org.eclipse.jst.jsf.common.webxml.internal.operations.ServletRemoverForJavaEE; - - -/** - * @author Debajit Adhikary - * - */ -public class WebXmlUpdaterForJavaEE extends AbstractWebXmlUpdater -{ - private final WebApp webApp; - - - /** - * @param webAppObj - * @param project - * @param provider - * @param monitor - */ - public WebXmlUpdaterForJavaEE (final Object webAppObj, - final IProject project, - final IModelProvider provider, - final IProgressMonitor monitor) - { - super(webAppObj, project, provider, monitor); - this.webApp = (WebApp) webAppObj; - } - - - @Override - public void addServlet (final String servletName, - final String servletClass, - final String loadOnStartup) - { - provider.modify(new ServletAdderForJavaEE(project, servletName, servletClass, loadOnStartup), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void removeServlet (final String servletClassName) - { - final Servlet servlet = findServlet(servletClassName, webApp); - if (servlet == null) - throw new IllegalArgumentException("Cannot find servlet named \"" + servletClassName + "\""); //$NON-NLS-1$//$NON-NLS-2$ - - provider.modify(new ServletRemoverForJavaEE(project, servletClassName), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void addServletMapping (final String servletName, - final String servletClass, - final String urlPattern) - { - provider.modify(new ServletMappingAdderForJavaEE(project, servletName, servletClass, urlPattern), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void addFilter (final String filterName, - final String filterClass) - { - provider.modify(new FilterAdderForJavaEE(project, filterName, filterClass), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void removeFilter (final String filterClassName) - { - final Filter filter = findFilter(webApp, filterClassName); - if (filter == null) - throw new IllegalArgumentException("Cannot find filter named \"" + filterClassName + "\""); //$NON-NLS-1$//$NON-NLS-2$ - - provider.modify(new FilterRemoverForJavaEE(project, filterClassName), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void addFilterMapping (final String filterName, - final String filterClass, - final String servletName) - { - provider.modify(new FilterMapperAdderForJavaEE(project, filterName, servletName), WebXmlUtils.WEB_XML_PATH); - } - - - - @Override - public void addContextParam (final String paramName, - final String paramValue, - final String description) - { - provider.modify(new ContextParamAdderForJavaEE(project, paramName, paramValue, description), WebXmlUtils.WEB_XML_PATH); - } - - - @Override - public void addListener (final String listenerClass) - { - provider.modify(new ListenerAdderForJavaEE(project, listenerClass), WebXmlUtils.WEB_XML_PATH); - }} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ContextParamAdderForJ2EE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ContextParamAdderForJ2EE.java deleted file mode 100644 index 1ea49e4b3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ContextParamAdderForJ2EE.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJ2EE; - - -/** - * Runnable to add a context-param to web.xml. - * - * @author Debajit Adhikary - * - */ -public class ContextParamAdderForJ2EE implements Runnable -{ - private final IProject project; - private final String paramName; - private final String paramValue; - private final String description; - - - /** - * @param project - * @param paramName - * @param paramValue - * @param description - */ - public ContextParamAdderForJ2EE (final IProject project, - final String paramName, - final String paramValue, - final String description) - { - this.project = project; - this.paramName = paramName; - this.paramValue = paramValue; - this.description = description; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJ2EE.addContextParam(webApp, paramName, paramValue, description); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ContextParamAdderForJavaEE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ContextParamAdderForJavaEE.java deleted file mode 100644 index 7b9aae749..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ContextParamAdderForJavaEE.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE; - - -/** - * Runnable to add a context-param to web.xml. - * - * @author Debajit Adhikary - * - */ -public class ContextParamAdderForJavaEE implements Runnable -{ - private final IProject project; - private final String paramName; - private final String paramValue; - private final String description; - - - /** - * @param project - * @param paramName - * @param paramValue - * @param description - */ - public ContextParamAdderForJavaEE (final IProject project, - final String paramName, - final String paramValue, - final String description) - { - this.project = project; - this.paramName = paramName; - this.paramValue = paramValue; - this.description = description; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJavaEE.addContextParam(webApp, paramName, paramValue, description); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterAdderForJ2EE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterAdderForJ2EE.java deleted file mode 100644 index d1ad0f995..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterAdderForJ2EE.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJ2EE; - - -/** - * Runnable to add a filter to web.xml. - * - * @author Debajit Adhikary - * - */ -public class FilterAdderForJ2EE implements Runnable -{ - private final IProject project; - private final String filterName; - private final String filterClass; - - - /** - * @param project - * @param filterName - * @param filterClass - */ - public FilterAdderForJ2EE (final IProject project, - final String filterName, - final String filterClass) - { - this.project = project; - this.filterName = filterName; - this.filterClass = filterClass; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJ2EE.addFilter(webApp, filterName, filterClass); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterAdderForJavaEE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterAdderForJavaEE.java deleted file mode 100644 index 9faa0677a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterAdderForJavaEE.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE; - - -/** - * Runnable to add a filter to web.xml. - * - * @author Debajit Adhikary - * - */ -public class FilterAdderForJavaEE implements Runnable -{ - private final IProject project; - private final String filterName; - private final String filterClass; - - - /** - * @param project - * @param filterName - * @param filterClass - */ - public FilterAdderForJavaEE (final IProject project, - final String filterName, - final String filterClass) - { - this.project = project; - this.filterName = filterName; - this.filterClass = filterClass; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJavaEE.addFilter(webApp, filterName, filterClass); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterMapperAdderForJ2EE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterMapperAdderForJ2EE.java deleted file mode 100644 index 7dd02a8c9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterMapperAdderForJ2EE.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJ2EE; - - -/** - * Runnable to add a filter-mapping to web.xml. - * - * @author Debajit Adhikary - * - */ -public class FilterMapperAdderForJ2EE implements Runnable -{ - private final IProject project; - private final String filterName; - private final String filterClass; - private final String servletName; - - - /** - * @param project - * @param filterName - * @param filterClass - * @param servletName - */ - public FilterMapperAdderForJ2EE (final IProject project, - final String filterName, - final String filterClass, - final String servletName) - { - this.project = project; - this.filterName = filterName; - this.filterClass = filterClass; - this.servletName = servletName; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJ2EE.addFilterMapping(webApp, filterName, filterClass, servletName); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterMapperAdderForJavaEE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterMapperAdderForJavaEE.java deleted file mode 100644 index 5fa9f4978..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterMapperAdderForJavaEE.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE; - - -/** - * Runnable to add a filter-mapping to web.xml. - * - * @author Debajit Adhikary - * - */ -public class FilterMapperAdderForJavaEE implements Runnable -{ - private final IProject project; - private final String filterName; - private final String servletName; - - - /** - * @param project - * @param filterName - * @param servletName - */ - public FilterMapperAdderForJavaEE (final IProject project, - final String filterName, - final String servletName) - { - this.project = project; - this.filterName = filterName; - this.servletName = servletName; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJavaEE.addFilterMapping(webApp, filterName, servletName); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterRemoverForJavaEE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterRemoverForJavaEE.java deleted file mode 100644 index 68bd2f78e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/FilterRemoverForJavaEE.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - - -import static org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE.findFilter; -import static org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE.removeFilter; -import static org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE.removeFilterMappings; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.Filter; -import org.eclipse.jst.javaee.web.WebApp; - - -/** - * Removes a filter and its associated mappings from web.xml - * - * @author Debajit Adhikary - * - */ -public class FilterRemoverForJavaEE implements Runnable -{ - private final IProject project; - private final String filterClassName; - - - /** - * @param project - * @param filterClassName - */ - public FilterRemoverForJavaEE (final IProject project, - final String filterClassName) - { - this.project = project; - this.filterClassName = filterClassName; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - final Filter filter = findFilter(webApp, filterClassName); - - removeFilterMappings(webApp, filter); - removeFilter(webApp, filter); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ListenerAdderForJ2EE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ListenerAdderForJ2EE.java deleted file mode 100644 index 25c70208d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ListenerAdderForJ2EE.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJ2EE; - - -/** - * Runnable to add a listener to web.xml. - * - * @author Debajit Adhikary - * - */ -public class ListenerAdderForJ2EE implements Runnable -{ - private final IProject project; - private final String listenerClass; - - - /** - * @param project - * @param listenerClass - */ - public ListenerAdderForJ2EE (final IProject project, - final String listenerClass) - { - this.project = project; - this.listenerClass = listenerClass; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJ2EE.addListener(webApp, listenerClass); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ListenerAdderForJavaEE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ListenerAdderForJavaEE.java deleted file mode 100644 index ea8c600cd..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ListenerAdderForJavaEE.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE; - - -/** - * Runnable to add a listener to web.xml. - * - * @author Debajit Adhikary - * - */ -public class ListenerAdderForJavaEE implements Runnable -{ - private final IProject project; - private final String listenerClass; - - - /** - * @param project - * @param listenerClass - */ - public ListenerAdderForJavaEE (final IProject project, - final String listenerClass) - { - this.project = project; - this.listenerClass = listenerClass; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJavaEE.addListener(webApp, listenerClass); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletAdderForJ2EE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletAdderForJ2EE.java deleted file mode 100644 index 2626fed66..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletAdderForJ2EE.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJ2EE; - - -/** - * Runnable to add a servlet to web.xml. - * - * @author Debajit Adhikary - * - */ -public class ServletAdderForJ2EE implements Runnable -{ - private final IProject project; - private final String servletName; - private final String servletClass; - private final String loadOnStartup; - - - /** - * @param project - * @param servletName - * @param servletClass - * @param loadOnStartup - */ - public ServletAdderForJ2EE (final IProject project, - final String servletName, - final String servletClass, - final String loadOnStartup) - { - this.project = project; - this.servletName = servletName; - this.servletClass = servletClass; - this.loadOnStartup = loadOnStartup; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJ2EE.addServlet(webApp, servletName, servletClass, loadOnStartup); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletAdderForJavaEE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletAdderForJavaEE.java deleted file mode 100644 index fd324a3bf..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletAdderForJavaEE.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE; - - -/** - * Runnable to add a servlet to web.xml. - * - * @author Debajit Adhikary - * - */ -public class ServletAdderForJavaEE implements Runnable -{ - private final IProject project; - private final String servletName; - private final String servletClass; - private final String loadOnStartup; - - - /** - * @param project - * @param servletName - * @param servletClass - * @param loadOnStartup - */ - public ServletAdderForJavaEE (final IProject project, - final String servletName, - final String servletClass, - final String loadOnStartup) - { - this.project = project; - this.servletName = servletName; - this.servletClass = servletClass; - this.loadOnStartup = loadOnStartup; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJavaEE.addServlet(webApp, servletName, servletClass, loadOnStartup); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletMappingAdderForJ2EE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletMappingAdderForJ2EE.java deleted file mode 100644 index d5bf7528f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletMappingAdderForJ2EE.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJ2EE; - - -/** - * Runnable to add a servlet-mapping to web.xml. - * - * @author Debajit Adhikary - * - */ -public class ServletMappingAdderForJ2EE implements Runnable -{ - private final IProject project; - private final String servletName; - private final String servletClass; - private final String urlPatternString; - - - /** - * @param project - * @param servletName - * @param servletClass - * @param urlPatternString - */ - public ServletMappingAdderForJ2EE (final IProject project, - final String servletName, - final String servletClass, - final String urlPatternString) - { - this.project = project; - this.servletName = servletName; - this.servletClass = servletClass; - this.urlPatternString = urlPatternString; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJ2EE.addServletMapping(webApp, servletName, servletClass, urlPatternString); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletMappingAdderForJavaEE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletMappingAdderForJavaEE.java deleted file mode 100644 index 16fe0848a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletMappingAdderForJavaEE.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE; - - -/** - * Runnable to add a servlet-mapping to web.xml. - * - * @author Debajit Adhikary - * - */ -public class ServletMappingAdderForJavaEE implements Runnable -{ - private final IProject project; - private final String servletName; - private final String servletClass; - private final String urlPatternString; - - - /** - * @param project - * @param servletName - * @param servletClass - * @param urlPatternString - */ - public ServletMappingAdderForJavaEE (final IProject project, - final String servletName, - final String servletClass, - final String urlPatternString) - { - this.project = project; - this.servletName = servletName; - this.servletClass = servletClass; - this.urlPatternString = urlPatternString; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - - WebXmlUtilsForJavaEE.addServletMapping(webApp, servletName, servletClass, urlPatternString); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletRemoverForJ2EE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletRemoverForJ2EE.java deleted file mode 100644 index 9134a9a42..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletRemoverForJ2EE.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import static org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJ2EE.findServlet; -import static org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJ2EE.removeServlet; -import static org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJ2EE.removeServletMappings; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.j2ee.webapplication.Servlet; -import org.eclipse.jst.j2ee.webapplication.WebApp; - - -/** - * Removes a servlet and its associated mappings from web.xml. - * - * @author Debajit Adhikary - * - */ -public class ServletRemoverForJ2EE implements Runnable -{ - private final IProject project; - private final String servletClassName; - - - /** - * @param project - * @param servletClassName - */ - public ServletRemoverForJ2EE (final IProject project, - final String servletClassName) - { - this.project = project; - this.servletClassName = servletClassName; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - final Servlet servlet = findServlet(webApp, servletClassName); - - removeServletMappings(webApp, servlet); - removeServlet(webApp, servlet); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletRemoverForJavaEE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletRemoverForJavaEE.java deleted file mode 100644 index baf6cd0ae..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/internal/operations/ServletRemoverForJavaEE.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation and others. - * 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 Corporation - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.common.webxml.internal.operations; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.j2ee.model.ModelProviderManager; -import org.eclipse.jst.javaee.web.Servlet; -import org.eclipse.jst.javaee.web.WebApp; -import org.eclipse.jst.jsf.common.webxml.WebXmlUtilsForJavaEE; - - -/** - * Removes a servlet and its associated mappings from web.xml - * - * @author Debajit Adhikary - * - */ -public class ServletRemoverForJavaEE implements Runnable -{ - private final IProject project; - private final String servletClassName; - - - /** - * @param project - * @param servletClassName - */ - public ServletRemoverForJavaEE (final IProject project, - final String servletClassName) - { - this.project = project; - this.servletClassName = servletClassName; - } - - - public void run () - { - final WebApp webApp = (WebApp) ModelProviderManager.getModelProvider(project).getModelObject(); - final Servlet servlet = WebXmlUtilsForJavaEE.findServlet(servletClassName, webApp); - - WebXmlUtilsForJavaEE.removeServletMappings(webApp, servlet); - WebXmlUtilsForJavaEE.removeServlet(webApp, servlet); - } -} |