diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource')
192 files changed, 0 insertions, 21786 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/IndeterminateContentDescriber.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/IndeterminateContentDescriber.java deleted file mode 100644 index 6184852469..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/IndeterminateContentDescriber.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.core.internal.resource; - -import java.io.InputStream; -import java.io.Reader; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.content.ITextContentDescriber; - -/** - * This class simply returns INDETERMINATE for any contents it receives. - * - * It is used currently for org.eclipse.jpt.core.content.baseJpaContent in order - * to make that content type act as an "abstract" content type. - */ -public class IndeterminateContentDescriber implements ITextContentDescriber -{ - public int describe(InputStream contents, IContentDescription description) { - return INDETERMINATE; - } - - public int describe(Reader contents, IContentDescription description) { - return INDETERMINATE; - } - - public QualifiedName[] getSupportedOptions() { - return new QualifiedName[0]; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourceNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourceNode.java deleted file mode 100644 index f047f4d8ef..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourceNode.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.utility.internal.model.AbstractModel; -import org.eclipse.jpt.utility.internal.model.CallbackChangeSupport; -import org.eclipse.jpt.utility.internal.model.ChangeSupport; - -/** - * Java resource containment hierarchy - */ -public abstract class AbstractJavaResourceNode - extends AbstractModel - implements JavaResourceNode -{ - protected final JavaResourceNode parent; - - - // ********** constructor ********** - - protected AbstractJavaResourceNode(JavaResourceNode parent) { - super(); - this.checkParent(parent); - this.parent = parent; - } - - - // ********** parent ********** - - protected void checkParent(JavaResourceNode p) { - if (p == null) { - if (this.requiresParent()) { - throw new IllegalArgumentException("'parent' cannot be null"); //$NON-NLS-1$ - } - } else { - if (this.forbidsParent()) { - throw new IllegalArgumentException("'parent' must be null"); //$NON-NLS-1$ - } - } - } - - protected boolean requiresParent() { - return true; - } - - protected boolean forbidsParent() { - return ! this.requiresParent(); // assume 'parent' is not optional - } - - - // ********** change support callback hook ********** - - @Override - protected final ChangeSupport buildChangeSupport() { - return new CallbackChangeSupport(this, this.buildChangeSupportListener()); - } - - private CallbackChangeSupport.Listener buildChangeSupportListener() { - return new CallbackChangeSupport.Listener() { - public void aspectChanged(String aspectName) { - AbstractJavaResourceNode.this.aspectChanged(aspectName); - } - }; - } - - /** - * ignore the aspect name, we notify listeners of *every* change - */ - protected void aspectChanged(@SuppressWarnings("unused") String aspectName) { - this.getRoot().resourceModelChanged(); - } - - - // ********** JavaResourceNode implementation ********** - - /** - * @see org.eclipse.jpt.core.internal.resource.java.source.SourceCompilationUnit#getRoot() - * @see org.eclipse.jpt.core.internal.resource.java.binary.BinaryPackageFragmentRoot#getRoot() - * @see org.eclipse.jpt.core.internal.resource.java.binary.BinaryPersistentTypeCache#getRoot() - */ - public Root getRoot() { - return this.parent.getRoot(); - } - - public IFile getFile() { - return this.getRoot().getFile(); - } - - - // ********** convenience methods ********** - - protected JpaAnnotationProvider getAnnotationProvider() { - return this.getRoot().getAnnotationProvider(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideAnnotationDefinition.java deleted file mode 100644 index 9fc26e3348..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa1.resource.java.binary.BinaryAssociationOverride1_0Annotation; -import org.eclipse.jpt.core.internal.jpa1.resource.java.source.SourceAssociationOverride1_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AssociationOverride - */ -public final class AssociationOverrideAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new AssociationOverrideAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AssociationOverrideAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return SourceAssociationOverride1_0Annotation.buildAssociationOverride(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryAssociationOverride1_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return AssociationOverrideAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesAnnotationDefinition.java deleted file mode 100644 index 2fd18af99f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa1.resource.java.binary.BinaryAssociationOverrides1_0Annotation; -import org.eclipse.jpt.core.internal.jpa1.resource.java.source.SourceAssociationOverrides1_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AssociationOverrides - */ -public final class AssociationOverridesAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new AssociationOverridesAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AssociationOverridesAnnotationDefinition() { - super(); - } - - public AssociationOverridesAnnotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceAssociationOverrides1_0Annotation(parent, member); - } - - public AssociationOverridesAnnotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryAssociationOverrides1_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return AssociationOverridesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideAnnotationDefinition.java deleted file mode 100644 index 03b83f682e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAttributeOverrideAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AttributeOverride - */ -public final class AttributeOverrideAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new AttributeOverrideAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AttributeOverrideAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return SourceAttributeOverrideAnnotation.buildAttributeOverride(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryAttributeOverrideAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return AttributeOverrideAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesAnnotationDefinition.java deleted file mode 100644 index 27c8986fcb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAttributeOverridesAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAttributeOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AttributeOverrides - */ -public final class AttributeOverridesAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new AttributeOverridesAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AttributeOverridesAnnotationDefinition() { - super(); - } - - public AttributeOverridesAnnotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceAttributeOverridesAnnotation(parent, member); - } - - public AttributeOverridesAnnotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryAttributeOverridesAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return AttributeOverridesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/BasicAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/BasicAnnotationDefinition.java deleted file mode 100644 index 989aa71ed0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/BasicAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryBasicAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceBasicAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Basic - */ -public final class BasicAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new BasicAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private BasicAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceBasicAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullBasicAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryBasicAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return BasicAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ColumnAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ColumnAnnotationDefinition.java deleted file mode 100644 index 219c98745c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ColumnAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryColumnAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceColumnAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Column - */ -public final class ColumnAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new ColumnAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ColumnAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceColumnAnnotation(parent, member, SourceColumnAnnotation.MAPPING_DECLARATION_ANNOTATION_ADAPTER); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullColumnAnnotation(parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryColumnAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ColumnAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnAnnotationDefinition.java deleted file mode 100644 index ff4ec04c77..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryDiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceDiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.DiscriminatorColumn - */ -public final class DiscriminatorColumnAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new DiscriminatorColumnAnnotationDefinition(); - - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private DiscriminatorColumnAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceDiscriminatorColumnAnnotation((JavaResourcePersistentType) parent, member, SourceDiscriminatorColumnAnnotation.DECLARATION_ANNOTATION_ADAPTER); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullDiscriminatorColumnAnnotation((JavaResourcePersistentType) parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryDiscriminatorColumnAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return DiscriminatorColumnAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueAnnotationDefinition.java deleted file mode 100644 index ea12342ee1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryDiscriminatorValueAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceDiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.DiscriminatorValue - */ -public final class DiscriminatorValueAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new DiscriminatorValueAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private DiscriminatorValueAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceDiscriminatorValueAnnotation(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullDiscriminatorValueAnnotation((JavaResourcePersistentType) parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryDiscriminatorValueAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return DiscriminatorValueAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddableAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddableAnnotationDefinition.java deleted file mode 100644 index fd7dbfa3c7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddableAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryEmbeddableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceEmbeddableAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Embeddable - */ -public final class EmbeddableAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new EmbeddableAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EmbeddableAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceEmbeddableAnnotation((JavaResourcePersistentType) parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryEmbeddableAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return EmbeddableAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedAnnotationDefinition.java deleted file mode 100644 index 1a3889fe3c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryEmbeddedAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceEmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Embedded - */ -public final class EmbeddedAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new EmbeddedAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EmbeddedAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceEmbeddedAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullEmbeddedAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryEmbeddedAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return EmbeddedAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdAnnotationDefinition.java deleted file mode 100644 index 741375240d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryEmbeddedIdAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceEmbeddedIdAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.EmbeddedId - */ -public final class EmbeddedIdAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new EmbeddedIdAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EmbeddedIdAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceEmbeddedIdAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryEmbeddedIdAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return EmbeddedIdAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EntityAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EntityAnnotationDefinition.java deleted file mode 100644 index 7c4f432ffe..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EntityAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryEntityAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceEntityAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EntityAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Entity - */ -public final class EntityAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new EntityAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EntityAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceEntityAnnotation((JavaResourcePersistentType) parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryEntityAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return EntityAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EnumeratedAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EnumeratedAnnotationDefinition.java deleted file mode 100644 index 5146a6d178..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/EnumeratedAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryEnumeratedAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceEnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Enumerated - */ -public final class EnumeratedAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new EnumeratedAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EnumeratedAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceEnumeratedAnnotation(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullEnumeratedAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryEnumeratedAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return EnumeratedAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueAnnotationDefinition.java deleted file mode 100644 index 7026476532..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryGeneratedValueAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceGeneratedValueAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.GeneratedValue - */ -public final class GeneratedValueAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new GeneratedValueAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private GeneratedValueAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceGeneratedValueAnnotation(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryGeneratedValueAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return GeneratedValueAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdAnnotationDefinition.java deleted file mode 100644 index 12ebf03b98..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryIdAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceIdAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.IdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Id - */ -public final class IdAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new IdAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private IdAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceIdAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryIdAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return IdAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdClassAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdClassAnnotationDefinition.java deleted file mode 100644 index 5e99e4c3e0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/IdClassAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryIdClassAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceIdClassAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.IdClassAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.IdClass - */ -public final class IdClassAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new IdClassAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private IdClassAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceIdClassAnnotation(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryIdClassAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return IdClassAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/InheritanceAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/InheritanceAnnotationDefinition.java deleted file mode 100644 index 297ae12fa7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/InheritanceAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryInheritanceAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceInheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Inheritance - */ -public final class InheritanceAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new InheritanceAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private InheritanceAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceInheritanceAnnotation((JavaResourcePersistentType) parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullInheritanceAnnotation((JavaResourcePersistentType) parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryInheritanceAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return InheritanceAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnAnnotationDefinition.java deleted file mode 100644 index c2c248a86c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryJoinColumnAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.JoinColumn - */ -public final class JoinColumnAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new JoinColumnAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private JoinColumnAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return SourceJoinColumnAnnotation.createJoinColumn(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryJoinColumnAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsAnnotationDefinition.java deleted file mode 100644 index 1c00f40fde..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryJoinColumnsAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceJoinColumnsAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.JoinColumns - */ -public final class JoinColumnsAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new JoinColumnsAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private JoinColumnsAnnotationDefinition() { - super(); - } - - public JoinColumnsAnnotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceJoinColumnsAnnotation(parent, member); - } - - public JoinColumnsAnnotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryJoinColumnsAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return JoinColumnsAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinTableAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinTableAnnotationDefinition.java deleted file mode 100644 index a58445ec6a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JoinTableAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryJoinTableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceJoinTableAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.JoinTable - */ -public final class JoinTableAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new JoinTableAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private JoinTableAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceJoinTableAnnotation(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullJoinTableAnnotation(parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryJoinTableAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return JoinTableAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/LobAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/LobAnnotationDefinition.java deleted file mode 100644 index 29022f2c7a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/LobAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryLobAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceLobAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.LobAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Lob - */ -public final class LobAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new LobAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private LobAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceLobAnnotation(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryLobAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return LobAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToManyAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToManyAnnotationDefinition.java deleted file mode 100644 index a10d93fec5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToManyAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryManyToManyAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceManyToManyAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.ManyToMany - */ -public final class ManyToManyAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new ManyToManyAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ManyToManyAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceManyToManyAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryManyToManyAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ManyToManyAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToOneAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToOneAnnotationDefinition.java deleted file mode 100644 index 140d7977b8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/ManyToOneAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryManyToOneAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceManyToOneAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.ManyToOne - */ -public final class ManyToOneAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new ManyToOneAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ManyToOneAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceManyToOneAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryManyToOneAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ManyToOneAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MapKeyAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MapKeyAnnotationDefinition.java deleted file mode 100644 index 03c6ff8b36..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MapKeyAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryMapKeyAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceMapKeyAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.MapKeyAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.MapKey - */ -public final class MapKeyAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MapKeyAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MapKeyAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceMapKeyAnnotation(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryMapKeyAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapKeyAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassAnnotationDefinition.java deleted file mode 100644 index c6452c9e68..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryMappedSuperclassAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceMappedSuperclassAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.MappedSuperclass - */ -public final class MappedSuperclassAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MappedSuperclassAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MappedSuperclassAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceMappedSuperclassAnnotation((JavaResourcePersistentType) parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryMappedSuperclassAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MappedSuperclassAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesAnnotationDefinition.java deleted file mode 100644 index 21d55cb918..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedNativeQueries - */ -public final class NamedNativeQueriesAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new NamedNativeQueriesAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NamedNativeQueriesAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceNamedNativeQueriesAnnotation(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryNamedNativeQueriesAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return NamedNativeQueriesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryAnnotationDefinition.java deleted file mode 100644 index db6d640c07..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedNativeQueryAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedNativeQueryAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedNativeQuery - */ -public final class NamedNativeQueryAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new NamedNativeQueryAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NamedNativeQueryAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return SourceNamedNativeQueryAnnotation.createNamedNativeQuery(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryNamedNativeQueryAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return NamedNativeQueryAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java deleted file mode 100644 index 6220ca19d7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedQueriesAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQueries - */ -public final class NamedQueriesAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new NamedQueriesAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NamedQueriesAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceNamedQueriesAnnotation(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryNamedQueriesAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return NamedQueriesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java deleted file mode 100644 index 2b40783b96..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedQueryAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQuery - */ -public final class NamedQueryAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new NamedQueryAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NamedQueryAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return SourceNamedQueryAnnotation.createNamedQuery(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryNamedQueryAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return NamedQueryAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java deleted file mode 100644 index 3fc989ff90..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * Simplify null annotation classes - */ -public abstract class NullAnnotation - extends AbstractJavaResourceNode - implements Annotation -{ - - protected NullAnnotation(JavaResourceNode parent) { - super(parent); - } - - public void initialize(CompilationUnit astRoot) { - // do nothing - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public JavaResourceCompilationUnit getJavaResourceCompilationUnit() { - throw new UnsupportedOperationException(); - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - /** - * Convenience method: Cast the annotation's parent to a - * persistent member. - */ - protected JavaResourcePersistentMember getMember() { - return (JavaResourcePersistentMember) this.parent; - } - - /** - * Convenience method: Add the type or attribute's annotation - * and return it. - * Pre-condition: The annotation's parent must be a persistent member - * (type or attribute). - */ - protected Annotation addAnnotation() { - return this.getMember().addAnnotation(this.getAnnotationName()); - } - - /** - * Convenience method: Add the type or attribute's annotation - * and return it. - * Pre-condition: The annotation's parent must be a persistent member - * (type or attribute). - */ - protected Annotation addAnnotation( - JavaResourcePersistentMember.AnnotationInitializer initializer) { - return this.getMember().addAnnotation(this.getAnnotationName(), initializer); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java deleted file mode 100644 index 85f0c6fe08..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; - -/** - * javax.persistence.Column - */ -public class NullAttributeOverrideColumnAnnotation - extends NullColumnAnnotation -{ - public NullAttributeOverrideColumnAnnotation(AttributeOverrideAnnotation parent) { - super(parent); - } - - private AttributeOverrideAnnotation getAttributeOverrideAnnotation() { - return (AttributeOverrideAnnotation) this.parent; - } - - @Override - protected ColumnAnnotation addAnnotation() { - return this.getAttributeOverrideAnnotation().addColumn(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java deleted file mode 100644 index 477b7f8da0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - */ -public abstract class NullBaseColumnAnnotation - extends NullNamedColumnAnnotation - implements BaseColumnAnnotation -{ - protected NullBaseColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - @Override - protected BaseColumnAnnotation addAnnotation() { - return (BaseColumnAnnotation) super.addAnnotation(); - } - - // ***** table - public String getTable() { - return null; - } - - public void setTable(String table) { - if (table != null) { - this.addAnnotation().setTable(table); - } - } - - public TextRange getTableTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - return false; - } - - // ***** unique - public Boolean getUnique() { - return null; - } - - public void setUnique(Boolean unique) { - if (unique != null) { - this.addAnnotation().setUnique(unique); - } - } - - public TextRange getUniqueTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** updatable - public Boolean getUpdatable() { - return null; - } - - public void setUpdatable(Boolean updatable) { - if (updatable != null) { - this.addAnnotation().setUpdatable(updatable); - } - } - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** insertable - public Boolean getInsertable() { - return null; - } - - public void setInsertable(Boolean insertable) { - if (insertable != null) { - this.addAnnotation().setInsertable(insertable); - } - } - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** nullable - public Boolean getNullable() { - return null; - } - - public void setNullable(Boolean nullable) { - if (nullable != null) { - this.addAnnotation().setNullable(nullable); - } - } - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java deleted file mode 100644 index 93160b0452..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseTableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - -/** - * javax.persistence.Table - * javax.persistence.JoinTable - */ -public abstract class NullBaseTableAnnotation - extends NullAnnotation - implements BaseTableAnnotation -{ - protected NullBaseTableAnnotation(JavaResourceNode parent) { - super(parent); - } - - @Override - protected BaseTableAnnotation addAnnotation() { - return (BaseTableAnnotation) super.addAnnotation(); - } - - public boolean isSpecified() { - return false; - } - - // ***** name - public String getName() { - return null; - } - - public void setName(String name) { - if (name != null) { - this.addAnnotation().setName(name); - } - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return false; - } - - // ***** schema - public String getSchema() { - return null; - } - - public void setSchema(String schema) { - if (schema != null) { - this.addAnnotation().setSchema(schema); - } - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - return false; - } - - // ***** catalog - public String getCatalog() { - return null; - } - - public void setCatalog(String catalog) { - if (catalog != null) { - this.addAnnotation().setCatalog(catalog); - } - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - return false; - } - - // ***** unique constraints - public ListIterator<UniqueConstraintAnnotation> uniqueConstraints() { - return EmptyListIterator.instance(); - } - - public int uniqueConstraintsSize() { - return 0; - } - - public UniqueConstraintAnnotation uniqueConstraintAt(int index) { - throw new UnsupportedOperationException(); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - throw new UnsupportedOperationException(); - } - - public UniqueConstraintAnnotation addUniqueConstraint(int index) { - return this.addAnnotation().addUniqueConstraint(index); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeUniqueConstraint(int index) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java deleted file mode 100644 index 0e16de1e07..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * null javax.persistence.Basic - */ -public final class NullBasicAnnotation - extends NullAnnotation - implements BasicAnnotation -{ - protected NullBasicAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected BasicAnnotation addAnnotation() { - return (BasicAnnotation) super.addAnnotation(); - } - - - // ***** fetch - - public FetchType getFetch() { - return null; - } - - public void setFetch(FetchType fetch) { - if (fetch != null) { - this.addAnnotation().setFetch(fetch); - } - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return null; - } - - - // ***** optional - - public Boolean getOptional() { - return null; - } - - public void setOptional(Boolean optional) { - if (optional != null) { - this.addAnnotation().setOptional(optional); - } - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java deleted file mode 100644 index 3bf5452a0b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - */ -public class NullColumnAnnotation - extends NullBaseColumnAnnotation - implements ColumnAnnotation -{ - public NullColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected ColumnAnnotation addAnnotation() { - return (ColumnAnnotation) super.addAnnotation(); - } - - // ***** length - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - if (length != null) { - this.addAnnotation().setLength(length); - } - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** scale - public Integer getScale() { - return null; - } - - public void setScale(Integer scale) { - if (scale != null) { - this.addAnnotation().setScale(scale); - } - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** precision - public Integer getPrecision() { - return null; - } - - public void setPrecision(Integer precision) { - if (precision != null) { - this.addAnnotation().setPrecision(precision); - } - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java deleted file mode 100644 index 126ad60814..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * javax.persistence.DiscriminatorColumn - */ -public final class NullDiscriminatorColumnAnnotation - extends NullNamedColumnAnnotation - implements DiscriminatorColumnAnnotation -{ - public NullDiscriminatorColumnAnnotation(JavaResourcePersistentType parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected DiscriminatorColumnAnnotation addAnnotation() { - return (DiscriminatorColumnAnnotation) super.addAnnotation(); - } - - // ***** discriminator type - public DiscriminatorType getDiscriminatorType() { - return null; - } - - public void setDiscriminatorType(DiscriminatorType discriminatorType) { - if (discriminatorType != null) { - this.addAnnotation().setDiscriminatorType(discriminatorType); - } - } - - // ***** length - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - if (length != null) { - this.addAnnotation().setLength(length); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java deleted file mode 100644 index 7a68d3d2dc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.DiscriminatorValue - */ -public final class NullDiscriminatorValueAnnotation - extends NullAnnotation - implements DiscriminatorValueAnnotation -{ - - protected NullDiscriminatorValueAnnotation(JavaResourcePersistentType parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected DiscriminatorValueAnnotation addAnnotation() { - return (DiscriminatorValueAnnotation) super.addAnnotation(); - } - - // ***** value - public String getValue() { - return null; - } - - public void setValue(String value) { - if (value != null) { - this.addAnnotation().setValue(value); - } - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEmbeddedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEmbeddedAnnotation.java deleted file mode 100644 index 029d2a6ffd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEmbeddedAnnotation.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.Embedded - */ -public final class NullEmbeddedAnnotation - extends NullAnnotation - implements EmbeddedAnnotation -{ - protected NullEmbeddedAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java deleted file mode 100644 index 1e45dd51a9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.EnumType; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Enumerated - */ -public final class NullEnumeratedAnnotation - extends NullAnnotation - implements EnumeratedAnnotation -{ - protected NullEnumeratedAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected EnumeratedAnnotation addAnnotation() { - return (EnumeratedAnnotation) super.addAnnotation(); - } - - // ***** value - public EnumType getValue() { - return null; - } - - public void setValue(EnumType value) { - if (value != null) { - this.addAnnotation().setValue(value); - } - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java deleted file mode 100644 index a4130b1b6e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.InheritanceType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Inheritance - */ -public final class NullInheritanceAnnotation - extends NullAnnotation - implements InheritanceAnnotation -{ - protected NullInheritanceAnnotation(JavaResourcePersistentType parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected InheritanceAnnotation addAnnotation() { - return (InheritanceAnnotation) super.addAnnotation(); - } - - // ***** strategy - public InheritanceType getStrategy() { - return null; - } - - public void setStrategy(InheritanceType strategy) { - if (strategy != null) { - this.addAnnotation().setStrategy(strategy); - } - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumnAnnotation.java deleted file mode 100644 index 32c74fa036..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumnAnnotation.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.JoinColumn - */ -public final class NullJoinColumnAnnotation - extends NullBaseColumnAnnotation - implements JoinColumnAnnotation -{ - public NullJoinColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected JoinColumnAnnotation addAnnotation() { - throw new UnsupportedOperationException(); - } - - // ***** referenced column name - public String getReferencedColumnName() { - return null; - } - - public void setReferencedColumnName(String referencedColumnName) { - throw new UnsupportedOperationException(); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - return false; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java deleted file mode 100644 index f54c7aac97..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import java.util.ListIterator; - -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember.AnnotationInitializer; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - -/** - * javax.persistence.JoinTable - */ -public class NullJoinTableAnnotation - extends NullBaseTableAnnotation - implements JoinTableAnnotation -{ - public NullJoinTableAnnotation(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected JoinTableAnnotation addAnnotation() { - return (JoinTableAnnotation) super.addAnnotation(); - } - - @Override - protected JoinColumnAnnotation addAnnotation(AnnotationInitializer initializer) { - return (JoinColumnAnnotation) super.addAnnotation(initializer); - } - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return EmptyListIterator.instance(); - } - - public int joinColumnsSize() { - return 0; - } - - public JoinColumnAnnotation joinColumnAt(int index) { - return null; - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation addJoinColumn(int index) { - // the JoinTable annotation is missing, add both it and a join column at the same time - return addAnnotation(buildJoinColumnInitializer()); - } - - protected AnnotationInitializer buildJoinColumnInitializer() { - return JOIN_COLUMN_INITIALIZER; - } - - protected static final AnnotationInitializer JOIN_COLUMN_INITIALIZER = - new AnnotationInitializer() { - public Annotation initializeAnnotation(Annotation supportingAnnotation) { - return ((JoinTableAnnotation) supportingAnnotation).initializeJoinColumns(); - } - }; - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation initializeJoinColumns() { - throw new UnsupportedOperationException(); - } - - // ***** inverse join columns - public ListIterator<JoinColumnAnnotation> inverseJoinColumns() { - return EmptyListIterator.instance(); - } - - public int inverseJoinColumnsSize() { - return 0; - } - - public JoinColumnAnnotation inverseJoinColumnAt(int index) { - return null; - } - - public int indexOfInverseJoinColumn(JoinColumnAnnotation joinColumn) { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation addInverseJoinColumn(int index) { - // the JoinTable annotation is missing, add both it and a join column at the same time - return addAnnotation(buildInverseJoinColumnInitializer()); - } - - protected AnnotationInitializer buildInverseJoinColumnInitializer() { - return INVERSE_JOIN_COLUMN_INITIALIZER; - } - - protected static final AnnotationInitializer INVERSE_JOIN_COLUMN_INITIALIZER = - new AnnotationInitializer() { - public Annotation initializeAnnotation(Annotation supportingAnnotation) { - return ((JoinTableAnnotation) supportingAnnotation).initializeInverseJoinColumns(); - } - }; - - - public void moveInverseJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeInverseJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation initializeInverseJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java deleted file mode 100644 index 0ae2b8cf38..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - * javax.persistence.DiscriminatorColumn - * javax.persistence.PrimaryKeyJoinColumn. - */ -public abstract class NullNamedColumnAnnotation - extends NullAnnotation - implements NamedColumnAnnotation -{ - protected NullNamedColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - public boolean isSpecified() { - return false; - } - - @Override - protected NamedColumnAnnotation addAnnotation() { - return (NamedColumnAnnotation) super.addAnnotation(); - } - - // ***** name - public String getName() { - return null; - } - - public void setName(String name) { - if (name != null) { - this.addAnnotation().setName(name); - } - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return false; - } - - // ***** column definition - public String getColumnDefinition() { - return null; - } - - public void setColumnDefinition(String columnDefinition) { - if (columnDefinition != null) { - this.addAnnotation().setColumnDefinition(columnDefinition); - } - } - - public TextRange getColumnDefinitionTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToManyAnnotation.java deleted file mode 100644 index 4d92110c51..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToManyAnnotation.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OneToManyAnnotation; - -/** - * javax.persistence.OneToMany - */ -public final class NullOneToManyAnnotation - extends NullOwnableRelationshipMappingAnnotation - implements OneToManyAnnotation -{ - public NullOneToManyAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java deleted file mode 100644 index ce6374c71b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OneToOneAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OneToOne - */ -public final class NullOneToOneAnnotation - extends NullOwnableRelationshipMappingAnnotation - implements OneToOneAnnotation -{ - protected NullOneToOneAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected OneToOneAnnotation addAnnotation() { - return (OneToOneAnnotation) super.addAnnotation(); - } - - // ***** optional - public Boolean getOptional() { - return null; - } - - public void setOptional(Boolean optional) { - if (optional != null) { - this.addAnnotation().setOptional(optional); - } - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java deleted file mode 100644 index dd29a044d7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OwnableRelationshipMappingAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OneToMany - * javax.persistence.OneToOne - */ -public abstract class NullOwnableRelationshipMappingAnnotation - extends NullAnnotation - implements OwnableRelationshipMappingAnnotation -{ - protected NullOwnableRelationshipMappingAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - - @Override - protected OwnableRelationshipMappingAnnotation addAnnotation() { - return (OwnableRelationshipMappingAnnotation) super.addAnnotation(); - } - - - // ***** target entity - - public String getTargetEntity() { - return null; - } - - public void setTargetEntity(String targetEntity) { - if (targetEntity != null) { - this.addAnnotation().setTargetEntity(targetEntity); - } - } - - public TextRange getTargetEntityTextRange(CompilationUnit astRoot) { - return null; - } - - - // ***** fully-qualified target entity class name - - public String getFullyQualifiedTargetEntityClassName() { - return null; - } - - - // ***** mapped by - - public String getMappedBy() { - return null; - } - - public void setMappedBy(String mappedBy) { - if (mappedBy != null) { - this.addAnnotation().setMappedBy(mappedBy); - } - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return false; - } - - - // ***** fetch - - public FetchType getFetch() { - return null; - } - - public void setFetch(FetchType fetch) { - if (fetch != null) { - this.addAnnotation().setFetch(fetch); - } - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return null; - } - - - // ***** cascade all - - public boolean isCascadeAll() { - return false; - } - - public void setCascadeAll(boolean all) { - this.addAnnotation().setCascadeAll(all); - } - - - // ***** cascade merge - - public boolean isCascadeMerge() { - return false; - } - - public void setCascadeMerge(boolean merge) { - this.addAnnotation().setCascadeMerge(merge); - } - - - // ***** cascade persist - - public boolean isCascadePersist() { - return false; - } - - public void setCascadePersist(boolean persist) { - this.addAnnotation().setCascadePersist(persist); - } - - - // ***** cascade refresh - - public boolean isCascadeRefresh() { - return false; - } - - public void setCascadeRefresh(boolean refresh) { - this.addAnnotation().setCascadeRefresh(refresh); - } - - - // ***** cascade remove - - public boolean isCascadeRemove() { - return false; - } - - public void setCascadeRemove(boolean remove) { - this.addAnnotation().setCascadeRemove(remove); - } - - public TextRange getCascadeTextRange(CompilationUnit astRoot) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumnAnnotation.java deleted file mode 100644 index a2ff594c03..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumnAnnotation.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.PrimaryKeyJoinColumn - */ -public final class NullPrimaryKeyJoinColumnAnnotation - extends NullNamedColumnAnnotation - implements PrimaryKeyJoinColumnAnnotation -{ - public NullPrimaryKeyJoinColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected NamedColumnAnnotation addAnnotation() { - throw new UnsupportedOperationException(); - } - - // ***** referenced column name - public String getReferencedColumnName() { - return null; - } - - public void setReferencedColumnName(String referencedColumnName) { - throw new UnsupportedOperationException(); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - return false; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java deleted file mode 100644 index bc831e7093..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.TableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember.AnnotationInitializer; - -/** - * javax.persistence.Table - */ -public final class NullTableAnnotation - extends NullBaseTableAnnotation - implements TableAnnotation -{ - protected NullTableAnnotation(JavaResourcePersistentType parent) { - super(parent); - } - - @Override - protected TableAnnotation addAnnotation() { - return (TableAnnotation) super.addAnnotation(); - } - - @Override - protected TableAnnotation addAnnotation(AnnotationInitializer initializer) { - return (TableAnnotation) super.addAnnotation(initializer); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java deleted file mode 100644 index ec38b00a84..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; -import org.eclipse.jpt.core.resource.java.TemporalType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Temporal - */ -public final class NullTemporalAnnotation - extends NullAnnotation - implements TemporalAnnotation -{ - protected NullTemporalAnnotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected TemporalAnnotation addAnnotation() { - return (TemporalAnnotation) super.addAnnotation(); - } - - - // ********** TemporalAnnotation implementation ********** - - // ***** value - public TemporalType getValue() { - return null; - } - - public void setValue(TemporalType value) { - if (value != null) { - this.addAnnotation().setValue(value); - } - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToManyAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToManyAnnotationDefinition.java deleted file mode 100644 index 29c3efe9f0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToManyAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryOneToManyAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceOneToManyAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.OneToManyAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.OneToMany - */ -public final class OneToManyAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new OneToManyAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private OneToManyAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceOneToManyAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullOneToManyAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryOneToManyAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return OneToManyAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToOneAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToOneAnnotationDefinition.java deleted file mode 100644 index 93ecc8e615..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OneToOneAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryOneToOneAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceOneToOneAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.OneToOneAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.OneToOne - */ -public final class OneToOneAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new OneToOneAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private OneToOneAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceOneToOneAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullOneToOneAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryOneToOneAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return OneToOneAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OrderByAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OrderByAnnotationDefinition.java deleted file mode 100644 index 271aa8a070..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/OrderByAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryOrderByAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceOrderByAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.OrderByAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.OrderBy - */ -public final class OrderByAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new OrderByAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private OrderByAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceOrderByAnnotation(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryOrderByAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return OrderByAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnAnnotationDefinition.java deleted file mode 100644 index 77499381c1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryPrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourcePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.PrimaryKeyJoinColumn - */ -public final class PrimaryKeyJoinColumnAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new PrimaryKeyJoinColumnAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private PrimaryKeyJoinColumnAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return SourcePrimaryKeyJoinColumnAnnotation.createPrimaryKeyJoinColumn(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryPrimaryKeyJoinColumnAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsAnnotationDefinition.java deleted file mode 100644 index 0c67aba310..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryPrimaryKeyJoinColumnsAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourcePrimaryKeyJoinColumnsAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnsAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.PrimaryKeyJoinColumns - */ -public final class PrimaryKeyJoinColumnsAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new PrimaryKeyJoinColumnsAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private PrimaryKeyJoinColumnsAnnotationDefinition() { - super(); - } - - public PrimaryKeyJoinColumnsAnnotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourcePrimaryKeyJoinColumnsAnnotation(parent, member); - } - - public PrimaryKeyJoinColumnsAnnotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryPrimaryKeyJoinColumnsAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableAnnotationDefinition.java deleted file mode 100644 index cca983ff52..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinarySecondaryTableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceSecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SecondaryTable - */ -public final class SecondaryTableAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new SecondaryTableAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private SecondaryTableAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return SourceSecondaryTableAnnotation.createSecondaryTable(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinarySecondaryTableAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return SecondaryTableAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesAnnotationDefinition.java deleted file mode 100644 index 037c96894c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinarySecondaryTablesAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceSecondaryTablesAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.SecondaryTablesAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SecondaryTables - */ -public final class SecondaryTablesAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new SecondaryTablesAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private SecondaryTablesAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceSecondaryTablesAnnotation((JavaResourcePersistentType) parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinarySecondaryTablesAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return SecondaryTablesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorAnnotationDefinition.java deleted file mode 100644 index 884b36bb1a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa1.resource.java.binary.BinarySequenceGenerator1_0Annotation; -import org.eclipse.jpt.core.internal.jpa1.resource.java.source.SourceSequenceGenerator1_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SequenceGenerator - */ -public final class SequenceGeneratorAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new SequenceGeneratorAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - protected SequenceGeneratorAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceSequenceGenerator1_0Annotation(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinarySequenceGenerator1_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return SequenceGeneratorAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableAnnotationDefinition.java deleted file mode 100644 index 6de211ef15..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableAnnotationDefinition.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryTableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceTableAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.TableAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Table - */ -public final class TableAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new TableAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TableAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceTableAnnotation(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullTableAnnotation((JavaResourcePersistentType) parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryTableAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return TableAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorAnnotationDefinition.java deleted file mode 100644 index 428e818d4c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorAnnotationDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryTableGeneratorAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceTableGeneratorAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.TableGenerator - */ -public final class TableGeneratorAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new TableGeneratorAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TableGeneratorAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceTableGeneratorAnnotation(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryTableGeneratorAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return TableGeneratorAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TemporalAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TemporalAnnotationDefinition.java deleted file mode 100644 index eb433e17f2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TemporalAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryTemporalAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceTemporalAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Temporal - */ -public final class TemporalAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new TemporalAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TemporalAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceTemporalAnnotation(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - return new NullTemporalAnnotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryTemporalAnnotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return TemporalAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TransientAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TransientAnnotationDefinition.java deleted file mode 100644 index 4d84704c0f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/TransientAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryTransientAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceTransientAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.TransientAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Transient - */ -public final class TransientAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new TransientAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TransientAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceTransientAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryTransientAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return TransientAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/VersionAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/VersionAnnotationDefinition.java deleted file mode 100644 index 3b11cce142..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/VersionAnnotationDefinition.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryVersionAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceVersionAnnotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.VersionAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Version - */ -public final class VersionAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new VersionAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private VersionAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SourceVersionAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - return new BinaryVersionAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return VersionAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java deleted file mode 100644 index 7d5b6bf1ec..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IMemberValuePair; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; - -/** - * JAR annotation - */ -public abstract class BinaryAnnotation - extends BinaryNode - implements Annotation -{ - final IAnnotation jdtAnnotation; - - protected BinaryAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent); - this.jdtAnnotation = jdtAnnotation; - } - - - // ********** convenience methods ********** - - /** - * Return the values of the JDT annotation's member with the specified name. - */ - protected Object[] getJdtMemberValues(String memberName) { - Object[] values = (Object[]) this.getJdtMemberValue(memberName); - return (values != null) ? values : EMPTY_OBJECT_ARRAY; - } - private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; - - /** - * Return the value of the JDT annotation's member with the specified name. - */ - protected Object getJdtMemberValue(String memberName) { - IMemberValuePair pair = this.getJdtMemberValuePair(memberName); - return (pair == null) ? null : pair.getValue(); - } - - /** - * Return the JDT annotation's member-value pair with the specified name. - */ - private IMemberValuePair getJdtMemberValuePair(String memberName) { - for (IMemberValuePair pair : this.getJdtMemberValuePairs()) { - if (pair.getMemberName().equals(memberName)) { - return pair; - } - } - return null; - } - - private IMemberValuePair[] getJdtMemberValuePairs() { - try { - return this.jdtAnnotation.getMemberValuePairs(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_MEMBER_VALUE_PAIR_ARRAY; - } - } - private static final IMemberValuePair[] EMPTY_MEMBER_VALUE_PAIR_ARRAY = new IMemberValuePair[0]; - - - // ********** Annotation implementation ********** - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - // ********** NestableAnnotation implementation ********** - public void moveAnnotation(@SuppressWarnings("unused") int index) { - throw new UnsupportedOperationException(); - } - public void initializeFrom(@SuppressWarnings("unused") NestableAnnotation oldAnnotation) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverrideAnnotation.java deleted file mode 100644 index 439b0442b3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverrideAnnotation.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverrideAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.AssociationOverride - */ -public abstract class BinaryAssociationOverrideAnnotation - extends BinaryOverrideAnnotation - implements NestableAssociationOverrideAnnotation -{ - private final Vector<JoinColumnAnnotation> joinColumns; - - - protected BinaryAssociationOverrideAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.joinColumns = this.buildJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updateJoinColumns(); - } - - - // ********** BinaryOverrideAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.ASSOCIATION_OVERRIDE__NAME; - } - - - // ********** AssociationOverrideAnnotation implementation ********** - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public JoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public JoinColumnAnnotation addJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<JoinColumnAnnotation> buildJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.ASSOCIATION_OVERRIDE__JOIN_COLUMNS); - Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - // TODO - private void updateJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverridesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverridesAnnotation.java deleted file mode 100644 index 22a782a291..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverridesAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverrideAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.AssociationOverrides - */ -public abstract class BinaryAssociationOverridesAnnotation - extends BinaryContainerAnnotation<NestableAssociationOverrideAnnotation> - implements AssociationOverridesAnnotation -{ - private final Vector<NestableAssociationOverrideAnnotation> associationOverrides; - - - protected BinaryAssociationOverridesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.associationOverrides = this.buildAssociationOverrides(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public ListIterator<NestableAssociationOverrideAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableAssociationOverrideAnnotation>(this.associationOverrides); - } - - public int nestedAnnotationsSize() { - return this.associationOverrides.size(); - } - - private Vector<NestableAssociationOverrideAnnotation> buildAssociationOverrides() { - Object[] jdtAssociationOverrides = this.getJdtMemberValues(JPA.ASSOCIATION_OVERRIDES__VALUE); - Vector<NestableAssociationOverrideAnnotation> result = new Vector<NestableAssociationOverrideAnnotation>(jdtAssociationOverrides.length); - for (Object jdtAssociationOverride : jdtAssociationOverrides) { - result.add(buildAssociationOverride(jdtAssociationOverride)); - } - return result; - } - - protected abstract NestableAssociationOverrideAnnotation buildAssociationOverride(Object jdtAssociationOverride); - - @Override - public void update() { - super.update(); - this.updateAssociationOverrides(); - } - - // TODO - private void updateAssociationOverrides() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverrideAnnotation.java deleted file mode 100644 index 37add8b4d8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverrideAnnotation.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.NullAttributeOverrideColumnAnnotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAttributeOverrideAnnotation; - -/** - * javax.persistence.AttributeOverride - */ -public final class BinaryAttributeOverrideAnnotation - extends BinaryOverrideAnnotation - implements NestableAttributeOverrideAnnotation -{ - private ColumnAnnotation column; - - - public BinaryAttributeOverrideAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.column = this.buildColumn(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updateColumn(); - } - - - //************ BinaryOverrideAnnotation implementation **************** - - @Override - protected String getNameElementName() { - return JPA.ATTRIBUTE_OVERRIDE__NAME; - } - - - //************ AttributeOverride implementation **************** - - // ***** column - public ColumnAnnotation getColumn() { - return this.column; - } - - public ColumnAnnotation getNonNullColumn() { - return (this.column != null) ? this.column : new NullAttributeOverrideColumnAnnotation(this); - } - - public ColumnAnnotation addColumn() { - throw new UnsupportedOperationException(); - } - - public void removeColumn() { - throw new UnsupportedOperationException(); - } - - private ColumnAnnotation buildColumn() { - IAnnotation jdtColumn = this.getJdtColumn(); - return (jdtColumn == null) ? null : this.buildColumn(jdtColumn); - } - - private ColumnAnnotation buildColumn(IAnnotation jdtColumn) { - return new BinaryColumnAnnotation(this, jdtColumn); - } - - private IAnnotation getJdtColumn() { - return (IAnnotation) this.getJdtMemberValue(JPA.ATTRIBUTE_OVERRIDE__COLUMN); - } - - private void setColumn(ColumnAnnotation column) { - ColumnAnnotation old = this.column; - this.column = column; - this.firePropertyChanged(COLUMN_PROPERTY, old, column); - } - - // TODO - private void updateColumn() { - throw new UnsupportedOperationException(); -// IAnnotation jdtColumn = this.getJdtColumn(); -// if (jdtColumn == null) { -// this.setColumn(null); -// } else { -// if (this.column == null) { -// this.setColumn(this.buildColumn(jdtColumn)); -// } else { -// this.column.update(jdtColumn); -// } -// } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverridesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverridesAnnotation.java deleted file mode 100644 index 2af0df8e18..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverridesAnnotation.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAttributeOverrideAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.AttributeOverrides - */ -public final class BinaryAttributeOverridesAnnotation - extends BinaryContainerAnnotation<NestableAttributeOverrideAnnotation> - implements AttributeOverridesAnnotation -{ - private final Vector<NestableAttributeOverrideAnnotation> attributeOverrides; - - - public BinaryAttributeOverridesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.attributeOverrides = this.buildAttributeOverrides(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public ListIterator<NestableAttributeOverrideAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableAttributeOverrideAnnotation>(this.attributeOverrides); - } - - public int nestedAnnotationsSize() { - return this.attributeOverrides.size(); - } - - private Vector<NestableAttributeOverrideAnnotation> buildAttributeOverrides() { - Object[] jdtAttributeOverrides = this.getJdtMemberValues(JPA.ATTRIBUTE_OVERRIDES__VALUE); - Vector<NestableAttributeOverrideAnnotation> result = new Vector<NestableAttributeOverrideAnnotation>(jdtAttributeOverrides.length); - for (Object jdtAttributeOverride : jdtAttributeOverrides) { - result.add(new BinaryAttributeOverrideAnnotation(this, (IAnnotation) jdtAttributeOverride)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updateAttributeOverrides(); - } - - // TODO - private void updateAttributeOverrides() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseColumnAnnotation.java deleted file mode 100644 index 7e7d4f32e9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseColumnAnnotation.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - */ -abstract class BinaryBaseColumnAnnotation - extends BinaryNamedColumnAnnotation - implements BaseColumnAnnotation -{ - private String table; - private Boolean unique; - private Boolean nullable; - private Boolean insertable; - private Boolean updatable; - - - BinaryBaseColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.table = this.buildTable(); - this.unique = this.buildUnique(); - this.nullable = this.buildNullable(); - this.insertable = this.buildInsertable(); - this.updatable = this.buildUpdatable(); - } - - @Override - public void update() { - super.update(); - this.setTable_(this.buildTable()); - this.setUnique_(this.buildUnique()); - this.setNullable_(this.buildNullable()); - this.setInsertable_(this.buildInsertable()); - this.setUpdatable_(this.buildUpdatable()); - } - - - //************* BaseColumnAnnotation implementation ************* - - // ***** table - public String getTable() { - return this.table; - } - - public void setTable(String table) { - throw new UnsupportedOperationException(); - } - - private void setTable_(String table) { - String old = this.table; - this.table = table; - this.firePropertyChanged(TABLE_PROPERTY, old, table); - } - - private String buildTable() { - return (String) this.getJdtMemberValue(this.getTableElementName()); - } - - abstract String getTableElementName(); - - public TextRange getTableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** unique - public Boolean getUnique() { - return this.unique; - } - - public void setUnique(Boolean unique) { - throw new UnsupportedOperationException(); - } - - private void setUnique_(Boolean unique) { - Boolean old = this.unique; - this.unique = unique; - this.firePropertyChanged(UNIQUE_PROPERTY, old, unique); - } - - private Boolean buildUnique() { - return (Boolean) this.getJdtMemberValue(this.getUniqueElementName()); - } - - abstract String getUniqueElementName(); - - public TextRange getUniqueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** nullable - public Boolean getNullable() { - return this.nullable; - } - - public void setNullable(Boolean nullable) { - throw new UnsupportedOperationException(); - } - - private void setNullable_(Boolean nullable) { - Boolean old = this.nullable; - this.nullable = nullable; - this.firePropertyChanged(NULLABLE_PROPERTY, old, nullable); - } - - private Boolean buildNullable() { - return (Boolean) this.getJdtMemberValue(this.getNullableElementName()); - } - - abstract String getNullableElementName(); - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** insertable - public Boolean getInsertable() { - return this.insertable; - } - - public void setInsertable(Boolean insertable) { - throw new UnsupportedOperationException(); - } - - private void setInsertable_(Boolean insertable) { - Boolean old = this.insertable; - this.insertable = insertable; - this.firePropertyChanged(INSERTABLE_PROPERTY, old, insertable); - } - - private Boolean buildInsertable() { - return (Boolean) this.getJdtMemberValue(this.getInsertableElementName()); - } - - abstract String getInsertableElementName(); - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** updatable - public Boolean getUpdatable() { - return this.updatable; - } - - public void setUpdatable(Boolean updatable) { - throw new UnsupportedOperationException(); - } - - private void setUpdatable_(Boolean updatable) { - Boolean old = this.updatable; - this.updatable = updatable; - this.firePropertyChanged(UPDATABLE_PROPERTY, old, updatable); - } - - private Boolean buildUpdatable() { - return (Boolean) this.getJdtMemberValue(this.getUpdatableElementName()); - } - - abstract String getUpdatableElementName(); - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseNamedQueryAnnotation.java deleted file mode 100644 index cb7745ef78..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseNamedQueryAnnotation.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseNamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.QueryHintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.NamedQuery - * javax.persistence.NamedNativeQuery - */ -abstract class BinaryBaseNamedQueryAnnotation - extends BinaryAnnotation - implements BaseNamedQueryAnnotation -{ - String name; - String query; - final Vector<QueryHintAnnotation> hints; - - - BinaryBaseNamedQueryAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - this.query = this.buildQuery(); - this.hints = this.buildHints(); - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - this.setQuery_(this.buildQuery()); - this.updateHints(); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** BaseNamedQueryAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(this.getNameElementName()); - } - - abstract String getNameElementName(); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** query - public String getQuery() { - return this.query; - } - - public void setQuery(String query) { - throw new UnsupportedOperationException(); - } - - private void setQuery_(String query) { - String old = this.query; - this.query = query; - this.firePropertyChanged(QUERY_PROPERTY, old, query); - } - - private String buildQuery() { - return (String) this.getJdtMemberValue(this.getQueryElementName()); - } - - abstract String getQueryElementName(); - - public TextRange getQueryTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** hints - public ListIterator<QueryHintAnnotation> hints() { - return new CloneListIterator<QueryHintAnnotation>(this.hints); - } - - public int hintsSize() { - return this.hints.size(); - } - - public QueryHintAnnotation hintAt(int index) { - return this.hints.get(index); - } - - public int indexOfHint(QueryHintAnnotation queryHint) { - return this.hints.indexOf(queryHint); - } - - public QueryHintAnnotation addHint(int index) { - throw new UnsupportedOperationException(); - } - - public void moveHint(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeHint(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<QueryHintAnnotation> buildHints() { - Object[] jdtHints = this.getJdtMemberValues(this.getHintsElementName()); - Vector<QueryHintAnnotation> result = new Vector<QueryHintAnnotation>(jdtHints.length); - for (Object jdtHint : jdtHints) { - result.add(new BinaryQueryHintAnnotation(this, (IAnnotation) jdtHint)); - } - return result; - } - - abstract String getHintsElementName(); - - // TODO - private void updateHints() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTableAnnotation.java deleted file mode 100644 index ca8c3d4ed4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTableAnnotation.java +++ /dev/null @@ -1,199 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BaseTableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.Table - * javax.persistence.JoinTable - * javax.persistence.SecondaryTable - */ -abstract class BinaryBaseTableAnnotation - extends BinaryAnnotation - implements BaseTableAnnotation -{ - String name; - String schema; - String catalog; - final Vector<UniqueConstraintAnnotation> uniqueConstraints; - - - BinaryBaseTableAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - this.schema = this.buildSchema(); - this.catalog = this.buildCatalog(); - this.uniqueConstraints = this.buildUniqueConstraints(); - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - this.setSchema_(this.buildSchema()); - this.setCatalog_(this.buildCatalog()); - this.updateUniqueConstraints(); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** BaseTableAnnotation implementation ********** - - public boolean isSpecified() { - return true; - } - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(this.getNameElementName()); - } - - abstract String getNameElementName(); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** schema - public String getSchema() { - return this.schema; - } - - public void setSchema(String schema) { - throw new UnsupportedOperationException(); - } - - private void setSchema_(String schema) { - String old = this.schema; - this.schema = schema; - this.firePropertyChanged(SCHEMA_PROPERTY, old, schema); - } - - private String buildSchema() { - return (String) this.getJdtMemberValue(this.getSchemaElementName()); - } - - abstract String getSchemaElementName(); - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** catalog - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String catalog) { - throw new UnsupportedOperationException(); - } - - private void setCatalog_(String catalog) { - String old = this.catalog; - this.catalog = catalog; - this.firePropertyChanged(CATALOG_PROPERTY, old, catalog); - } - - private String buildCatalog() { - return (String) this.getJdtMemberValue(this.getCatalogElementName()); - } - - abstract String getCatalogElementName(); - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** unique constraints - public ListIterator<UniqueConstraintAnnotation> uniqueConstraints() { - return new CloneListIterator<UniqueConstraintAnnotation>(this.uniqueConstraints); - } - - public int uniqueConstraintsSize() { - return this.uniqueConstraints.size(); - } - - public UniqueConstraintAnnotation uniqueConstraintAt(int index) { - return this.uniqueConstraints.get(index); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - return this.uniqueConstraints.indexOf(uniqueConstraint); - } - - public UniqueConstraintAnnotation addUniqueConstraint(int index) { - throw new UnsupportedOperationException(); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeUniqueConstraint(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<UniqueConstraintAnnotation> buildUniqueConstraints() { - Object[] jdtUniqueConstraints = this.getJdtMemberValues(this.getUniqueConstraintElementName()); - Vector<UniqueConstraintAnnotation> result = new Vector<UniqueConstraintAnnotation>(jdtUniqueConstraints.length); - for (Object jdtUniqueConstraint : jdtUniqueConstraints) { - result.add(new BinaryUniqueConstraintAnnotation(this, (IAnnotation) jdtUniqueConstraint)); - } - return result; - } - - abstract String getUniqueConstraintElementName(); - - // TODO - private void updateUniqueConstraints() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBasicAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBasicAnnotation.java deleted file mode 100644 index 9db25330ce..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBasicAnnotation.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Basic - */ -public final class BinaryBasicAnnotation - extends BinaryAnnotation - implements BasicAnnotation -{ - private Boolean optional; - private FetchType fetch; - - - public BinaryBasicAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.optional = this.buildOptional(); - this.fetch = this.buildFetch(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setOptional_(this.buildOptional()); - this.setFetch_(this.buildFetch()); - } - - - //*************** Basic implementation **************** - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - throw new UnsupportedOperationException(); - } - - private void setOptional_(Boolean optional) { - Boolean old = this.optional; - this.optional = optional; - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); - } - - private Boolean buildOptional() { - return (Boolean) this.getJdtMemberValue(JPA.BASIC__OPTIONAL); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** fetch - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType fetch) { - throw new UnsupportedOperationException(); - } - - private void setFetch_(FetchType fetch) { - FetchType old = this.fetch; - this.fetch = fetch; - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); - } - - private FetchType buildFetch() { - return FetchType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.BASIC__FETCH)); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryClassFile.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryClassFile.java deleted file mode 100644 index 037eda1ea4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryClassFile.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.core.resource.java.JavaResourceClassFile; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragment; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * binary class file - */ -final class BinaryClassFile - extends BinaryNode - implements JavaResourceClassFile -{ - /** JDT class file */ - private final IClassFile classFile; - - /** class file's persistent type */ - private final JavaResourcePersistentType persistentType; - - - // ********** construction/initialization ********** - - /** - * The JDT type gets passed in because the package fragment inspects it - * beforehand to determine whether it is "persistable". (We only build - * class files for "persistable" types.) - */ - BinaryClassFile(JavaResourcePackageFragment parent, IClassFile classFile, IType jdtType) { - super(parent); - this.classFile = classFile; - this.persistentType = this.buildPersistentType(jdtType); - } - - private JavaResourcePersistentType buildPersistentType(IType jdtType) { - return new BinaryPersistentType(this, jdtType); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.classFile.getElementName()); - } - - - // ********** JavaResourceClassFile implementation ********** - - public JavaResourcePersistentType getPersistentType() { - return this.persistentType; - } - - // TODO - @Override - public void update() { - super.update(); -// this.persistentType.update(this.classFile.getType()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java deleted file mode 100644 index 3290815860..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - */ -public final class BinaryColumnAnnotation - extends BinaryBaseColumnAnnotation - implements ColumnAnnotation -{ - private Integer length; - private Integer precision; - private Integer scale; - - - public BinaryColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.length = this.buildLength(); - this.precision = this.buildPrecision(); - this.scale = this.buildScale(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setLength_(this.buildLength()); - this.setPrecision_(this.buildPrecision()); - this.setScale_(this.buildScale()); - } - - - // ********** JavaSourceNamedColumnAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.COLUMN__NAME; - } - - @Override - String getColumnDefinitionElementName() { - return JPA.COLUMN__COLUMN_DEFINITION; - } - - - // ********** JavaSourceBaseColumnAnnotation implementation ********** - - @Override - String getTableElementName() { - return JPA.COLUMN__TABLE; - } - - @Override - String getUniqueElementName() { - return JPA.COLUMN__UNIQUE; - } - - @Override - String getNullableElementName() { - return JPA.COLUMN__NULLABLE; - } - - @Override - String getInsertableElementName() { - return JPA.COLUMN__INSERTABLE; - } - - @Override - String getUpdatableElementName() { - return JPA.COLUMN__UPDATABLE; - } - - - // ********** Column implementation ********** - - // ***** length - public Integer getLength() { - return this.length; - } - - public void setLength(Integer length) { - throw new UnsupportedOperationException(); - } - - private void setLength_(Integer length) { - Integer old = this.length; - this.length = length; - this.firePropertyChanged(LENGTH_PROPERTY, old, length); - } - - private Integer buildLength() { - return (Integer) this.getJdtMemberValue(JPA.COLUMN__LENGTH); - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** precision - public Integer getPrecision() { - return this.precision; - } - - public void setPrecision(Integer precision) { - throw new UnsupportedOperationException(); - } - - private void setPrecision_(Integer precision) { - Integer old = this.precision; - this.precision = precision; - this.firePropertyChanged(PRECISION_PROPERTY, old, precision); - } - - private Integer buildPrecision() { - return (Integer) this.getJdtMemberValue(JPA.COLUMN__PRECISION); - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** scale - public Integer getScale() { - return this.scale; - } - - public void setScale(Integer scale) { - throw new UnsupportedOperationException(); - } - - private void setScale_(Integer scale) { - Integer old = this.scale; - this.scale = scale; - this.firePropertyChanged(SCALE_PROPERTY, old, scale); - } - - private Integer buildScale() { - return (Integer) this.getJdtMemberValue(JPA.COLUMN__SCALE); - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java deleted file mode 100644 index 871b9b54f1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; - -/** - * JAR annotations do not support most of the container annotation protocol. - */ -abstract class BinaryContainerAnnotation<T extends NestableAnnotation> - extends BinaryAnnotation - implements ContainerAnnotation<T> -{ - - public BinaryContainerAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getContainerAnnotationName() { - throw new UnsupportedOperationException(); - } - - public Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public String getElementName() { - throw new UnsupportedOperationException(); - } - - public String getNestableAnnotationName() { - throw new UnsupportedOperationException(); - } - - public T addNestedAnnotationInternal() { - throw new UnsupportedOperationException(); - } - - public void nestedAnnotationAdded(int index, T nestedAnnotation) { - throw new UnsupportedOperationException(); - } - - public T moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public T removeNestedAnnotationInternal(int index) { - throw new UnsupportedOperationException(); - } - - public void nestedAnnotationRemoved(int index, T nestedAnnotation) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java deleted file mode 100644 index 779578ff56..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * javax.persistence.DiscriminatorColumn - */ -public final class BinaryDiscriminatorColumnAnnotation - extends BinaryNamedColumnAnnotation - implements DiscriminatorColumnAnnotation -{ - private DiscriminatorType discriminatorType; - private Integer length; - - - public BinaryDiscriminatorColumnAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.discriminatorType = this.buildDiscriminatorType(); - this.length = this.buildLength(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setDiscriminatorType_(this.buildDiscriminatorType()); - this.setLength_(this.buildLength()); - } - - - // ********** AbstractNamedColumn implementation ********** - - @Override - String getNameElementName() { - return JPA.DISCRIMINATOR_COLUMN__NAME; - } - - @Override - String getColumnDefinitionElementName() { - return JPA.DISCRIMINATOR_COLUMN__COLUMN_DEFINITION; - } - - - // ********** DiscriminatorColumn implementation ********** - - // ***** discriminator type - public DiscriminatorType getDiscriminatorType() { - return null; - } - - public void setDiscriminatorType(DiscriminatorType discriminatorType) { - throw new UnsupportedOperationException(); - } - - private void setDiscriminatorType_(DiscriminatorType discriminatorType) { - DiscriminatorType old = this.discriminatorType; - this.discriminatorType = discriminatorType; - this.firePropertyChanged(DISCRIMINATOR_TYPE_PROPERTY, old, discriminatorType); - } - - private DiscriminatorType buildDiscriminatorType() { - return DiscriminatorType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE)); - } - - // ***** length - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - throw new UnsupportedOperationException(); - } - - private void setLength_(Integer length) { - Integer old = this.length; - this.length = length; - this.firePropertyChanged(LENGTH_PROPERTY, old, length); - } - - private Integer buildLength() { - return (Integer) this.getJdtMemberValue(JPA.DISCRIMINATOR_COLUMN__LENGTH); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorValueAnnotation.java deleted file mode 100644 index 883f99695f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorValueAnnotation.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.DiscriminatorValue - */ -public final class BinaryDiscriminatorValueAnnotation - extends BinaryAnnotation - implements DiscriminatorValueAnnotation -{ - private String value; - - - public BinaryDiscriminatorValueAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** DiscriminatorValueAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA.DISCRIMINATOR_VALUE__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddableAnnotation.java deleted file mode 100644 index 91db09f2a2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddableAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * javax.persistence.Embeddable - */ -public final class BinaryEmbeddableAnnotation - extends BinaryAnnotation - implements EmbeddableAnnotation -{ - - public BinaryEmbeddableAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedAnnotation.java deleted file mode 100644 index 2fd143485d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.Embedded - */ -public final class BinaryEmbeddedAnnotation - extends BinaryAnnotation - implements EmbeddedAnnotation -{ - - public BinaryEmbeddedAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedIdAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedIdAnnotation.java deleted file mode 100644 index 604f5be572..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedIdAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.EmbeddedId - */ -public final class BinaryEmbeddedIdAnnotation - extends BinaryAnnotation - implements EmbeddedIdAnnotation -{ - - public BinaryEmbeddedIdAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEntityAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEntityAnnotation.java deleted file mode 100644 index bd4acb47b9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEntityAnnotation.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.EntityAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Entity - */ -public final class BinaryEntityAnnotation - extends BinaryAnnotation - implements EntityAnnotation -{ - private String name; - - - public BinaryEntityAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** EntityAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(JPA.ENTITY__NAME); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEnumeratedAnnotation.java deleted file mode 100644 index 0263fb7765..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEnumeratedAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.EnumType; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Enumerated - */ -public final class BinaryEnumeratedAnnotation - extends BinaryAnnotation - implements EnumeratedAnnotation -{ - private EnumType value; - - - public BinaryEnumeratedAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** EnumeratedAnnotation implementation ********** - - // ***** value - public EnumType getValue() { - return this.value; - } - - public void setValue(EnumType value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(EnumType value) { - EnumType old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private EnumType buildValue() { - return EnumType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.ENUMERATED__VALUE)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratedValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratedValueAnnotation.java deleted file mode 100644 index a6b26366a0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratedValueAnnotation.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation; -import org.eclipse.jpt.core.resource.java.GenerationType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.GeneratedValue - */ -public final class BinaryGeneratedValueAnnotation - extends BinaryAnnotation - implements GeneratedValueAnnotation -{ - private GenerationType strategy; - private String generator; - - - public BinaryGeneratedValueAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.strategy = this.buildStrategy(); - this.generator = this.buildGenerator(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setStrategy_(this.buildStrategy()); - this.setGenerator_(this.buildGenerator()); - } - - - // ********** GeneratedValueAnnotation implementation ********** - - // ***** strategy - public GenerationType getStrategy() { - return this.strategy; - } - - public void setStrategy(GenerationType strategy) { - throw new UnsupportedOperationException(); - } - - private void setStrategy_(GenerationType strategy) { - GenerationType old = this.strategy; - this.strategy = strategy; - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); - } - - private GenerationType buildStrategy() { - return GenerationType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.GENERATED_VALUE__STRATEGY)); - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** generator - public String getGenerator() { - return this.generator; - } - - public void setGenerator(String generator) { - throw new UnsupportedOperationException(); - } - - private void setGenerator_(String generator) { - String old = this.generator; - this.generator = generator; - this.firePropertyChanged(GENERATOR_PROPERTY, old, generator); - } - - private String buildGenerator() { - return (String) this.getJdtMemberValue(JPA.GENERATED_VALUE__GENERATOR); - } - - public TextRange getGeneratorTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean generatorTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratorAnnotation.java deleted file mode 100644 index d89cff9ec8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratorAnnotation.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.GeneratorAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.SequenceGenerator - * javax.persistence.TableGenerator - */ -abstract class BinaryGeneratorAnnotation - extends BinaryAnnotation - implements GeneratorAnnotation -{ - String name; - Integer initialValue; - Integer allocationSize; - - - BinaryGeneratorAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - this.initialValue = this.buildInitialValue(); - this.allocationSize = this.buildAllocationSize(); - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - this.setInitialValue_(this.buildInitialValue()); - this.setAllocationSize_(this.buildAllocationSize()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** GeneratorAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(this.getNameElementName()); - } - - abstract String getNameElementName(); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** initial value - public Integer getInitialValue() { - return this.initialValue; - } - - public void setInitialValue(Integer initialValue) { - throw new UnsupportedOperationException(); - } - - private void setInitialValue_(Integer initialValue) { - Integer old = this.initialValue; - this.initialValue = initialValue; - this.firePropertyChanged(INITIAL_VALUE_PROPERTY, old, initialValue); - } - - private Integer buildInitialValue() { - return (Integer) this.getJdtMemberValue(this.getInitialValueElementName()); - } - - abstract String getInitialValueElementName(); - - public TextRange getInitialValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** name - public Integer getAllocationSize() { - return this.allocationSize; - } - - public void setAllocationSize(Integer allocationSize) { - throw new UnsupportedOperationException(); - } - - private void setAllocationSize_(Integer allocationSize) { - Integer old = this.allocationSize; - this.allocationSize = allocationSize; - this.firePropertyChanged(NAME_PROPERTY, old, allocationSize); - } - - private Integer buildAllocationSize() { - return (Integer) this.getJdtMemberValue(this.getAllocationSizeElementName()); - } - - abstract String getAllocationSizeElementName(); - - public TextRange getAllocationSizeTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdAnnotation.java deleted file mode 100644 index 95946b447e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.IdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.Id - */ -public final class BinaryIdAnnotation - extends BinaryAnnotation - implements IdAnnotation -{ - - public BinaryIdAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdClassAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdClassAnnotation.java deleted file mode 100644 index 74ff351246..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdClassAnnotation.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.IdClassAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.IdClass - */ -public final class BinaryIdClassAnnotation - extends BinaryAnnotation - implements IdClassAnnotation -{ - private String value; - - - public BinaryIdClassAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** IdClassAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, value); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA.ID_CLASS__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** fully-qualified class name - /** - * binary is already fully-qualified - */ - public String getFullyQualifiedClassName() { - return this.value; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryInheritanceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryInheritanceAnnotation.java deleted file mode 100644 index 81711643ed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryInheritanceAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.InheritanceType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Inheritance - */ -public final class BinaryInheritanceAnnotation - extends BinaryAnnotation - implements InheritanceAnnotation -{ - private InheritanceType strategy; - - - public BinaryInheritanceAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.strategy = this.buildStrategy(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setStrategy_(this.buildStrategy()); - } - - - // ********** InheritanceAnnotation implementation ********** - - // ***** strategy - public InheritanceType getStrategy() { - return this.strategy; - } - - public void setStrategy(InheritanceType strategy) { - throw new UnsupportedOperationException(); - } - - private void setStrategy_(InheritanceType strategy) { - InheritanceType old = this.strategy; - this.strategy = strategy; - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); - } - - private InheritanceType buildStrategy() { - return InheritanceType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.INHERITANCE__STRATEGY)); - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java deleted file mode 100644 index 5c15fcefac..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.JoinColumn - */ -public final class BinaryJoinColumnAnnotation - extends BinaryBaseColumnAnnotation - implements NestableJoinColumnAnnotation -{ - private String referencedColumnName; - - - public BinaryJoinColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.referencedColumnName = this.buildReferencedColumnName(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setReferencedColumnName_(this.buildReferencedColumnName()); - } - - - // ********** JavaSourceNamedColumnAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.JOIN_COLUMN__NAME; - } - - @Override - String getColumnDefinitionElementName() { - return JPA.JOIN_COLUMN__COLUMN_DEFINITION; - } - - - // ********** JavaSourceNamedColumnAnnotation implementation ********** - - @Override - String getTableElementName() { - return JPA.JOIN_COLUMN__TABLE; - } - - @Override - String getUniqueElementName() { - return JPA.JOIN_COLUMN__UNIQUE; - } - - @Override - String getNullableElementName() { - return JPA.JOIN_COLUMN__NULLABLE; - } - - @Override - String getInsertableElementName() { - return JPA.JOIN_COLUMN__INSERTABLE; - } - - @Override - String getUpdatableElementName() { - return JPA.JOIN_COLUMN__UPDATABLE; - } - - - //************ JoinColumn implementation *************** - - // referenced column name - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - public void setReferencedColumnName(String referencedColumnName) { - throw new UnsupportedOperationException(); - } - - private void setReferencedColumnName_(String referencedColumnName) { - String old = this.referencedColumnName; - this.referencedColumnName = referencedColumnName; - this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, referencedColumnName); - } - - private String buildReferencedColumnName() { - return (String) this.getJdtMemberValue(JPA.JOIN_COLUMN__REFERENCED_COLUMN_NAME); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnsAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnsAnnotation.java deleted file mode 100644 index 196dd994d1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnsAnnotation.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.JoinColumns - */ -public final class BinaryJoinColumnsAnnotation - extends BinaryContainerAnnotation<NestableJoinColumnAnnotation> - implements JoinColumnsAnnotation -{ - private final Vector<NestableJoinColumnAnnotation> joinColumns; - - - public BinaryJoinColumnsAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.joinColumns = this.buildJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public ListIterator<NestableJoinColumnAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableJoinColumnAnnotation>(this.joinColumns); - } - - public int nestedAnnotationsSize() { - return this.joinColumns.size(); - } - - private Vector<NestableJoinColumnAnnotation> buildJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.JOIN_COLUMNS__VALUE); - Vector<NestableJoinColumnAnnotation> result = new Vector<NestableJoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updateJoinColumns(); - } - - // TODO - private void updateJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinTableAnnotation.java deleted file mode 100644 index 615b84b17e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinTableAnnotation.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.JoinTable - */ -public final class BinaryJoinTableAnnotation - extends BinaryBaseTableAnnotation - implements JoinTableAnnotation -{ - private final Vector<JoinColumnAnnotation> joinColumns; - private final Vector<JoinColumnAnnotation> inverseJoinColumns; - - - public BinaryJoinTableAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.joinColumns = this.buildJoinColumns(); - this.inverseJoinColumns = this.buildInverseJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updateJoinColumns(); - this.updateInverseJoinColumns(); - } - - - // ********** AbstractBaseTableAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.JOIN_TABLE__NAME; - } - - @Override - String getSchemaElementName() { - return JPA.JOIN_TABLE__SCHEMA; - } - - @Override - String getCatalogElementName() { - return JPA.JOIN_TABLE__CATALOG; - } - - @Override - String getUniqueConstraintElementName() { - return JPA.JOIN_TABLE__UNIQUE_CONSTRAINTS; - } - - - // ********** JoinTableAnnotation implementation ********** - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public JoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public JoinColumnAnnotation addJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<JoinColumnAnnotation> buildJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.JOIN_TABLE__JOIN_COLUMNS); - Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - // TODO - private void updateJoinColumns() { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation initializeJoinColumns() { - throw new UnsupportedOperationException(); - } - - // ***** inverse join columns - public ListIterator<JoinColumnAnnotation> inverseJoinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.inverseJoinColumns); - } - - public int inverseJoinColumnsSize() { - return this.inverseJoinColumns.size(); - } - - public JoinColumnAnnotation inverseJoinColumnAt(int index) { - return this.inverseJoinColumns.get(index); - } - - public int indexOfInverseJoinColumn(JoinColumnAnnotation joinColumn) { - return this.inverseJoinColumns.indexOf(joinColumn); - } - - public JoinColumnAnnotation addInverseJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void moveInverseJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeInverseJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<JoinColumnAnnotation> buildInverseJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.JOIN_TABLE__INVERSE_JOIN_COLUMNS); - Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - // TODO - private void updateInverseJoinColumns() { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation initializeInverseJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryLobAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryLobAnnotation.java deleted file mode 100644 index 2d5dc244cd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryLobAnnotation.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.LobAnnotation; - -/** - * javax.persistence.Lob - */ -public final class BinaryLobAnnotation - extends BinaryAnnotation - implements LobAnnotation -{ - public BinaryLobAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToManyAnnotation.java deleted file mode 100644 index 5428fce84a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToManyAnnotation.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.ManyToMany - */ -public final class BinaryManyToManyAnnotation - extends BinaryRelationshipMappingAnnotation - implements ManyToManyAnnotation -{ - private String mappedBy; - - - public BinaryManyToManyAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.mappedBy = this.buildMappedBy(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setMappedBy_(this.buildMappedBy()); - } - - - // ********** BinaryRelationshipMappingAnnotation implementation ********** - - @Override - String getTargetEntityElementName() { - return JPA.MANY_TO_MANY__TARGET_ENTITY; - } - - @Override - String getFetchElementName() { - return JPA.MANY_TO_MANY__FETCH; - } - - @Override - String getCascadeElementName() { - return JPA.MANY_TO_MANY__CASCADE; - } - - - //**************** OwnableRelationshipMappingAnnotation implementation ************** - - // ***** mapped by - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - throw new UnsupportedOperationException(); - } - - private void setMappedBy_(String mappedBy) { - String old = this.mappedBy; - this.mappedBy = mappedBy; - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); - } - - private String buildMappedBy() { - return (String) this.getJdtMemberValue(JPA.MANY_TO_MANY__MAPPED_BY); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToOneAnnotation.java deleted file mode 100644 index 77ad757c4f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToOneAnnotation.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.ManyToOne - */ -public final class BinaryManyToOneAnnotation - extends BinaryRelationshipMappingAnnotation - implements ManyToOneAnnotation -{ - private Boolean optional; - - - public BinaryManyToOneAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.optional = this.buildOptional(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setOptional_(this.buildOptional()); - } - - - // ********** BinaryRelationshipMappingAnnotation implementation ********** - - @Override - String getTargetEntityElementName() { - return JPA.MANY_TO_ONE__TARGET_ENTITY; - } - - @Override - String getFetchElementName() { - return JPA.MANY_TO_ONE__FETCH; - } - - @Override - String getCascadeElementName() { - return JPA.MANY_TO_ONE__CASCADE; - } - - - // ********** ManyToOneMappingAnnotation implementation ********** - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - throw new UnsupportedOperationException(); - } - - private void setOptional_(Boolean optional) { - Boolean old = this.optional; - this.optional = optional; - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); - } - - private Boolean buildOptional() { - return (Boolean) this.getJdtMemberValue(JPA.MANY_TO_ONE__OPTIONAL); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMapKeyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMapKeyAnnotation.java deleted file mode 100644 index 73b09dbed1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMapKeyAnnotation.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.MapKeyAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.MapKey - */ -public final class BinaryMapKeyAnnotation - extends BinaryAnnotation - implements MapKeyAnnotation -{ - private String name; - - - public BinaryMapKeyAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** MapKeyAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(JPA.MAP_KEY__NAME); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMappedSuperclassAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMappedSuperclassAnnotation.java deleted file mode 100644 index 419bfaaa06..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMappedSuperclassAnnotation.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation; - -public final class BinaryMappedSuperclassAnnotation - extends BinaryAnnotation - implements MappedSuperclassAnnotation -{ - public BinaryMappedSuperclassAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java deleted file mode 100644 index fb9168e6e5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - * javax.persistence.DiscriminatorColumn - * javax.persistence.PrimaryKeyJoinColumn. - */ -abstract class BinaryNamedColumnAnnotation - extends BinaryAnnotation - implements NamedColumnAnnotation -{ - private String name; - private String columnDefinition; - - - BinaryNamedColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - this.columnDefinition = this.buildColumnDefinition(); - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - this.setColumnDefinition_(this.buildColumnDefinition()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** NamedColumn implementation ********** - - public boolean isSpecified() { - return true; - } - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(this.getNameElementName()); - } - - abstract String getNameElementName(); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** column definition - public String getColumnDefinition() { - return null; - } - - public void setColumnDefinition(String columnDefinition) { - throw new UnsupportedOperationException(); - } - - private void setColumnDefinition_(String columnDefinition) { - String old = this.columnDefinition; - this.columnDefinition = columnDefinition; - this.firePropertyChanged(COLUMN_DEFINITION_PROPERTY, old, columnDefinition); - } - - private String buildColumnDefinition() { - return (String) this.getJdtMemberValue(this.getColumnDefinitionElementName()); - } - - abstract String getColumnDefinitionElementName(); - - public TextRange getColumnDefinitionTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueriesAnnotation.java deleted file mode 100644 index bc0ebc51e0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueriesAnnotation.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.NamedNativeQueries - */ -public final class BinaryNamedNativeQueriesAnnotation - extends BinaryContainerAnnotation<NestableNamedNativeQueryAnnotation> - implements NamedNativeQueriesAnnotation -{ - private final Vector<NestableNamedNativeQueryAnnotation> namedNativeQueries; - - - public BinaryNamedNativeQueriesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.namedNativeQueries = this.buildNamedNativeQueries(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public ListIterator<NestableNamedNativeQueryAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableNamedNativeQueryAnnotation>(this.namedNativeQueries); - } - - public int nestedAnnotationsSize() { - return this.namedNativeQueries.size(); - } - - private Vector<NestableNamedNativeQueryAnnotation> buildNamedNativeQueries() { - Object[] jdtQueries = this.getJdtMemberValues(JPA.NAMED_NATIVE_QUERIES__VALUE); - Vector<NestableNamedNativeQueryAnnotation> result = new Vector<NestableNamedNativeQueryAnnotation>(jdtQueries.length); - for (Object jdtQuery : jdtQueries) { - result.add(new BinaryNamedNativeQueryAnnotation(this, (IAnnotation) jdtQuery)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updateNamedNativeQueries(); - } - - // TODO - private void updateNamedNativeQueries() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueryAnnotation.java deleted file mode 100644 index 7b96cfc170..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueryAnnotation.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.NamedNativeQuery - */ -public final class BinaryNamedNativeQueryAnnotation - extends BinaryBaseNamedQueryAnnotation - implements NestableNamedNativeQueryAnnotation -{ - private String resultClass; - private String resultSetMapping; - - - public BinaryNamedNativeQueryAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.resultClass = this.buildResultClass(); - this.resultSetMapping = this.buildResultSetMapping(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setResultClass_(this.buildResultClass()); - this.setResultSetMapping_(this.buildResultSetMapping()); - } - - - // ********** BinaryBaseNamedQueryAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.NAMED_NATIVE_QUERY__NAME; - } - - @Override - String getQueryElementName() { - return JPA.NAMED_NATIVE_QUERY__QUERY; - } - - @Override - String getHintsElementName() { - return JPA.NAMED_NATIVE_QUERY__HINTS; - } - - - // ********** NamedNativeQueryAnnotation implementation ********** - - // ***** result class - public String getResultClass() { - return this.resultClass; - } - - public void setResultClass(String resultClass) { - throw new UnsupportedOperationException(); - } - - private void setResultClass_(String resultClass) { - String old = this.resultClass; - this.resultClass = resultClass; - this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass); - } - - private String buildResultClass() { - return (String) this.getJdtMemberValue(JPA.NAMED_NATIVE_QUERY__RESULT_CLASS); - } - - public TextRange getResultClassTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** fully-qualified result class name - public String getFullyQualifiedResultClassName() { - return this.resultClass; - } - - // ***** result set mapping - public String getResultSetMapping() { - return this.resultSetMapping; - } - - public void setResultSetMapping(String resultSetMapping) { - throw new UnsupportedOperationException(); - } - - private void setResultSetMapping_(String resultSetMapping) { - String old = this.resultSetMapping; - this.resultSetMapping = resultSetMapping; - this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping); - } - - private String buildResultSetMapping() { - return (String) this.getJdtMemberValue(JPA.NAMED_NATIVE_QUERY__RESULT_CLASS); - } - - public TextRange getResultSetMappingTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java deleted file mode 100644 index f671570332..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.NamedQueries - */ -public final class BinaryNamedQueriesAnnotation - extends BinaryContainerAnnotation<NestableNamedQueryAnnotation> - implements NamedQueriesAnnotation -{ - private final Vector<NestableNamedQueryAnnotation> namedQueries; - - - public BinaryNamedQueriesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.namedQueries = this.buildNamedQueries(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public ListIterator<NestableNamedQueryAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableNamedQueryAnnotation>(this.namedQueries); - } - - public int nestedAnnotationsSize() { - return this.namedQueries.size(); - } - - private Vector<NestableNamedQueryAnnotation> buildNamedQueries() { - Object[] jdtQueries = this.getJdtMemberValues(JPA.NAMED_QUERIES__VALUE); - Vector<NestableNamedQueryAnnotation> result = new Vector<NestableNamedQueryAnnotation>(jdtQueries.length); - for (Object jdtQuery : jdtQueries) { - result.add(new BinaryNamedQueryAnnotation(this, (IAnnotation) jdtQuery)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updateNamedQueries(); - } - - // TODO - private void updateNamedQueries() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java deleted file mode 100644 index 95b7b0e2a0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; - -/** - * javax.persistence.NamedQuery - */ -public final class BinaryNamedQueryAnnotation - extends BinaryBaseNamedQueryAnnotation - implements NestableNamedQueryAnnotation -{ - public BinaryNamedQueryAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** BinaryBaseNamedQueryAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.NAMED_QUERY__NAME; - } - - @Override - String getQueryElementName() { - return JPA.NAMED_QUERY__QUERY; - } - - @Override - String getHintsElementName() { - return JPA.NAMED_QUERY__HINTS; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java deleted file mode 100644 index 07a15f79a1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * Binary convenience methods - */ -// TODO hopefully this class can go away with some sort of refactoring of the -// source and binary hierarchies... -public abstract class BinaryNode - extends AbstractJavaResourceNode -{ - - // ********** construction ********** - - protected BinaryNode(JavaResourceNode parent) { - super(parent); - } - - - // ********** JavaResourceNode implementation ********** - - @Override - public IFile getFile() { - return null; // only BinaryPackageFragmentRoot has a file... - } - - public void update() { - // nothing by default - } - - public JavaResourceCompilationUnit getJavaResourceCompilationUnit() { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public void initialize(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToManyAnnotation.java deleted file mode 100644 index fcd1c05da2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToManyAnnotation.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OneToManyAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OneToMany - */ -public final class BinaryOneToManyAnnotation - extends BinaryRelationshipMappingAnnotation - implements OneToManyAnnotation -{ - private String mappedBy; - - - public BinaryOneToManyAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.mappedBy = this.buildMappedBy(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setMappedBy_(this.buildMappedBy()); - } - - - // ********** BinaryRelationshipMappingAnnotation implementation ********** - - @Override - String getTargetEntityElementName() { - return JPA.ONE_TO_MANY__TARGET_ENTITY; - } - - @Override - String getFetchElementName() { - return JPA.ONE_TO_MANY__FETCH; - } - - @Override - String getCascadeElementName() { - return JPA.ONE_TO_MANY__CASCADE; - } - - - //**************** OwnableRelationshipMappingAnnotation implementation ************** - - // ***** mapped by - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - throw new UnsupportedOperationException(); - } - - private void setMappedBy_(String mappedBy) { - String old = this.mappedBy; - this.mappedBy = mappedBy; - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); - } - - private String buildMappedBy() { - return (String) this.getJdtMemberValue(JPA.ONE_TO_MANY__MAPPED_BY); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToOneAnnotation.java deleted file mode 100644 index a36c7bf1d8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToOneAnnotation.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OneToOneAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OneToOne - */ -public final class BinaryOneToOneAnnotation - extends BinaryRelationshipMappingAnnotation - implements OneToOneAnnotation -{ - private Boolean optional; - private String mappedBy; - - public BinaryOneToOneAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.optional = this.buildOptional(); - this.mappedBy = this.buildMappedBy(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setOptional_(this.buildOptional()); - this.setMappedBy_(this.buildMappedBy()); - } - - - // ********** BinaryRelationshipMappingAnnotation implementation ********** - - @Override - String getTargetEntityElementName() { - return JPA.ONE_TO_ONE__TARGET_ENTITY; - } - - @Override - String getFetchElementName() { - return JPA.ONE_TO_ONE__FETCH; - } - - @Override - String getCascadeElementName() { - return JPA.ONE_TO_ONE__CASCADE; - } - - - //**************** OwnableRelationshipMappingAnnotation implementation ************** - - // ***** mapped by - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - throw new UnsupportedOperationException(); - } - - private void setMappedBy_(String mappedBy) { - String old = this.mappedBy; - this.mappedBy = mappedBy; - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); - } - - private String buildMappedBy() { - return (String) this.getJdtMemberValue(JPA.ONE_TO_ONE__MAPPED_BY); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - - //**************** OneToOneAnnotation implementation ************** - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - throw new UnsupportedOperationException(); - } - - private void setOptional_(Boolean optional) { - Boolean old = this.optional; - this.optional = optional; - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); - } - - private Boolean buildOptional() { - return (Boolean) this.getJdtMemberValue(JPA.MANY_TO_ONE__OPTIONAL); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOrderByAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOrderByAnnotation.java deleted file mode 100644 index 690fdc3263..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOrderByAnnotation.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.OrderByAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OrderBy - */ -public final class BinaryOrderByAnnotation - extends BinaryAnnotation - implements OrderByAnnotation -{ - private String value; - - - public BinaryOrderByAnnotation(JavaResourceNode parent, IAnnotation annotation) { - super(parent, annotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** OrderByAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA.ORDER_BY__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOverrideAnnotation.java deleted file mode 100644 index 4e129f6372..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOverrideAnnotation.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.OverrideAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * Common behavior for - * javax.persistence.AttributeOverride - * javax.persistence.AssociationOverride - */ -public abstract class BinaryOverrideAnnotation - extends BinaryAnnotation - implements OverrideAnnotation -{ - private String name; - - - public BinaryOverrideAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** OverrideAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(OverrideAnnotation.NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(this.getNameElementName()); - } - - protected abstract String getNameElementName(); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java deleted file mode 100644 index 734439b56d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java +++ /dev/null @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.ListIterator; -import java.util.Vector; -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.JavaResourceClassFile; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragment; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * binary package fragment - */ -final class BinaryPackageFragment - extends BinaryNode - implements JavaResourcePackageFragment -{ - /** JDT package fragment */ - private final IPackageFragment packageFragment; - - /** - * class files in the package fragment; - * we only hold class files/types that are actually annotated; - * if the unannotated types are needed (e.g. for orm.xml or an - * inheritance tree) they can be discovered on the classpath as needed - */ - private final Vector<JavaResourceClassFile> classFiles = new Vector<JavaResourceClassFile>(); - - - // ********** construction/initialization ********** - - BinaryPackageFragment(JavaResourcePackageFragmentRoot parent, IPackageFragment packageFragment) { - super(parent); - this.packageFragment = packageFragment; - this.classFiles.addAll(this.buildClassFiles()); - } - - private Collection<JavaResourceClassFile> buildClassFiles() { - IJavaElement[] children = this.getJDTChildren(); - ArrayList<JavaResourceClassFile> result = new ArrayList<JavaResourceClassFile>(children.length); - for (IJavaElement child : children) { - IClassFile jdtClassFile = (IClassFile) child; - IType jdtType = jdtClassFile.getType(); - if (BinaryPersistentType.typeIsPersistable(jdtType)) { - JavaResourceClassFile classFile = new BinaryClassFile(this, jdtClassFile, jdtType); - if (classFile.getPersistentType().isAnnotated()) { // we only hold annotated types - result.add(classFile); - } - } - } - return result; - } - - - // ********** JarResourceNode implementation ********** - - @Override - public void update() { - super.update(); - this.updateClassFiles(); - } - - // TODO - private void updateClassFiles() { - throw new UnsupportedOperationException(); - } - - - // ********** JavaResourcePackageFragment implementation ********** - - public ListIterator<JavaResourceClassFile> classFiles() { - return new CloneListIterator<JavaResourceClassFile>(this.classFiles); - } - - public int classFilesSize() { - return this.classFiles.size(); - } - - public Iterator<JavaResourcePersistentType> persistedTypes() { - return new TransformationIterator<JavaResourceClassFile, JavaResourcePersistentType>(this.classFiles()) { - @Override - protected JavaResourcePersistentType transform(JavaResourceClassFile classFile) { - return classFile.getPersistentType(); // we only hold annotated types - } - }; - } - - - // ********** misc ********** - - private IJavaElement[] getJDTChildren() { - try { - return this.packageFragment.getChildren(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_JAVA_ELEMENT_ARRAY; - } - } - protected static final IJavaElement[] EMPTY_JAVA_ELEMENT_ARRAY = new IJavaElement[0]; - - @Override - public void toString(StringBuilder sb) { - sb.append(this.packageFragment.getElementName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java deleted file mode 100644 index 52276c41a0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.Vector; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragment; -import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.internal.iterators.CloneIterator; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * binary package fragment root - */ -public final class BinaryPackageFragmentRoot - extends RootBinaryNode - implements JavaResourcePackageFragmentRoot -{ - /** JDT package fragment root */ - private final IPackageFragmentRoot packageFragmentRoot; - - /** package fragments in the JAR */ - private final Vector<JavaResourcePackageFragment> packageFragments = new Vector<JavaResourcePackageFragment>(); - - - // ********** construction/initialization ********** - - public BinaryPackageFragmentRoot(IPackageFragmentRoot packageFragmentRoot, JpaAnnotationProvider annotationProvider) { - super(null, annotationProvider); // the package fragment root is the root of its sub-tree - this.packageFragmentRoot = packageFragmentRoot; - this.packageFragments.addAll(this.buildPackageFragments()); - } - - private Collection<JavaResourcePackageFragment> buildPackageFragments() { - IJavaElement[] jdtChildren = this.getJDTChildren(); - ArrayList<JavaResourcePackageFragment> result = new ArrayList<JavaResourcePackageFragment>(jdtChildren.length); - for (IJavaElement child : jdtChildren) { - result.add(new BinaryPackageFragment(this, (IPackageFragment) child)); - } - return result; - } - - - // ********** overrides ********** - - @Override - public IFile getFile() { - return (IFile) this.packageFragmentRoot.getResource(); - } - - @Override - public void update() { - super.update(); - this.updatePackageFragments(); - } - - // TODO - private void updatePackageFragments() { - throw new UnsupportedOperationException(); - } - - - // ********** JavaResourceNode.Root implementation ********** - - /** - * NB: we hold only annotated types - */ - public Iterator<JavaResourcePersistentType> persistentTypes() { - return new CompositeIterator<JavaResourcePersistentType>(this.persistedTypeIterators()); - } - - private Iterator<Iterator<JavaResourcePersistentType>> persistedTypeIterators() { - return new TransformationIterator<JavaResourcePackageFragment, Iterator<JavaResourcePersistentType>>(this.packageFragments()) { - @Override - protected Iterator<JavaResourcePersistentType> transform(JavaResourcePackageFragment fragment) { - return fragment.persistedTypes(); - } - }; - } - - - // ********** JavaResourcePackageFragmentRoot implementation ********** - - public Iterator<JavaResourcePackageFragment> packageFragments() { - return new CloneIterator<JavaResourcePackageFragment>(this.packageFragments); - } - - public int packageFragmentsSize() { - return this.packageFragments.size(); - } - - - // ********** misc ********** - - private IJavaElement[] getJDTChildren() { - try { - return this.packageFragmentRoot.getChildren(); - } catch (JavaModelException ex) { - // ignore FNFE - which can happen when the workspace is out of synch with O/S file system - if ( ! (ex.getCause() instanceof FileNotFoundException)) { - JptCorePlugin.log(ex); - } - return EMPTY_JAVA_ELEMENT_ARRAY; - } - } - private static final IJavaElement[] EMPTY_JAVA_ELEMENT_ARRAY = new IJavaElement[0]; - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getFile().getName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java deleted file mode 100644 index 392396901d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java +++ /dev/null @@ -1,648 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Vector; -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IField; -import org.eclipse.jdt.core.IJavaProject; -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.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.utility.jdt.JPTTools; -import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.MethodSignature; -import org.eclipse.jpt.utility.internal.ClassTools; -import org.eclipse.jpt.utility.internal.NameTools; -import org.eclipse.jpt.utility.internal.iterators.CloneIterator; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * binary persistent attribute (field or property) - */ -final class BinaryPersistentAttribute - extends BinaryPersistentMember - implements JavaResourcePersistentAttribute -{ - private int modifiers; - - private String typeName; - - private boolean typeIsInterface; - - private boolean typeIsEnum; - - private final Vector<String> typeSuperclassNames = new Vector<String>(); - - private final Vector<String> typeInterfaceNames = new Vector<String>(); - - private final Vector<String> typeTypeArgumentNames = new Vector<String>(); - - - BinaryPersistentAttribute(JavaResourcePersistentType parent, IField field) { - this(parent, new FieldAdapter(field)); - } - - BinaryPersistentAttribute(JavaResourcePersistentType parent, IMethod method) { - this(parent, new MethodAdapter(method)); - } - - private BinaryPersistentAttribute(JavaResourcePersistentType parent, Adapter adapter) { - super(parent, adapter); - this.modifiers = this.buildModifiers(); - this.typeName = this.buildTypeName(); - - IType type = this.getType(); // shouldn't be an array... - this.typeIsInterface = this.buildTypeIsInterface(type); - this.typeIsEnum = this.buildTypeIsEnum(type); - this.typeSuperclassNames.addAll(this.buildTypeSuperclassNames(type)); - this.typeInterfaceNames.addAll(this.buildTypeInterfaceNames(type)); - - this.typeTypeArgumentNames.addAll(this.buildTypeTypeArgumentNames()); - } - - - // ******** overrides ******** - - @Override - public void update() { - super.update(); - this.setModifiers(this.buildModifiers()); - this.setTypeName(this.buildTypeName()); - - IType type = this.getType(); // shouldn't be an array... - this.setTypeIsInterface(this.buildTypeIsInterface(type)); - this.setTypeIsEnum(this.buildTypeIsEnum(type)); - this.setTypeSuperclassNames(this.buildTypeSuperclassNames(type)); - this.setTypeInterfaceNames(this.buildTypeInterfaceNames(type)); - - this.setTypeTypeArgumentNames(this.buildTypeTypeArgumentNames()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getName()); - } - - - // ********** BinaryPersistentMember implementation ********** - - private Adapter getAdapter() { - return (Adapter) this.adapter; - } - - @Override - Iterator<String> validAnnotationNames() { - return this.getAnnotationProvider().attributeAnnotationNames(); - } - - @Override - Annotation buildAnnotation(IAnnotation jdtAnnotation) { - return this.getAnnotationProvider().buildAttributeAnnotation(this, jdtAnnotation); - } - - Annotation buildNullAnnotation_(String annotationName) { - return this.getAnnotationProvider().buildNullAttributeAnnotation(this, annotationName); - } - - - // ********** JavaResourcePersistentAttribute implementation ********** - - public String getName() { - return this.getAdapter().getAttributeName(); - } - - @Override - public Annotation buildNullAnnotation(String annotationName) { - return (annotationName == null) ? null : this.buildNullAnnotation_(annotationName); - } - - public boolean isField() { - return this.getAdapter().isField(); - } - - public boolean isProperty() { - return ! this.isField(); - } - - public boolean isFor(MethodSignature methodSignature, int occurrence) { - throw new UnsupportedOperationException(); - } - - public AccessType getSpecifiedAccess() { - Access2_0Annotation accessAnnotation = (Access2_0Annotation) this.getAnnotation(Access2_0Annotation.ANNOTATION_NAME); - return accessAnnotation == null ? null : accessAnnotation.getValue(); - } - - public boolean typeIsSubTypeOf(String tn) { - return ((this.typeName != null) && this.typeName.equals(tn)) - || this.typeInterfaceNames.contains(tn) - || this.typeSuperclassNames.contains(tn); - } - - public boolean typeIsVariablePrimitive() { - return (this.typeName != null) && ClassTools.classNamedIsVariablePrimitive(this.typeName); - } - - // ***** modifiers - public int getModifiers() { - return this.modifiers; - } - - private void setModifiers(int modifiers) { - int old = this.modifiers; - this.modifiers = modifiers; - this.firePropertyChanged(MODIFIERS_PROPERTY, old, modifiers); - } - - /** - * zero seems like a reasonable default... - */ - private int buildModifiers() { - try { - return this.getMember().getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - // ***** type name - public String getTypeName() { - return this.typeName; - } - - private void setTypeName(String typeName) { - String old = this.typeName; - this.typeName = typeName; - this.firePropertyChanged(TYPE_NAME_PROPERTY, old, typeName); - } - - /** - * JARs don't have array types; - * also, no generic type parameters - */ - private String buildTypeName() { - return convertTypeSignatureToTypeName(this.getTypeSignature()); - } - - // ***** type is interface - public boolean typeIsInterface() { - return this.typeIsInterface; - } - - private void setTypeIsInterface(boolean typeIsInterface) { - boolean old = this.typeIsInterface; - this.typeIsInterface = typeIsInterface; - this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, typeIsInterface); - } - - private boolean buildTypeIsInterface(IType type) { - try { - return (type != null) && type.isInterface(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** type is enum - public boolean typeIsEnum() { - return this.typeIsEnum; - } - - private void setTypeIsEnum(boolean typeIsEnum) { - boolean old = this.typeIsEnum; - this.typeIsEnum = typeIsEnum; - this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, typeIsEnum); - } - - private boolean buildTypeIsEnum(IType type) { - try { - return (type != null) && type.isEnum(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** type superclass hierarchy - public ListIterator<String> typeSuperclassNames() { - return new CloneListIterator<String>(this.typeSuperclassNames); - } - - public boolean typeSuperclassNamesContains(String superclassName) { - return this.typeSuperclassNames.contains(superclassName); - } - - private void setTypeSuperclassNames(List<String> typeSuperclassNames) { - this.synchronizeList(typeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_LIST); - } - - private List<String> buildTypeSuperclassNames(IType type) { - if (type == null) { - return Collections.emptyList(); - } - - ArrayList<String> names = new ArrayList<String>(); - type = this.findSuperclass(type); - while (type != null) { - names.add(type.getFullyQualifiedName('.')); // no parameters are included here - type = this.findSuperclass(type); - } - return names; - } - - // ***** type interface hierarchy - public Iterator<String> typeInterfaceNames() { - return new CloneIterator<String>(this.typeInterfaceNames); - } - - public boolean typeInterfaceNamesContains(String interfaceName) { - return this.typeInterfaceNames.contains(interfaceName); - } - - private void setTypeInterfaceNames(Collection<String> typeInterfaceNames) { - this.synchronizeCollection(typeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION); - } - - private Collection<String> buildTypeInterfaceNames(IType type) { - if (type == null) { - return Collections.emptySet(); - } - - HashSet<String> names = new HashSet<String>(); - while (type != null) { - this.addInterfaceNamesTo(type, names); - type = this.findSuperclass(type); - } - return names; - } - - private void addInterfaceNamesTo(IType type, HashSet<String> names) { - for (String interfaceSignature : this.getSuperInterfaceTypeSignatures(type)) { - String interfaceName = convertTypeSignatureToTypeName(interfaceSignature); - names.add(interfaceName); - IType interfaceType = this.findType(interfaceName); - if (interfaceType != null) { - this.addInterfaceNamesTo(interfaceType, names); // recurse - } - } - } - - // ***** type type argument names - public ListIterator<String> typeTypeArgumentNames() { - return new CloneListIterator<String>(this.typeTypeArgumentNames); - } - - public int typeTypeArgumentNamesSize() { - return this.typeTypeArgumentNames.size(); - } - - public String getTypeTypeArgumentName(int index) { - return this.typeTypeArgumentNames.get(index); - } - - private void setTypeTypeArgumentNames(List<String> typeTypeArgumentNames) { - this.synchronizeList(typeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_LIST); - } - - /** - * these types can be arrays (e.g. "java.lang.String[]"); - * but they won't have any further nested generic type arguments - * (e.g. "java.util.Collection<java.lang.String>") - */ - private List<String> buildTypeTypeArgumentNames() { - String typeSignature = this.getTypeSignature(); - if (typeSignature == null) { - return Collections.emptyList(); - } - - String[] typeArgumentSignatures = Signature.getTypeArguments(typeSignature); - if (typeArgumentSignatures.length == 0) { - return Collections.emptyList(); - } - - ArrayList<String> names = new ArrayList<String>(typeArgumentSignatures.length); - for (String typeArgumentSignature : typeArgumentSignatures) { - names.add(convertTypeSignatureToTypeName(typeArgumentSignature)); - } - return names; - } - - - // ********** convenience methods ********** - - private String getTypeSignature() { - try { - return this.getAdapter().getTypeSignature(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - private IType findSuperclass(IType type) { - return this.findTypeBySignature(this.getSuperclassSignature(type)); - } - - private String getSuperclassSignature(IType type) { - try { - return type.getSuperclassTypeSignature(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - private String[] getSuperInterfaceTypeSignatures(IType type) { - try { - return type.getSuperInterfaceTypeSignatures(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_STRING_ARRAY; - } - } - private static final String[] EMPTY_STRING_ARRAY = new String[0]; - - private IType findTypeBySignature(String typeSignature) { - return (typeSignature == null) ? null : this.findType(convertTypeSignatureToTypeName_(typeSignature)); - } - - private IType getType() { - return (this.typeName == null) ? null : this.findType(this.typeName); - } - - private IType findType(String fullyQualifiedName) { - try { - return this.getJavaProject().findType(fullyQualifiedName); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - private IJavaProject getJavaProject() { - return this.getMember().getJavaProject(); - } - - - - // ********** adapters ********** - - /** - * Adapt an IField or IMethod. - */ - interface Adapter - extends BinaryPersistentMember.Adapter - { - /** - * Return the field or getter method's "attribute" name - * (e.g. field "foo" -> "foo"; method "getFoo" -> "foo"). - */ - String getAttributeName(); - - /** - * Return whether the attribute is a Java field (as opposed to a method). - */ - boolean isField(); - - /** - * Return the attribute's type signature. - */ - String getTypeSignature() throws JavaModelException; - } - - /** - * IField adapter - */ - static class FieldAdapter - implements Adapter - { - final IField field; - - FieldAdapter(IField field) { - super(); - this.field = field; - } - - public IField getMember() { - return this.field; - } - - public boolean isPersistable() { - return this.field.exists() && JPTTools.fieldIsPersistable(new JPTToolsAdapter()); - } - - public IAnnotation[] getAnnotations() throws JavaModelException { - return this.field.getAnnotations(); - } - - public String getAttributeName() { - return this.field.getElementName(); - } - - public boolean isField() { - return true; - } - - public String getTypeSignature() throws JavaModelException { - return this.field.getTypeSignature(); - } - - /** - * JPTTools needs an adapter so it can work with either an IField - * or an IVariableBinding etc. - */ - class JPTToolsAdapter implements JPTTools.FieldAdapter { - public int getModifiers() { - try { - return FieldAdapter.this.field.getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - } - - } - - /** - * IMethod adapter - */ - static class MethodAdapter - implements Adapter - { - final IMethod method; - static final IMethod[] EMPTY_METHOD_ARRAY = new IMethod[0]; - - MethodAdapter(IMethod method) { - super(); - this.method = method; - } - - public IMethod getMember() { - return this.method; - } - - public boolean isPersistable() { - return JPTTools.methodIsPersistablePropertyGetter(new JPTToolsAdapter()); - } - - public IAnnotation[] getAnnotations() throws JavaModelException { - return this.method.getAnnotations(); - } - - public String getAttributeName() { - return NameTools.convertGetterMethodNameToPropertyName(this.method.getElementName()); - } - - public boolean isField() { - return false; - } - - public String getTypeSignature() throws JavaModelException { - return this.method.getReturnType(); - } - - /** - * JPTTools needs an adapter so it can work with either an IMethod - * or an IMethodBinding etc. - */ - abstract static class AbstractJPTToolsAdapter - implements JPTTools.SimpleMethodAdapter - { - AbstractJPTToolsAdapter() { - super(); - } - - abstract IMethod getMethod(); - - public int getModifiers() { - try { - return this.getMethod().getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - public String getReturnTypeErasureName() { - return convertTypeSignatureToTypeName(this.getReturnTypeSignature()); - } - - private String getReturnTypeSignature() { - try { - return this.getMethod().getReturnType(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - public boolean isConstructor() { - try { - return this.getMethod().isConstructor(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - } - - static class SimpleJPTToolsAdapter - extends AbstractJPTToolsAdapter - { - private final IMethod method; - - SimpleJPTToolsAdapter(IMethod method) { - super(); - this.method = method; - } - - @Override - IMethod getMethod() { - return this.method; - } - - } - - class JPTToolsAdapter - extends AbstractJPTToolsAdapter - implements JPTTools.MethodAdapter - { - JPTToolsAdapter() { - super(); - } - - @Override - IMethod getMethod() { - return MethodAdapter.this.method; - } - - public String getName() { - return this.getMethod().getElementName(); - } - - public int getParametersLength() { - return this.getMethod().getParameterTypes().length; - } - - public JPTTools.SimpleMethodAdapter getSibling(String name) { - for (IMethod sibling : this.getSiblings()) { - if ((sibling.getParameterTypes().length == 0) - && sibling.getElementName().equals(name)) { - return new SimpleJPTToolsAdapter(sibling); - } - } - return null; - } - - public JPTTools.SimpleMethodAdapter getSibling(String name, String parameterTypeErasureName) { - for (IMethod sibling : this.getSiblings()) { - String[] parmTypes = sibling.getParameterTypes(); - if ((parmTypes.length == 1) - && sibling.getElementName().equals(name) - && convertTypeSignatureToTypeName(parmTypes[0]).equals(parameterTypeErasureName)) { - return new SimpleJPTToolsAdapter(sibling); - } - } - return null; - } - - private IMethod[] getSiblings() { - try { - return this.getMethod().getDeclaringType().getMethods(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_METHOD_ARRAY; - } - } - - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java deleted file mode 100644 index c8676f67c6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java +++ /dev/null @@ -1,283 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.Iterator; -import java.util.Vector; -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IMember; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator; - -/** - * binary persistent member - */ -abstract class BinaryPersistentMember - extends BinaryNode - implements JavaResourcePersistentMember -{ - /** JDT member adapter */ - final Adapter adapter; - - /** annotations */ - final Vector<Annotation> annotations = new Vector<Annotation>(); - - boolean persistable; - - - // ********** construction/initialization ********** - - public BinaryPersistentMember(JavaResourceNode parent, Adapter adapter) { - super(parent); - this.adapter = adapter; - this.initializeAnnotations(); - this.persistable = this.buildPersistable(); - } - - private void initializeAnnotations() { - for (IAnnotation annotation : this.getJdtAnnotations()) { - this.addAnnotation(annotation); - } - } - - private void addAnnotation(IAnnotation jdtAnnotation) { - if (this.annotationIsValid(jdtAnnotation)) { - this.annotations.add(this.buildAnnotation(jdtAnnotation)); - } - } - - - // ********** updating ********** - - @Override - public void update() { - super.update(); - this.updateAnnotations(); - this.setPersistable(this.buildPersistable()); - } - - // TODO - private void updateAnnotations() { - throw new UnsupportedOperationException(); - } - - - // ********** annotations ********** - - public Iterator<Annotation> annotations() { - return this.getAnnotations().iterator(); - } - - private Iterable<Annotation> getAnnotations() { - return new LiveCloneIterable<Annotation>(this.annotations); - } - - public int annotationsSize() { - return this.annotations.size(); - } - - public Annotation getAnnotation(String annotationName) { - return this.selectAnnotationNamed(this.getAnnotations(), annotationName); - } - - public Annotation getNonNullAnnotation(String annotationName) { - Annotation annotation = this.getAnnotation(annotationName); - return (annotation != null) ? annotation : this.buildNullAnnotation(annotationName); - } - - public Iterator<NestableAnnotation> annotations( - String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = - getContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - return containerAnnotation.nestedAnnotations(); - } - NestableAnnotation nestableAnnotation = - getNestableAnnotation(nestableAnnotationName); - return (nestableAnnotation == null) ? - EmptyListIterator.<NestableAnnotation>instance() : - new SingleElementIterator<NestableAnnotation>(nestableAnnotation); - } - - private NestableAnnotation getNestableAnnotation(String annotationName) { - return (NestableAnnotation) this.getAnnotation(annotationName); - } - - @SuppressWarnings("unchecked") - private ContainerAnnotation<NestableAnnotation> getContainerAnnotation(String annotationName) { - return (ContainerAnnotation<NestableAnnotation>) this.getAnnotation(annotationName); - } - - private boolean annotationIsValid(IAnnotation jdtAnnotation) { - return CollectionTools.contains( - this.validAnnotationNames(), jdtAnnotation.getElementName()); - } - - abstract Iterator<String> validAnnotationNames(); - - abstract Annotation buildAnnotation(IAnnotation jdtAnnotation); - - abstract Annotation buildNullAnnotation(String annotationName); - - - // ********** simple state ********** - - public boolean isPersistable() { - return this.persistable; - } - - private void setPersistable(boolean persistable) { - boolean old = this.persistable; - this.persistable = persistable; - this.firePropertyChanged(PERSISTABLE_PROPERTY, old, persistable); - } - - private boolean buildPersistable() { - return this.adapter.isPersistable(); - } - - public boolean isAnnotated() { - return ! this.annotations.isEmpty(); - } - - - // ********** miscellaneous ********** - - IMember getMember() { - return this.adapter.getMember(); - } - - private Annotation selectAnnotationNamed(Iterable<Annotation> annotations, String annotationName) { - for (Annotation annotation : annotations) { - if (annotation.getAnnotationName().equals(annotationName)) { - return annotation; - } - } - return null; - } - - /** - * convenience method - */ - <T extends JavaResourcePersistentMember> Iterator<T> persistableMembers(Iterator<T> members) { - return new FilteringIterator<T, T>(members) { - @Override - protected boolean accept(T m) { - return m.isPersistable(); - } - }; - } - - /** - * Strip off the type signature's parameters if present. - * Convert to a readable string. - */ - static String convertTypeSignatureToTypeName(String typeSignature) { - return (typeSignature == null) ? null : convertTypeSignatureToTypeName_(typeSignature); - } - - /** - * no null check - */ - static String convertTypeSignatureToTypeName_(String typeSignature) { - return Signature.toString(Signature.getTypeErasure(typeSignature)); - } - - private IAnnotation[] getJdtAnnotations() { - try { - return this.adapter.getAnnotations(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_JDT_ANNOTATION_ARRAY; - } - } - private static final IAnnotation[] EMPTY_JDT_ANNOTATION_ARRAY = new IAnnotation[0]; - - - // ********** IMember adapter ********** - - interface Adapter { - /** - * Return the adapter's JDT member (IType, IField, IMethod). - */ - IMember getMember(); - - /** - * Return whether the adapter's member is "persistable" - * (i.e. according to the JPA spec the member can be mapped) - */ - boolean isPersistable(); - - /** - * Return the adapter's member's JDT annotations. - */ - IAnnotation[] getAnnotations() throws JavaModelException; - } - - - // ********** unsupported JavaResourcePersistentMember implementation ********** - - public Annotation addAnnotation(String annotationName) { - throw new UnsupportedOperationException(); - } - - public Annotation addAnnotation(String annotationName, AnnotationInitializer foo) { - throw new UnsupportedOperationException(); - } - - public NestableAnnotation addAnnotation( - int index, String nestableAnnotationName, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - public void moveAnnotation( - int targetIndex, int sourceIndex, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation(String annotationName) { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation( - int index, String nestableAnnotationName, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - public Annotation setPrimaryAnnotation( - String primaryAnnotationName, String[] supportingAnnotationNames) { - throw new UnsupportedOperationException(); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public void resolveTypes(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean isFor(String memberName, int occurrence) { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java deleted file mode 100644 index 0ad5c16718..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java +++ /dev/null @@ -1,543 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Vector; -import org.eclipse.jdt.core.Flags; -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.IField; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.utility.jdt.JPTTools; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.MethodSignature; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; - -/** - * binary persistent type - */ -final class BinaryPersistentType - extends BinaryPersistentMember - implements JavaResourcePersistentType -{ - private String name; - - private String qualifiedName; - - private String superclassQualifiedName; - - private boolean abstract_; // 'abstract' is a reserved word - - private final Vector<JavaResourcePersistentAttribute> fields; - - private final Vector<JavaResourcePersistentAttribute> methods; - - private AccessType access; - - - // ********** construction/initialization ********** - - BinaryPersistentType(JavaResourceNode parent, IType type) { - super(parent, new TypeAdapter(type)); - this.name = this.buildName(); - this.qualifiedName = this.buildQualifiedName(); - this.superclassQualifiedName = this.buildSuperclassQualifiedName(); - this.abstract_ = this.buildAbstract(); - this.fields = this.buildFields(); - this.methods = this.buildMethods(); - // need to wait until everything is built to calculate 'access' - this.access = this.buildAccess(); - } - - - // ********** overrides ********** - - @Override - public void update() { - super.update(); - this.setName(this.buildName()); - this.setQualifiedName(this.buildQualifiedName()); - this.setSuperclassQualifiedName(this.buildSuperclassQualifiedName()); - this.setAbstract(this.buildAbstract()); - this.updateFields(); - this.updateMethods(); - // need to wait until everything is updated to calculate 'access' - this.setAccess(this.buildAccess()); - } - - // TODO - private void updateFields() { - throw new UnsupportedOperationException(); - } - - // TODO - private void updateMethods() { - throw new UnsupportedOperationException(); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** BinaryPersistentMember implementation ********** - - @Override - Annotation buildAnnotation(IAnnotation jdtAnnotation) { - return this.getAnnotationProvider().buildTypeAnnotation(this, jdtAnnotation); - } - - @Override - Annotation buildNullAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullTypeAnnotation(this, annotationName); - } - - @Override - Iterator<String> validAnnotationNames() { - return this.getAnnotationProvider().typeAnnotationNames(); - } - - - // ********** JavaResourcePersistentType implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - private void setName(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return this.getMember().getElementName(); - } - - // ***** qualified name - public String getQualifiedName() { - return this.qualifiedName; - } - - private void setQualifiedName(String qualifiedName) { - String old = this.qualifiedName; - this.qualifiedName = qualifiedName; - this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, qualifiedName); - } - - private String buildQualifiedName() { - return this.getMember().getFullyQualifiedName('.'); // no parameters are included here - } - - // ***** superclass qualified name - public String getSuperclassQualifiedName() { - return this.superclassQualifiedName; - } - - private void setSuperclassQualifiedName(String superclassQualifiedName) { - String old = this.superclassQualifiedName; - this.superclassQualifiedName = superclassQualifiedName; - this.firePropertyChanged(SUPERCLASS_QUALIFIED_NAME_PROPERTY, old, superclassQualifiedName); - } - - private String buildSuperclassQualifiedName() { - return convertTypeSignatureToTypeName(this.getSuperclassTypeSignature()); - } - - private String getSuperclassTypeSignature() { - try { - return this.getMember().getSuperclassTypeSignature(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - // ***** abstract - public boolean isAbstract() { - return this.abstract_; - } - - private void setAbstract(boolean abstract_) { - boolean old = this.abstract_; - this.abstract_ = abstract_; - this.firePropertyChanged(ABSTRACT_PROPERTY, old, abstract_); - } - - private boolean buildAbstract() { - try { - return Flags.isAbstract(this.getMember().getFlags()); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** access - public AccessType getAccess() { - return this.access; - } - - private void setAccess(AccessType access) { - AccessType old = this.access; - this.access = access; - this.firePropertyChanged(ACCESS_PROPERTY, old, access); - } - - private AccessType buildAccess() { - return JPTTools.buildAccess(this); - } - - public boolean isMapped() { - for (Annotation each : CollectionTools.iterable(annotations())) { - if (CollectionTools.contains( - getAnnotationProvider().typeMappingAnnotationNames(), - each.getAnnotationName())) { - return true; - } - } - return false; - } - - /** - * check only persistable attributes - */ - public boolean hasAnyAnnotatedAttributes() { - for (Iterator<JavaResourcePersistentAttribute> stream = this.persistableAttributes(); stream.hasNext(); ) { - if (stream.next().isAnnotated()) { - return true; - } - } - return false; - } - - @Override - public IType getMember() { - return (IType) super.getMember(); - } - - - // ********** fields ********** - - public Iterator<JavaResourcePersistentAttribute> fields() { - return this.getFields().iterator(); - } - - private Iterable<JavaResourcePersistentAttribute> getFields() { - return new LiveCloneIterable<JavaResourcePersistentAttribute>(this.fields); - } - - public Iterator<JavaResourcePersistentAttribute> persistableFields() { - return this.persistableMembers(this.fields()); - } - - public Iterator<JavaResourcePersistentAttribute> persistableFieldsWithSpecifiedFieldAccess() { - return new FilteringIterator<JavaResourcePersistentAttribute, JavaResourcePersistentAttribute>(this.persistableFields()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.FIELD; - } - }; - } - - private void addField(JavaResourcePersistentAttribute field) { - this.addItemToCollection(field, this.fields, FIELDS_COLLECTION); - } - - private JavaResourcePersistentAttribute getField(String fieldName, int occurrence) { - for (JavaResourcePersistentAttribute field : this.getFields()) { - if (field.isFor(fieldName, occurrence)) { - return field; - } - } - return null; - } - - private void removeFields(Collection<JavaResourcePersistentAttribute> remove) { - this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION); - } - - private Vector<JavaResourcePersistentAttribute> buildFields() { - IField[] jdtFields = this.getFields(this.getMember()); - Vector<JavaResourcePersistentAttribute> result = new Vector<JavaResourcePersistentAttribute>(jdtFields.length); - for (IField jdtField : jdtFields) { - result.add(this.buildField(jdtField)); - } - return result; - } - - private IField[] getFields(IType type) { - try { - return type.getFields(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_FIELD_ARRAY; - } - } - private static final IField[] EMPTY_FIELD_ARRAY = new IField[0]; - - private JavaResourcePersistentAttribute buildField(IField jdtField) { - return new BinaryPersistentAttribute(this, jdtField); - } - - - // ********** methods ********** - - public Iterator<JavaResourcePersistentAttribute> methods() { - return this.getMethods().iterator(); - } - - private Iterable<JavaResourcePersistentAttribute> getMethods() { - return new LiveCloneIterable<JavaResourcePersistentAttribute>(this.methods); - } - - public Iterator<JavaResourcePersistentAttribute> persistableProperties() { - return persistableMembers(this.methods()); - } - - public Iterator<JavaResourcePersistentAttribute> persistablePropertiesWithSpecifiedPropertyAccess() { - return new FilteringIterator<JavaResourcePersistentAttribute, JavaResourcePersistentAttribute>(this.persistableProperties()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.PROPERTY; - } - }; - } - - private JavaResourcePersistentAttribute getMethod(MethodSignature signature, int occurrence) { - for (JavaResourcePersistentAttribute method : this.getMethods()) { - if (method.isFor(signature, occurrence)) { - return method; - } - } - return null; - } - - private void addMethod(JavaResourcePersistentAttribute method) { - this.addItemToCollection(method, this.methods, METHODS_COLLECTION); - } - - private void removeMethods(Collection<JavaResourcePersistentAttribute> remove) { - this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION); - } - - private Vector<JavaResourcePersistentAttribute> buildMethods() { - IMethod[] jdtMethods = this.getMethods(this.getMember()); - Vector<JavaResourcePersistentAttribute> result = new Vector<JavaResourcePersistentAttribute>(jdtMethods.length); - for (IMethod jdtMethod : jdtMethods) { - result.add(this.buildMethod(jdtMethod)); - } - return result; - } - - private IMethod[] getMethods(IType type) { - try { - return type.getMethods(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_METHOD_ARRAY; - } - } - private static final IMethod[] EMPTY_METHOD_ARRAY = new IMethod[0]; - - private JavaResourcePersistentAttribute buildMethod(IMethod jdtMethod) { - return new BinaryPersistentAttribute(this, jdtMethod); - } - - - // ********** attributes ********** - - @SuppressWarnings("unchecked") - public Iterator<JavaResourcePersistentAttribute> persistableAttributes() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableFields(), - this.persistableProperties() - ); - } - - public Iterator<JavaResourcePersistentAttribute> persistableAttributes(AccessType specifiedAccess) { - if (specifiedAccess == null) { - throw new IllegalArgumentException("specified access is null"); //$NON-NLS-1$ - } - return (specifiedAccess == AccessType.FIELD) ? - this.persistableAttributesForFieldAccessType() : - this.persistableAttributesForPropertyAccessType(); - } - - @SuppressWarnings("unchecked") - private Iterator<JavaResourcePersistentAttribute> persistableAttributesForFieldAccessType() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableFields(), - this.persistablePropertiesWithSpecifiedPropertyAccess() - ); - } - - @SuppressWarnings("unchecked") - private Iterator<JavaResourcePersistentAttribute> persistableAttributesForPropertyAccessType() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableProperties(), - this.persistableFieldsWithSpecifiedFieldAccess() - ); - } - - - // ********** IType adapter ********** - - static class TypeAdapter implements Adapter { - private final IType type; - - TypeAdapter(IType type) { - super(); - this.type = type; - } - - public IType getMember() { - return this.type; - } - - public boolean isPersistable() { - return true; // we only build a JAR type if it is "persistable" - } - - public IAnnotation[] getAnnotations() throws JavaModelException { - return this.type.getAnnotations(); - } - - } - - - // ********** "persistable" check ********** - - static boolean typeIsPersistable(IType type) { - return (type != null) - && type.exists() - && JPTTools.typeIsPersistable(new JPTToolsAdapter(type)); - } - - - // ********** JPT tools adapter ********** - - /** - * JPTTools needs an adapter so it can work with either an IType - * or an ITypeBinding etc. - */ - static class JPTToolsAdapter implements JPTTools.TypeAdapter { - private final IType type; - - protected JPTToolsAdapter(IType type) { - super(); - if (type == null) { - throw new NullPointerException(); - } - this.type = type; - } - - public int getModifiers() { - try { - return this.type.getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - public boolean isAnnotation() { - try { - return this.type.isAnnotation(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isAnonymous() { - try { - return this.type.isAnonymous(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isArray() { - return false; // ??? - } - - public boolean isEnum() { - try { - return this.type.isEnum(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isInterface() { - try { - return this.type.isInterface(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isLocal() { - try { - return this.type.isLocal(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isMember() { - try { - return this.type.isMember(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public boolean isPrimitive() { - return false; // ??? - } - - } - - - // ********** unsupported JavaResourcePersistentType implementation ********** - - public Iterator<JavaResourcePersistentType> types() { - throw new UnsupportedOperationException(); - } - - public Iterator<JavaResourcePersistentType> allTypes() { - throw new UnsupportedOperationException(); - } - - public Iterator<JavaResourcePersistentType> persistableTypes() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentTypeCache.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentTypeCache.java deleted file mode 100644 index bc1b8a1225..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentTypeCache.java +++ /dev/null @@ -1,149 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.Iterator; -import java.util.Vector; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentTypeCache; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterables.TransformationIterable; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * cache used to hold binary "external" Java resource persistent types - * (typically derived from JARs on the project's build path) - */ -public final class BinaryPersistentTypeCache - extends RootBinaryNode - implements JavaResourcePersistentTypeCache -{ - /** populated on-demand */ - private final Vector<Entry> entries = new Vector<Entry>(); - - - // ********** construction ********** - - public BinaryPersistentTypeCache(JpaAnnotationProvider annotationProvider) { - super(null, annotationProvider); - } - - - // ********** JavaResourceNode.Root implementation ********** - - public Iterator<JavaResourcePersistentType> persistentTypes() { - return this.getPersistentTypes().iterator(); - } - - private Iterable<JavaResourcePersistentType> getPersistentTypes() { - return new TransformationIterable<Entry, JavaResourcePersistentType>(this.getEntries()) { - @Override - protected JavaResourcePersistentType transform(Entry entry) { - return entry.persistentType; - } - }; - } - - private Iterable<Entry> getEntries() { - return new LiveCloneIterable<Entry>(this.entries); - } - - - // ********** JavaResourcePersistentTypeCache implementation ********** - - public int persistentTypesSize() { - return this.entries.size(); - } - - public JavaResourcePersistentType addPersistentType(IType jdtType) { - Entry entry = this.buildEntry(jdtType); - this.entries.add(entry); - this.fireItemAdded(PERSISTENT_TYPES_COLLECTION, entry.persistentType); - return entry.persistentType; - } - - private Entry buildEntry(IType jdtType) { - return new Entry(this.buildPersistentType(jdtType), jdtType.getResource()); - } - - private JavaResourcePersistentType buildPersistentType(IType jdtType) { - return new BinaryPersistentType(this, jdtType); - } - - public boolean removePersistentTypes(IFile jarFile) { - boolean modified = false; - for (Entry entry : this.getEntries()) { - IResource resource = entry.resource; - if ((resource != null) && resource.equals(jarFile)) { - this.removeEntry(entry); - modified = true; - } - } - return modified; - } - - private void removeEntry(Entry entry) { - this.entries.remove(entry); - this.fireItemRemoved(PERSISTENT_TYPES_COLLECTION, entry.persistentType); - } - - - // ********** overrides ********** - - /** - * Ignore changes to this collection. Adds can be ignored since they are triggered - * by requests that will, themselves, trigger updates (typically during the - * update of an object that calls a setter with the newly-created resource - * type). Deletes will be accompanied by manual updates. - */ - @Override - protected void aspectChanged(String aspectName) { - if ((aspectName != null) && ! aspectName.equals(PERSISTENT_TYPES_COLLECTION)) { - super.aspectChanged(aspectName); - } - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.entries); - } - - - // ********** cache entry ********** - - /** - * Associate a persistent type with its resource. - * This will be a JAR in the case of a type loaded from a JAR that is in - * the Eclipse workspace. The resource will be null for a type loaded - * from a JAR or class directory outside of the workspace. - */ - static class Entry { - final JavaResourcePersistentType persistentType; - final IResource resource; - - Entry(JavaResourcePersistentType persistentType, IResource resource) { - super(); - this.persistentType = persistentType; - this.resource = resource; - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.persistentType); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java deleted file mode 100644 index 35a6401ce0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.PrimaryKeyJoinColumn - */ -public final class BinaryPrimaryKeyJoinColumnAnnotation - extends BinaryNamedColumnAnnotation - implements NestablePrimaryKeyJoinColumnAnnotation -{ - private String referencedColumnName; - - - public BinaryPrimaryKeyJoinColumnAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.referencedColumnName = this.buildReferencedColumnName(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setReferencedColumnName_(this.buildReferencedColumnName()); - } - - - // ********** AbstractNamedColumn implementation ********** - - @Override - String getNameElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN__NAME; - } - - @Override - String getColumnDefinitionElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN__COLUMN_DEFINITION; - } - - - // ********** PrimaryKeyJoinColumn implementation ********** - - // ***** referenced column name - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - public void setReferencedColumnName(String referencedColumnName) { - throw new UnsupportedOperationException(); - } - - private void setReferencedColumnName_(String referencedColumnName) { - String old = this.referencedColumnName; - this.referencedColumnName = referencedColumnName; - this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, referencedColumnName); - } - - private String buildReferencedColumnName() { - return (String) this.getJdtMemberValue(JPA.PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnsAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnsAnnotation.java deleted file mode 100644 index 0951dbc459..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnsAnnotation.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnsAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.PrimaryKeyJoinColumns - */ -public final class BinaryPrimaryKeyJoinColumnsAnnotation - extends BinaryContainerAnnotation<NestablePrimaryKeyJoinColumnAnnotation> - implements PrimaryKeyJoinColumnsAnnotation -{ - private final Vector<NestablePrimaryKeyJoinColumnAnnotation> pkJoinColumns; - - - public BinaryPrimaryKeyJoinColumnsAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.pkJoinColumns = this.buildPkJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public ListIterator<NestablePrimaryKeyJoinColumnAnnotation> nestedAnnotations() { - return new CloneListIterator<NestablePrimaryKeyJoinColumnAnnotation>(this.pkJoinColumns); - } - - public int nestedAnnotationsSize() { - return this.pkJoinColumns.size(); - } - - private Vector<NestablePrimaryKeyJoinColumnAnnotation> buildPkJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.PRIMARY_KEY_JOIN_COLUMNS__VALUE); - Vector<NestablePrimaryKeyJoinColumnAnnotation> result = new Vector<NestablePrimaryKeyJoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryPrimaryKeyJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updatePkJoinColumns(); - } - - // TODO - private void updatePkJoinColumns() { - throw new UnsupportedOperationException(); - } - -} - diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryQueryHintAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryQueryHintAnnotation.java deleted file mode 100644 index c3f76581e6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryQueryHintAnnotation.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.QueryHintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.QueryHint - */ -class BinaryQueryHintAnnotation - extends BinaryAnnotation - implements QueryHintAnnotation -{ - private String name; - private String value; - - - BinaryQueryHintAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.name = this.buildName(); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setName_(this.buildName()); - this.setValue_(this.buildValue()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** QueryHintAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - private void setName_(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName() { - return (String) this.getJdtMemberValue(JPA.QUERY_HINT__NAME); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA.QUERY_HINT__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryRelationshipMappingAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryRelationshipMappingAnnotation.java deleted file mode 100644 index 1ba6e11ed3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryRelationshipMappingAnnotation.java +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.CascadeType; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.RelationshipMappingAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.ArrayTools; - -/** - * javax.persistence.ManyToMany - * javax.persistence.ManyToOne - * javax.persistence.OneToMany - * javax.persistence.OneToOne - */ -abstract class BinaryRelationshipMappingAnnotation - extends BinaryAnnotation - implements RelationshipMappingAnnotation -{ - String targetEntity; - FetchType fetch; - boolean cascadeAll; - boolean cascadeMerge; - boolean cascadePersist; - boolean cascadeRefresh; - boolean cascadeRemove; - - - BinaryRelationshipMappingAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.targetEntity = this.buildTargetEntity(); - this.fetch = this.buildFetch(); - - CascadeType[] cascadeTypes = this.buildCascadeTypes(); - this.cascadeAll = ArrayTools.contains(cascadeTypes, CascadeType.ALL); - this.cascadeMerge = ArrayTools.contains(cascadeTypes, CascadeType.MERGE); - this.cascadePersist = ArrayTools.contains(cascadeTypes, CascadeType.PERSIST); - this.cascadeRefresh = ArrayTools.contains(cascadeTypes, CascadeType.REFRESH); - this.cascadeRemove = ArrayTools.contains(cascadeTypes, CascadeType.REMOVE); - } - - @Override - public void update() { - super.update(); - this.setTargetEntity_(this.buildTargetEntity()); - this.setFetch_(this.buildFetch()); - - CascadeType[] cascadeTypes = this.buildCascadeTypes(); - this.setCascadeAll_(ArrayTools.contains(cascadeTypes, CascadeType.ALL)); - this.setCascadeMerge_(ArrayTools.contains(cascadeTypes, CascadeType.MERGE)); - this.setCascadePersist_(ArrayTools.contains(cascadeTypes, CascadeType.PERSIST)); - this.setCascadeRefresh_(ArrayTools.contains(cascadeTypes, CascadeType.REFRESH)); - this.setCascadeRemove_(ArrayTools.contains(cascadeTypes, CascadeType.REMOVE)); - } - - - // ********** RelationshipMappingAnnotation implementation ********** - - // ***** target entity - public String getTargetEntity() { - return this.targetEntity; - } - - public void setTargetEntity(String targetEntity) { - throw new UnsupportedOperationException(); - } - - private void setTargetEntity_(String targetEntity) { - String old = this.targetEntity; - this.targetEntity = targetEntity; - this.firePropertyChanged(TARGET_ENTITY_PROPERTY, old, targetEntity); - this.firePropertyChanged(FULLY_QUALIFIED_TARGET_ENTITY_CLASS_NAME_PROPERTY, old, targetEntity); - } - - private String buildTargetEntity() { - return (String) this.getJdtMemberValue(this.getTargetEntityElementName()); - } - - abstract String getTargetEntityElementName(); - - public TextRange getTargetEntityTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** fully-qualified target entity class name - public String getFullyQualifiedTargetEntityClassName() { - return this.targetEntity; - } - - // ***** fetch - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType fetch) { - throw new UnsupportedOperationException(); - } - - private void setFetch_(FetchType fetch) { - FetchType old = this.fetch; - this.fetch = fetch; - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); - } - - private FetchType buildFetch() { - return FetchType.fromJavaAnnotationValue(this.getJdtMemberValue(this.getFetchElementName())); - } - - abstract String getFetchElementName(); - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** cascade - private CascadeType[] buildCascadeTypes() { - return CascadeType.fromJavaAnnotationValues(this.getJdtMemberValues(this.getCascadeElementName())); - } - - abstract String getCascadeElementName(); - - public TextRange getCascadeTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** cascade all - public boolean isCascadeAll() { - return this.cascadeAll; - } - - public void setCascadeAll(boolean cascadeAll) { - throw new UnsupportedOperationException(); - } - - private void setCascadeAll_(boolean cascadeAll) { - boolean old = this.cascadeAll; - this.cascadeAll = cascadeAll; - this.firePropertyChanged(CASCADE_ALL_PROPERTY, old, cascadeAll); - } - - // ***** cascade merge - public boolean isCascadeMerge() { - return this.cascadeMerge; - } - - public void setCascadeMerge(boolean cascadeMerge) { - throw new UnsupportedOperationException(); - } - - private void setCascadeMerge_(boolean cascadeMerge) { - boolean old = this.cascadeMerge; - this.cascadeMerge = cascadeMerge; - this.firePropertyChanged(CASCADE_MERGE_PROPERTY, old, cascadeMerge); - } - - // ***** cascade persist - public boolean isCascadePersist() { - return this.cascadePersist; - } - - public void setCascadePersist(boolean cascadePersist) { - throw new UnsupportedOperationException(); - } - - private void setCascadePersist_(boolean cascadePersist) { - boolean old = this.cascadePersist; - this.cascadePersist = cascadePersist; - this.firePropertyChanged(CASCADE_PERSIST_PROPERTY, old, cascadePersist); - } - - // ***** cascade refresh - public boolean isCascadeRefresh() { - return this.cascadeRefresh; - } - - public void setCascadeRefresh(boolean cascadeRefresh) { - throw new UnsupportedOperationException(); - } - - private void setCascadeRefresh_(boolean cascadeRefresh) { - boolean old = this.cascadeRefresh; - this.cascadeRefresh = cascadeRefresh; - this.firePropertyChanged(CASCADE_REFRESH_PROPERTY, old, cascadeRefresh); - } - - // ***** cascade remove - public boolean isCascadeRemove() { - return this.cascadeRemove; - } - - public void setCascadeRemove(boolean cascadeRemove) { - throw new UnsupportedOperationException(); - } - - private void setCascadeRemove_(boolean cascadeRemove) { - boolean old = this.cascadeRemove; - this.cascadeRemove = cascadeRemove; - this.firePropertyChanged(CASCADE_REMOVE_PROPERTY, old, cascadeRemove); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTableAnnotation.java deleted file mode 100644 index dd8eaa1a7e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTableAnnotation.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableSecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.SecondaryTable - */ -public final class BinarySecondaryTableAnnotation - extends BinaryBaseTableAnnotation - implements NestableSecondaryTableAnnotation -{ - private final Vector<PrimaryKeyJoinColumnAnnotation> pkJoinColumns; - - public BinarySecondaryTableAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.pkJoinColumns = this.buildPkJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updatePkJoinColumns(); - } - - - // ********** BinaryBaseTableAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.SECONDARY_TABLE__NAME; - } - - @Override - String getSchemaElementName() { - return JPA.SECONDARY_TABLE__SCHEMA; - } - - @Override - String getCatalogElementName() { - return JPA.SECONDARY_TABLE__CATALOG; - } - - @Override - String getUniqueConstraintElementName() { - return JPA.SECONDARY_TABLE__UNIQUE_CONSTRAINTS; - } - - - // ************* SecondaryTable implementation ******************* - - // ***** pk join columns - public ListIterator<PrimaryKeyJoinColumnAnnotation> pkJoinColumns() { - return new CloneListIterator<PrimaryKeyJoinColumnAnnotation>(this.pkJoinColumns); - } - - public int pkJoinColumnsSize() { - return this.pkJoinColumns.size(); - } - - public PrimaryKeyJoinColumnAnnotation pkJoinColumnAt(int index) { - return this.pkJoinColumns.get(index); - } - - public int indexOfPkJoinColumn(PrimaryKeyJoinColumnAnnotation pkJoinColumn) { - return this.pkJoinColumns.indexOf(pkJoinColumn); - } - - public PrimaryKeyJoinColumnAnnotation addPkJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void movePkJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removePkJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<PrimaryKeyJoinColumnAnnotation> buildPkJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.SECONDARY_TABLE__PK_JOIN_COLUMNS); - Vector<PrimaryKeyJoinColumnAnnotation> result = new Vector<PrimaryKeyJoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryPrimaryKeyJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - // TODO - private void updatePkJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTablesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTablesAnnotation.java deleted file mode 100644 index 01edfe1e8c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTablesAnnotation.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.NestableSecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.SecondaryTablesAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.SecondaryTables - */ -public final class BinarySecondaryTablesAnnotation - extends BinaryContainerAnnotation<NestableSecondaryTableAnnotation> - implements SecondaryTablesAnnotation -{ - private final Vector<NestableSecondaryTableAnnotation> secondaryTables; - - - public BinarySecondaryTablesAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.secondaryTables = this.buildSecondaryTables(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public ListIterator<NestableSecondaryTableAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableSecondaryTableAnnotation>(this.secondaryTables); - } - - public int nestedAnnotationsSize() { - return this.secondaryTables.size(); - } - - private Vector<NestableSecondaryTableAnnotation> buildSecondaryTables() { - Object[] jdtSecondaryTables = this.getJdtMemberValues(JPA.SECONDARY_TABLES__VALUE); - Vector<NestableSecondaryTableAnnotation> result = new Vector<NestableSecondaryTableAnnotation>(jdtSecondaryTables.length); - for (Object jdtSecondaryTable : jdtSecondaryTables) { - result.add(new BinarySecondaryTableAnnotation(this, (IAnnotation) jdtSecondaryTable)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updateSecondaryTables(); - } - - // TODO - private void updateSecondaryTables() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySequenceGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySequenceGeneratorAnnotation.java deleted file mode 100644 index cfe2c821ba..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySequenceGeneratorAnnotation.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.SequenceGenerator - */ -public abstract class BinarySequenceGeneratorAnnotation - extends BinaryGeneratorAnnotation - implements SequenceGeneratorAnnotation -{ - private String sequenceName; - - - protected BinarySequenceGeneratorAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.sequenceName = this.buildSequenceName(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setSequenceName_(this.buildSequenceName()); - } - - - // ********** BinaryGeneratorAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.SEQUENCE_GENERATOR__NAME; - } - - @Override - String getInitialValueElementName() { - return JPA.SEQUENCE_GENERATOR__INITIAL_VALUE; - } - - @Override - String getAllocationSizeElementName() { - return JPA.SEQUENCE_GENERATOR__ALLOCATION_SIZE; - } - - - // ********** SequenceGeneratorAnnotation implementation ********** - - // ***** sequence name - public String getSequenceName() { - return this.sequenceName; - } - - public void setSequenceName(String sequenceName) { - throw new UnsupportedOperationException(); - } - - private void setSequenceName_(String sequenceName) { - String old = this.sequenceName; - this.sequenceName = sequenceName; - this.firePropertyChanged(SEQUENCE_NAME_PROPERTY, old, sequenceName); - } - - private String buildSequenceName() { - return (String) this.getJdtMemberValue(JPA.SEQUENCE_GENERATOR__SEQUENCE_NAME); - } - - public TextRange getSequenceNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean sequenceNameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableAnnotation.java deleted file mode 100644 index bc456e6b8f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableAnnotation.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.TableAnnotation; - -/** - * javax.persistence.Table - */ -public final class BinaryTableAnnotation - extends BinaryBaseTableAnnotation - implements TableAnnotation -{ - public BinaryTableAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** BinaryBaseTableAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.TABLE__NAME; - } - - @Override - String getSchemaElementName() { - return JPA.TABLE__SCHEMA; - } - - @Override - String getCatalogElementName() { - return JPA.TABLE__CATALOG; - } - - @Override - String getUniqueConstraintElementName() { - return JPA.TABLE__UNIQUE_CONSTRAINTS; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableGeneratorAnnotation.java deleted file mode 100644 index 0ecdebbb42..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableGeneratorAnnotation.java +++ /dev/null @@ -1,293 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.TableGenerator - */ -public final class BinaryTableGeneratorAnnotation - extends BinaryGeneratorAnnotation - implements TableGeneratorAnnotation -{ - private String table; - private String schema; - private String catalog; - private String pkColumnName; - private String valueColumnName; - private String pkColumnValue; - private final Vector<UniqueConstraintAnnotation> uniqueConstraints; - - - public BinaryTableGeneratorAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.table = this.buildTable(); - this.schema = this.buildSchema(); - this.catalog = this.buildCatalog(); - this.pkColumnName = this.buildPkColumnName(); - this.valueColumnName = this.buildValueColumnName(); - this.pkColumnValue = this.buildPkColumnValue(); - this.uniqueConstraints = this.buildUniqueConstraints(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setTable_(this.buildTable()); - this.setSchema_(this.buildSchema()); - this.setCatalog_(this.buildCatalog()); - this.setPkColumnName_(this.buildPkColumnName()); - this.setValueColumnName_(this.buildValueColumnName()); - this.setPkColumnValue_(this.buildPkColumnValue()); - this.updateUniqueConstraints(); - } - - - // ********** AbstractGeneratorAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.TABLE_GENERATOR__NAME; - } - - @Override - String getInitialValueElementName() { - return JPA.TABLE_GENERATOR__INITIAL_VALUE; - } - - @Override - String getAllocationSizeElementName() { - return JPA.TABLE_GENERATOR__ALLOCATION_SIZE; - } - - - // ********** TableGeneratorAnnotation implementation ********** - - // ***** table - public String getTable() { - return this.table; - } - - public void setTable(String table) { - throw new UnsupportedOperationException(); - } - - private void setTable_(String table) { - String old = this.table; - this.table = table; - this.firePropertyChanged(TABLE_PROPERTY, old, table); - } - - private String buildTable() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__TABLE); - } - - public TextRange getTableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** schema - public String getSchema() { - return this.schema; - } - - public void setSchema(String schema) { - throw new UnsupportedOperationException(); - } - - private void setSchema_(String schema) { - String old = this.schema; - this.schema = schema; - this.firePropertyChanged(SCHEMA_PROPERTY, old, schema); - } - - private String buildSchema() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__SCHEMA); - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** catalog - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String catalog) { - throw new UnsupportedOperationException(); - } - - private void setCatalog_(String catalog) { - String old = this.catalog; - this.catalog = catalog; - this.firePropertyChanged(CATALOG_PROPERTY, old, catalog); - } - - private String buildCatalog() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__CATALOG); - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** pk column name - public String getPkColumnName() { - return this.pkColumnName; - } - - public void setPkColumnName(String pkColumnName) { - throw new UnsupportedOperationException(); - } - - private void setPkColumnName_(String pkColumnName) { - String old = this.pkColumnName; - this.pkColumnName = pkColumnName; - this.firePropertyChanged(PK_COLUMN_NAME_PROPERTY, old, pkColumnName); - } - - private String buildPkColumnName() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__PK_COLUMN_NAME); - } - - public TextRange getPkColumnNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean pkColumnNameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** value column name - public String getValueColumnName() { - return this.valueColumnName; - } - - public void setValueColumnName(String valueColumnName) { - throw new UnsupportedOperationException(); - } - - private void setValueColumnName_(String valueColumnName) { - String old = this.valueColumnName; - this.valueColumnName = valueColumnName; - this.firePropertyChanged(VALUE_COLUMN_NAME_PROPERTY, old, valueColumnName); - } - - private String buildValueColumnName() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__VALUE_COLUMN_NAME); - } - - public TextRange getValueColumnNameTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean valueColumnNameTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** pk column value - public String getPkColumnValue() { - return this.pkColumnValue; - } - - public void setPkColumnValue(String pkColumnValue) { - throw new UnsupportedOperationException(); - } - - private void setPkColumnValue_(String pkColumnValue) { - String old = this.pkColumnValue; - this.pkColumnValue = pkColumnValue; - this.firePropertyChanged(PK_COLUMN_VALUE_PROPERTY, old, pkColumnValue); - } - - private String buildPkColumnValue() { - return (String) this.getJdtMemberValue(JPA.TABLE_GENERATOR__PK_COLUMN_VALUE); - } - - public TextRange getPkColumnValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean pkColumnValueTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** unique constraints - public ListIterator<UniqueConstraintAnnotation> uniqueConstraints() { - return new CloneListIterator<UniqueConstraintAnnotation>(this.uniqueConstraints); - } - - public int uniqueConstraintsSize() { - return this.uniqueConstraints.size(); - } - - public UniqueConstraintAnnotation uniqueConstraintAt(int index) { - return this.uniqueConstraints.get(index); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - return this.uniqueConstraints.indexOf(uniqueConstraint); - } - - public UniqueConstraintAnnotation addUniqueConstraint(int index) { - throw new UnsupportedOperationException(); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeUniqueConstraint(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<UniqueConstraintAnnotation> buildUniqueConstraints() { - Object[] jdtUniqueConstraints = this.getJdtMemberValues(JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS); - Vector<UniqueConstraintAnnotation> result = new Vector<UniqueConstraintAnnotation>(jdtUniqueConstraints.length); - for (Object jdtUniqueConstraint : jdtUniqueConstraints) { - result.add(new BinaryUniqueConstraintAnnotation(this, (IAnnotation) jdtUniqueConstraint)); - } - return result; - } - - // TODO - private void updateUniqueConstraints() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTemporalAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTemporalAnnotation.java deleted file mode 100644 index d2945aa198..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTemporalAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; -import org.eclipse.jpt.core.resource.java.TemporalType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Temporal - */ -public final class BinaryTemporalAnnotation - extends BinaryAnnotation - implements TemporalAnnotation -{ - private TemporalType value; - - - public BinaryTemporalAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** TemporalAnnotation implementation ********** - - // ***** value - public TemporalType getValue() { - return this.value; - } - - public void setValue(TemporalType value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(TemporalType value) { - TemporalType old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private TemporalType buildValue() { - return TemporalType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.TEMPORAL__VALUE)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTransientAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTransientAnnotation.java deleted file mode 100644 index 92e643fd4b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTransientAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.TransientAnnotation; - -/** - * javax.persistence.Transient - */ -public final class BinaryTransientAnnotation - extends BinaryAnnotation - implements TransientAnnotation -{ - - public BinaryTransientAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryUniqueConstraintAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryUniqueConstraintAnnotation.java deleted file mode 100644 index 2d8af3aec7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryUniqueConstraintAnnotation.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.UniqueConstraint - */ -final class BinaryUniqueConstraintAnnotation - extends BinaryAnnotation - implements UniqueConstraintAnnotation -{ - private final Vector<String> columnNames; - - - BinaryUniqueConstraintAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.columnNames = this.buildColumnNames(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updateColumnNames(); - } - - // TODO - private void updateColumnNames() { - throw new UnsupportedOperationException(); - } - - - // ********** UniqueConstraintAnnotation implementation ********** - - // ***** column names - public ListIterator<String> columnNames() { - return new CloneListIterator<String>(this.columnNames); - } - - public int columnNamesSize() { - return this.columnNames.size(); - } - - private Vector<String> buildColumnNames() { - Object[] jdtColumnNames = this.getJdtMemberValues(JPA.UNIQUE_CONSTRAINT__COLUMN_NAMES); - Vector<String> result = new Vector<String>(jdtColumnNames.length); - for (Object jdtColumnName : jdtColumnNames) { - result.add((String) jdtColumnName); - } - return result; - } - - public void addColumnName(String columnName) { - throw new UnsupportedOperationException(); - } - - public void addColumnName(int index, String columnName) { - throw new UnsupportedOperationException(); - } - - public void moveColumnName(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public boolean columnNamesTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public void removeColumnName(String columnName) { - throw new UnsupportedOperationException(); - } - - public void removeColumnName(int index) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryVersionAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryVersionAnnotation.java deleted file mode 100644 index 37f3256a19..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryVersionAnnotation.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.VersionAnnotation; - -/** - * javax.persistence.Version - */ -public final class BinaryVersionAnnotation - extends BinaryAnnotation - implements VersionAnnotation -{ - - public BinaryVersionAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/RootBinaryNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/RootBinaryNode.java deleted file mode 100644 index be9981c144..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/RootBinaryNode.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.binary; - -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.JpaResourceModelListener; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.utility.internal.ListenerList; - -/** - * JAR and external types - */ -abstract class RootBinaryNode - extends BinaryNode - implements JavaResourceNode.Root -{ - /** pluggable annotation provider */ - private final JpaAnnotationProvider annotationProvider; - - /** listeners notified whenever the resource model changes */ - private final ListenerList<JpaResourceModelListener> resourceModelListenerList = new ListenerList<JpaResourceModelListener>(JpaResourceModelListener.class); - - - // ********** construction ********** - - RootBinaryNode(JavaResourceNode parent, JpaAnnotationProvider annotationProvider) { - super(parent); - this.annotationProvider = annotationProvider; - } - - - // ********** overrides ********** - - @Override - protected boolean requiresParent() { - return false; - } - - @Override - public Root getRoot() { - return this; - } - - @Override - public JpaAnnotationProvider getAnnotationProvider() { - return this.annotationProvider; - } - - - // ********** JavaResourceNode.Root implementation ********** - - public void resourceModelChanged() { - for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelChanged(); - } - } - - - // ********** JpaResourceModel implementation ********** - - public void addResourceModelListener(JpaResourceModelListener listener) { - this.resourceModelListenerList.add(listener); - } - - public void removeResourceModelListener(JpaResourceModelListener listener) { - this.resourceModelListenerList.remove(listener); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java deleted file mode 100644 index 97446b9da0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java +++ /dev/null @@ -1,270 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; - -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.ArrayInitializer; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.core.dom.ITypeBinding; -import org.eclipse.jdt.core.dom.MemberValuePair; -import org.eclipse.jdt.core.dom.NormalAnnotation; -import org.eclipse.jdt.core.dom.SingleMemberAnnotation; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * Utility methods for manipulating annotation containers. - */ -public final class AnnotationContainerTools { - - /** - * Add a nested annotation to the specified annotation container - * at the specified index. - * This method modifies both the model annotation container and the - * AST; with the appropriate change notification occurring afterwards. - */ - public static <T extends NestableAnnotation> NestableAnnotation addNestedAnnotation(int index, AnnotationContainer<T> annotationContainer) { - // add a new annotation to the end of the list... - int sourceIndex = annotationContainer.nestedAnnotationsSize(); - T nestedAnnotation = annotationContainer.addNestedAnnotationInternal(); - nestedAnnotation.newAnnotation(); - // ...then move it to the specified index... - annotationContainer.moveNestedAnnotationInternal(index, sourceIndex); - synchJavaAnnotationsAfterMove(index, sourceIndex, annotationContainer, nestedAnnotation); - // ...then, when all is settled, tell the container to fire change notification - annotationContainer.nestedAnnotationAdded(index, nestedAnnotation); - return nestedAnnotation; - } - - /** - * Move the nested annotation at the specified source index in the - * specified annotation container to the specified target index. - * This method modifies both the model annotation container and the - * AST; with the appropriate change notification occurring afterwards. - */ - public static <T extends NestableAnnotation> void moveNestedAnnotation(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer) { - NestableAnnotation nestedAnnotation = annotationContainer.moveNestedAnnotationInternal(targetIndex, sourceIndex); - synchJavaAnnotationsAfterMove(targetIndex, sourceIndex, annotationContainer, nestedAnnotation); - annotationContainer.nestedAnnotationMoved(targetIndex, sourceIndex); - } - - /** - * An annotation was moved within the specified annotation container from - * the specified source index to the specified target index. - * Synchronize the AST annotations with the model annotation container, - * starting with the lower index to prevent overlap. - */ - private static <T extends NestableAnnotation> void synchJavaAnnotationsAfterMove(int targetIndex, int sourceIndex, AnnotationContainer<T> annotationContainer, NestableAnnotation nestedAnnotationAnnotation) { - // move the Java annotation to the end of the list... - nestedAnnotationAnnotation.moveAnnotation(annotationContainer.nestedAnnotationsSize()); - // ...then shift the other Java annotations over one slot... - List<T> nestableAnnotations = CollectionTools.list(annotationContainer.nestedAnnotations()); - if (sourceIndex < targetIndex) { - for (int i = sourceIndex; i < targetIndex; i++) { - nestableAnnotations.get(i).moveAnnotation(i); - } - } else { - for (int i = sourceIndex; i > targetIndex; i-- ) { - nestableAnnotations.get(i).moveAnnotation(i); - } - } - // ...then move the Java annotation to the now empty slot at the target index - nestedAnnotationAnnotation.moveAnnotation(targetIndex); - } - - /** - * Remove the nested annotation at the specified index in the - * specified annotation container. - * This method modifies both the model annotation container and the - * AST; with the appropriate change notification occurring afterwards. - */ - public static <T extends NestableAnnotation> void removeNestedAnnotation(int index, AnnotationContainer<T> annotationContainer) { - T nestedAnnotation = annotationContainer.removeNestedAnnotationInternal(index); - nestedAnnotation.removeAnnotation(); - synchJavaAnnotationsAfterRemove(index, annotationContainer); - annotationContainer.nestedAnnotationRemoved(index, nestedAnnotation); - } - - /** - * An annotation was removed from the specified annotation container at the - * specified index. - * Synchronize the AST annotations with the model annotation container, - * starting at the specified index to prevent overlap. - */ - private static <T extends NestableAnnotation> void synchJavaAnnotationsAfterRemove(int index, AnnotationContainer<T> annotationContainer) { - List<T> nestableAnnotations = CollectionTools.list(annotationContainer.nestedAnnotations()); - for (int i = index; i < nestableAnnotations.size(); i++) { - // the indices are the same because the model annotations are - // already in the proper locations - it's the Java annotations that - // need to be moved to the same location - nestableAnnotations.get(i).moveAnnotation(i); - } - } - - /** - * Initialize the specified annotation container to be in synch with the - * specified AST. No change notification will occur. - */ - public static <T extends NestableAnnotation> void initialize(AnnotationContainer<T> annotationContainer, CompilationUnit astRoot) { - // ignore the nested AST annotations themselves - // (maybe someday we can use them during initialization...) - int size = getNestedAstAnnotations(astRoot, annotationContainer).size(); - for (int i = 0; i < size; i++) { - T nestedAnnotation = annotationContainer.addNestedAnnotationInternal(); - nestedAnnotation.initialize(astRoot); - } - } - - /** - * Return a list of the nested AST annotations. - */ - private static <T extends NestableAnnotation> ArrayList<Annotation> getNestedAstAnnotations(CompilationUnit astRoot, AnnotationContainer<T> annotationContainer) { - ArrayList<Annotation> result = new ArrayList<Annotation>(); - Annotation containerAstAnnotation = annotationContainer.getContainerJdtAnnotation(astRoot); - if (containerAstAnnotation.isMarkerAnnotation()) { - // no nested annotations - } - else if (containerAstAnnotation.isSingleMemberAnnotation()) { - if (annotationContainer.getElementName().equals("value")) { //$NON-NLS-1$ - Expression ex = ((SingleMemberAnnotation) containerAstAnnotation).getValue(); - addAstAnnotationsTo(ex, annotationContainer.getNestableAnnotationName(), result); - } else { - // no nested annotations - } - } - else if (containerAstAnnotation.isNormalAnnotation()) { - MemberValuePair pair = getMemberValuePair((NormalAnnotation) containerAstAnnotation, annotationContainer.getElementName()); - if (pair == null) { - // no nested annotations - } else { - addAstAnnotationsTo(pair.getValue(), annotationContainer.getNestableAnnotationName(), result); - } - } - return result; - } - - /** - * Add whatever annotations are represented by the specified expression to - * the specified bag. Add null to the bag for any non-annotation expression. - */ - private static void addAstAnnotationsTo(Expression expression, String annotationName, ArrayList<Annotation> astAnnotations) { - if (expression == null) { - astAnnotations.add(null); // not sure how we would get here... - } - else if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) { - addAstAnnotationsTo((ArrayInitializer) expression, annotationName, astAnnotations); - } - else { - astAnnotations.add(getAstAnnotation_(expression, annotationName)); - } - } - - private static void addAstAnnotationsTo(ArrayInitializer arrayInitializer, String annotationName, ArrayList<Annotation> astAnnotations) { - @SuppressWarnings("unchecked") - List<Expression> expressions = arrayInitializer.expressions(); - for (Expression expression : expressions) { - astAnnotations.add(getAstAnnotation(expression, annotationName)); - } - } - - /** - * If the specified expression is an annotation with the specified name, return it; - * otherwise return null. - */ - private static Annotation getAstAnnotation(Expression expression, String annotationName) { - // not sure how the expression could be null... - return (expression == null) ? null : getAstAnnotation_(expression, annotationName); - } - - /** - * pre-condition: expression is not null - */ - private static Annotation getAstAnnotation_(Expression expression, String annotationName) { - switch (expression.getNodeType()) { - case ASTNode.NORMAL_ANNOTATION: - case ASTNode.SINGLE_MEMBER_ANNOTATION: - case ASTNode.MARKER_ANNOTATION: - Annotation astAnnotation = (Annotation) expression; - if (getQualifiedName(astAnnotation).equals(annotationName)) { - return astAnnotation; - } - return null; - default: - return null; - } - } - - private static String getQualifiedName(Annotation astAnnotation) { - ITypeBinding typeBinding = astAnnotation.resolveTypeBinding(); - if (typeBinding != null) { - String resolvedName = typeBinding.getQualifiedName(); - if (resolvedName != null) { - return resolvedName; - } - } - return astAnnotation.getTypeName().getFullyQualifiedName(); - } - - private static MemberValuePair getMemberValuePair(NormalAnnotation annotation, String elementName) { - @SuppressWarnings("unchecked") - List<MemberValuePair> pairs = annotation.values(); - for (MemberValuePair pair : pairs) { - if (pair.getName().getFullyQualifiedName().equals(elementName)) { - return pair; - } - } - return null; - } - - /** - * Update the annotations in the specified annotation container to be in - * synch with those in the specified AST. The appropriate change - * notification will occur. - */ - public static <T extends NestableAnnotation> void update(AnnotationContainer<T> annotationContainer, CompilationUnit astRoot) { - ListIterator<Annotation> astAnnotations = getNestedAstAnnotations(astRoot, annotationContainer).listIterator(); - - for (ListIterator<T> nestedAnnotations = annotationContainer.nestedAnnotations(); nestedAnnotations.hasNext(); ) { - T nestedAnnotation = nestedAnnotations.next(); - if (astAnnotations.hasNext()) { - // matching AST annotation is present - update the nested annotation - astAnnotations.next(); // maybe someday we can pass this to the update - nestedAnnotation.update(astRoot); - } else { - // no more AST annotations - remove the nested annotation at the end of the container's list - int last = annotationContainer.nestedAnnotationsSize() - 1; - T remove = annotationContainer.removeNestedAnnotationInternal(last); - annotationContainer.nestedAnnotationRemoved(last, remove); - } - } - - // add nested annotations for the remaining AST annotations - int i = annotationContainer.nestedAnnotationsSize(); - while (astAnnotations.hasNext()) { - astAnnotations.next(); // maybe someday we can pass this to the initialize - T nestedAnnotation = annotationContainer.addNestedAnnotationInternal(); - nestedAnnotation.initialize(astRoot); - annotationContainer.nestedAnnotationAdded(i++, nestedAnnotation); - } - } - - private AnnotationContainerTools() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java deleted file mode 100644 index 78e6e5ba82..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jpt.core.internal.utility.jdt.ASTNodeTextRange; -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * some common state and behavior for Java source annotations; - * and lots of convenience methods - */ -public abstract class SourceAnnotation<M extends Member> - extends SourceNode - implements Annotation -{ - protected final M member; - - protected final DeclarationAnnotationAdapter daa; - - protected final AnnotationAdapter annotationAdapter; - - - /** - * constructor for straight member annotation - */ - protected SourceAnnotation(JavaResourceNode parent, M member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - } - - /** - * constructor for nested annotation (typically) - */ - protected SourceAnnotation(JavaResourceNode parent, M member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent); - this.member = member; - this.daa = daa; - this.annotationAdapter = annotationAdapter; - } - - - // ********** JavaResourceNode implementation ********** - - public TextRange getTextRange(CompilationUnit astRoot) { - return this.getAnnotationTextRange(astRoot); - } - - - // ********** Annotation implementation ********** - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return this.annotationAdapter.getAnnotation(astRoot); - } - - public void newAnnotation() { - this.annotationAdapter.newMarkerAnnotation(); - } - - public void removeAnnotation() { - this.annotationAdapter.removeAnnotation(); - } - - - // ********** convenience methods ********** - - /** - * Return the text range corresponding to the annotation. - * If the annotation is missing, return null. - */ - protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { - return this.getTextRange(this.getJdtAnnotation(astRoot)); - } - - /** - * Convenience method. - * Return the text range corresponding to the specified element. - * If the specified element is missing, return the annotation's text range instead. - */ - protected TextRange getElementTextRange(DeclarationAnnotationElementAdapter<?> elementAdapter, CompilationUnit astRoot) { - return this.getElementTextRange(this.getAnnotationElementTextRange(elementAdapter, astRoot), astRoot); - } - - /** - * Convenience method. If the specified element text range is null - * return the member's text range instead. - */ - protected TextRange getElementTextRange(TextRange elementTextRange, CompilationUnit astRoot) { - return (elementTextRange != null) ? elementTextRange : this.getAnnotationTextRange(astRoot); - } - - /** - * Convenience method. Return whether the specified position exists and - * touches the specified element. - */ - protected boolean elementTouches(DeclarationAnnotationElementAdapter<?> elementAdapter, int pos, CompilationUnit astRoot) { - return this.textRangeTouches(this.getAnnotationElementTextRange(elementAdapter, astRoot), pos); - } - - /** - * Convenience method. Return whether the specified text range is not - * null (meaning the corresponding AST node exists) and the specified position touches it. - */ - protected boolean textRangeTouches(TextRange textRange, int pos) { - return (textRange != null) && textRange.touches(pos); - } - - /** - * Return the text range corresponding to the specified element. - * If the element is missing, return null. - */ - protected TextRange getAnnotationElementTextRange(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) { - return this.getTextRange(this.getAnnotationElementExpression(adapter, astRoot)); - } - - /** - * Return the specified AST DOM element. - */ - protected Expression getAnnotationElementExpression(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) { - return adapter.getExpression(this.member.getModifiedDeclaration(astRoot)); - } - - /** - * Return the text range corresponding to the specified AST node. - * If the AST node is null, return null. - */ - protected TextRange getTextRange(ASTNode astNode) { - return (astNode == null) ? null : new ASTNodeTextRange(astNode); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java deleted file mode 100644 index 9f2ccc4032..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.AssociationOverride - */ -public abstract class SourceAssociationOverrideAnnotation - extends SourceOverrideAnnotation - implements NestableAssociationOverrideAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableJoinColumnAnnotation> joinColumns = new Vector<NestableJoinColumnAnnotation>(); - private final JoinColumnsAnnotationContainer joinColumnsContainer = new JoinColumnsAnnotationContainer(); - - - // ********** construction/initialization ********** - - protected SourceAssociationOverrideAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - AnnotationContainerTools.initialize(this.joinColumnsContainer, astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - AnnotationContainerTools.update(this.joinColumnsContainer, astRoot); - } - - - // ********** SourceOverrideAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.ASSOCIATION_OVERRIDE__NAME; - } - - - // ********** AssociationOverrideAnnotation implementation ********** - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.joinColumns); - } - - ListIterator<NestableJoinColumnAnnotation> nestableJoinColumns() { - return new CloneListIterator<NestableJoinColumnAnnotation>(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public NestableJoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public NestableJoinColumnAnnotation addJoinColumn(int index) { - return (NestableJoinColumnAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation addJoinColumnInternal() { - NestableJoinColumnAnnotation joinColumn = this.buildJoinColumn(this.joinColumns.size()); - this.joinColumns.add(joinColumn); - return joinColumn; - } - - private NestableJoinColumnAnnotation buildJoinColumn(int index) { - return SourceJoinColumnAnnotation.createAssociationOverrideJoinColumn(this.daa, this, this.member, index); - } - - void joinColumnAdded(int index, NestableJoinColumnAnnotation joinColumn) { - this.fireItemAdded(JOIN_COLUMNS_LIST, index, joinColumn); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation moveJoinColumnInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.joinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - void joinColumnMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - public void removeJoinColumn(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation removeJoinColumnInternal(int index) { - return this.joinColumns.remove(index); - } - - void joinColumnRemoved(int index, NestableJoinColumnAnnotation joinColumn) { - this.fireItemRemoved(JOIN_COLUMNS_LIST, index, joinColumn); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - AssociationOverrideAnnotation oldOverride = (AssociationOverrideAnnotation) oldAnnotation; - for (JoinColumnAnnotation oldJoinColumn : CollectionTools.iterable(oldOverride.joinColumns())) { - NestableJoinColumnAnnotation newJoinColumn = this.addJoinColumn(oldOverride.indexOfJoinColumn(oldJoinColumn)); - newJoinColumn.initializeFrom((NestableAnnotation) oldJoinColumn); - } - } - - // ********** join column container ********** - - /** - * adapt the AnnotationContainer interface to the override's join columns - */ - class JoinColumnsAnnotationContainer - implements AnnotationContainer<NestableJoinColumnAnnotation> - { - public String getContainerAnnotationName() { - return SourceAssociationOverrideAnnotation.this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceAssociationOverrideAnnotation.this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return JPA.ASSOCIATION_OVERRIDE__JOIN_COLUMNS; - } - - public String getNestableAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestableJoinColumnAnnotation> nestedAnnotations() { - return SourceAssociationOverrideAnnotation.this.nestableJoinColumns(); - } - - public int nestedAnnotationsSize() { - return SourceAssociationOverrideAnnotation.this.joinColumnsSize(); - } - - public NestableJoinColumnAnnotation addNestedAnnotationInternal() { - return SourceAssociationOverrideAnnotation.this.addJoinColumnInternal(); - } - - public void nestedAnnotationAdded(int index, NestableJoinColumnAnnotation nestedAnnotation) { - SourceAssociationOverrideAnnotation.this.joinColumnAdded(index, nestedAnnotation); - } - - public NestableJoinColumnAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return SourceAssociationOverrideAnnotation.this.moveJoinColumnInternal(targetIndex, sourceIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - SourceAssociationOverrideAnnotation.this.joinColumnMoved(targetIndex, sourceIndex); - } - - public NestableJoinColumnAnnotation removeNestedAnnotationInternal(int index) { - return SourceAssociationOverrideAnnotation.this.removeJoinColumnInternal(index); - } - - public void nestedAnnotationRemoved(int index, NestableJoinColumnAnnotation nestedAnnotation) { - SourceAssociationOverrideAnnotation.this.joinColumnRemoved(index, nestedAnnotation); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java deleted file mode 100644 index 65acf31d66..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverrideAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.AssociationOverrides - */ -public abstract class SourceAssociationOverridesAnnotation - extends SourceAnnotation<Member> - implements AssociationOverridesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableAssociationOverrideAnnotation> associationOverrides = new Vector<NestableAssociationOverrideAnnotation>(); - - - protected SourceAssociationOverridesAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.associationOverrides); - } - - - // ********** AnnotationContainer implementation ********** - - public String getContainerAnnotationName() { - return this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return JPA.ASSOCIATION_OVERRIDES__VALUE; - } - - public String getNestableAnnotationName() { - return AssociationOverrideAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestableAssociationOverrideAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableAssociationOverrideAnnotation>(this.associationOverrides); - } - - public int nestedAnnotationsSize() { - return this.associationOverrides.size(); - } - - public NestableAssociationOverrideAnnotation addNestedAnnotationInternal() { - NestableAssociationOverrideAnnotation associationOverride = this.buildAssociationOverride(this.associationOverrides.size()); - this.associationOverrides.add(associationOverride); - return associationOverride; - } - - protected abstract NestableAssociationOverrideAnnotation buildAssociationOverride(int index); - - public void nestedAnnotationAdded(int index, NestableAssociationOverrideAnnotation nestedAnnotation) { - this.fireItemAdded(ASSOCIATION_OVERRIDES_LIST, index, nestedAnnotation); - } - - public NestableAssociationOverrideAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.associationOverrides, targetIndex, sourceIndex).get(targetIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(ASSOCIATION_OVERRIDES_LIST, targetIndex, sourceIndex); - } - - public NestableAssociationOverrideAnnotation removeNestedAnnotationInternal(int index) { - return this.associationOverrides.remove(index); - } - - public void nestedAnnotationRemoved(int index, NestableAssociationOverrideAnnotation nestedAnnotation) { - this.fireItemRemoved(ASSOCIATION_OVERRIDES_LIST, index, nestedAnnotation); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java deleted file mode 100644 index 5f7fdb2d8e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.NullAttributeOverrideColumnAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.NestableColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AttributeOverride - */ -public final class SourceAttributeOverrideAnnotation - extends SourceOverrideAnnotation - implements NestableAttributeOverrideAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final MemberAnnotationAdapter columnAdapter; - private NestableColumnAnnotation column; - - - // ********** construction/initialization ********** - - public SourceAttributeOverrideAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.columnAdapter = new MemberAnnotationAdapter(this.member, SourceColumnAnnotation.buildAttributeOverrideAnnotationAdapter(this.daa)); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - if (this.columnAdapter.getAnnotation(astRoot) != null) { - this.column = SourceColumnAnnotation.createAttributeOverrideColumn(this, this.member, this.daa); - this.column.initialize(astRoot); - } - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.updateColumn(astRoot); - } - - - // ********** SourceOverrideAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA.ATTRIBUTE_OVERRIDE__NAME; - } - - - //************ AttributeOverride implementation **************** - - // ***** column - public ColumnAnnotation getColumn() { - return this.column; - } - - public NestableColumnAnnotation addColumn() { - NestableColumnAnnotation col = SourceColumnAnnotation.createAttributeOverrideColumn(this, this.member, this.daa); - col.newAnnotation(); - this.setColumn(col); - return col; - } - - public void removeColumn() { - this.column.removeAnnotation(); - setColumn(null); - } - - private void setColumn(NestableColumnAnnotation column) { - ColumnAnnotation old = this.column; - this.column = column; - this.firePropertyChanged(COLUMN_PROPERTY, old, column); - } - - public ColumnAnnotation getNonNullColumn() { - return (this.column != null) ? this.column : new NullAttributeOverrideColumnAnnotation(this); - } - - private void updateColumn(CompilationUnit astRoot) { - if (this.columnAdapter.getAnnotation(astRoot) == null) { - this.setColumn(null); - } else { - if (this.column == null) { - NestableColumnAnnotation col = SourceColumnAnnotation.createAttributeOverrideColumn(this, this.member, this.daa); - col.initialize(astRoot); - this.setColumn(col); - } else { - this.column.update(astRoot); - } - } - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - AttributeOverrideAnnotation oldOverride = (AttributeOverrideAnnotation) oldAnnotation; - ColumnAnnotation oldColumn = oldOverride.getColumn(); - if (oldColumn != null) { - NestableColumnAnnotation newColumn = this.addColumn(); - newColumn.initializeFrom((NestableAnnotation) oldColumn); - } - } - - - // ********** static methods ********** - - public static SourceAttributeOverrideAnnotation buildAttributeOverride(JavaResourceNode parent, Member member) { - return new SourceAttributeOverrideAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); - } - - static SourceAttributeOverrideAnnotation buildNestedAttributeOverride(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa); - return new SourceAttributeOverrideAnnotation(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(attributeOverridesAdapter, index, JPA.ATTRIBUTE_OVERRIDE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java deleted file mode 100644 index 8d41766fe8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.AttributeOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAttributeOverrideAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.AttributeOverrides - */ -public final class SourceAttributeOverridesAnnotation - extends SourceAnnotation<Member> - implements AttributeOverridesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableAttributeOverrideAnnotation> attributesOverrides = new Vector<NestableAttributeOverrideAnnotation>(); - - - public SourceAttributeOverridesAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.attributesOverrides); - } - - - // ********** AnnotationContainer implementation ********** - - public String getContainerAnnotationName() { - return this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return JPA.ATTRIBUTE_OVERRIDES__VALUE; - } - - public String getNestableAnnotationName() { - return AttributeOverrideAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestableAttributeOverrideAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableAttributeOverrideAnnotation>(this.attributesOverrides); - } - - public int nestedAnnotationsSize() { - return this.attributesOverrides.size(); - } - - public NestableAttributeOverrideAnnotation addNestedAnnotationInternal() { - NestableAttributeOverrideAnnotation attributeOverride = this.buildAttributeOverride(this.attributesOverrides.size()); - this.attributesOverrides.add(attributeOverride); - return attributeOverride; - } - - private NestableAttributeOverrideAnnotation buildAttributeOverride(int index) { - return SourceAttributeOverrideAnnotation.buildNestedAttributeOverride(this, this.member, index, this.daa); - } - - public void nestedAnnotationAdded(int index, NestableAttributeOverrideAnnotation nestedAnnotation) { - this.fireItemAdded(ATTRIBUTE_OVERRIDES_LIST, index, nestedAnnotation); - } - - public NestableAttributeOverrideAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.attributesOverrides, targetIndex, sourceIndex).get(targetIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(ATTRIBUTE_OVERRIDES_LIST, targetIndex, sourceIndex); - } - - public NestableAttributeOverrideAnnotation removeNestedAnnotationInternal(int index) { - return this.attributesOverrides.remove(index); - } - - public void nestedAnnotationRemoved(int index, NestableAttributeOverrideAnnotation nestedAnnotation) { - this.fireItemRemoved(ATTRIBUTE_OVERRIDES_LIST, index, nestedAnnotation); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java deleted file mode 100644 index 2fac36bf04..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java +++ /dev/null @@ -1,237 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.BaseColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - */ -abstract class SourceBaseColumnAnnotation - extends SourceNamedColumnAnnotation - implements BaseColumnAnnotation -{ - final DeclarationAnnotationElementAdapter<String> tableDeclarationAdapter; - final AnnotationElementAdapter<String> tableAdapter; - String table; - - final DeclarationAnnotationElementAdapter<Boolean> uniqueDeclarationAdapter; - final AnnotationElementAdapter<Boolean> uniqueAdapter; - Boolean unique; - - final DeclarationAnnotationElementAdapter<Boolean> nullableDeclarationAdapter; - final AnnotationElementAdapter<Boolean> nullableAdapter; - Boolean nullable; - - final DeclarationAnnotationElementAdapter<Boolean> insertableDeclarationAdapter; - final AnnotationElementAdapter<Boolean> insertableAdapter; - Boolean insertable; - - final DeclarationAnnotationElementAdapter<Boolean> updatableDeclarationAdapter; - final AnnotationElementAdapter<Boolean> updatableAdapter; - Boolean updatable; - - - SourceBaseColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - } - - SourceBaseColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.tableDeclarationAdapter = this.buildStringElementAdapter(this.getTableElementName()); - this.tableAdapter = this.buildShortCircuitElementAdapter(this.tableDeclarationAdapter); - this.uniqueDeclarationAdapter = this.buildBooleanElementAdapter(this.getUniqueElementName()); - this.uniqueAdapter = this.buildShortCircuitBooleanElementAdapter(this.uniqueDeclarationAdapter); - this.nullableDeclarationAdapter = this.buildBooleanElementAdapter(this.getNullableElementName()); - this.nullableAdapter = this.buildShortCircuitBooleanElementAdapter(this.nullableDeclarationAdapter); - this.insertableDeclarationAdapter = this.buildBooleanElementAdapter(this.getInsertableElementName()); - this.insertableAdapter = this.buildShortCircuitBooleanElementAdapter(this.insertableDeclarationAdapter); - this.updatableDeclarationAdapter = this.buildBooleanElementAdapter(this.getUpdatableElementName()); - this.updatableAdapter = this.buildShortCircuitBooleanElementAdapter(this.updatableDeclarationAdapter); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.table = this.buildTable(astRoot); - this.unique = this.buildUnique(astRoot); - this.nullable = this.buildNullable(astRoot); - this.insertable = this.buildInsertable(astRoot); - this.updatable = this.buildUpdatable(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setTable(this.buildTable(astRoot)); - this.setUnique(this.buildUnique(astRoot)); - this.setNullable(this.buildNullable(astRoot)); - this.setInsertable(this.buildInsertable(astRoot)); - this.setUpdatable(this.buildUpdatable(astRoot)); - } - - - //************* BaseColumnAnnotation implementation ************* - - // ***** table - public String getTable() { - return this.table; - } - - public void setTable(String table) { - if (this.attributeValueHasNotChanged(this.table, table)) { - return; - } - String old = this.table; - this.table = table; - this.tableAdapter.setValue(table); - this.firePropertyChanged(TABLE_PROPERTY, old, table); - } - - private String buildTable(CompilationUnit astRoot) { - return this.tableAdapter.getValue(astRoot); - } - - public TextRange getTableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.tableDeclarationAdapter, astRoot); - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.tableDeclarationAdapter, pos, astRoot); - } - - abstract String getTableElementName(); - - // ***** unique - public Boolean getUnique() { - return this.unique; - } - - public void setUnique(Boolean unique) { - if (this.attributeValueHasNotChanged(this.unique, unique)) { - return; - } - Boolean old = this.unique; - this.unique = unique; - this.uniqueAdapter.setValue(unique); - this.firePropertyChanged(UNIQUE_PROPERTY, old, unique); - } - - private Boolean buildUnique(CompilationUnit astRoot) { - return this.uniqueAdapter.getValue(astRoot); - } - - public TextRange getUniqueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.uniqueDeclarationAdapter, astRoot); - } - - abstract String getUniqueElementName(); - - // ***** nullable - public Boolean getNullable() { - return this.nullable; - } - - public void setNullable(Boolean nullable) { - if (this.attributeValueHasNotChanged(this.nullable, nullable)) { - return; - } - Boolean old = this.nullable; - this.nullable = nullable; - this.nullableAdapter.setValue(nullable); - this.firePropertyChanged(NULLABLE_PROPERTY, old, nullable); - } - - private Boolean buildNullable(CompilationUnit astRoot) { - return this.nullableAdapter.getValue(astRoot); - } - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nullableDeclarationAdapter, astRoot); - } - - abstract String getNullableElementName(); - - // ***** insertable - public Boolean getInsertable() { - return this.insertable; - } - - public void setInsertable(Boolean insertable) { - if (this.attributeValueHasNotChanged(this.insertable, insertable)) { - return; - } - Boolean old = this.insertable; - this.insertable = insertable; - this.insertableAdapter.setValue(insertable); - this.firePropertyChanged(INSERTABLE_PROPERTY, old, insertable); - } - - private Boolean buildInsertable(CompilationUnit astRoot) { - return this.insertableAdapter.getValue(astRoot); - } - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.insertableDeclarationAdapter, astRoot); - } - - abstract String getInsertableElementName(); - - // ***** updatable - public Boolean getUpdatable() { - return this.updatable; - } - - public void setUpdatable(Boolean updatable) { - if (this.attributeValueHasNotChanged(this.updatable, updatable)) { - return; - } - Boolean old = this.updatable; - this.updatable = updatable; - this.updatableAdapter.setValue(updatable); - this.firePropertyChanged(UPDATABLE_PROPERTY, old, updatable); - } - - private Boolean buildUpdatable(CompilationUnit astRoot) { - return this.updatableAdapter.getValue(astRoot); - } - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.updatableDeclarationAdapter, astRoot); - } - - abstract String getUpdatableElementName(); - - - //************* NestableAnnotation implementation ************* - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - BaseColumnAnnotation oldColumn = (BaseColumnAnnotation) oldAnnotation; - this.setTable(oldColumn.getTable()); - this.setUnique(oldColumn.getUnique()); - this.setNullable(oldColumn.getNullable()); - this.setInsertable(oldColumn.getInsertable()); - this.setUpdatable(oldColumn.getUpdatable()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java deleted file mode 100644 index 20e69a94f7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java +++ /dev/null @@ -1,305 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.BaseNamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation; -import org.eclipse.jpt.core.resource.java.QueryHintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.NamedQuery - * javax.persistence.NamedNativeQuery - */ -abstract class SourceBaseNamedQueryAnnotation - extends SourceAnnotation<Type> - implements BaseNamedQueryAnnotation -{ - final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - final AnnotationElementAdapter<String> nameAdapter; - String name; - - final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter; - final AnnotationElementAdapter<String> queryAdapter; - String query; - - final Vector<NestableQueryHintAnnotation> hints = new Vector<NestableQueryHintAnnotation>(); - final HintsAnnotationContainer hintsContainer = new HintsAnnotationContainer(); - - - SourceBaseNamedQueryAnnotation(JavaResourceNode parent, Type type,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, type, daa, annotationAdapter); - this.nameDeclarationAdapter = this.buildNameAdapter(daa); - this.queryDeclarationAdapter = this.buildQueryAdapter(daa); - this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter); - this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - this.query = this.buildQuery(astRoot); - AnnotationContainerTools.initialize(this.hintsContainer, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - this.setQuery(this.buildQuery(astRoot)); - AnnotationContainerTools.update(this.hintsContainer, astRoot); - } - - /** - * convenience method - */ - AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** BaseNamedQueryAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; - } - String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, this.getNameElementName()); - } - - abstract String getNameElementName(); - - // ***** query - public String getQuery() { - return this.query; - } - - public void setQuery(String query) { - if (this.attributeValueHasNotChanged(this.query, query)) { - return; - } - String old = this.query; - this.query = query; - this.queryAdapter.setValue(query); - this.firePropertyChanged(QUERY_PROPERTY, old, query); - } - - private String buildQuery(CompilationUnit astRoot) { - return this.queryAdapter.getValue(astRoot); - } - - public TextRange getQueryTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.queryDeclarationAdapter, astRoot); - } - - private DeclarationAnnotationElementAdapter<String> buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, this.getQueryElementName()); - } - - abstract String getQueryElementName(); - - // ***** hints - public ListIterator<QueryHintAnnotation> hints() { - return new CloneListIterator<QueryHintAnnotation>(this.hints); - } - - ListIterator<NestableQueryHintAnnotation> nestableHints() { - return new CloneListIterator<NestableQueryHintAnnotation>(this.hints); - } - - public int hintsSize() { - return this.hints.size(); - } - - public NestableQueryHintAnnotation hintAt(int index) { - return this.hints.get(index); - } - - public int indexOfHint(QueryHintAnnotation queryHint) { - return this.hints.indexOf(queryHint); - } - - public NestableQueryHintAnnotation addHint(int index) { - return (NestableQueryHintAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.hintsContainer); - } - - NestableQueryHintAnnotation addHintInternal() { - NestableQueryHintAnnotation hint = this.buildQueryHint(this.hints.size()); - this.hints.add(hint); - return hint; - } - - abstract NestableQueryHintAnnotation buildQueryHint(int index); - - void hintAdded(int index, NestableQueryHintAnnotation hint) { - this.fireItemAdded(HINTS_LIST, index, hint); - } - - public void moveHint(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.hintsContainer); - } - - NestableQueryHintAnnotation moveHintInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.hints, targetIndex, sourceIndex).get(targetIndex); - } - - void hintMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(HINTS_LIST, targetIndex, sourceIndex); - } - - public void removeHint(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer); - } - - NestableQueryHintAnnotation removeHintInternal(int index) { - return this.hints.remove(index); - } - - void hintRemoved(int index, NestableQueryHintAnnotation hint) { - this.fireItemRemoved(HINTS_LIST, index, hint); - } - - abstract String getHintsElementName(); - - - // ********** NestableAnnotation implementation ********** - - /** - * convenience implementation of method from NestableAnnotation interface - * for subclasses - */ - public void initializeFrom(NestableAnnotation oldAnnotation) { - BaseNamedQueryAnnotation oldQuery = (BaseNamedQueryAnnotation) oldAnnotation; - this.setName(oldQuery.getName()); - this.setQuery(oldQuery.getQuery()); - for (QueryHintAnnotation oldQueryHint : CollectionTools.iterable(oldQuery.hints())) { - NestableQueryHintAnnotation newQueryHint = this.addHint(oldQuery.indexOfHint(oldQueryHint)); - newQueryHint.initializeFrom((NestableQueryHintAnnotation) oldQueryHint); - } - } - - /** - * convenience implementation of method from NestableAnnotation interface - * for subclasses - */ - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - private IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - - // ********** hint container ********** - - /** - * adapt the AnnotationContainer interface to the override's join columns - */ - class HintsAnnotationContainer - implements AnnotationContainer<NestableQueryHintAnnotation> - { - public String getContainerAnnotationName() { - return SourceBaseNamedQueryAnnotation.this.getAnnotationName(); - } - - public Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceBaseNamedQueryAnnotation.this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return SourceBaseNamedQueryAnnotation.this.getHintsElementName(); - } - - public String getNestableAnnotationName() { - return QueryHintAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestableQueryHintAnnotation> nestedAnnotations() { - return SourceBaseNamedQueryAnnotation.this.nestableHints(); - } - - public int nestedAnnotationsSize() { - return SourceBaseNamedQueryAnnotation.this.hintsSize(); - } - - public NestableQueryHintAnnotation addNestedAnnotationInternal() { - return SourceBaseNamedQueryAnnotation.this.addHintInternal(); - } - - public void nestedAnnotationAdded(int index, NestableQueryHintAnnotation nestedAnnotation) { - SourceBaseNamedQueryAnnotation.this.hintAdded(index, nestedAnnotation); - } - - public NestableQueryHintAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return SourceBaseNamedQueryAnnotation.this.moveHintInternal(targetIndex, sourceIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - SourceBaseNamedQueryAnnotation.this.hintMoved(targetIndex, sourceIndex); - } - - public NestableQueryHintAnnotation removeNestedAnnotationInternal(int index) { - return SourceBaseNamedQueryAnnotation.this.removeHintInternal(index); - } - - public void nestedAnnotationRemoved(int index, NestableQueryHintAnnotation nestedAnnotation) { - SourceBaseNamedQueryAnnotation.this.hintRemoved(index, nestedAnnotation); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java deleted file mode 100644 index 608f9c5cdb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java +++ /dev/null @@ -1,352 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.BaseTableAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraintAnnotation; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.Table - * javax.persistence.JoinTable - * javax.persistence.SecondaryTable - */ -abstract class SourceBaseTableAnnotation - extends SourceAnnotation<Member> - implements BaseTableAnnotation -{ - final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - final AnnotationElementAdapter<String> nameAdapter; - String name; - - final DeclarationAnnotationElementAdapter<String> schemaDeclarationAdapter; - final AnnotationElementAdapter<String> schemaAdapter; - String schema; - - final DeclarationAnnotationElementAdapter<String> catalogDeclarationAdapter; - final AnnotationElementAdapter<String> catalogAdapter; - String catalog; - - final Vector<NestableUniqueConstraintAnnotation> uniqueConstraints = new Vector<NestableUniqueConstraintAnnotation>(); - final UniqueConstraintsAnnotationContainer uniqueConstraintsContainer = new UniqueConstraintsAnnotationContainer(); - - - SourceBaseTableAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - } - - SourceBaseTableAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.nameDeclarationAdapter = this.getNameAdapter(daa); - this.schemaDeclarationAdapter = this.getSchemaAdapter(daa); - this.catalogDeclarationAdapter = this.getCatalogAdapter(daa); - this.nameAdapter = this.buildAnnotationElementAdapter(this.nameDeclarationAdapter); - this.schemaAdapter = this.buildAnnotationElementAdapter(this.schemaDeclarationAdapter); - this.catalogAdapter = this.buildAnnotationElementAdapter(this.catalogDeclarationAdapter); - } - - private AnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - this.schema = this.buildSchema(astRoot); - this.catalog = this.buildCatalog(astRoot); - AnnotationContainerTools.initialize(this.uniqueConstraintsContainer, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - this.setSchema(this.buildSchema(astRoot)); - this.setCatalog(this.buildCatalog(astRoot)); - AnnotationContainerTools.update(this.uniqueConstraintsContainer, astRoot); - } - - /** - * Return the uniqueConstraints element name - */ - abstract String getUniqueConstraintsElementName(); - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** BaseTableAnnotation implementation ********** - - public boolean isSpecified() { - return true; - } - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; - } - String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); - } - - /** - * Build and return a declaration element adapter for the table's 'name' element - */ - abstract DeclarationAnnotationElementAdapter<String> getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter); - - // ***** schema - public String getSchema() { - return this.schema; - } - - public void setSchema(String schema) { - if (this.attributeValueHasNotChanged(this.schema, schema)) { - return; - } - String old = this.schema; - this.schema = schema; - this.schemaAdapter.setValue(schema); - this.firePropertyChanged(SCHEMA_PROPERTY, old, schema); - } - - private String buildSchema(CompilationUnit astRoot) { - return this.schemaAdapter.getValue(astRoot); - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.schemaDeclarationAdapter, astRoot); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.schemaDeclarationAdapter, pos, astRoot); - } - - /** - * Build and return a declaration element adapter for the table's 'schema' element - */ - abstract DeclarationAnnotationElementAdapter<String> getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter); - - // ***** catalog - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String catalog) { - if (this.attributeValueHasNotChanged(this.catalog, catalog)) { - return; - } - String old = this.catalog; - this.catalog = catalog; - this.catalogAdapter.setValue(catalog); - this.firePropertyChanged(CATALOG_PROPERTY, old, catalog); - } - - private String buildCatalog(CompilationUnit astRoot) { - return this.catalogAdapter.getValue(astRoot); - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.catalogDeclarationAdapter, astRoot); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.catalogDeclarationAdapter, pos, astRoot); - } - - /** - * Build and return a declaration element adapter for the table's 'catalog' element - */ - abstract DeclarationAnnotationElementAdapter<String> getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter); - - // ***** unique constraints - public ListIterator<UniqueConstraintAnnotation> uniqueConstraints() { - return new CloneListIterator<UniqueConstraintAnnotation>(this.uniqueConstraints); - } - - ListIterator<NestableUniqueConstraintAnnotation> nestableUniqueConstraints() { - return new CloneListIterator<NestableUniqueConstraintAnnotation>(this.uniqueConstraints); - } - - public int uniqueConstraintsSize() { - return this.uniqueConstraints.size(); - } - - public NestableUniqueConstraintAnnotation uniqueConstraintAt(int index) { - return this.uniqueConstraints.get(index); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - return this.uniqueConstraints.indexOf(uniqueConstraint); - } - - public NestableUniqueConstraintAnnotation addUniqueConstraint(int index) { - return (NestableUniqueConstraintAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation addUniqueConstraintInternal() { - NestableUniqueConstraintAnnotation uniqueConstraint = this.buildUniqueConstraint(this.uniqueConstraints.size()); - this.uniqueConstraints.add(uniqueConstraint); - return uniqueConstraint; - } - - NestableUniqueConstraintAnnotation buildUniqueConstraint(int index) { - return new SourceUniqueConstraintAnnotation(this, this.member, buildUniqueConstraintAnnotationAdapter(index)); - } - - IndexedDeclarationAnnotationAdapter buildUniqueConstraintAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(this.daa, getUniqueConstraintsElementName(), index, JPA.UNIQUE_CONSTRAINT); - } - - void uniqueConstraintAdded(int index, NestableUniqueConstraintAnnotation constraint) { - this.fireItemAdded(UNIQUE_CONSTRAINTS_LIST, index, constraint); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation moveUniqueConstraintInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.uniqueConstraints, targetIndex, sourceIndex).get(targetIndex); - } - - void uniqueConstraintMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(UNIQUE_CONSTRAINTS_LIST, targetIndex, sourceIndex); - } - - public void removeUniqueConstraint(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation removeUniqueConstraintInternal(int index) { - return this.uniqueConstraints.remove(index); - } - - void uniqueConstraintRemoved(int index, NestableUniqueConstraintAnnotation constraint) { - this.fireItemRemoved(UNIQUE_CONSTRAINTS_LIST, index, constraint); - } - - - // ********** NestableAnnotation implementation ********** - - protected void initializeFrom(NestableAnnotation oldAnnotation) { - BaseTableAnnotation oldTable = (BaseTableAnnotation) oldAnnotation; - this.setName(oldTable.getName()); - this.setSchema(oldTable.getSchema()); - this.setCatalog(oldTable.getCatalog()); - for (UniqueConstraintAnnotation oldUniqueConstraint : CollectionTools.iterable(oldTable.uniqueConstraints())) { - NestableUniqueConstraintAnnotation newUniqueConstraint = this.addUniqueConstraint(oldTable.indexOfUniqueConstraint(oldUniqueConstraint)); - newUniqueConstraint.initializeFrom((NestableAnnotation) oldUniqueConstraint); - } - } - - // ********** unique constraint container ********** - - /** - * adapt the AnnotationContainer interface to the table's unique constraints - */ - class UniqueConstraintsAnnotationContainer - implements AnnotationContainer<NestableUniqueConstraintAnnotation> - { - public String getContainerAnnotationName() { - return SourceBaseTableAnnotation.this.getAnnotationName(); - } - - public Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceBaseTableAnnotation.this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return SourceBaseTableAnnotation.this.getUniqueConstraintsElementName(); - } - - public String getNestableAnnotationName() { - return UniqueConstraintAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestableUniqueConstraintAnnotation> nestedAnnotations() { - return SourceBaseTableAnnotation.this.nestableUniqueConstraints(); - } - - public int nestedAnnotationsSize() { - return SourceBaseTableAnnotation.this.uniqueConstraintsSize(); - } - - public NestableUniqueConstraintAnnotation addNestedAnnotationInternal() { - return SourceBaseTableAnnotation.this.addUniqueConstraintInternal(); - } - - public void nestedAnnotationAdded(int index, NestableUniqueConstraintAnnotation nestedAnnotation) { - SourceBaseTableAnnotation.this.uniqueConstraintAdded(index, nestedAnnotation); - } - - public NestableUniqueConstraintAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return SourceBaseTableAnnotation.this.moveUniqueConstraintInternal(targetIndex, sourceIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - SourceBaseTableAnnotation.this.uniqueConstraintMoved(targetIndex, sourceIndex); - } - - public NestableUniqueConstraintAnnotation removeNestedAnnotationInternal(int index) { - return SourceBaseTableAnnotation.this.removeUniqueConstraintInternal(index); - } - - public void nestedAnnotationRemoved(int index, NestableUniqueConstraintAnnotation nestedAnnotation) { - SourceBaseTableAnnotation.this.uniqueConstraintRemoved(index, nestedAnnotation); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java deleted file mode 100644 index c9d4466863..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.Basic - */ -public final class SourceBasicAnnotation - extends SourceAnnotation<Attribute> - implements BasicAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<Boolean> OPTIONAL_ADAPTER = buildOptionalAdapter(); - private final AnnotationElementAdapter<Boolean> optionalAdapter; - private Boolean optional; - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - private final AnnotationElementAdapter<String> fetchAdapter; - private FetchType fetch; - - - public SourceBasicAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.optionalAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(attribute, OPTIONAL_ADAPTER); - this.fetchAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, FETCH_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.optional = this.buildOptional(astRoot); - this.fetch = this.buildFetch(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setOptional(this.buildOptional(astRoot)); - this.setFetch(this.buildFetch(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.fetch); - } - - - //*************** Basic implementation **************** - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - if (this.attributeValueHasNotChanged(this.optional, optional)) { - return; - } - Boolean old = this.optional; - this.optional = optional; - this.optionalAdapter.setValue(optional); - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); - } - - protected Boolean buildOptional(CompilationUnit astRoot) { - return this.optionalAdapter.getValue(astRoot); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(OPTIONAL_ADAPTER, astRoot); - } - - // ***** fetch - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType fetch) { - if (this.attributeValueHasNotChanged(this.fetch, fetch)) { - return; - } - FetchType old = this.fetch; - this.fetch = fetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); - } - - protected FetchType buildFetch(CompilationUnit astRoot) { - return FetchType.fromJavaAnnotationValue(this.fetchAdapter.getValue(astRoot)); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(FETCH_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<Boolean> buildOptionalAdapter() { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__OPTIONAL, false, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__FETCH, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java deleted file mode 100644 index d04fb8b97c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java +++ /dev/null @@ -1,224 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Column - */ -public final class SourceColumnAnnotation - extends SourceBaseColumnAnnotation - implements NestableColumnAnnotation -{ - // this adapter is only used by a Column annotation associated with a mapping annotation (e.g. Basic) - public static final DeclarationAnnotationAdapter MAPPING_DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final DeclarationAnnotationElementAdapter<Integer> lengthDeclarationAdapter; - private final AnnotationElementAdapter<Integer> lengthAdapter; - private Integer length; - - private final DeclarationAnnotationElementAdapter<Integer> precisionDeclarationAdapter; - private final AnnotationElementAdapter<Integer> precisionAdapter; - private Integer precision; - - private final DeclarationAnnotationElementAdapter<Integer> scaleDeclarationAdapter; - private final AnnotationElementAdapter<Integer> scaleAdapter; - private Integer scale; - - - public SourceColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - super(parent, member, daa); - this.lengthDeclarationAdapter = this.buildIntegerElementAdapter(JPA.COLUMN__LENGTH); - this.lengthAdapter = this.buildShortCircuitIntegerElementAdapter(this.lengthDeclarationAdapter); - this.precisionDeclarationAdapter = this.buildIntegerElementAdapter(JPA.COLUMN__PRECISION); - this.precisionAdapter = this.buildShortCircuitIntegerElementAdapter(this.precisionDeclarationAdapter); - this.scaleDeclarationAdapter = this.buildIntegerElementAdapter(JPA.COLUMN__SCALE); - this.scaleAdapter = this.buildShortCircuitIntegerElementAdapter(this.scaleDeclarationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.length = this.buildLength(astRoot); - this.precision = this.buildPrecision(astRoot); - this.scale = this.buildScale(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setLength(this.buildLength(astRoot)); - this.setPrecision(this.buildPrecision(astRoot)); - this.setScale(this.buildScale(astRoot)); - } - - - // ********** JavaSourceNamedColumnAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.COLUMN__NAME; - } - - @Override - String getColumnDefinitionElementName() { - return JPA.COLUMN__COLUMN_DEFINITION; - } - - - // ********** JavaSourceBaseColumnAnnotation implementation ********** - - @Override - String getTableElementName() { - return JPA.COLUMN__TABLE; - } - - @Override - String getUniqueElementName() { - return JPA.COLUMN__UNIQUE; - } - - @Override - String getNullableElementName() { - return JPA.COLUMN__NULLABLE; - } - - @Override - String getInsertableElementName() { - return JPA.COLUMN__INSERTABLE; - } - - @Override - String getUpdatableElementName() { - return JPA.COLUMN__UPDATABLE; - } - - - // ********** Column implementation ********** - - // ***** length - public Integer getLength() { - return this.length; - } - - public void setLength(Integer length) { - if (this.attributeValueHasNotChanged(this.length, length)) { - return; - } - Integer old = this.length; - this.length = length; - this.lengthAdapter.setValue(length); - this.firePropertyChanged(LENGTH_PROPERTY, old, length); - } - - private Integer buildLength(CompilationUnit astRoot) { - return this.lengthAdapter.getValue(astRoot); - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.lengthDeclarationAdapter, astRoot); - } - - // ***** precision - public Integer getPrecision() { - return this.precision; - } - - public void setPrecision(Integer precision) { - if (this.attributeValueHasNotChanged(this.precision, precision)) { - return; - } - Integer old = this.precision; - this.precision = precision; - this.precisionAdapter.setValue(precision); - this.firePropertyChanged(PRECISION_PROPERTY, old, precision); - } - - private Integer buildPrecision(CompilationUnit astRoot) { - return this.precisionAdapter.getValue(astRoot); - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.precisionDeclarationAdapter, astRoot); - } - - // ***** scale - public Integer getScale() { - return this.scale; - } - - public void setScale(Integer scale) { - if (this.attributeValueHasNotChanged(this.scale, scale)) { - return; - } - Integer old = this.scale; - this.scale = scale; - this.scaleAdapter.setValue(scale); - this.firePropertyChanged(SCALE_PROPERTY, old, scale); - } - - private Integer buildScale(CompilationUnit astRoot) { - return this.scaleAdapter.getValue(astRoot); - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.scaleDeclarationAdapter, astRoot); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - ColumnAnnotation oldColumn = (ColumnAnnotation) oldAnnotation; - this.setLength(oldColumn.getLength()); - this.setPrecision(oldColumn.getPrecision()); - this.setScale(oldColumn.getScale()); - } - - public void moveAnnotation(int newIndex) { - // the only place where a column annotation is nested is in an - // attribute override; and that only nests a single column, not an array - // of columns; so #moveAnnotation(int) is never called - // TODO maybe NestableAnnotation should be split up; - // moving this method to something like IndexableAnnotation - throw new UnsupportedOperationException(); - } - - - // ********** static methods ********** - - static NestableColumnAnnotation createAttributeOverrideColumn(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter attributeOverrideAnnotationAdapter) { - return new SourceColumnAnnotation(parent, member, buildAttributeOverrideAnnotationAdapter(attributeOverrideAnnotationAdapter)); - } - - static DeclarationAnnotationAdapter buildAttributeOverrideAnnotationAdapter(DeclarationAnnotationAdapter attributeOverrideAnnotationAdapter) { - return new NestedDeclarationAnnotationAdapter(attributeOverrideAnnotationAdapter, JPA.ATTRIBUTE_OVERRIDE__COLUMN, JPA.COLUMN); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java deleted file mode 100644 index 05b908a909..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.TypeDeclaration; -import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.JpaResourceModelListener; -import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter; -import org.eclipse.jpt.utility.CommandExecutor; -import org.eclipse.jpt.utility.internal.ListenerList; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; - -/** - * Java compilation unit (source file) - */ -public final class SourceCompilationUnit - extends SourceNode - implements JavaResourceCompilationUnit -{ - /** JDT compilation unit */ - private final ICompilationUnit compilationUnit; - - /** pluggable annotation provider */ - private final JpaAnnotationProvider annotationProvider; - - /** improved annotation formatting */ - private final AnnotationEditFormatter annotationEditFormatter; - - /** pluggable executor that allows the document to be modified on another thread */ - private final CommandExecutor modifySharedDocumentCommandExecutor; - - /** listeners notified whenever the resource model changes */ - private final ListenerList<JpaResourceModelListener> resourceModelListenerList; - - /** - * The primary type of the AST compilation unit. We are not going to handle - * multiple types defined in a single compilation unit. Entities must have - * a public/protected no-arg constructor, and there is no way to access - * the constructor in a package class (which is what all top-level, - * non-primary classes must be). - */ - protected JavaResourcePersistentType persistentType; - - - // ********** construction ********** - - public SourceCompilationUnit( - ICompilationUnit compilationUnit, - JpaAnnotationProvider annotationProvider, - AnnotationEditFormatter annotationEditFormatter, - CommandExecutor modifySharedDocumentCommandExecutor) { - super(null); // the JPA compilation unit is the root of its sub-tree - this.compilationUnit = compilationUnit; - this.annotationProvider = annotationProvider; - this.annotationEditFormatter = annotationEditFormatter; - this.modifySharedDocumentCommandExecutor = modifySharedDocumentCommandExecutor; - this.resourceModelListenerList = new ListenerList<JpaResourceModelListener>(JpaResourceModelListener.class); - this.persistentType = this.buildPersistentType(); - } - - protected JavaResourcePersistentType buildPersistentType() { - this.openCompilationUnit(); - CompilationUnit astRoot = this.buildASTRoot(); - this.closeCompilationUnit(); - return this.buildPersistentType(astRoot); - } - - protected void openCompilationUnit() { - try { - this.compilationUnit.open(null); - } catch (JavaModelException ex) { - // do nothing - we just won't have a primary type in this case - } - } - - protected void closeCompilationUnit() { - try { - this.compilationUnit.close(); - } catch (JavaModelException ex) { - // hmmm - } - } - - protected JavaResourcePersistentType buildPersistentType(CompilationUnit astRoot) { - TypeDeclaration td = this.getPrimaryType(astRoot); - return (td == null) ? null : this.buildPersistentType(astRoot, td); - } - - @Override - protected boolean requiresParent() { - return false; - } - - public void initialize(CompilationUnit astRoot) { - // never called? - } - - - // ********** AbstractJavaResourceNode overrides ********** - - @Override - public JavaResourceCompilationUnit getRoot() { - return this; - } - - @Override - public IFile getFile() { - return (IFile) this.compilationUnit.getResource(); - } - - @Override - public JpaAnnotationProvider getAnnotationProvider() { - return this.annotationProvider; - } - - - // ********** JavaResourceNode implementation ********** - - public void update(CompilationUnit astRoot) { - TypeDeclaration td = this.getPrimaryType(astRoot); - if (td == null) { - this.persistentType = null; - } else { - if (this.persistentType == null) { - this.persistentType = this.buildPersistentType(astRoot, td); - } else { - this.persistentType.update(astRoot); - } - } - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - - // ********** JavaResourceNode.Root implementation ********** - - /** - * NB: return *all* the persistent types since we build them all - */ - public Iterator<JavaResourcePersistentType> persistentTypes() { - return (this.persistentType == null) ? - EmptyIterator.<JavaResourcePersistentType>instance() : - this.persistentType.allTypes(); - } - - public void resourceModelChanged() { - for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelChanged(); - } - } - - - // ********** JavaResourceCompilationUnit implementation ********** - - public ICompilationUnit getCompilationUnit() { - return this.compilationUnit; - } - - public void resolveTypes() { - if (this.persistentType != null) { - this.persistentType.resolveTypes(this.buildASTRoot()); - } - } - - public CommandExecutor getModifySharedDocumentCommandExecutor() { - return this.modifySharedDocumentCommandExecutor; - } - - public AnnotationEditFormatter getAnnotationEditFormatter() { - return this.annotationEditFormatter; - } - - public CompilationUnit buildASTRoot() { - return JDTTools.buildASTRoot(this.compilationUnit); - } - - - // ********** JpaResourceModel implementation ********** - - public void addResourceModelListener(JpaResourceModelListener listener) { - this.resourceModelListenerList.add(listener); - } - - public void removeResourceModelListener(JpaResourceModelListener listener) { - this.resourceModelListenerList.remove(listener); - } - - - // ********** Java changes ********** - - public void update() { - this.update(this.buildASTRoot()); - } - - - // ********** internal ********** - - protected JavaResourcePersistentType buildPersistentType(CompilationUnit astRoot, TypeDeclaration typeDeclaration) { - return SourcePersistentType.newInstance(this, typeDeclaration, astRoot); - } - - /** - * i.e. the type with the same name as the compilation unit; - * return the first class or interface (ignore annotations and enums) with - * the same name as the compilation unit (file); - * NB: this type could be in error if there is an annotation or enum - * with the same name preceding it in the compilation unit - * - * Return null if the parser did not resolve the type declaration's binding. - * This can occur if the project JRE is removed (bug 225332). - */ - protected TypeDeclaration getPrimaryType(CompilationUnit astRoot) { - String primaryTypeName = this.getPrimaryTypeName(); - for (AbstractTypeDeclaration atd : types(astRoot)) { - if ((atd.getNodeType() == ASTNode.TYPE_DECLARATION) - && atd.getName().getFullyQualifiedName().equals(primaryTypeName)) { - return (atd.resolveBinding() == null) ? null : (TypeDeclaration) atd; - } - } - return null; - } - - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - protected static List<AbstractTypeDeclaration> types(CompilationUnit astRoot) { - return astRoot.types(); - } - - /** - * i.e. the name of the compilation unit - */ - protected String getPrimaryTypeName() { - return removeJavaExtension(this.compilationUnit.getElementName()); - } - - protected static String removeJavaExtension(String fileName) { - int index = fileName.lastIndexOf(".java"); //$NON-NLS-1$ - return (index == -1) ? fileName : fileName.substring(0, index); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getPrimaryTypeName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java deleted file mode 100644 index 0239d3f048..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.DiscriminatorColumn - */ -public final class SourceDiscriminatorColumnAnnotation - extends SourceNamedColumnAnnotation - implements DiscriminatorColumnAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> DISCRIMINATOR_TYPE_ADAPTER = buildDiscriminatorTypeAdapter(); - private final AnnotationElementAdapter<String> discriminatorTypeAdapter; - private DiscriminatorType discriminatorType; - - private final DeclarationAnnotationElementAdapter<Integer> lengthDeclarationAdapter; - private final AnnotationElementAdapter<Integer> lengthAdapter; - private Integer length; - - - public SourceDiscriminatorColumnAnnotation(JavaResourcePersistentType parent, Member member, DeclarationAnnotationAdapter daa) { - super(parent, member, daa); - this.discriminatorTypeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, DISCRIMINATOR_TYPE_ADAPTER); - this.lengthDeclarationAdapter = this.buildIntegerElementAdapter(JPA.DISCRIMINATOR_COLUMN__LENGTH); - this.lengthAdapter = this.buildShortCircuitIntegerElementAdapter(this.lengthDeclarationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.discriminatorType = this.buildDiscriminatorType(astRoot); - this.length = this.buildLength(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setLength(this.buildLength(astRoot)); - this.setDiscriminatorType(this.buildDiscriminatorType(astRoot)); - } - - - // ********** JavaSourceNamedColumnAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.DISCRIMINATOR_COLUMN__NAME; - } - - @Override - String getColumnDefinitionElementName() { - return JPA.DISCRIMINATOR_COLUMN__COLUMN_DEFINITION; - } - - - // ********** DiscriminatorColumn implementation ********** - - // ***** discriminator type - public DiscriminatorType getDiscriminatorType() { - return this.discriminatorType; - } - - public void setDiscriminatorType(DiscriminatorType discriminatorType) { - if (this.attributeValueHasNotChanged(this.discriminatorType, discriminatorType)) { - return; - } - DiscriminatorType old = this.discriminatorType; - this.discriminatorType = discriminatorType; - this.discriminatorTypeAdapter.setValue(DiscriminatorType.toJavaAnnotationValue(discriminatorType)); - this.firePropertyChanged(DISCRIMINATOR_TYPE_PROPERTY, old, discriminatorType); - } - - private DiscriminatorType buildDiscriminatorType(CompilationUnit astRoot) { - return DiscriminatorType.fromJavaAnnotationValue(this.discriminatorTypeAdapter.getValue(astRoot)); - } - - // ***** length - public Integer getLength() { - return this.length; - } - - public void setLength(Integer length) { - if (this.attributeValueHasNotChanged(this.length, length)) { - return; - } - Integer old = this.length; - this.length = length; - this.lengthAdapter.setValue(length); - this.firePropertyChanged(LENGTH_PROPERTY, old, length); - } - - private Integer buildLength(CompilationUnit astRoot) { - return this.lengthAdapter.getValue(astRoot); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - throw new UnsupportedOperationException("DiscriminatorColumn is not a nestable annotation"); //$NON-NLS-1$ - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildDiscriminatorTypeAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java deleted file mode 100644 index 33dac08ce5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.DiscriminatorValue - */ -public final class SourceDiscriminatorValueAnnotation - extends SourceAnnotation<Type> - implements DiscriminatorValueAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private String value; - - - public SourceDiscriminatorValueAnnotation(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** DiscriminatorValueAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; - } - String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_VALUE__VALUE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java deleted file mode 100644 index 787e136a18..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Embeddable - */ -public final class SourceEmbeddableAnnotation - extends SourceAnnotation<Type> - implements EmbeddableAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceEmbeddableAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void update(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java deleted file mode 100644 index 723086ad8a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Embedded - */ -public final class SourceEmbeddedAnnotation - extends SourceAnnotation<Attribute> - implements EmbeddedAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceEmbeddedAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void update(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java deleted file mode 100644 index c35382bb7d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.EmbeddedId - */ -public final class SourceEmbeddedIdAnnotation - extends SourceAnnotation<Attribute> - implements EmbeddedIdAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceEmbeddedIdAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void update(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java deleted file mode 100644 index 55662448e9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.EntityAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Entity - */ -public final class SourceEntityAnnotation - extends SourceAnnotation<Type> - implements EntityAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildNameAdapter(); - private final AnnotationElementAdapter<String> nameAdapter; - private String name; - - - public SourceEntityAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, NAME_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** EntityAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; - } - String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(NAME_ADAPTER, astRoot); - } - - - //*********** static methods **************** - - private static DeclarationAnnotationElementAdapter<String> buildNameAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ENTITY__NAME, false); // false = do not remove annotation when empty - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java deleted file mode 100644 index 9ba3ff5f65..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.EnumType; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.Enumerated - */ -public final class SourceEnumeratedAnnotation - extends SourceAnnotation<Attribute> - implements EnumeratedAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private EnumType value; - - - public SourceEnumeratedAnnotation(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** EnumeratedAnnotation implementation ********** - - // ***** value - public EnumType getValue() { - return this.value; - } - - public void setValue(EnumType value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; - } - EnumType old = this.value; - this.value = value; - this.valueAdapter.setValue(EnumType.toJavaAnnotationValue(value)); - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private EnumType buildValue(CompilationUnit astRoot) { - return EnumType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ENUMERATED__VALUE, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java deleted file mode 100644 index 8461845e88..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation; -import org.eclipse.jpt.core.resource.java.GenerationType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.GeneratedValue - */ -public final class SourceGeneratedValueAnnotation - extends SourceAnnotation<Member> - implements GeneratedValueAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> STRATEGY_ADAPTER = buildStrategyAdapter(); - private final AnnotationElementAdapter<String> strategyAdapter; - private GenerationType strategy; - - private static final DeclarationAnnotationElementAdapter<String> GENERATOR_ADAPTER = buildGeneratorAdapter(); - private final AnnotationElementAdapter<String> generatorAdapter; - private String generator; - - - public SourceGeneratedValueAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.strategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, STRATEGY_ADAPTER); - this.generatorAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, GENERATOR_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.strategy = this.buildStrategy(astRoot); - this.generator = this.buildGenerator(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setStrategy(this.buildStrategy(astRoot)); - this.setGenerator(this.buildGenerator(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.strategy); - } - - - // ********** GeneratedValueAnnotation implementation ********** - - // ***** strategy - public GenerationType getStrategy() { - return this.strategy; - } - - public void setStrategy(GenerationType strategy) { - if (this.attributeValueHasNotChanged(this.strategy, strategy)) { - return; - } - GenerationType old = this.strategy; - this.strategy = strategy; - this.strategyAdapter.setValue(GenerationType.toJavaAnnotationValue(strategy)); - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); - } - - private GenerationType buildStrategy(CompilationUnit astRoot) { - return GenerationType.fromJavaAnnotationValue(this.strategyAdapter.getValue(astRoot)); - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(STRATEGY_ADAPTER, astRoot); - } - - // ***** generator - public String getGenerator() { - return this.generator; - } - - public void setGenerator(String generator) { - if (this.attributeValueHasNotChanged(this.generator, generator)) { - return; - } - String old = this.generator; - this.generator = generator; - this.generatorAdapter.setValue(generator); - this.firePropertyChanged(GENERATOR_PROPERTY, old, generator); - } - - private String buildGenerator(CompilationUnit astRoot) { - return this.generatorAdapter.getValue(astRoot); - } - - public TextRange getGeneratorTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(GENERATOR_ADAPTER, astRoot); - } - - public boolean generatorTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(GENERATOR_ADAPTER, pos, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildStrategyAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__STRATEGY, false); - } - - private static DeclarationAnnotationElementAdapter<String> buildGeneratorAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__GENERATOR, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java deleted file mode 100644 index fd6d68a5ed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.GeneratorAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SequenceGenerator - * javax.persistence.TableGenerator - */ -abstract class SourceGeneratorAnnotation - extends SourceAnnotation<Member> - implements GeneratorAnnotation -{ - final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - final AnnotationElementAdapter<String> nameAdapter; - String name; - - final DeclarationAnnotationElementAdapter<Integer> initialValueDeclarationAdapter; - final AnnotationElementAdapter<Integer> initialValueAdapter; - Integer initialValue; - - final DeclarationAnnotationElementAdapter<Integer> allocationSizeDeclarationAdapter; - final AnnotationElementAdapter<Integer> allocationSizeAdapter; - Integer allocationSize; - - - SourceGeneratorAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - super(parent, member, daa); - this.nameDeclarationAdapter = this.getNameAdapter(); - this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter); - this.initialValueDeclarationAdapter = this.getInitialValueAdapter(); - this.initialValueAdapter = this.buildIntegerAdapter(this.initialValueDeclarationAdapter); - this.allocationSizeDeclarationAdapter = this.getAllocationSizeAdapter(); - this.allocationSizeAdapter = this.buildIntegerAdapter(this.allocationSizeDeclarationAdapter); - } - - protected AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); - } - - protected AnnotationElementAdapter<Integer> buildIntegerAdapter(DeclarationAnnotationElementAdapter<Integer> daea) { - return new ShortCircuitAnnotationElementAdapter<Integer>(this.member, daea); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - this.initialValue = this.buildInitialValue(astRoot); - this.allocationSize = this.buildAllocationSize(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - this.setInitialValue(this.buildInitialValue(astRoot)); - this.setAllocationSize(this.buildAllocationSize(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** GeneratorAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; - } - String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - abstract DeclarationAnnotationElementAdapter<String> getNameAdapter(); - - // ***** initial value - public Integer getInitialValue() { - return this.initialValue; - } - - public void setInitialValue(Integer initialValue) { - if (this.attributeValueHasNotChanged(this.initialValue, initialValue)) { - return; - } - Integer old = this.initialValue; - this.initialValue = initialValue; - this.initialValueAdapter.setValue(initialValue); - this.firePropertyChanged(INITIAL_VALUE_PROPERTY, old, initialValue); - } - - private Integer buildInitialValue(CompilationUnit astRoot) { - return this.initialValueAdapter.getValue(astRoot); - } - - public TextRange getInitialValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.initialValueDeclarationAdapter, astRoot); - } - - abstract DeclarationAnnotationElementAdapter<Integer> getInitialValueAdapter(); - - // ***** allocation size - public Integer getAllocationSize() { - return this.allocationSize; - } - - public void setAllocationSize(Integer allocationSize) { - if (this.attributeValueHasNotChanged(this.allocationSize, allocationSize)) { - return; - } - Integer old = this.allocationSize; - this.allocationSize = allocationSize; - this.allocationSizeAdapter.setValue(allocationSize); - this.firePropertyChanged(ALLOCATION_SIZE_PROPERTY, old, allocationSize); - } - - private Integer buildAllocationSize(CompilationUnit astRoot) { - return this.allocationSizeAdapter.getValue(astRoot); - } - - public TextRange getAllocationSizeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.allocationSizeDeclarationAdapter, astRoot); - } - - abstract DeclarationAnnotationElementAdapter<Integer> getAllocationSizeAdapter(); - - - // ********** static methods ********** - - static DeclarationAnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(annotationAdapter, elementName); - } - - static DeclarationAnnotationElementAdapter<Integer> buildIntegerAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Integer>(annotationAdapter, elementName, NumberIntegerExpressionConverter.instance()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java deleted file mode 100644 index 224785258d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.IdAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Id - */ -public final class SourceIdAnnotation - extends SourceAnnotation<Attribute> - implements IdAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceIdAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void update(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java deleted file mode 100644 index 96712da0a5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; -import org.eclipse.jpt.core.resource.java.IdClassAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.IdClass - */ -public final class SourceIdClassAnnotation - extends SourceAnnotation<Type> - implements IdClassAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private String value; - - private String fullyQualifiedClassName; - - - public SourceIdClassAnnotation(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - this.fullyQualifiedClassName = this.buildFullyQualifiedClassName(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); - this.setFullyQualifiedClassName(this.buildFullyQualifiedClassName(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** IdClassAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; - } - String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - // ***** fully-qualified class name - public String getFullyQualifiedClassName() { - return this.fullyQualifiedClassName; - } - - private void setFullyQualifiedClassName(String fullyQualifiedClassName) { - String old = this.fullyQualifiedClassName; - this.fullyQualifiedClassName = fullyQualifiedClassName; - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, fullyQualifiedClassName); - } - - private String buildFullyQualifiedClassName(CompilationUnit astRoot) { - return (this.value == null) ? null : JDTTools.resolveFullyQualifiedName(this.valueAdapter.getExpression(astRoot)); - } - - - // ********** static methods ********** - - protected static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter<String>(DECLARATION_ANNOTATION_ADAPTER, JPA.ID_CLASS__VALUE, SimpleTypeStringExpressionConverter.instance()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java deleted file mode 100644 index 12957ce4b5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.InheritanceType; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Inheritance - */ -public final class SourceInheritanceAnnotation - extends SourceAnnotation<Type> - implements InheritanceAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> STRATEGY_ADAPTER = buildStrategyAdapter(); - private final AnnotationElementAdapter<String> strategyAdapter; - private InheritanceType strategy; - - - public SourceInheritanceAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.strategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, STRATEGY_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.strategy = this.buildStrategy(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setStrategy(this.buildStrategy(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.strategy); - } - - - // ********** InheritanceAnnotation implementation ********** - - // ***** strategy - public InheritanceType getStrategy() { - return this.strategy; - } - - public void setStrategy(InheritanceType strategy) { - if (this.attributeValueHasNotChanged(this.strategy, strategy)) { - return; - } - InheritanceType old = this.strategy; - this.strategy = strategy; - this.strategyAdapter.setValue(InheritanceType.toJavaAnnotationValue(strategy)); - this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy); - } - - private InheritanceType buildStrategy(CompilationUnit astRoot) { - return InheritanceType.fromJavaAnnotationValue(this.strategyAdapter.getValue(astRoot)); - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(STRATEGY_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildStrategyAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.INHERITANCE__STRATEGY); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java deleted file mode 100644 index cf9f24a3a6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java +++ /dev/null @@ -1,189 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.JoinColumn - */ -public final class SourceJoinColumnAnnotation - extends SourceBaseColumnAnnotation - implements NestableJoinColumnAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final DeclarationAnnotationElementAdapter<String> referencedColumnNameDeclarationAdapter; - private final AnnotationElementAdapter<String> referencedColumnNameAdapter; - private String referencedColumnName; - - - public SourceJoinColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.referencedColumnNameDeclarationAdapter = this.buildStringElementAdapter(JPA.JOIN_COLUMN__REFERENCED_COLUMN_NAME); - this.referencedColumnNameAdapter = this.buildShortCircuitElementAdapter(this.referencedColumnNameDeclarationAdapter); - } - - public SourceJoinColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - } - - public SourceJoinColumnAnnotation(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { - this(parent, member, idaa, new MemberIndexedAnnotationAdapter(member, idaa)); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.referencedColumnName = this.buildReferencedColumnName(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setReferencedColumnName(this.buildReferencedColumnName(astRoot)); - } - - - // ********** JavaSourceNamedColumnAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.JOIN_COLUMN__NAME; - } - - @Override - String getColumnDefinitionElementName() { - return JPA.JOIN_COLUMN__COLUMN_DEFINITION; - } - - - // ********** JavaSourceNamedColumnAnnotation implementation ********** - - @Override - String getTableElementName() { - return JPA.JOIN_COLUMN__TABLE; - } - - @Override - String getUniqueElementName() { - return JPA.JOIN_COLUMN__UNIQUE; - } - - @Override - String getNullableElementName() { - return JPA.JOIN_COLUMN__NULLABLE; - } - - @Override - String getInsertableElementName() { - return JPA.JOIN_COLUMN__INSERTABLE; - } - - @Override - String getUpdatableElementName() { - return JPA.JOIN_COLUMN__UPDATABLE; - } - - - //************ JoinColumn implementation *************** - - // referenced column name - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - public void setReferencedColumnName(String referencedColumnName) { - if (this.attributeValueHasNotChanged(this.referencedColumnName, referencedColumnName)) { - return; - } - String old = this.referencedColumnName; - this.referencedColumnName = referencedColumnName; - this.referencedColumnNameAdapter.setValue(referencedColumnName); - this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, referencedColumnName); - } - - private String buildReferencedColumnName(CompilationUnit astRoot) { - return this.referencedColumnNameAdapter.getValue(astRoot); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.referencedColumnNameDeclarationAdapter, astRoot); - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.referencedColumnNameDeclarationAdapter, pos, astRoot); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - JoinColumnAnnotation oldJoinColumn = (JoinColumnAnnotation) oldAnnotation; - this.setReferencedColumnName(oldJoinColumn.getReferencedColumnName()); - } - - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - protected IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - - // ********** static methods ********** - - public static SourceJoinColumnAnnotation createJoinColumn(JavaResourceNode parent, Member member) { - return new SourceJoinColumnAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - static SourceJoinColumnAnnotation createNestedJoinColumn(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter joinColumnsAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, joinColumnsAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa); - return new SourceJoinColumnAnnotation(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter joinColumnsAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(joinColumnsAdapter, index, JPA.JOIN_COLUMN); - } - - static NestableJoinColumnAnnotation createAssociationOverrideJoinColumn(DeclarationAnnotationAdapter associationOverrideAdapter, JavaResourceNode parent, Member member, int index) { - return new SourceJoinColumnAnnotation(parent, member, buildAssociationOverrideAnnotationAdapter(associationOverrideAdapter, index)); - } - - private static IndexedDeclarationAnnotationAdapter buildAssociationOverrideAnnotationAdapter(DeclarationAnnotationAdapter associationOverrideAdapter, int index) { - return new NestedIndexedDeclarationAnnotationAdapter(associationOverrideAdapter, JPA.ASSOCIATION_OVERRIDE__JOIN_COLUMNS, index, JPA.JOIN_COLUMN); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java deleted file mode 100644 index 30f633fd88..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.JoinColumns - */ -public final class SourceJoinColumnsAnnotation - extends SourceAnnotation<Member> - implements JoinColumnsAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableJoinColumnAnnotation> joinColumns = new Vector<NestableJoinColumnAnnotation>(); - - - public SourceJoinColumnsAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.joinColumns); - } - - - // ********** AnnotationContainer implementation ********** - - public String getContainerAnnotationName() { - return this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return JPA.JOIN_COLUMNS__VALUE; - } - - public String getNestableAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestableJoinColumnAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableJoinColumnAnnotation>(this.joinColumns); - } - - public int nestedAnnotationsSize() { - return this.joinColumns.size(); - } - - public NestableJoinColumnAnnotation addNestedAnnotationInternal() { - NestableJoinColumnAnnotation joinColumn = this.buildJoinColumn(this.joinColumns.size()); - this.joinColumns.add(joinColumn); - return joinColumn; - } - - private NestableJoinColumnAnnotation buildJoinColumn(int index) { - return SourceJoinColumnAnnotation.createNestedJoinColumn(this, this.member, index, this.daa); - } - - public void nestedAnnotationAdded(int index, NestableJoinColumnAnnotation nestedAnnotation) { - this.fireItemAdded(JOIN_COLUMNS_LIST, index, nestedAnnotation); - } - - public NestableJoinColumnAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.joinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - public NestableJoinColumnAnnotation removeNestedAnnotationInternal(int index) { - return this.joinColumns.remove(index); - } - - public void nestedAnnotationRemoved(int index, NestableJoinColumnAnnotation nestedAnnotation) { - this.fireItemRemoved(JOIN_COLUMNS_LIST, index, nestedAnnotation); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java deleted file mode 100644 index 56822b9f22..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java +++ /dev/null @@ -1,381 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinTableAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.JoinTable - */ -public class SourceJoinTableAnnotation - extends SourceBaseTableAnnotation - implements NestableJoinTableAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JoinTableAnnotation.ANNOTATION_NAME); - - - private final Vector<NestableJoinColumnAnnotation> joinColumns = new Vector<NestableJoinColumnAnnotation>(); - private final JoinColumnsAnnotationContainer joinColumnsContainer = new JoinColumnsAnnotationContainer(); - - private final Vector<NestableJoinColumnAnnotation> inverseJoinColumns = new Vector<NestableJoinColumnAnnotation>(); - private final InverseJoinColumnsContainerAnnotation inverseJoinColumnsContainer = new InverseJoinColumnsContainerAnnotation(); - - - public SourceJoinTableAnnotation(JavaResourceNode parent, Member member) { - this(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public SourceJoinTableAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - super(parent, member, daa); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - AnnotationContainerTools.initialize(this.joinColumnsContainer, astRoot); - AnnotationContainerTools.initialize(this.inverseJoinColumnsContainer, astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - AnnotationContainerTools.update(this.joinColumnsContainer, astRoot); - AnnotationContainerTools.update(this.inverseJoinColumnsContainer, astRoot); - } - - - // ********** AbstractBaseTableAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.JOIN_TABLE__NAME); - } - - @Override - DeclarationAnnotationElementAdapter<String> getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.JOIN_TABLE__SCHEMA); - } - - @Override - DeclarationAnnotationElementAdapter<String> getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.JOIN_TABLE__CATALOG); - } - - @Override - String getUniqueConstraintsElementName() { - return JPA.JOIN_TABLE__UNIQUE_CONSTRAINTS; - } - - // ********** JoinTableAnnotation implementation ********** - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.joinColumns); - } - - ListIterator<NestableJoinColumnAnnotation> nestableJoinColumns() { - return new CloneListIterator<NestableJoinColumnAnnotation>(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public NestableJoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public NestableJoinColumnAnnotation addJoinColumn(int index) { - return (NestableJoinColumnAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation addJoinColumnInternal() { - NestableJoinColumnAnnotation joinColumn = this.buildJoinColumn(this.joinColumns.size()); - this.joinColumns.add(joinColumn); - return joinColumn; - } - - private NestableJoinColumnAnnotation buildJoinColumn(int index) { - return new SourceJoinColumnAnnotation(this, this.member, buildJoinColumnAnnotationAdapter(index)); - } - - private IndexedDeclarationAnnotationAdapter buildJoinColumnAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(this.daa, JPA.JOIN_TABLE__JOIN_COLUMNS, index, JPA.JOIN_COLUMN); - } - - void joinColumnAdded(int index, NestableJoinColumnAnnotation joinColumn) { - this.fireItemAdded(JOIN_COLUMNS_LIST, index, joinColumn); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation moveJoinColumnInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.joinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - void joinColumnMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - public void removeJoinColumn(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation removeJoinColumnInternal(int index) { - return this.joinColumns.remove(index); - } - - void joinColumnRemoved(int index, NestableJoinColumnAnnotation joinColumn) { - this.fireItemRemoved(JOIN_COLUMNS_LIST, index, joinColumn); - } - - public JoinColumnAnnotation initializeJoinColumns() { - return this.addJoinColumnInternal(); - } - - // ***** inverse join columns - public ListIterator<JoinColumnAnnotation> inverseJoinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.inverseJoinColumns); - } - - ListIterator<NestableJoinColumnAnnotation> nestableInverseJoinColumns() { - return new CloneListIterator<NestableJoinColumnAnnotation>(this.inverseJoinColumns); - } - - public int inverseJoinColumnsSize() { - return this.inverseJoinColumns.size(); - } - - public NestableJoinColumnAnnotation inverseJoinColumnAt(int index) { - return this.inverseJoinColumns.get(index); - } - - public int indexOfInverseJoinColumn(JoinColumnAnnotation joinColumn) { - return this.inverseJoinColumns.indexOf(joinColumn); - } - - public NestableJoinColumnAnnotation addInverseJoinColumn(int index) { - return (NestableJoinColumnAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.inverseJoinColumnsContainer); - } - - NestableJoinColumnAnnotation addInverseJoinColumnInternal() { - NestableJoinColumnAnnotation joinColumn = this.buildInverseJoinColumn(this.inverseJoinColumns.size()); - this.inverseJoinColumns.add(joinColumn); - return joinColumn; - } - - private NestableJoinColumnAnnotation buildInverseJoinColumn(int index) { - return new SourceJoinColumnAnnotation(this, this.member, buildInverseJoinColumnAnnotationAdapter(index)); - } - - private IndexedDeclarationAnnotationAdapter buildInverseJoinColumnAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(this.daa, JPA.JOIN_TABLE__INVERSE_JOIN_COLUMNS, index, JPA.JOIN_COLUMN); - } - - void inverseJoinColumnAdded(int index, NestableJoinColumnAnnotation joinColumn) { - this.fireItemAdded(INVERSE_JOIN_COLUMNS_LIST, index, joinColumn); - } - - public void moveInverseJoinColumn(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.inverseJoinColumnsContainer); - } - - NestableJoinColumnAnnotation moveInverseJoinColumnInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.inverseJoinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - void inverseJoinColumnMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(INVERSE_JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - public void removeInverseJoinColumn(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.inverseJoinColumnsContainer); - } - - NestableJoinColumnAnnotation removeInverseJoinColumnInternal(int index) { - return this.inverseJoinColumns.remove(index); - } - - void inverseJoinColumnRemoved(int index, NestableJoinColumnAnnotation joinColumn) { - this.fireItemRemoved(INVERSE_JOIN_COLUMNS_LIST, index, joinColumn); - } - - public JoinColumnAnnotation initializeInverseJoinColumns() { - return this.addInverseJoinColumnInternal(); - } - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - JoinTableAnnotation oldJoinTable = (JoinTableAnnotation) oldAnnotation; - for (JoinColumnAnnotation oldJoinColumn : CollectionTools.iterable(oldJoinTable.joinColumns())) { - NestableJoinColumnAnnotation newJoinColumn = this.addJoinColumn(oldJoinTable.indexOfJoinColumn(oldJoinColumn)); - newJoinColumn.initializeFrom((NestableAnnotation) oldJoinColumn); - } - for (JoinColumnAnnotation oldInverseJoinColumn : CollectionTools.iterable(oldJoinTable.inverseJoinColumns())) { - NestableJoinColumnAnnotation newInverseJoinColumn = this.addInverseJoinColumn(oldJoinTable.indexOfInverseJoinColumn(oldInverseJoinColumn)); - newInverseJoinColumn.initializeFrom((NestableAnnotation) oldInverseJoinColumn); - } - } - - public void moveAnnotation(int newIndex) { - // the only place where a join table annotation is nested is in an - // association override; and that only nests a single join table, not an array - // of join tables; so #moveAnnotation(int) is never called - // TODO maybe NestableAnnotation should be split up; - // moving this method to something like IndexableAnnotation - throw new UnsupportedOperationException(); - } - - // ********** annotation containers ********** - - abstract class AbstractJoinColumnAnnotationContainer - implements AnnotationContainer<NestableJoinColumnAnnotation> - { - public String getContainerAnnotationName() { - return SourceJoinTableAnnotation.this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceJoinTableAnnotation.this.getJdtAnnotation(astRoot); - } - - public String getNestableAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - } - - - /** - * adapt the AnnotationContainer interface to the join table's join columns - */ - class JoinColumnsAnnotationContainer - extends AbstractJoinColumnAnnotationContainer - { - public String getElementName() { - return JPA.JOIN_TABLE__JOIN_COLUMNS; - } - - public ListIterator<NestableJoinColumnAnnotation> nestedAnnotations() { - return SourceJoinTableAnnotation.this.nestableJoinColumns(); - } - - public int nestedAnnotationsSize() { - return SourceJoinTableAnnotation.this.joinColumnsSize(); - } - - public NestableJoinColumnAnnotation addNestedAnnotationInternal() { - return SourceJoinTableAnnotation.this.addJoinColumnInternal(); - } - - public void nestedAnnotationAdded(int index, NestableJoinColumnAnnotation nestedAnnotation) { - SourceJoinTableAnnotation.this.joinColumnAdded(index, nestedAnnotation); - } - - public NestableJoinColumnAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return SourceJoinTableAnnotation.this.moveJoinColumnInternal(targetIndex, sourceIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - SourceJoinTableAnnotation.this.joinColumnMoved(targetIndex, sourceIndex); - } - - public NestableJoinColumnAnnotation removeNestedAnnotationInternal(int index) { - return SourceJoinTableAnnotation.this.removeJoinColumnInternal(index); - } - - public void nestedAnnotationRemoved(int index, NestableJoinColumnAnnotation nestedAnnotation) { - SourceJoinTableAnnotation.this.joinColumnRemoved(index, nestedAnnotation); - } - } - - - /** - * adapt the AnnotationContainer interface to the join table's inverse join columns - */ - class InverseJoinColumnsContainerAnnotation - extends AbstractJoinColumnAnnotationContainer - { - public String getElementName() { - return JPA.JOIN_TABLE__INVERSE_JOIN_COLUMNS; - } - - public ListIterator<NestableJoinColumnAnnotation> nestedAnnotations() { - return SourceJoinTableAnnotation.this.nestableInverseJoinColumns(); - } - - public int nestedAnnotationsSize() { - return SourceJoinTableAnnotation.this.inverseJoinColumnsSize(); - } - - public NestableJoinColumnAnnotation addNestedAnnotationInternal() { - return SourceJoinTableAnnotation.this.addInverseJoinColumnInternal(); - } - - public void nestedAnnotationAdded(int index, NestableJoinColumnAnnotation nestedAnnotation) { - SourceJoinTableAnnotation.this.inverseJoinColumnAdded(index, nestedAnnotation); - } - - public NestableJoinColumnAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return SourceJoinTableAnnotation.this.moveInverseJoinColumnInternal(targetIndex, sourceIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - SourceJoinTableAnnotation.this.inverseJoinColumnMoved(targetIndex, sourceIndex); - } - - public NestableJoinColumnAnnotation removeNestedAnnotationInternal(int index) { - return SourceJoinTableAnnotation.this.removeInverseJoinColumnInternal(index); - } - - public void nestedAnnotationRemoved(int index, NestableJoinColumnAnnotation nestedAnnotation) { - SourceJoinTableAnnotation.this.inverseJoinColumnRemoved(index, nestedAnnotation); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java deleted file mode 100644 index 05228b8d51..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.LobAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Lob - */ -public final class SourceLobAnnotation - extends SourceAnnotation<Attribute> - implements LobAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceLobAnnotation(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void update(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java deleted file mode 100644 index 73d8ef8db2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java +++ /dev/null @@ -1,132 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.ManyToMany - */ -public final class SourceManyToManyAnnotation - extends SourceRelationshipMappingAnnotation - implements ManyToManyAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter<String[]> CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> MAPPED_BY_ADAPTER = buildMappedByAdapter(); - private final AnnotationElementAdapter<String> mappedByAdapter; - private String mappedBy; - - - public SourceManyToManyAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.mappedByAdapter = this.buildAnnotationElementAdapter(MAPPED_BY_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.mappedBy = this.buildMappedBy(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setMappedBy(this.buildMappedBy(astRoot)); - } - - - // ********** SourceRelationshipMappingAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String> getFetchAdapter() { - return FETCH_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String[]> getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - - //**************** OwnableRelationshipMappingAnnotation implementation ************** - - // ***** mapped by - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - if (this.attributeValueHasNotChanged(this.mappedBy, mappedBy)) { - return; - } - String old = this.mappedBy; - this.mappedBy = mappedBy; - this.mappedByAdapter.setValue(mappedBy); - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); - } - - private String buildMappedBy(CompilationUnit astRoot) { - return this.mappedByAdapter.getValue(astRoot); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(MAPPED_BY_ADAPTER, astRoot); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(MAPPED_BY_ADAPTER, pos, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter<String> buildMappedByAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__MAPPED_BY, false); // false = do not remove annotation when empty - } - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__FETCH); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__CASCADE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java deleted file mode 100644 index 6883f3d1c6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.ManyToOne - */ -public final class SourceManyToOneAnnotation - extends SourceRelationshipMappingAnnotation - implements ManyToOneAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter<String[]> CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter<Boolean> OPTIONAL_ADAPTER = buildOptionalAdapter(); - private final AnnotationElementAdapter<Boolean> optionalAdapter; - private Boolean optional; - - - public SourceManyToOneAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.optionalAdapter = this.buildBooleanAnnotationElementAdapter(OPTIONAL_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.optional = this.buildOptional(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setOptional(this.buildOptional(astRoot)); - } - - - // ********** SourceRelationshipMappingAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String> getFetchAdapter() { - return FETCH_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String[]> getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - - // ********** ManyToOneMappingAnnotation implementation ********** - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - if (this.attributeValueHasNotChanged(this.optional, optional)) { - return; - } - Boolean old = this.optional; - this.optional = optional; - this.optionalAdapter.setValue(optional); - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); - } - - private Boolean buildOptional(CompilationUnit astRoot) { - return this.optionalAdapter.getValue(astRoot); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(OPTIONAL_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__FETCH); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOptionalAdapter() { - return buildOptionalAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__OPTIONAL); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__CASCADE); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOptionalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(annotationAdapter, elementName, false, BooleanExpressionConverter.instance()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java deleted file mode 100644 index 34f409fe27..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.MapKeyAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.MapKey - */ -public final class SourceMapKeyAnnotation - extends SourceAnnotation<Attribute> - implements MapKeyAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildNameAdapter(); - private final AnnotationElementAdapter<String> nameAdapter; - private String name; - - - public SourceMapKeyAnnotation(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, NAME_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** MapKeyAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; - } - String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(NAME_ADAPTER, astRoot); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(NAME_ADAPTER, pos, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildNameAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.MAP_KEY__NAME, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java deleted file mode 100644 index 3703e3ab2e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.MappedSuperclass - */ -public final class SourceMappedSuperclassAnnotation - extends SourceAnnotation<Type> - implements MappedSuperclassAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceMappedSuperclassAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void update(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java deleted file mode 100644 index 3f6048f7e3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Column - * javax.persistence.JoinColumn - * javax.persistence.DiscriminatorColumn - * javax.persistence.PrimaryKeyJoinColumn. - */ -abstract class SourceNamedColumnAnnotation - extends SourceAnnotation<Member> - implements NamedColumnAnnotation -{ - private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - private final AnnotationElementAdapter<String> nameAdapter; - private String name; - - private final DeclarationAnnotationElementAdapter<String> columnDefinitionDeclarationAdapter; - private final AnnotationElementAdapter<String> columnDefinitionAdapter; - private String columnDefinition; - - - SourceNamedColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - } - - SourceNamedColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.nameDeclarationAdapter = this.buildStringElementAdapter(this.getNameElementName()); - this.nameAdapter = this.buildShortCircuitElementAdapter(this.nameDeclarationAdapter); - this.columnDefinitionDeclarationAdapter = this.buildStringElementAdapter(this.getColumnDefinitionElementName()); - this.columnDefinitionAdapter = this.buildShortCircuitElementAdapter(this.columnDefinitionDeclarationAdapter); - } - - DeclarationAnnotationElementAdapter<String> buildStringElementAdapter(String elementName) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, elementName); - } - - DeclarationAnnotationElementAdapter<Boolean> buildBooleanElementAdapter(String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(this.daa, elementName, BooleanExpressionConverter.instance()); - } - - DeclarationAnnotationElementAdapter<Integer> buildIntegerElementAdapter(String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Integer>(this.daa, elementName, NumberIntegerExpressionConverter.instance()); - } - - AnnotationElementAdapter<String> buildShortCircuitElementAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); - } - - AnnotationElementAdapter<Boolean> buildShortCircuitBooleanElementAdapter(DeclarationAnnotationElementAdapter<Boolean> daea) { - return new ShortCircuitAnnotationElementAdapter<Boolean>(this.member, daea); - } - - AnnotationElementAdapter<Integer> buildShortCircuitIntegerElementAdapter(DeclarationAnnotationElementAdapter<Integer> daea) { - return new ShortCircuitAnnotationElementAdapter<Integer>(this.member, daea); - } - - AnnotationElementAdapter<String> buildShortCircuitStringElementAdapter(String elementName) { - return this.buildShortCircuitElementAdapter(this.buildStringElementAdapter(elementName)); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - this.columnDefinition = this.buildColumnDefinition(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - this.setColumnDefinition(this.buildColumnDefinition(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** NamedColumn implementation ********** - - public boolean isSpecified() { - return true; - } - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; - } - String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); - } - - abstract String getNameElementName(); - - // ***** column definition - public String getColumnDefinition() { - return this.columnDefinition; - } - - public void setColumnDefinition(String columnDefinition) { - if (this.attributeValueHasNotChanged(this.columnDefinition, columnDefinition)) { - return; - } - String old = this.columnDefinition; - this.columnDefinition = columnDefinition; - this.columnDefinitionAdapter.setValue(columnDefinition); - this.firePropertyChanged(COLUMN_DEFINITION_PROPERTY, old, columnDefinition); - } - - private String buildColumnDefinition(CompilationUnit astRoot) { - return this.columnDefinitionAdapter.getValue(astRoot); - } - - public TextRange getColumnDefinitionTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.columnDefinitionDeclarationAdapter, astRoot); - } - - abstract String getColumnDefinitionElementName(); - - - // ********** NestableAnnotation implementation ********** - - public void initializeFrom(NestableAnnotation oldAnnotation) { - NamedColumnAnnotation oldColumn = (NamedColumnAnnotation) oldAnnotation; - this.setName(oldColumn.getName()); - this.setColumnDefinition(oldColumn.getColumnDefinition()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java deleted file mode 100644 index 966e3506d3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.NamedNativeQueries - */ -public final class SourceNamedNativeQueriesAnnotation - extends SourceAnnotation<Type> - implements NamedNativeQueriesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableNamedNativeQueryAnnotation> namedNativeQueries = new Vector<NestableNamedNativeQueryAnnotation>(); - - - public SourceNamedNativeQueriesAnnotation(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.namedNativeQueries); - } - - - // ********** AnnotationContainer implementation ********** - - public String getContainerAnnotationName() { - return this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return JPA.NAMED_NATIVE_QUERIES__VALUE; - } - - public String getNestableAnnotationName() { - return NamedNativeQueryAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestableNamedNativeQueryAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableNamedNativeQueryAnnotation>(this.namedNativeQueries); - } - - public int nestedAnnotationsSize() { - return this.namedNativeQueries.size(); - } - - public NestableNamedNativeQueryAnnotation addNestedAnnotationInternal() { - NestableNamedNativeQueryAnnotation namedNativeQuery = this.buildNamedNativeQuery(this.namedNativeQueries.size()); - this.namedNativeQueries.add(namedNativeQuery); - return namedNativeQuery; - } - - private NestableNamedNativeQueryAnnotation buildNamedNativeQuery(int index) { - return SourceNamedNativeQueryAnnotation.createNestedNamedNativeQuery(this, this.member, index, this.daa); - } - - public void nestedAnnotationAdded(int index, NestableNamedNativeQueryAnnotation nestedAnnotation) { - this.fireItemAdded(NAMED_NATIVE_QUERIES_LIST, index, nestedAnnotation); - } - - public NestableNamedNativeQueryAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.namedNativeQueries, targetIndex, sourceIndex).get(targetIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(NAMED_NATIVE_QUERIES_LIST, targetIndex, sourceIndex); - } - - public NestableNamedNativeQueryAnnotation removeNestedAnnotationInternal(int index) { - return this.namedNativeQueries.remove(index); - } - - public void nestedAnnotationRemoved(int index, NestableNamedNativeQueryAnnotation nestedAnnotation) { - this.fireItemRemoved(NAMED_NATIVE_QUERIES_LIST, index, nestedAnnotation); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java deleted file mode 100644 index 0c5cadde71..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedNativeQuery - */ -public final class SourceNamedNativeQueryAnnotation - extends SourceBaseNamedQueryAnnotation - implements NestableNamedNativeQueryAnnotation -{ - public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final DeclarationAnnotationElementAdapter<String> resultClassDeclarationAdapter; - private final AnnotationElementAdapter<String> resultClassAdapter; - private String resultClass; - - private String fullyQualifiedResultClassName; - - private final DeclarationAnnotationElementAdapter<String> resultSetMappingDeclarationAdapter; - private final AnnotationElementAdapter<String> resultSetMappingAdapter; - private String resultSetMapping; - - - public SourceNamedNativeQueryAnnotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, type, daa, annotationAdapter); - this.resultClassDeclarationAdapter = this.buildResultClassAdapter(daa); - this.resultClassAdapter = this.buildAdapter(this.resultClassDeclarationAdapter); - this.resultSetMappingDeclarationAdapter = this.buildResultSetMappingAdapter(daa); - this.resultSetMappingAdapter = this.buildAdapter(this.resultSetMappingDeclarationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.resultClass = this.buildResultClass(astRoot); - this.fullyQualifiedResultClassName = this.buildFullyQualifiedResultClassName(astRoot); - this.resultSetMapping = this.buildResultSetMapping(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setResultClass(this.buildResultClass(astRoot)); - this.setFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot)); - this.setResultSetMapping(this.buildResultSetMapping(astRoot)); - } - - - // ********** AbstractBaseNamedQueryAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.NAMED_NATIVE_QUERY__NAME; - } - - @Override - String getQueryElementName() { - return JPA.NAMED_NATIVE_QUERY__QUERY; - } - - @Override - String getHintsElementName() { - return JPA.NAMED_NATIVE_QUERY__HINTS; - } - - @Override - NestableQueryHintAnnotation buildQueryHint(int index) { - return SourceQueryHintAnnotation.createNamedNativeQueryQueryHint(this, this.member, this.daa, index); - } - - - // ********** NamedNativeQueryAnnotation implementation ********** - - // ***** result class - public String getResultClass() { - return this.resultClass; - } - - public void setResultClass(String resultClass) { - if (this.attributeValueHasNotChanged(this.resultClass, resultClass)) { - return; - } - String old = this.resultClass; - this.resultClass = resultClass; - this.resultClassAdapter.setValue(resultClass); - this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass); - } - - private String buildResultClass(CompilationUnit astRoot) { - return this.resultClassAdapter.getValue(astRoot); - } - - public TextRange getResultClassTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.resultClassDeclarationAdapter, astRoot); - } - - private DeclarationAnnotationElementAdapter<String> buildResultClassAdapter(DeclarationAnnotationAdapter daAdapter) { - return new ConversionDeclarationAnnotationElementAdapter<String>(daAdapter, JPA.NAMED_NATIVE_QUERY__RESULT_CLASS, SimpleTypeStringExpressionConverter.instance()); - } - - // ***** fully-qualified result class name - public String getFullyQualifiedResultClassName() { - return this.fullyQualifiedResultClassName; - } - - private void setFullyQualifiedResultClassName(String name) { - String old = this.fullyQualifiedResultClassName; - this.fullyQualifiedResultClassName = name; - this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old, name); - } - - private String buildFullyQualifiedResultClassName(CompilationUnit astRoot) { - return (this.resultClass == null) ? null : JDTTools.resolveFullyQualifiedName(this.resultClassAdapter.getExpression(astRoot)); - } - - // ***** result set mapping - public String getResultSetMapping() { - return this.resultSetMapping; - } - - public void setResultSetMapping(String resultSetMapping) { - if (this.attributeValueHasNotChanged(this.resultSetMapping, resultSetMapping)) { - return; - } - String old = this.resultSetMapping; - this.resultSetMapping = resultSetMapping; - this.resultSetMappingAdapter.setValue(resultSetMapping); - this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping); - } - - private String buildResultSetMapping(CompilationUnit astRoot) { - return this.resultSetMappingAdapter.getValue(astRoot); - } - - public TextRange getResultSetMappingTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.resultSetMappingDeclarationAdapter, astRoot); - } - - private DeclarationAnnotationElementAdapter<String> buildResultSetMappingAdapter(DeclarationAnnotationAdapter daAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, JPA.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - NamedNativeQueryAnnotation oldQuery = (NamedNativeQueryAnnotation) oldAnnotation; - this.setResultClass(oldQuery.getResultClass()); - this.setResultSetMapping(oldQuery.getResultSetMapping()); - } - - - // ********** static methods ********** - - public static SourceNamedNativeQueryAnnotation createNamedNativeQuery(JavaResourceNode parent, Type type) { - return new SourceNamedNativeQueryAnnotation(parent, type, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER)); - } - - static SourceNamedNativeQueryAnnotation createNestedNamedNativeQuery(JavaResourceNode parent, Type type, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(type, idaa); - return new SourceNamedNativeQueryAnnotation(parent, type, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter namedQueriesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(namedQueriesAdapter, index, JPA.NAMED_NATIVE_QUERY); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java deleted file mode 100644 index 25734c6cc4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.NamedQueries - */ -public final class SourceNamedQueriesAnnotation - extends SourceAnnotation<Type> - implements NamedQueriesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableNamedQueryAnnotation> namedQueries = new Vector<NestableNamedQueryAnnotation>(); - - - public SourceNamedQueriesAnnotation(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.namedQueries); - } - - - // ********** AnnotationContainer implementation ********** - - public String getContainerAnnotationName() { - return this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return JPA.NAMED_QUERIES__VALUE; - } - - public String getNestableAnnotationName() { - return NamedQueryAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestableNamedQueryAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableNamedQueryAnnotation>(this.namedQueries); - } - - public int nestedAnnotationsSize() { - return this.namedQueries.size(); - } - - public NestableNamedQueryAnnotation addNestedAnnotationInternal() { - NestableNamedQueryAnnotation namedQuery = this.buildNamedQuery(this.namedQueries.size()); - this.namedQueries.add(namedQuery); - return namedQuery; - } - - private NestableNamedQueryAnnotation buildNamedQuery(int index) { - return SourceNamedQueryAnnotation.createNestedNamedQuery(this, member, index, this.daa); - } - - public void nestedAnnotationAdded(int index, NestableNamedQueryAnnotation nestedAnnotation) { - this.fireItemAdded(NAMED_QUERIES_LIST, index, nestedAnnotation); - } - - public NestableNamedQueryAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.namedQueries, targetIndex, sourceIndex).get(targetIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(NAMED_QUERIES_LIST, targetIndex, sourceIndex); - } - - public NestableNamedQueryAnnotation removeNestedAnnotationInternal(int index) { - return this.namedQueries.remove(index); - } - - public void nestedAnnotationRemoved(int index, NestableNamedQueryAnnotation nestedAnnotation) { - this.fireItemRemoved(NAMED_QUERIES_LIST, index, nestedAnnotation); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java deleted file mode 100644 index 3408082826..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQuery - */ -public final class SourceNamedQueryAnnotation - extends SourceBaseNamedQueryAnnotation - implements NestableNamedQueryAnnotation -{ - public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceNamedQueryAnnotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, type, daa, annotationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** AbstractBaseNamedQueryAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.NAMED_QUERY__NAME; - } - - @Override - String getQueryElementName() { - return JPA.NAMED_QUERY__QUERY; - } - - @Override - String getHintsElementName() { - return JPA.NAMED_QUERY__HINTS; - } - - @Override - NestableQueryHintAnnotation buildQueryHint(int index) { - return SourceQueryHintAnnotation.createNamedQueryQueryHint(this, this.member, this.daa, index); - } - - - // ********** static methods ********** - - public static SourceNamedQueryAnnotation createNamedQuery(JavaResourceNode parent, Type type) { - return new SourceNamedQueryAnnotation(parent, type, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER)); - } - - static SourceNamedQueryAnnotation createNestedNamedQuery(JavaResourceNode parent, Type type, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(type, idaa); - return new SourceNamedQueryAnnotation(parent, type, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter namedQueriesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(namedQueriesAdapter, index, JPA.NAMED_QUERY); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNode.java deleted file mode 100644 index 354ba9d633..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceNode.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; - -/** - * Source convenience methods - */ -public abstract class SourceNode - extends AbstractJavaResourceNode -{ - - public SourceNode(JavaResourceNode parent) { - super(parent); - } - - public JavaResourceCompilationUnit getJavaResourceCompilationUnit() { - return (JavaResourceCompilationUnit) this.getRoot(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java deleted file mode 100644 index 388c22f842..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OneToManyAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.OneToMany - */ -public final class SourceOneToManyAnnotation - extends SourceRelationshipMappingAnnotation - implements OneToManyAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter<String[]> CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> MAPPED_BY_ADAPTER = buildMappedByAdapter(); - private final AnnotationElementAdapter<String> mappedByAdapter; - private String mappedBy; - - - public SourceOneToManyAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.mappedByAdapter = this.buildAnnotationElementAdapter(MAPPED_BY_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.mappedBy = this.buildMappedBy(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setMappedBy(this.buildMappedBy(astRoot)); - } - - - // ********** SourceRelationshipMappingAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String> getFetchAdapter() { - return FETCH_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String[]> getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - - // ********** OwnableRelationshipMappingAnnotation implementation ********** - - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - if (this.attributeValueHasNotChanged(this.mappedBy, mappedBy)) { - return; - } - String old = this.mappedBy; - this.mappedBy = mappedBy; - this.mappedByAdapter.setValue(mappedBy); - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); - } - - private String buildMappedBy(CompilationUnit astRoot) { - return this.mappedByAdapter.getValue(astRoot); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return getElementTextRange(MAPPED_BY_ADAPTER, astRoot); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(MAPPED_BY_ADAPTER, pos, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter<String> buildMappedByAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__MAPPED_BY, false); // false = do not remove annotation when empty - } - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__FETCH); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__CASCADE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java deleted file mode 100644 index 0beac3af1b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.OneToOneAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.OneToOne - */ -public final class SourceOneToOneAnnotation - extends SourceRelationshipMappingAnnotation - implements OneToOneAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - static final DeclarationAnnotationElementAdapter<String> TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter<String[]> CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter<Boolean> OPTIONAL_ADAPTER = buildOptionalAdapter(); - private final AnnotationElementAdapter<Boolean> optionalAdapter; - private Boolean optional; - - private static final DeclarationAnnotationElementAdapter<String> MAPPED_BY_ADAPTER = buildMappedByAdapter(); - private final AnnotationElementAdapter<String> mappedByAdapter; - private String mappedBy; - - - public SourceOneToOneAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.mappedByAdapter = this.buildAnnotationElementAdapter(MAPPED_BY_ADAPTER); - this.optionalAdapter = this.buildBooleanAnnotationElementAdapter(OPTIONAL_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.mappedBy = this.buildMappedBy(astRoot); - this.optional = this.buildOptional(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setMappedBy(this.buildMappedBy(astRoot)); - this.setOptional(this.buildOptional(astRoot)); - } - - - // ********** SourceRelationshipMappingAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String> getFetchAdapter() { - return FETCH_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String[]> getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - - // ********** OneToOneAnnotation implementation ********** - - // ***** mapped by - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String mappedBy) { - if (this.attributeValueHasNotChanged(this.mappedBy, mappedBy)) { - return; - } - String old = this.mappedBy; - this.mappedBy = mappedBy; - this.mappedByAdapter.setValue(mappedBy); - this.firePropertyChanged(MAPPED_BY_PROPERTY, old, mappedBy); - } - - private String buildMappedBy(CompilationUnit astRoot) { - return this.mappedByAdapter.getValue(astRoot); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(MAPPED_BY_ADAPTER, astRoot); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(MAPPED_BY_ADAPTER, pos, astRoot); - } - - // ***** optional - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean optional) { - if (this.attributeValueHasNotChanged(this.optional, optional)) { - return; - } - Boolean old = this.optional; - this.optional = optional; - this.optionalAdapter.setValue(optional); - this.firePropertyChanged(OPTIONAL_PROPERTY, old, optional); - } - - private Boolean buildOptional(CompilationUnit astRoot) { - return this.optionalAdapter.getValue(astRoot); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(OPTIONAL_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter<String> buildMappedByAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__MAPPED_BY, false); // false = do not remove annotation when empty - } - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__FETCH); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOptionalAdapter() { - return buildOptionalAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__OPTIONAL); - } - - private static DeclarationAnnotationElementAdapter<Boolean> buildOptionalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(annotationAdapter, elementName, false, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__CASCADE); - } - - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java deleted file mode 100644 index 6aeb27ca59..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.OrderByAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.OrderBy - */ -public final class SourceOrderByAnnotation - extends SourceAnnotation<Attribute> - implements OrderByAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private String value; - - - public SourceOrderByAnnotation(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** OrderByAnnotation implementation ********** - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; - } - String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ORDER_BY__VALUE, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java deleted file mode 100644 index 8d0758b647..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.OverrideAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * Common behavior for - * javax.persistence.AttributeOverride - * javax.persistence.AssociationOverride - */ -abstract class SourceOverrideAnnotation - extends SourceAnnotation<Member> - implements OverrideAnnotation -{ - final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - final AnnotationElementAdapter<String> nameAdapter; - String name; - - - // ********** construction/initialization ********** - - SourceOverrideAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.nameDeclarationAdapter = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, this.getNameElementName(), false); // false = do not remove annotation when empty - this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, this.nameDeclarationAdapter); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** OverrideAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; - } - String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(OverrideAnnotation.NAME_PROPERTY, old, name); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); - } - - protected abstract String getNameElementName(); - - - // ********** NestableAnnotation implementation ********** - - void initializeFrom(NestableAnnotation oldAnnotation) { - OverrideAnnotation oldOverride = (OverrideAnnotation) oldAnnotation; - this.setName(oldOverride.getName()); - } - - /** - * convenience implementation of method from NestableAnnotation interface - * for subclasses - */ - public void moveAnnotation(int index) { - this.getIndexedAnnotationAdapter().moveAnnotation(index); - } - - private IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java deleted file mode 100644 index c2d79684ed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java +++ /dev/null @@ -1,388 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Vector; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.IBinding; -import org.eclipse.jdt.core.dom.ITypeBinding; -import org.eclipse.jpt.core.internal.utility.jdt.JDTFieldAttribute; -import org.eclipse.jpt.core.internal.utility.jdt.JDTMethodAttribute; -import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.MethodAttribute; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.MethodSignature; -import org.eclipse.jpt.utility.internal.ClassTools; -import org.eclipse.jpt.utility.internal.iterators.CloneIterator; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * Java source persistent attribute (field or property) - */ -final class SourcePersistentAttribute - extends SourcePersistentMember<Attribute> - implements JavaResourcePersistentAttribute -{ - private int modifiers; - - private String typeName; - - private boolean typeIsInterface; - - private boolean typeIsEnum; - - private final Vector<String> typeSuperclassNames = new Vector<String>(); - - private final Vector<String> typeInterfaceNames = new Vector<String>(); - - private final Vector<String> typeTypeArgumentNames = new Vector<String>(); - - - /** - * construct field attribute - */ - static JavaResourcePersistentAttribute newInstance( - JavaResourcePersistentType parent, - Type declaringType, - String name, - int occurrence, - JavaResourceCompilationUnit javaResourceCompilationUnit, - CompilationUnit astRoot) { - Attribute attribute = new JDTFieldAttribute( - declaringType, - name, - occurrence, - javaResourceCompilationUnit.getCompilationUnit(), - javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(), - javaResourceCompilationUnit.getAnnotationEditFormatter()); - JavaResourcePersistentAttribute jrpa = new SourcePersistentAttribute(parent, attribute); - jrpa.initialize(astRoot); - return jrpa; - } - - /** - * construct property attribute - */ - static JavaResourcePersistentAttribute newInstance( - JavaResourcePersistentType parent, - Type declaringType, - MethodSignature signature, - int occurrence, - JavaResourceCompilationUnit javaResourceCompilationUnit, - CompilationUnit astRoot) { - Attribute attribute = JDTMethodAttribute.newInstance( - declaringType, - signature, - occurrence, - javaResourceCompilationUnit.getCompilationUnit(), - javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(), - javaResourceCompilationUnit.getAnnotationEditFormatter()); - JavaResourcePersistentAttribute jrpa = new SourcePersistentAttribute(parent, attribute); - jrpa.initialize(astRoot); - return jrpa; - } - - private SourcePersistentAttribute(JavaResourcePersistentType parent, Attribute attribute){ - super(parent, attribute); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.modifiers = this.buildModifiers(astRoot); - this.typeName = this.buildTypeName(astRoot); - this.typeIsInterface = this.buildTypeIsInterface(astRoot); - this.typeIsEnum = this.buildTypeIsEnum(astRoot); - this.typeSuperclassNames.addAll(this.buildTypeSuperclassNames(astRoot)); - this.typeInterfaceNames.addAll(this.buildTypeInterfaceNames(astRoot)); - this.typeTypeArgumentNames.addAll(this.buildTypeTypeArgumentNames(astRoot)); - } - - - // ******** overrides ******** - - @Override - public void resolveTypes(CompilationUnit astRoot) { - super.resolveTypes(astRoot); - this.setTypeName(this.buildTypeName(astRoot)); - this.setTypeSuperclassNames(this.buildTypeSuperclassNames(astRoot)); - this.setTypeInterfaceNames(this.buildTypeInterfaceNames(astRoot)); - this.setTypeTypeArgumentNames(this.buildTypeTypeArgumentNames(astRoot)); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setModifiers(this.buildModifiers(astRoot)); - this.setTypeName(this.buildTypeName(astRoot)); - this.setTypeIsInterface(this.buildTypeIsInterface(astRoot)); - this.setTypeIsEnum(this.buildTypeIsEnum(astRoot)); - this.setTypeSuperclassNames(this.buildTypeSuperclassNames(astRoot)); - this.setTypeInterfaceNames(this.buildTypeInterfaceNames(astRoot)); - this.setTypeTypeArgumentNames(this.buildTypeTypeArgumentNames(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getName()); - } - - - // ******** AbstractJavaResourcePersistentMember implementation ******** - - @Override - Iterator<String> validAnnotationNames() { - return this.getAnnotationProvider().attributeAnnotationNames(); - } - - @Override - Annotation buildAnnotation(String annotationName) { - return this.getAnnotationProvider(). - buildAttributeAnnotation(this, this.member, annotationName); - } - - Annotation buildNullAnnotation_(String annotationName) { - return this.getAnnotationProvider(). - buildNullAttributeAnnotation(this, annotationName); - } - - public boolean isFor(MethodSignature signature, int occurrence) { - return ((MethodAttribute) this.member).matches(signature, occurrence); - } - - - // ******** JavaResourcePersistentAttribute implementation ******** - - public String getName() { - return this.member.getAttributeName(); - } - - @Override - public Annotation buildNullAnnotation(String annotationName) { - return (annotationName == null) ? null : this.buildNullAnnotation_(annotationName); - } - - public boolean isField() { - return this.member.isField(); - } - - public boolean isProperty() { - return ! this.isField(); - } - - public AccessType getSpecifiedAccess() { - Access2_0Annotation accessAnnotation = - (Access2_0Annotation) getAnnotation(Access2_0Annotation.ANNOTATION_NAME); - return (accessAnnotation == null) ? null : accessAnnotation.getValue(); - } - - public boolean typeIsSubTypeOf(String tn) { - if (this.typeName == null) { - return false; - } - return this.typeName.equals(tn) - || this.typeInterfaceNames.contains(tn) - || this.typeSuperclassNames.contains(tn); - } - - public boolean typeIsVariablePrimitive() { - return (this.typeName != null) && ClassTools.classNamedIsVariablePrimitive(this.typeName); - } - - private ITypeBinding getTypeBinding(CompilationUnit astRoot) { - return this.member.getTypeBinding(astRoot); - } - - - // ***** modifiers - public int getModifiers() { - return this.modifiers; - } - - private void setModifiers(int modifiers) { - int old = this.modifiers; - this.modifiers = modifiers; - this.firePropertyChanged(MODIFIERS_PROPERTY, old, modifiers); - } - - /** - * zero seems like a reasonable default... - */ - private int buildModifiers(CompilationUnit astRoot) { - IBinding binding = this.member.getBinding(astRoot); - return (binding == null) ? 0 : binding.getModifiers(); - } - - // ***** type name - public String getTypeName() { - return this.typeName; - } - - private void setTypeName(String typeName) { - String old = this.typeName; - this.typeName = typeName; - this.firePropertyChanged(TYPE_NAME_PROPERTY, old, typeName); - } - - /** - * this can be an array (e.g. "java.lang.String[]"); - * but no generic type arguments - */ - private String buildTypeName(CompilationUnit astRoot) { - ITypeBinding typeBinding = this.getTypeBinding(astRoot); - return (typeBinding == null) ? null : typeBinding.getTypeDeclaration().getQualifiedName(); - } - - // ***** type is interface - public boolean typeIsInterface() { - return this.typeIsInterface; - } - - private void setTypeIsInterface(boolean typeIsInterface) { - boolean old = this.typeIsInterface; - this.typeIsInterface = typeIsInterface; - this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, typeIsInterface); - } - - private boolean buildTypeIsInterface(CompilationUnit astRoot) { - ITypeBinding typeBinding = this.getTypeBinding(astRoot); - return (typeBinding != null) && ( ! typeBinding.isArray()) && typeBinding.isInterface(); - } - - // ***** type is enum - public boolean typeIsEnum() { - return this.typeIsEnum; - } - - private void setTypeIsEnum(boolean typeIsEnum) { - boolean old = this.typeIsEnum; - this.typeIsEnum = typeIsEnum; - this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, typeIsEnum); - } - - private boolean buildTypeIsEnum(CompilationUnit astRoot) { - ITypeBinding typeBinding = this.getTypeBinding(astRoot); - return (typeBinding != null) && ( ! typeBinding.isArray()) && typeBinding.isEnum(); - } - - // ***** type superclass hierarchy - public ListIterator<String> typeSuperclassNames() { - return new CloneListIterator<String>(this.typeSuperclassNames); - } - - private void setTypeSuperclassNames(List<String> typeSuperclassNames) { - this.synchronizeList(typeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_LIST); - } - - private List<String> buildTypeSuperclassNames(CompilationUnit astRoot) { - ITypeBinding typeBinding = this.getTypeBinding(astRoot); - if (typeBinding == null) { - return Collections.emptyList(); - } - ArrayList<String> names = new ArrayList<String>(); - typeBinding = typeBinding.getSuperclass(); - while (typeBinding != null) { - names.add(typeBinding.getQualifiedName()); - typeBinding = typeBinding.getSuperclass(); - } - return names; - } - - // ***** type interface hierarchy - public Iterator<String> typeInterfaceNames() { - return new CloneIterator<String>(this.typeInterfaceNames); - } - -// private boolean typeInterfaceNamesContains(String interfaceName) { -// return this.typeInterfaceNames.contains(interfaceName); -// } -// - private void setTypeInterfaceNames(Collection<String> typeInterfaceNames) { - this.synchronizeCollection(typeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION); - } - - private Collection<String> buildTypeInterfaceNames(CompilationUnit astRoot) { - ITypeBinding typeBinding = this.getTypeBinding(astRoot); - if (typeBinding == null) { - return Collections.emptySet(); - } - HashSet<String> names = new HashSet<String>(); - while (typeBinding != null) { - this.addInterfaceNamesTo(typeBinding, names); - typeBinding = typeBinding.getSuperclass(); - } - return names; - } - - private void addInterfaceNamesTo(ITypeBinding typeBinding, HashSet<String> names) { - for (ITypeBinding interfaceBinding : typeBinding.getInterfaces()) { - names.add(interfaceBinding.getQualifiedName()); - this.addInterfaceNamesTo(interfaceBinding, names); // recurse - } - } - - // ***** type type argument names - public ListIterator<String> typeTypeArgumentNames() { - return new CloneListIterator<String>(this.typeTypeArgumentNames); - } - - public int typeTypeArgumentNamesSize() { - return this.typeTypeArgumentNames.size(); - } - - public String getTypeTypeArgumentName(int index) { - return this.typeTypeArgumentNames.get(index); - } - - private void setTypeTypeArgumentNames(List<String> typeTypeArgumentNames) { - this.synchronizeList(typeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_LIST); - } - - /** - * these types can be arrays (e.g. "java.lang.String[]"); - * but they won't have any further nested generic type arguments - * (e.g. "java.util.Collection<java.lang.String>") - */ - private List<String> buildTypeTypeArgumentNames(CompilationUnit astRoot) { - ITypeBinding typeBinding = this.getTypeBinding(astRoot); - if (typeBinding == null) { - return Collections.emptyList(); - } - - ITypeBinding[] typeArguments = typeBinding.getTypeArguments(); - if (typeArguments.length == 0) { - return Collections.emptyList(); - } - - ArrayList<String> names = new ArrayList<String>(typeArguments.length); - for (ITypeBinding typeArgument : typeArguments) { - if (typeArgument == null) { - names.add(null); - } else { - names.add(typeArgument.getTypeDeclaration().getQualifiedName()); - } - } - return names; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java deleted file mode 100644 index a0ea958697..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java +++ /dev/null @@ -1,549 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.ASTVisitor; -import org.eclipse.jdt.core.dom.BodyDeclaration; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.MarkerAnnotation; -import org.eclipse.jdt.core.dom.NormalAnnotation; -import org.eclipse.jdt.core.dom.SingleMemberAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.ASTNodeTextRange; -import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.ArrayTools; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator; - -/** - * Java source persistent member (annotations, "persistable") - */ -abstract class SourcePersistentMember<E extends Member> - extends SourceNode - implements JavaResourcePersistentMember -{ - final E member; - - /** - * annotations; no duplicates (java compiler has an error for duplicates) - */ - final Vector<Annotation> annotations = new Vector<Annotation>(); - - boolean persistable; - - - // ********** construction/initialization ********** - - SourcePersistentMember(JavaResourceNode parent, E member) { - super(parent); - this.member = member; - } - - public void initialize(CompilationUnit astRoot) { - this.member.getBodyDeclaration(astRoot).accept(this.buildInitialAnnotationVisitor(astRoot)); - this.persistable = this.buildPersistable(astRoot); - } - - private ASTVisitor buildInitialAnnotationVisitor(CompilationUnit astRoot) { - return new InitialAnnotationVisitor(astRoot, this.member.getBodyDeclaration(astRoot)); - } - - /** - * called from InitialAnnotationVisitor - */ - void addInitialAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot) { - String jdtAnnotationName = JDTTools.resolveAnnotation(node); - if (jdtAnnotationName == null) { - return; - } - if (this.annotationIsValid(jdtAnnotationName)) { - if (this.selectAnnotationNamed(this.annotations, jdtAnnotationName) == null) { // ignore duplicates - Annotation annotation = this.buildAnnotation(jdtAnnotationName); - annotation.initialize(astRoot); - this.annotations.add(annotation); - } - } - } - - - // ********** annotations ********** - - public Iterator<Annotation> annotations() { - return this.getAnnotations().iterator(); - } - - private Iterable<Annotation> getAnnotations() { - return new LiveCloneIterable<Annotation>(this.annotations); - } - - public int annotationsSize() { - return this.annotations.size(); - } - - public Annotation getAnnotation(String annotationName) { - return this.selectAnnotationNamed(this.getAnnotations(), annotationName); - } - - public Annotation getNonNullAnnotation(String annotationName) { - Annotation annotation = this.getAnnotation(annotationName); - return (annotation != null) ? annotation : this.buildNullAnnotation(annotationName); - } - - public Iterator<NestableAnnotation> annotations( - String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = - this.getContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - return containerAnnotation.nestedAnnotations(); - } - NestableAnnotation nestableAnnotation = - getNestableAnnotation(nestableAnnotationName); - if (nestableAnnotation != null) { - return new SingleElementIterator<NestableAnnotation>(nestableAnnotation); - } - return EmptyIterator.instance(); - } - - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - private ContainerAnnotation<NestableAnnotation> getContainerAnnotation(String annotationName) { - return (ContainerAnnotation<NestableAnnotation>) getAnnotation(annotationName); - } - - private NestableAnnotation getNestableAnnotation(String annotationName) { - return (NestableAnnotation) this.getAnnotation(annotationName); - } - - public Annotation addAnnotation(String annotationName) { - Annotation annotation = this.buildAnnotation(annotationName); - this.annotations.add(annotation); - annotation.newAnnotation(); - this.fireItemAdded(ANNOTATIONS_COLLECTION, annotation); - return annotation; - } - - public Annotation addAnnotation(String annotationName, AnnotationInitializer annotationInitializer) { - Annotation annotation = this.buildAnnotation(annotationName); - this.annotations.add(annotation); - annotation.newAnnotation(); - Annotation nestedAnnotation = annotationInitializer.initializeAnnotation(annotation); - nestedAnnotation.newAnnotation(); - this.fireItemAdded(ANNOTATIONS_COLLECTION, annotation); - return nestedAnnotation; - } - - /** - * 1. check for a container annotation; - * if it is present, add a nested annotation to it - * 2. check for a stand-alone nested annotation; - * if it is missing, add a stand-alone nested annotation - * 3. if there is an existing stand-alone nested annotation, - * add a container annotation and move the stand-alone nested annotation to it - * and add a new nested annotation to it also - */ - public NestableAnnotation addAnnotation( - int index, String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = - getContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - // ignore any stand-alone nestable annotations and just add to the container annotation - return AnnotationContainerTools.addNestedAnnotation(index, containerAnnotation); - } - NestableAnnotation standAloneAnnotation = - getNestableAnnotation(nestableAnnotationName); - if (standAloneAnnotation == null) { - // add a stand-alone nestable annotation since neither the nestable nor the container exist - return (NestableAnnotation) this.addAnnotation(nestableAnnotationName); - } - // move the stand-alone nestable annotation to a container and add another nestable - return this.addSecondNestedAnnotation(index, containerAnnotationName, standAloneAnnotation); - } - - /** - * "move" the existing nestable annotation to a new container annotation and - * add a new nestable annotation at the specified index (which should be 0 or 1) - * - * NB: we make all the necessary changes to the resource model and the - * Java source code *before* we fire any events; so that everything is in - * place when the context model gets an "update" and looks at the resource - * model to determine what has changed - */ - private NestableAnnotation addSecondNestedAnnotation( - int index, String containerAnnotationName, NestableAnnotation standAloneAnnotation) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = - buildContainerAnnotation(containerAnnotationName); - this.annotations.add(containerAnnotation); - containerAnnotation.newAnnotation(); - - NestableAnnotation nestedAnnotation0 = containerAnnotation.addNestedAnnotationInternal(); - nestedAnnotation0.newAnnotation(); - NestableAnnotation nestedAnnotation1 = containerAnnotation.addNestedAnnotationInternal(); - nestedAnnotation1.newAnnotation(); - this.removeAnnotation(standAloneAnnotation); - this.fireItemAdded(ANNOTATIONS_COLLECTION, containerAnnotation); - - if (index == 0) { - // adding new annotation at 0, so stand-alone is "copied" to slot 1 - nestedAnnotation1.initializeFrom(standAloneAnnotation); - } else { - // adding new annotation at 1, so stand-alone is "copied" to slot 0 - nestedAnnotation0.initializeFrom(standAloneAnnotation); - } - - return (index == 0) ? nestedAnnotation0 : nestedAnnotation1; - } - - public void moveAnnotation( - int targetIndex, int sourceIndex, String containerAnnotationName) { - moveAnnotation(targetIndex, sourceIndex, getContainerAnnotation(containerAnnotationName)); - } - - private void moveAnnotation( - int targetIndex, int sourceIndex, - ContainerAnnotation<NestableAnnotation> containerAnnotation) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, containerAnnotation); - } - - public void removeAnnotation(String annotationName) { - Annotation annotation = getAnnotation(annotationName); - if (annotation != null) { - this.removeAnnotation(annotation); - } - } - - private void removeAnnotation(Annotation annotation) { - this.annotations.remove(annotation); - annotation.removeAnnotation(); - this.fireItemRemoved(ANNOTATIONS_COLLECTION, annotation); - } - - public void removeAnnotation( - int index, String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation<NestableAnnotation> containerAnnotation = - getContainerAnnotation(containerAnnotationName); - if (containerAnnotation == null) { // assume the index is 0 - removeAnnotation(getAnnotation(nestableAnnotationName)); - } - else { - removeAnnotation(index, containerAnnotation); - } - } - - /** - * after we remove the nested annotation, check to see whether we need to - * either remove the container (if it is empty) or convert the last nested - * annotation to a stand-alone annotation - */ - private void removeAnnotation( - int index, ContainerAnnotation<NestableAnnotation> containerAnnotation) { - AnnotationContainerTools.removeNestedAnnotation(index, containerAnnotation); - switch (containerAnnotation.nestedAnnotationsSize()) { - case 0: - this.removeAnnotation(containerAnnotation); - break; - case 1: - this.convertLastNestedAnnotation(containerAnnotation); - break; - default: - break; - } - } - - /** - * convert the last nested annotation in the container to a stand-alone - * annotation - * - * NB: we make all the necessary changes to the resource model and the - * Java source code *before* we fire any events; so that everything is in - * place when the context model gets an "update" and looks at the resource - * model to determine what has changed - */ - private void convertLastNestedAnnotation( - ContainerAnnotation<NestableAnnotation> containerAnnotation) { - NestableAnnotation lastNestedAnnotation = containerAnnotation.nestedAnnotations().next(); - annotations.remove(containerAnnotation); - containerAnnotation.removeAnnotation(); - - NestableAnnotation standAloneAnnotation = - buildNestableAnnotation(lastNestedAnnotation.getAnnotationName()); - this.annotations.add(standAloneAnnotation); - standAloneAnnotation.newAnnotation(); - this.fireItemRemoved(ANNOTATIONS_COLLECTION, containerAnnotation); - this.fireItemAdded(ANNOTATIONS_COLLECTION, standAloneAnnotation); - standAloneAnnotation.initializeFrom(lastNestedAnnotation); - } - - public Annotation setPrimaryAnnotation( - String primaryAnnotationName, String[] supportingAnnotationNames) { - Annotation newPrimaryAnnotation = null; - String[] annotationNamesToKeep = supportingAnnotationNames; - if (primaryAnnotationName != null) { - annotationNamesToKeep = ArrayTools.add(supportingAnnotationNames, primaryAnnotationName); - } - for (Annotation existingAnnotation : getAnnotations()) { - if (! ArrayTools.contains(annotationNamesToKeep, existingAnnotation.getAnnotationName())) { - this.annotations.remove(existingAnnotation); - existingAnnotation.removeAnnotation(); - } - } - if (primaryAnnotationName != null && getAnnotation(primaryAnnotationName) == null) { - newPrimaryAnnotation = buildAnnotation(primaryAnnotationName); - this.annotations.add(newPrimaryAnnotation); - newPrimaryAnnotation.newAnnotation(); - } - // fire collection change event after all annotation changes are done - fireCollectionChanged(ANNOTATIONS_COLLECTION, Collections.unmodifiableCollection(this.annotations)); - return newPrimaryAnnotation; - } - - private boolean annotationIsValid(String annotationName) { - return CollectionTools.contains(this.validAnnotationNames(), annotationName); - } - - abstract Iterator<String> validAnnotationNames(); - - abstract Annotation buildAnnotation(String mappingAnnotationName); - - abstract Annotation buildNullAnnotation(String annotationName); - - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - private ContainerAnnotation<NestableAnnotation> buildContainerAnnotation(String annotationName) { - return (ContainerAnnotation<NestableAnnotation>) buildAnnotation(annotationName); - } - - @SuppressWarnings("unchecked") - private NestableAnnotation buildNestableAnnotation(String annotationName) { - return (NestableAnnotation) buildAnnotation(annotationName); - } - - - // ********** simple state ********** - - public boolean isPersistable() { - return this.persistable; - } - - private void setPersistable(boolean persistable) { - boolean old = this.persistable; - this.persistable = persistable; - this.firePropertyChanged(PERSISTABLE_PROPERTY, old, persistable); - } - - private boolean buildPersistable(CompilationUnit astRoot) { - return this.member.isPersistable(astRoot); - } - - public boolean isAnnotated() { - return ! this.annotations.isEmpty(); - } - - public boolean isFor(String memberName, int occurrence) { - return this.member.matches(memberName, occurrence); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return this.fullTextRange(astRoot); - } - - private TextRange fullTextRange(CompilationUnit astRoot) { - return this.buildTextRange(this.member.getBodyDeclaration(astRoot)); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.member.getNameTextRange(astRoot); - } - - - // ********** update ********** - - public void update(CompilationUnit astRoot) { - this.updateAnnotations(astRoot); - this.setPersistable(this.buildPersistable(astRoot)); - } - - private void updateAnnotations(CompilationUnit astRoot) { - HashSet<Annotation> annotationsToRemove = - new HashSet<Annotation>(this.annotations); - - this.member.getBodyDeclaration(astRoot).accept( - this.buildUpdateAnnotationVisitor(astRoot, annotationsToRemove)); - - for (Annotation annotation : annotationsToRemove) { - this.removeItemFromCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION); - } - } - - private ASTVisitor buildUpdateAnnotationVisitor( - CompilationUnit astRoot, Set<Annotation> annotationsToRemove) { - return new UpdateAnnotationVisitor( - astRoot, this.member.getBodyDeclaration(astRoot), annotationsToRemove); - } - - void addOrUpdateAnnotation( - org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot, - Set<Annotation> annotationsToRemove) { - String jdtAnnotationName = JDTTools.resolveAnnotation(node); - if (jdtAnnotationName == null) { - return; - } - if (this.annotationIsValid(jdtAnnotationName)) { - this.addOrUpdateAnnotation(jdtAnnotationName, astRoot, annotationsToRemove); - return; - } - } - - private void addOrUpdateAnnotation( - String jdtAnnotationName, CompilationUnit astRoot, - Set<Annotation> annotationsToRemove) { - Annotation annotation = this.selectAnnotationNamed(annotationsToRemove, jdtAnnotationName); - if (annotation != null) { - annotation.update(astRoot); - annotationsToRemove.remove(annotation); - } - else { - annotation = this.buildAnnotation(jdtAnnotationName); - annotation.initialize(astRoot); - this.addItemToCollection(annotation, this.annotations, ANNOTATIONS_COLLECTION); - } - } - - - // ********** miscellaneous ********** - - public void resolveTypes(CompilationUnit astRoot) { - this.setPersistable(this.buildPersistable(astRoot)); - } - - private Annotation selectAnnotationNamed(Iterable<Annotation> annotations, String annotationName) { - for (Annotation annotation : annotations) { - if (annotation.getAnnotationName().equals(annotationName)) { - return annotation; - } - } - return null; - } - - private TextRange buildTextRange(ASTNode astNode) { - return (astNode == null) ? null : new ASTNodeTextRange(astNode); - } - - /** - * convenience method - */ - <T extends JavaResourcePersistentMember> Iterator<T> persistableMembers(Iterator<T> members) { - return new FilteringIterator<T, T>(members) { - @Override - protected boolean accept(T m) { - return m.isPersistable(); - } - }; - } - - - // ********** AST visitors ********** - - /** - * annotation visitor - */ - protected static abstract class AnnotationVisitor - extends ASTVisitor - { - protected final CompilationUnit astRoot; - protected final BodyDeclaration bodyDeclaration; - - protected AnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration) { - super(); - this.astRoot = astRoot; - this.bodyDeclaration = bodyDeclaration; - } - - @Override - public boolean visit(SingleMemberAnnotation node) { - return visit_(node); - } - - @Override - public boolean visit(NormalAnnotation node) { - return visit_(node); - } - - @Override - public boolean visit(MarkerAnnotation node) { - return visit_(node); - } - - protected boolean visit_(org.eclipse.jdt.core.dom.Annotation node) { - // ignore annotations for child members, only this member - if (node.getParent() == this.bodyDeclaration) { - this.visitChildAnnotation(node); - } - return false; - } - - protected abstract void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node); - } - - - /** - * initial annotation visitor - */ - protected class InitialAnnotationVisitor - extends AnnotationVisitor - { - protected InitialAnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration) { - super(astRoot, bodyDeclaration); - } - - @Override - protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) { - SourcePersistentMember.this.addInitialAnnotation(node, this.astRoot); - } - } - - - /** - * update annotation visitor - */ - protected class UpdateAnnotationVisitor - extends AnnotationVisitor - { - protected final Set<Annotation> annotationsToRemove; - - protected UpdateAnnotationVisitor( - CompilationUnit astRoot, BodyDeclaration bodyDeclaration, - Set<Annotation> annotationsToRemove) { - super(astRoot, bodyDeclaration); - this.annotationsToRemove = annotationsToRemove; - } - - @Override - protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) { - SourcePersistentMember.this.addOrUpdateAnnotation( - node, this.astRoot, this.annotationsToRemove); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java deleted file mode 100644 index 67c306b809..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java +++ /dev/null @@ -1,606 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.FieldDeclaration; -import org.eclipse.jdt.core.dom.ITypeBinding; -import org.eclipse.jdt.core.dom.MethodDeclaration; -import org.eclipse.jdt.core.dom.Modifier; -import org.eclipse.jdt.core.dom.TypeDeclaration; -import org.eclipse.jdt.core.dom.VariableDeclarationFragment; -import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.JDTType; -import org.eclipse.jpt.core.internal.utility.jdt.JPTTools; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.MethodSignature; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.Counter; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.utility.internal.iterators.TreeIterator; - -/** - * Java source persistent type - */ -final class SourcePersistentType - extends SourcePersistentMember<Type> - implements JavaResourcePersistentType -{ - private String name; - - private String qualifiedName; - - private String superclassQualifiedName; - - private boolean abstract_; // 'abstract' is a reserved word - - private final Vector<JavaResourcePersistentType> types; - - private final Vector<JavaResourcePersistentAttribute> fields; - - private final Vector<JavaResourcePersistentAttribute> methods; - - private AccessType access; - - - // ********** construction/initialization ********** - - /** - * build top-level persistent type - */ - static JavaResourcePersistentType newInstance( - JavaResourceCompilationUnit javaResourceCompilationUnit, - TypeDeclaration typeDeclaration, - CompilationUnit astRoot) { - Type type = new JDTType( - typeDeclaration, - javaResourceCompilationUnit.getCompilationUnit(), - javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(), - javaResourceCompilationUnit.getAnnotationEditFormatter()); - JavaResourcePersistentType jrpt = new SourcePersistentType(javaResourceCompilationUnit, type); - jrpt.initialize(astRoot); - return jrpt; - } - - /** - * build nested persistent type - */ - private static JavaResourcePersistentType newInstance( - JavaResourceCompilationUnit javaResourceCompilationUnit, - Type declaringType, - TypeDeclaration typeDeclaration, - int occurrence, - CompilationUnit astRoot) { - Type type = new JDTType( - declaringType, - typeDeclaration, - occurrence, - javaResourceCompilationUnit.getCompilationUnit(), - javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(), - javaResourceCompilationUnit.getAnnotationEditFormatter()); - JavaResourcePersistentType jrpt = new SourcePersistentType(javaResourceCompilationUnit, type); - jrpt.initialize(astRoot); - return jrpt; - } - - private SourcePersistentType(JavaResourceCompilationUnit javaResourceCompilationUnit, Type type) { - super(javaResourceCompilationUnit, type); - this.types = new Vector<JavaResourcePersistentType>(); - this.fields = new Vector<JavaResourcePersistentAttribute>(); - this.methods = new Vector<JavaResourcePersistentAttribute>(); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.name = this.buildName(astRoot); - this.qualifiedName = this.buildQualifiedName(astRoot); - this.superclassQualifiedName = this.buildSuperclassQualifiedName(astRoot); - this.abstract_ = this.buildAbstract(astRoot); - this.initializeTypes(astRoot); - this.initializeFields(astRoot); - this.initializeMethods(astRoot); - // need to wait until everything is built to calculate 'access' - this.access = this.buildAccess(); - } - - private void initializeTypes(CompilationUnit astRoot) { - TypeDeclaration[] typeDeclarations = this.member.getTypes(astRoot); - CounterMap counters = new CounterMap(typeDeclarations.length); - for (TypeDeclaration td : typeDeclarations) { - String tdName = td.getName().getFullyQualifiedName(); - int occurrence = counters.increment(tdName); - this.types.add(this.buildType(td, occurrence, astRoot)); - } - } - - private void initializeFields(CompilationUnit astRoot) { - FieldDeclaration[] fieldDeclarations = this.member.getFields(astRoot); - CounterMap counters = new CounterMap(fieldDeclarations.length); - for (FieldDeclaration fieldDeclaration : fieldDeclarations) { - for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) { - String fieldName = fragment.getName().getFullyQualifiedName(); - int occurrence = counters.increment(fieldName); - this.fields.add(this.buildField(fieldName, occurrence, astRoot)); - } - } - } - - private void initializeMethods(CompilationUnit astRoot) { - MethodDeclaration[] methodDeclarations = this.member.getMethods(astRoot); - CounterMap counters = new CounterMap(methodDeclarations.length); - for (MethodDeclaration methodDeclaration : methodDeclarations) { - MethodSignature signature = JDTTools.buildMethodSignature(methodDeclaration); - int occurrence = counters.increment(signature); - this.methods.add(this.buildMethod(signature, occurrence, astRoot)); - } - } - - - // ********** AbstractJavaResourcePersistentMember implementation ********** - - @Override - Iterator<String> validAnnotationNames() { - return this.getAnnotationProvider().typeAnnotationNames(); - } - - @Override - Annotation buildAnnotation(String mappingAnnotationName) { - return this.getAnnotationProvider(). - buildTypeAnnotation(this, this.member, mappingAnnotationName); - } - - @Override - Annotation buildNullAnnotation(String annotationName) { - return this.getAnnotationProvider(). - buildNullTypeAnnotation(this, annotationName); - } - - @Override - public void resolveTypes(CompilationUnit astRoot) { - super.resolveTypes(astRoot); - - this.setSuperclassQualifiedName(this.buildSuperclassQualifiedName(astRoot)); - - for (JavaResourcePersistentAttribute field : this.getFields()) { - field.resolveTypes(astRoot); - } - - // a new type can trigger a method parameter type to be a resolved, - // fully-qualified name, so we need to rebuild our list of methods: - // "setFoo(Foo)" is not the same as "setFoo(com.bar.Foo)" - // and, vice-versa, a removed type can "unresolve" a parameter type - this.updateMethods(astRoot); - - for (JavaResourcePersistentAttribute method : this.getMethods()) { - method.resolveTypes(astRoot); - } - for (JavaResourcePersistentType type : this.getTypes()) { - type.resolveTypes(astRoot); - } - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ******** JavaResourcePersistentType implementation ******** - - // ***** name - public String getName() { - return this.name; - } - - private void setName(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName(CompilationUnit astRoot) { - ITypeBinding binding = this.member.getBinding(astRoot); - return (binding == null) ? null : binding.getName(); - } - - // ***** qualified name - public String getQualifiedName() { - return this.qualifiedName; - } - - private void setQualifiedName(String qualifiedName) { - String old = this.qualifiedName; - this.qualifiedName = qualifiedName; - this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, qualifiedName); - } - - private String buildQualifiedName(CompilationUnit astRoot) { - ITypeBinding binding = this.member.getBinding(astRoot); - return (binding == null) ? null : binding.getQualifiedName(); - } - - // ***** superclass qualified name - public String getSuperclassQualifiedName() { - return this.superclassQualifiedName; - } - - private void setSuperclassQualifiedName(String superclassQualifiedName) { - String old = this.superclassQualifiedName; - this.superclassQualifiedName = superclassQualifiedName; - this.firePropertyChanged(SUPERCLASS_QUALIFIED_NAME_PROPERTY, old, superclassQualifiedName); - } - - private String buildSuperclassQualifiedName(CompilationUnit astRoot) { - ITypeBinding binding = this.member.getBinding(astRoot); - if (binding == null) { - return null; - } - ITypeBinding superclass = binding.getSuperclass(); - return (superclass == null) ? null : superclass.getTypeDeclaration().getQualifiedName(); - } - - // ***** abstract - public boolean isAbstract() { - return this.abstract_; - } - - private void setAbstract(boolean abstract_) { - boolean old = this.abstract_; - this.abstract_ = abstract_; - this.firePropertyChanged(ABSTRACT_PROPERTY, old, abstract_); - } - - private boolean buildAbstract(CompilationUnit astRoot) { - ITypeBinding binding = this.member.getBinding(astRoot); - return (binding == null) ? false : Modifier.isAbstract(binding.getModifiers()); - } - - // ***** access - public AccessType getAccess() { - return this.access; - } - - // TODO - //seems we could have a public changeAccess() api which would - //move all annotations from fields to their corresponding methods or vice versa - //though of course it's more complicated than that since what if the - //corresponding field/method does not exist? - //making this internal since it should only be set based on changes in the source, the - //context model should not need to set this - private void setAccess(AccessType access) { - AccessType old = this.access; - this.access = access; - this.firePropertyChanged(ACCESS_PROPERTY, old, access); - } - - private AccessType buildAccess() { - return JPTTools.buildAccess(this); - } - - public boolean isMapped() { - for (Annotation each : CollectionTools.iterable(annotations())) { - if (CollectionTools.contains( - getAnnotationProvider().typeMappingAnnotationNames(), - each.getAnnotationName())) { - return true; - } - } - return false; - } - - /** - * check only persistable attributes - */ - public boolean hasAnyAnnotatedAttributes() { - for (Iterator<JavaResourcePersistentAttribute> stream = - this.persistableAttributes(); stream.hasNext(); ) { - if (stream.next().isAnnotated()) { - return true; - } - } - return false; - } - - - // ********** types ********** - - public Iterator<JavaResourcePersistentType> types() { - return this.getTypes().iterator(); - } - - private Iterable<JavaResourcePersistentType> getTypes() { - return new LiveCloneIterable<JavaResourcePersistentType>(this.types); // read-only - } - - public Iterator<JavaResourcePersistentType> allTypes() { - return new TreeIterator<JavaResourcePersistentType>(this) { - @Override - protected Iterator<? extends JavaResourcePersistentType> children(JavaResourcePersistentType type) { - return type.types(); - } - }; - } - - public Iterator<JavaResourcePersistentType> persistableTypes() { - return this.persistableMembers(this.types()); - } - - private JavaResourcePersistentType getType(String typeName, int occurrence) { - for (JavaResourcePersistentType type : this.getTypes()) { - if (type.isFor(typeName, occurrence)) { - return type; - } - } - return null; - } - - private void addType(JavaResourcePersistentType type) { - this.addItemToCollection(type, this.types, TYPES_COLLECTION); - } - - private void removeTypes(Collection<JavaResourcePersistentType> remove) { - this.removeItemsFromCollection(remove, this.types, TYPES_COLLECTION); - } - - - // ********** fields ********** - - public Iterator<JavaResourcePersistentAttribute> fields() { - return this.getFields().iterator(); - } - - private Iterable<JavaResourcePersistentAttribute> getFields() { - return new LiveCloneIterable<JavaResourcePersistentAttribute>(this.fields); - } - - public Iterator<JavaResourcePersistentAttribute> persistableFields() { - return this.persistableMembers(this.fields()); - } - - public Iterator<JavaResourcePersistentAttribute> persistableFieldsWithSpecifiedFieldAccess() { - return new FilteringIterator<JavaResourcePersistentAttribute, JavaResourcePersistentAttribute>(this.persistableFields()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.FIELD; - } - }; - } - - private void addField(JavaResourcePersistentAttribute field) { - this.addItemToCollection(field, this.fields, FIELDS_COLLECTION); - } - - private JavaResourcePersistentAttribute getField(String fieldName, int occurrence) { - for (JavaResourcePersistentAttribute field : this.getFields()) { - if (field.isFor(fieldName, occurrence)) { - return field; - } - } - return null; - } - - private void removeFields(Collection<JavaResourcePersistentAttribute> remove) { - this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION); - } - - - // ********** methods ********** - - public Iterator<JavaResourcePersistentAttribute> methods() { - return this.getMethods().iterator(); - } - - private Iterable<JavaResourcePersistentAttribute> getMethods() { - return new LiveCloneIterable<JavaResourcePersistentAttribute>(this.methods); - } - - public Iterator<JavaResourcePersistentAttribute> persistableProperties() { - return this.persistableMembers(this.methods()); - } - - public Iterator<JavaResourcePersistentAttribute> persistablePropertiesWithSpecifiedPropertyAccess() { - return new FilteringIterator<JavaResourcePersistentAttribute, JavaResourcePersistentAttribute>(this.persistableProperties()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.PROPERTY; - } - }; - } - - private JavaResourcePersistentAttribute getMethod(MethodSignature signature, int occurrence) { - for (JavaResourcePersistentAttribute method : this.getMethods()) { - if (method.isFor(signature, occurrence)) { - return method; - } - } - return null; - } - - private void addMethod(JavaResourcePersistentAttribute method) { - this.addItemToCollection(method, this.methods, METHODS_COLLECTION); - } - - private void removeMethods(Collection<JavaResourcePersistentAttribute> remove) { - this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION); - } - - - // ********** attributes ********** - - @SuppressWarnings("unchecked") - public Iterator<JavaResourcePersistentAttribute> persistableAttributes() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableFields(), - this.persistableProperties() - ); - } - - public Iterator<JavaResourcePersistentAttribute> persistableAttributes(AccessType specifiedAccess) { - if (specifiedAccess == null) { - throw new IllegalArgumentException("specified access is null"); //$NON-NLS-1$ - } - return (specifiedAccess == AccessType.FIELD) ? - this.persistableAttributesForFieldAccessType() : - this.persistableAttributesForPropertyAccessType(); - } - - @SuppressWarnings("unchecked") - private Iterator<JavaResourcePersistentAttribute> persistableAttributesForFieldAccessType() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableFields(), - this.persistablePropertiesWithSpecifiedPropertyAccess() - ); - } - - @SuppressWarnings("unchecked") - private Iterator<JavaResourcePersistentAttribute> persistableAttributesForPropertyAccessType() { - return new CompositeIterator<JavaResourcePersistentAttribute>( - this.persistableProperties(), - this.persistableFieldsWithSpecifiedFieldAccess() - ); - } - - - // ********** update from Java ********** - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setName(this.buildName(astRoot)); - this.setQualifiedName(this.buildQualifiedName(astRoot)); - this.setSuperclassQualifiedName(this.buildSuperclassQualifiedName(astRoot)); - this.setAbstract(this.buildAbstract(astRoot)); - this.updateTypes(astRoot); - this.updateFields(astRoot); - this.updateMethods(astRoot); - // need to wait until everything is built to calculate 'access' - this.setAccess(this.buildAccess()); - } - - private void updateTypes(CompilationUnit astRoot) { - TypeDeclaration[] typeDeclarations = this.member.getTypes(astRoot); - CounterMap counters = new CounterMap(typeDeclarations.length); - HashSet<JavaResourcePersistentType> typesToRemove = new HashSet<JavaResourcePersistentType>(this.types); - for (TypeDeclaration typeDeclaration : typeDeclarations) { - String tdName = typeDeclaration.getName().getFullyQualifiedName(); - int occurrence = counters.increment(tdName); - - JavaResourcePersistentType type = this.getType(tdName, occurrence); - if (type == null) { - this.addType(this.buildType(typeDeclaration, occurrence, astRoot)); - } else { - typesToRemove.remove(type); - type.update(astRoot); - } - } - this.removeTypes(typesToRemove); - } - - private JavaResourcePersistentType buildType(TypeDeclaration nestedTypeDeclaration, int occurrence, CompilationUnit astRoot) { - return newInstance(this.getJavaResourceCompilationUnit(), this.member, nestedTypeDeclaration, occurrence, astRoot); - } - - private void updateFields(CompilationUnit astRoot) { - FieldDeclaration[] fieldDeclarations = this.member.getFields(astRoot); - CounterMap counters = new CounterMap(fieldDeclarations.length); - HashSet<JavaResourcePersistentAttribute> fieldsToRemove = new HashSet<JavaResourcePersistentAttribute>(this.fields); - for (FieldDeclaration fieldDeclaration : fieldDeclarations) { - for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) { - String fieldName = fragment.getName().getFullyQualifiedName(); - int occurrence = counters.increment(fieldName); - - JavaResourcePersistentAttribute field = this.getField(fieldName, occurrence); - if (field == null) { - this.addField(this.buildField(fieldName, occurrence, astRoot)); - } else { - fieldsToRemove.remove(field); - field.update(astRoot); - } - } - } - this.removeFields(fieldsToRemove); - } - - private JavaResourcePersistentAttribute buildField(String fieldName, int occurrence, CompilationUnit astRoot) { - return SourcePersistentAttribute.newInstance(this, this.member, fieldName, occurrence, this.getJavaResourceCompilationUnit(), astRoot); - } - - private void updateMethods(CompilationUnit astRoot) { - MethodDeclaration[] methodDeclarations = this.member.getMethods(astRoot); - CounterMap counters = new CounterMap(methodDeclarations.length); - HashSet<JavaResourcePersistentAttribute> methodsToRemove = new HashSet<JavaResourcePersistentAttribute>(this.methods); - for (MethodDeclaration methodDeclaration : methodDeclarations) { - MethodSignature signature = JDTTools.buildMethodSignature(methodDeclaration); - int occurrence = counters.increment(signature); - - JavaResourcePersistentAttribute method = this.getMethod(signature, occurrence); - if (method == null) { - this.addMethod(this.buildMethod(signature, occurrence, astRoot)); - } else { - methodsToRemove.remove(method); - method.update(astRoot); - } - } - this.removeMethods(methodsToRemove); - } - - private JavaResourcePersistentAttribute buildMethod(MethodSignature signature, int occurrence, CompilationUnit astRoot) { - return SourcePersistentAttribute.newInstance(this, this.member, signature, occurrence, this.getJavaResourceCompilationUnit(), astRoot); - } - - - // ********** static methods ********** - - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - private static List<VariableDeclarationFragment> fragments(FieldDeclaration fd) { - return fd.fragments(); - } - - - // ********** CounterMap ********** - - private static class CounterMap { - private final HashMap<Object, Counter> counters; - - protected CounterMap(int initialCapacity) { - super(); - this.counters = new HashMap<Object, Counter>(initialCapacity); - } - - /** - * Return the incremented count for the specified object. - */ - int increment(Object o) { - Counter counter = this.counters.get(o); - if (counter == null) { - counter = new Counter(); - this.counters.put(o, counter); - } - counter.increment(); - return counter.count(); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java deleted file mode 100644 index 7e7a3a2e21..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.PrimaryKeyJoinColumn - */ -public final class SourcePrimaryKeyJoinColumnAnnotation - extends SourceNamedColumnAnnotation - implements NestablePrimaryKeyJoinColumnAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final DeclarationAnnotationElementAdapter<String> referencedColumnNameDeclarationAdapter; - private final AnnotationElementAdapter<String> referencedColumnNameAdapter; - private String referencedColumnName; - - - public SourcePrimaryKeyJoinColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.referencedColumnNameDeclarationAdapter = this.buildStringElementAdapter(JPA.PRIMARY_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME); - this.referencedColumnNameAdapter = this.buildShortCircuitElementAdapter(this.referencedColumnNameDeclarationAdapter); - } - - public SourcePrimaryKeyJoinColumnAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - } - - public SourcePrimaryKeyJoinColumnAnnotation(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { - this(parent, member, idaa, new MemberIndexedAnnotationAdapter(member, idaa)); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.referencedColumnName = this.buildReferencedColumnName(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setReferencedColumnName(this.buildReferencedColumnName(astRoot)); - } - - - // ********** JavaSourceNamedColumnAnnotation implementation ********** - - @Override - String getNameElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN__NAME; - } - - @Override - String getColumnDefinitionElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN__COLUMN_DEFINITION; - } - - - // ********** PrimaryKeyJoinColumn implementation ********** - - // ***** referenced column name - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - public void setReferencedColumnName(String referencedColumnName) { - if (this.attributeValueHasNotChanged(this.referencedColumnName, referencedColumnName)) { - return; - } - String old = this.referencedColumnName; - this.referencedColumnName = referencedColumnName; - this.referencedColumnNameAdapter.setValue(referencedColumnName); - this.firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, old, referencedColumnName); - } - - private String buildReferencedColumnName(CompilationUnit astRoot) { - return this.referencedColumnNameAdapter.getValue(astRoot); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.referencedColumnNameDeclarationAdapter, astRoot); - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.referencedColumnNameDeclarationAdapter, pos, astRoot); - } - - - // ********** NestableAnnotation implementation ********** - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - PrimaryKeyJoinColumnAnnotation oldJoinColumn = (PrimaryKeyJoinColumnAnnotation) oldAnnotation; - this.setReferencedColumnName(oldJoinColumn.getReferencedColumnName()); - } - - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - protected IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - - // ********** static methods ********** - - public static SourcePrimaryKeyJoinColumnAnnotation createPrimaryKeyJoinColumn(JavaResourceNode parent, Member member) { - return new SourcePrimaryKeyJoinColumnAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - static SourcePrimaryKeyJoinColumnAnnotation createNestedPrimaryKeyJoinColumn(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter pkJoinColumnsAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, pkJoinColumnsAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa); - return new SourcePrimaryKeyJoinColumnAnnotation(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter pkJoinColumnsAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(pkJoinColumnsAdapter, index, JPA.PRIMARY_KEY_JOIN_COLUMN); - } - - static NestablePrimaryKeyJoinColumnAnnotation createSecondaryTablePrimaryKeyJoinColumn(DeclarationAnnotationAdapter secondaryTableAdapter, JavaResourceNode parent, Member member, int index) { - return new SourcePrimaryKeyJoinColumnAnnotation(parent, member, buildSecondaryTableAnnotationAdapter(secondaryTableAdapter, index)); - } - - private static IndexedDeclarationAnnotationAdapter buildSecondaryTableAnnotationAdapter(DeclarationAnnotationAdapter secondaryTableAdapter, int index) { - return new NestedIndexedDeclarationAnnotationAdapter(secondaryTableAdapter, JPA.SECONDARY_TABLE__PK_JOIN_COLUMNS, index, JPA.PRIMARY_KEY_JOIN_COLUMN); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java deleted file mode 100644 index 0a3ea82674..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnsAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.PrimaryKeyJoinColumns - */ -public final class SourcePrimaryKeyJoinColumnsAnnotation - extends SourceAnnotation<Member> - implements PrimaryKeyJoinColumnsAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestablePrimaryKeyJoinColumnAnnotation> pkJoinColumns = new Vector<NestablePrimaryKeyJoinColumnAnnotation>(); - - - public SourcePrimaryKeyJoinColumnsAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.pkJoinColumns); - } - - - // ********** AnnotationContainer Implementation ********** - - public String getContainerAnnotationName() { - return this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMNS__VALUE; - } - - public String getNestableAnnotationName() { - return PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestablePrimaryKeyJoinColumnAnnotation> nestedAnnotations() { - return new CloneListIterator<NestablePrimaryKeyJoinColumnAnnotation>(this.pkJoinColumns); - } - - public int nestedAnnotationsSize() { - return this.pkJoinColumns.size(); - } - - public NestablePrimaryKeyJoinColumnAnnotation addNestedAnnotationInternal() { - NestablePrimaryKeyJoinColumnAnnotation pkJoinColumn = this.buildPrimaryKeyJoinColumn(this.pkJoinColumns.size()); - this.pkJoinColumns.add(pkJoinColumn); - return pkJoinColumn; - } - - private NestablePrimaryKeyJoinColumnAnnotation buildPrimaryKeyJoinColumn(int index) { - return SourcePrimaryKeyJoinColumnAnnotation.createNestedPrimaryKeyJoinColumn(this, this.member, index, this.daa); - } - - public void nestedAnnotationAdded(int index, NestablePrimaryKeyJoinColumnAnnotation nestedAnnotation) { - this.fireItemAdded(PK_JOIN_COLUMNS_LIST, index, nestedAnnotation); - } - - public NestablePrimaryKeyJoinColumnAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.pkJoinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(PK_JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - public NestablePrimaryKeyJoinColumnAnnotation removeNestedAnnotationInternal(int index) { - return this.pkJoinColumns.remove(index); - } - - public void nestedAnnotationRemoved(int index, NestablePrimaryKeyJoinColumnAnnotation nestedAnnotation) { - this.fireItemRemoved(PK_JOIN_COLUMNS_LIST, index, nestedAnnotation); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java deleted file mode 100644 index 23484c15f1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation; -import org.eclipse.jpt.core.resource.java.QueryHintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.QueryHint - */ -public final class SourceQueryHintAnnotation - extends SourceAnnotation<Type> - implements NestableQueryHintAnnotation -{ - private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; - private final AnnotationElementAdapter<String> nameAdapter; - private String name; - - private final DeclarationAnnotationElementAdapter<String> valueDeclarationAdapter; - private final AnnotationElementAdapter<String> valueAdapter; - private String value; - - - public SourceQueryHintAnnotation(JavaResourceNode parent, Type type, IndexedDeclarationAnnotationAdapter idaa) { - super(parent, type, idaa, new MemberIndexedAnnotationAdapter(type, idaa)); - this.nameDeclarationAdapter = this.buildNameAdapter(idaa); - this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter); - this.valueDeclarationAdapter = this.buildValueAdapter(idaa); - this.valueAdapter = this.buildAdapter(this.valueDeclarationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - private AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); - } - - private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter adapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter, JPA.QUERY_HINT__NAME); - } - - private DeclarationAnnotationElementAdapter<String> buildValueAdapter(DeclarationAnnotationAdapter adapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter, JPA.QUERY_HINT__VALUE); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.buildName(astRoot); - this.value = this.buildValue(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.buildName(astRoot)); - this.setValue(this.buildValue(astRoot)); - } - - public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** QueryHintAnnotation implementation ********** - - // ***** name - public String getName() { - return this.name; - } - - public void setName(String name) { - if (this.attributeValueHasNotChanged(this.name, name)) { - return; - } - String old = this.name; - this.name = name; - this.nameAdapter.setValue(name); - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - private String buildName(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; - } - String old = this.value; - this.value = value; - this.valueAdapter.setValue(value); - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.valueDeclarationAdapter, astRoot); - } - - - // ********** NestableAnnotation implementation ********** - - public void initializeFrom(NestableAnnotation oldAnnotation) { - QueryHintAnnotation oldHint = (QueryHintAnnotation) oldAnnotation; - this.setName(oldHint.getName()); - this.setValue(oldHint.getValue()); - } - - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - - // ********** static methods ********** - - static SourceQueryHintAnnotation createNamedQueryQueryHint(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter namedQueryAdapter, int index) { - return new SourceQueryHintAnnotation(parent, type, buildNamedQueryQueryHintAnnotationAdapter(namedQueryAdapter, index)); - } - - private static IndexedDeclarationAnnotationAdapter buildNamedQueryQueryHintAnnotationAdapter(DeclarationAnnotationAdapter namedQueryAdapter, int index) { - return new NestedIndexedDeclarationAnnotationAdapter(namedQueryAdapter, JPA.NAMED_QUERY__HINTS, index, JPA.QUERY_HINT); - } - - static SourceQueryHintAnnotation createNamedNativeQueryQueryHint(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter namedNativeQueryAdapter, int index) { - return new SourceQueryHintAnnotation(parent, type, buildNamedNativeQueryQueryHintAnnotationAdapter(namedNativeQueryAdapter, index)); - } - - private static IndexedDeclarationAnnotationAdapter buildNamedNativeQueryQueryHintAnnotationAdapter(DeclarationAnnotationAdapter namedNativeQueryAdapter, int index) { - return new NestedIndexedDeclarationAnnotationAdapter(namedNativeQueryAdapter, JPA.NAMED_NATIVE_QUERY__HINTS, index, JPA.QUERY_HINT); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java deleted file mode 100644 index 5cdc49f8f0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java +++ /dev/null @@ -1,315 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.EnumArrayDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitArrayAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; -import org.eclipse.jpt.core.resource.java.CascadeType; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.RelationshipMappingAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.ExpressionConverter; -import org.eclipse.jpt.utility.internal.ArrayTools; - -/** - * javax.persistence.ManyToMany - * javax.persistence.ManyToOne - * javax.persistence.OneToMany - * javax.persistence.OneToOne - */ -abstract class SourceRelationshipMappingAnnotation - extends SourceAnnotation<Attribute> - implements RelationshipMappingAnnotation -{ - final DeclarationAnnotationElementAdapter<String> targetEntityDeclarationAdapter; - final AnnotationElementAdapter<String> targetEntityAdapter; - String targetEntity; - - String fullyQualifiedTargetEntityClassName; - - final DeclarationAnnotationElementAdapter<String> fetchDeclarationAdapter; - final AnnotationElementAdapter<String> fetchAdapter; - FetchType fetch; - - final DeclarationAnnotationElementAdapter<String[]> cascadeDeclarationAdapter; - final AnnotationElementAdapter<String[]> cascadeAdapter; - boolean cascadeAll; - boolean cascadePersist; - boolean cascadeMerge; - boolean cascadeRemove; - boolean cascadeRefresh; - - - SourceRelationshipMappingAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa) { - super(parent, attribute, daa); - this.targetEntityDeclarationAdapter = this.getTargetEntityAdapter(); - this.targetEntityAdapter = this.buildAnnotationElementAdapter(this.targetEntityDeclarationAdapter); - this.fetchDeclarationAdapter = this.getFetchAdapter(); - this.fetchAdapter = this.buildAnnotationElementAdapter(this.fetchDeclarationAdapter); - this.cascadeDeclarationAdapter = this.getCascadeAdapter(); - this.cascadeAdapter = new ShortCircuitArrayAnnotationElementAdapter<String>(attribute, this.cascadeDeclarationAdapter); - } - - AnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); - } - - AnnotationElementAdapter<Boolean> buildBooleanAnnotationElementAdapter(DeclarationAnnotationElementAdapter<Boolean> daea) { - return new ShortCircuitAnnotationElementAdapter<Boolean>(this.member, daea); - } - - public void initialize(CompilationUnit astRoot) { - this.targetEntity = this.buildTargetEntity(astRoot); - this.fullyQualifiedTargetEntityClassName = this.buildFullyQualifiedTargetEntityClassName(astRoot); - this.fetch = this.buildFetch(astRoot); - this.initializeCascadeTypes(astRoot); - } - - private void initializeCascadeTypes(CompilationUnit astRoot) { - CascadeType[] cascadeTypes = CascadeType.fromJavaAnnotationValues(this.cascadeAdapter.getValue(astRoot)); - this.cascadeAll = ArrayTools.contains(cascadeTypes, CascadeType.ALL); - this.cascadeMerge = ArrayTools.contains(cascadeTypes, CascadeType.MERGE); - this.cascadePersist = ArrayTools.contains(cascadeTypes, CascadeType.PERSIST); - this.cascadeRefresh = ArrayTools.contains(cascadeTypes, CascadeType.REFRESH); - this.cascadeRemove = ArrayTools.contains(cascadeTypes, CascadeType.REMOVE); - } - - public void update(CompilationUnit astRoot) { - this.setFetch(this.buildFetch(astRoot)); - this.setTargetEntity(this.buildTargetEntity(astRoot)); - this.setFullyQualifiedTargetEntityClassName(this.buildFullyQualifiedTargetEntityClassName(astRoot)); - this.updateCascade(astRoot); - } - - private void updateCascade(CompilationUnit astRoot) { - CascadeType[] cascadeTypes = CascadeType.fromJavaAnnotationValues(this.cascadeAdapter.getValue(astRoot)); - this.setCascadeAll(ArrayTools.contains(cascadeTypes, CascadeType.ALL)); - this.setCascadeMerge(ArrayTools.contains(cascadeTypes, CascadeType.MERGE)); - this.setCascadePersist(ArrayTools.contains(cascadeTypes, CascadeType.PERSIST)); - this.setCascadeRefresh(ArrayTools.contains(cascadeTypes, CascadeType.REFRESH)); - this.setCascadeRemove(ArrayTools.contains(cascadeTypes, CascadeType.REMOVE)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.targetEntity); - } - - - // ********** RelationshipMappingAnnotation implementation ********** - - // ***** target entity - public String getTargetEntity() { - return this.targetEntity; - } - - public void setTargetEntity(String targetEntity) { - if (this.attributeValueHasNotChanged(this.targetEntity, targetEntity)) { - return; - } - String old = this.targetEntity; - this.targetEntity = targetEntity; - this.targetEntityAdapter.setValue(targetEntity); - this.firePropertyChanged(TARGET_ENTITY_PROPERTY, old, targetEntity); - } - - private String buildTargetEntity(CompilationUnit astRoot) { - return this.targetEntityAdapter.getValue(astRoot); - } - - public TextRange getTargetEntityTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.targetEntityDeclarationAdapter, astRoot); - } - - /** - * return the Java adapter's 'targetEntity' element adapter config - */ - abstract DeclarationAnnotationElementAdapter<String> getTargetEntityAdapter(); - - // ***** fully-qualified target entity class name - public String getFullyQualifiedTargetEntityClassName() { - return this.fullyQualifiedTargetEntityClassName; - } - - private void setFullyQualifiedTargetEntityClassName(String name) { - String old = this.fullyQualifiedTargetEntityClassName; - this.fullyQualifiedTargetEntityClassName = name; - this.firePropertyChanged(FULLY_QUALIFIED_TARGET_ENTITY_CLASS_NAME_PROPERTY, old, name); - } - - private String buildFullyQualifiedTargetEntityClassName(CompilationUnit astRoot) { - return (this.targetEntity == null) ? null : JDTTools.resolveFullyQualifiedName(this.targetEntityAdapter.getExpression(astRoot)); - } - - // ***** fetch - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType fetch) { - if (this.attributeValueHasNotChanged(this.fetch, fetch)) { - return; - } - FetchType old = this.fetch; - this.fetch = fetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); - } - - private FetchType buildFetch(CompilationUnit astRoot) { - return FetchType.fromJavaAnnotationValue(this.fetchAdapter.getValue(astRoot)); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.fetchDeclarationAdapter, astRoot); - } - - /** - * return the Java adapter's 'fetch' element adapter config - */ - abstract DeclarationAnnotationElementAdapter<String> getFetchAdapter(); - - // ***** cascade - private void setCascadeTypes(CascadeType[] cascadeTypes) { - this.cascadeAdapter.setValue(CascadeType.toJavaAnnotationValues(cascadeTypes)); - } - - private void setCascade(CascadeType cascadeType, boolean set) { - String[] javaValues = this.cascadeAdapter.getValue(); - CascadeType[] cascadeTypes = CascadeType.fromJavaAnnotationValues(javaValues); - - boolean present = ArrayTools.contains(cascadeTypes, cascadeType); - if (set) { - if ( ! present) { - this.setCascadeTypes(ArrayTools.add(cascadeTypes, cascadeType)); - } - } else { - if (present) { - this.setCascadeTypes(ArrayTools.remove(cascadeTypes, cascadeType)); - } - } - } - - public TextRange getCascadeTextRange(CompilationUnit astRoot) { - return getElementTextRange(this.cascadeDeclarationAdapter, astRoot); - } - - /** - * return the Java adapter's 'cascade' element adapter config - */ - abstract DeclarationAnnotationElementAdapter<String[]> getCascadeAdapter(); - - // ***** cascade all - public boolean isCascadeAll() { - return this.cascadeAll; - } - - public void setCascadeAll(boolean cascadeAll) { - if (this.cascadeAll == cascadeAll) { - return; - } - boolean old = this.cascadeAll; - this.cascadeAll = cascadeAll; - this.setCascade(CascadeType.ALL, cascadeAll); - this.firePropertyChanged(CASCADE_ALL_PROPERTY, old, cascadeAll); - } - - // ***** cascade persist - public boolean isCascadePersist() { - return this.cascadePersist; - } - - public void setCascadePersist(boolean cascadePersist) { - if (this.cascadePersist == cascadePersist) { - return; - } - boolean old = this.cascadePersist; - this.cascadePersist = cascadePersist; - this.setCascade(CascadeType.PERSIST, cascadePersist); - this.firePropertyChanged(CASCADE_PERSIST_PROPERTY, old, cascadePersist); - } - - // ***** cascade merge - public boolean isCascadeMerge() { - return this.cascadeMerge; - } - - public void setCascadeMerge(boolean cascadeMerge) { - if (this.cascadeMerge == cascadeMerge) { - return; - } - boolean old = this.cascadeMerge; - this.cascadeMerge = cascadeMerge; - this.setCascade(CascadeType.MERGE, cascadeMerge); - this.firePropertyChanged(CASCADE_MERGE_PROPERTY, old, cascadeMerge); - } - - // ***** cascade remove - public boolean isCascadeRemove() { - return this.cascadeRemove; - } - - public void setCascadeRemove(boolean cascadeRemove) { - if (this.cascadeRemove == cascadeRemove) { - return; - } - boolean old = this.cascadeRemove; - this.cascadeRemove = cascadeRemove; - this.setCascade(CascadeType.REMOVE, cascadeRemove); - this.firePropertyChanged(CASCADE_REMOVE_PROPERTY, old, cascadeRemove); - } - - // ***** cascade refresh - public boolean isCascadeRefresh() { - return this.cascadeRefresh; - } - - public void setCascadeRefresh(boolean cascadeRefresh) { - if (this.cascadeRefresh == cascadeRefresh) { - return; - } - boolean old = this.cascadeRefresh; - this.cascadeRefresh = cascadeRefresh; - this.setCascade(CascadeType.REFRESH, cascadeRefresh); - this.firePropertyChanged(CASCADE_REFRESH_PROPERTY, old, cascadeRefresh); - } - - - // ********** static methods ********** - - static DeclarationAnnotationElementAdapter<String> buildTargetEntityAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - // TODO what about QualifiedType? - return buildAnnotationElementAdapter(annotationAdapter, elementName, SimpleTypeStringExpressionConverter.instance()); - } - - static DeclarationAnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String> converter) { - return new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, elementName, false, converter); - } - - static DeclarationAnnotationElementAdapter<String> buildFetchAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new EnumDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false); - } - - static DeclarationAnnotationElementAdapter<String[]> buildEnumArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new EnumArrayDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java deleted file mode 100644 index ada1107dc3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java +++ /dev/null @@ -1,264 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableSecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.SecondaryTable - */ -public final class SourceSecondaryTableAnnotation - extends SourceBaseTableAnnotation - implements NestableSecondaryTableAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(SecondaryTableAnnotation.ANNOTATION_NAME); - - private final Vector<NestablePrimaryKeyJoinColumnAnnotation> pkJoinColumns = new Vector<NestablePrimaryKeyJoinColumnAnnotation>(); - private final PkJoinColumnsAnnotationContainer pkJoinColumnsContainer = new PkJoinColumnsAnnotationContainer(); - - - public SourceSecondaryTableAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - AnnotationContainerTools.initialize(this.pkJoinColumnsContainer, astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - AnnotationContainerTools.update(this.pkJoinColumnsContainer, astRoot); - } - - - // ********** AbstractBaseTableAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__NAME); - } - - @Override - DeclarationAnnotationElementAdapter<String> getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__SCHEMA); - } - - @Override - DeclarationAnnotationElementAdapter<String> getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__CATALOG); - } - - @Override - String getUniqueConstraintsElementName() { - return JPA.SECONDARY_TABLE__UNIQUE_CONSTRAINTS; - } - - - // ************* SecondaryTable implementation ******************* - - // ***** pk join columns - public ListIterator<PrimaryKeyJoinColumnAnnotation> pkJoinColumns() { - return new CloneListIterator<PrimaryKeyJoinColumnAnnotation>(this.pkJoinColumns); - } - - ListIterator<NestablePrimaryKeyJoinColumnAnnotation> nestablePkJoinColumns() { - return new CloneListIterator<NestablePrimaryKeyJoinColumnAnnotation>(this.pkJoinColumns); - } - - public int pkJoinColumnsSize() { - return this.pkJoinColumns.size(); - } - - public NestablePrimaryKeyJoinColumnAnnotation pkJoinColumnAt(int index) { - return this.pkJoinColumns.get(index); - } - - public int indexOfPkJoinColumn(PrimaryKeyJoinColumnAnnotation joinColumn) { - return this.pkJoinColumns.indexOf(joinColumn); - } - - public NestablePrimaryKeyJoinColumnAnnotation addPkJoinColumn(int index) { - return (NestablePrimaryKeyJoinColumnAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.pkJoinColumnsContainer); - } - - NestablePrimaryKeyJoinColumnAnnotation addPkJoinColumnInternal() { - NestablePrimaryKeyJoinColumnAnnotation pkJoinColumn = this.buildPrimaryKeyJoinColumn(this.pkJoinColumns.size()); - this.pkJoinColumns.add(pkJoinColumn); - return pkJoinColumn; - } - - private NestablePrimaryKeyJoinColumnAnnotation buildPrimaryKeyJoinColumn(int index) { - return SourcePrimaryKeyJoinColumnAnnotation.createSecondaryTablePrimaryKeyJoinColumn(this.daa, this, this.member, index); - } - - void pkJoinColumnAdded(int index, NestablePrimaryKeyJoinColumnAnnotation joinColumn) { - this.fireItemAdded(PK_JOIN_COLUMNS_LIST, index, joinColumn); - } - - public void movePkJoinColumn(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.pkJoinColumnsContainer); - } - - NestablePrimaryKeyJoinColumnAnnotation movePkJoinColumnInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.pkJoinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - void pkJoinColumnMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(PK_JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - public void removePkJoinColumn(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.pkJoinColumnsContainer); - } - - NestablePrimaryKeyJoinColumnAnnotation removePkJoinColumnInternal(int index) { - return this.pkJoinColumns.remove(index); - } - - void pkJoinColumnRemoved(int index, NestablePrimaryKeyJoinColumnAnnotation joinColumn) { - this.fireItemRemoved(PK_JOIN_COLUMNS_LIST, index, joinColumn); - } - - - // ********** NestableAnnotation implementation ********** - - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - protected IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - SecondaryTableAnnotation oldTable = (SecondaryTableAnnotation) oldAnnotation; - for (PrimaryKeyJoinColumnAnnotation oldPkJoinColumn : CollectionTools.iterable(oldTable.pkJoinColumns())) { - NestablePrimaryKeyJoinColumnAnnotation newPkJoinColumn = this.addPkJoinColumn(oldTable.indexOfPkJoinColumn(oldPkJoinColumn)); - newPkJoinColumn.initializeFrom((NestableAnnotation) oldPkJoinColumn); - } - } - - - // ********** static methods ********** - - public static SourceSecondaryTableAnnotation createSecondaryTable(JavaResourceNode parent, Member member) { - return new SourceSecondaryTableAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); - } - - static SourceSecondaryTableAnnotation createNestedSecondaryTable(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter secondaryTablesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, secondaryTablesAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa); - return new SourceSecondaryTableAnnotation(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter secondaryTablesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(secondaryTablesAdapter, index, JPA.SECONDARY_TABLE); - } - - - // ********** pk join column container ********** - - /** - * adapt the AnnotationContainer interface to the secondary table's - * primary key join columns - */ - class PkJoinColumnsAnnotationContainer - implements AnnotationContainer<NestablePrimaryKeyJoinColumnAnnotation> - { - public String getContainerAnnotationName() { - return SourceSecondaryTableAnnotation.this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceSecondaryTableAnnotation.this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return JPA.SECONDARY_TABLE__PK_JOIN_COLUMNS; - } - - public String getNestableAnnotationName() { - return PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestablePrimaryKeyJoinColumnAnnotation> nestedAnnotations() { - return SourceSecondaryTableAnnotation.this.nestablePkJoinColumns(); - } - - public int nestedAnnotationsSize() { - return SourceSecondaryTableAnnotation.this.pkJoinColumnsSize(); - } - - public NestablePrimaryKeyJoinColumnAnnotation addNestedAnnotationInternal() { - return SourceSecondaryTableAnnotation.this.addPkJoinColumnInternal(); - } - - public void nestedAnnotationAdded(int index, NestablePrimaryKeyJoinColumnAnnotation nestedAnnotation) { - SourceSecondaryTableAnnotation.this.pkJoinColumnAdded(index, nestedAnnotation); - } - - public NestablePrimaryKeyJoinColumnAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return SourceSecondaryTableAnnotation.this.movePkJoinColumnInternal(targetIndex, sourceIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - SourceSecondaryTableAnnotation.this.pkJoinColumnMoved(targetIndex, sourceIndex); - } - - public NestablePrimaryKeyJoinColumnAnnotation removeNestedAnnotationInternal(int index) { - return SourceSecondaryTableAnnotation.this.removePkJoinColumnInternal(index); - } - - public void nestedAnnotationRemoved(int index, NestablePrimaryKeyJoinColumnAnnotation nestedAnnotation) { - SourceSecondaryTableAnnotation.this.pkJoinColumnRemoved(index, nestedAnnotation); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java deleted file mode 100644 index bf37125772..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.NestableSecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation; -import org.eclipse.jpt.core.resource.java.SecondaryTablesAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.SecondaryTables - */ -public final class SourceSecondaryTablesAnnotation - extends SourceAnnotation<Member> - implements SecondaryTablesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableSecondaryTableAnnotation> secondaryTables = new Vector<NestableSecondaryTableAnnotation>(); - - - public SourceSecondaryTablesAnnotation(JavaResourcePersistentType parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void update(CompilationUnit astRoot) { - AnnotationContainerTools.update(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.secondaryTables); - } - - - // ********** AnnotationContainer implementation ********** - - public String getContainerAnnotationName() { - return this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return JPA.SECONDARY_TABLES__VALUE; - } - - public String getNestableAnnotationName() { - return SecondaryTableAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestableSecondaryTableAnnotation> nestedAnnotations() { - return new CloneListIterator<NestableSecondaryTableAnnotation>(this.secondaryTables); - } - - public int nestedAnnotationsSize() { - return this.secondaryTables.size(); - } - - public NestableSecondaryTableAnnotation addNestedAnnotationInternal() { - NestableSecondaryTableAnnotation secondaryTable = this.buildSecondaryTable(this.secondaryTables.size()); - this.secondaryTables.add(secondaryTable); - return secondaryTable; - } - - private NestableSecondaryTableAnnotation buildSecondaryTable(int index) { - return SourceSecondaryTableAnnotation.createNestedSecondaryTable(this, this.member, index, this.daa); - } - - public void nestedAnnotationAdded(int index, NestableSecondaryTableAnnotation nestedAnnotation) { - this.fireItemAdded(SECONDARY_TABLES_LIST, index, nestedAnnotation); - } - - public NestableSecondaryTableAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.secondaryTables, targetIndex, sourceIndex).get(targetIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(SECONDARY_TABLES_LIST, targetIndex, sourceIndex); - } - - public NestableSecondaryTableAnnotation removeNestedAnnotationInternal(int index) { - return this.secondaryTables.remove(index); - } - - public void nestedAnnotationRemoved(int index, NestableSecondaryTableAnnotation nestedAnnotation) { - this.fireItemRemoved(SECONDARY_TABLES_LIST, index, nestedAnnotation); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java deleted file mode 100644 index 90387e4bf8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SequenceGenerator - */ -public abstract class SourceSequenceGeneratorAnnotation - extends SourceGeneratorAnnotation - implements SequenceGeneratorAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__NAME); - - private static final DeclarationAnnotationElementAdapter<Integer> INITIAL_VALUE_ADAPTER = buildIntegerAdapter(JPA.SEQUENCE_GENERATOR__INITIAL_VALUE); - - private static final DeclarationAnnotationElementAdapter<Integer> ALLOCATION_SIZE_ADAPTER = buildIntegerAdapter(JPA.SEQUENCE_GENERATOR__ALLOCATION_SIZE); - - private static final DeclarationAnnotationElementAdapter<String> SEQUENCE_NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__SEQUENCE_NAME); - private final AnnotationElementAdapter<String> sequenceNameAdapter; - private String sequenceName; - - - protected SourceSequenceGeneratorAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.sequenceNameAdapter = this.buildAdapter(SEQUENCE_NAME_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.sequenceName = this.buildSequenceName(astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setSequenceName(this.buildSequenceName(astRoot)); - } - - - // ********** AbstractGeneratorAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getNameAdapter() { - return NAME_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<Integer> getInitialValueAdapter() { - return INITIAL_VALUE_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<Integer> getAllocationSizeAdapter() { - return ALLOCATION_SIZE_ADAPTER; - } - - - // ********** SequenceGeneratorAnnotation implementation ********** - - // ***** sequence name - public String getSequenceName() { - return this.sequenceName; - } - - public void setSequenceName(String sequenceName) { - if (this.attributeValueHasNotChanged(this.sequenceName, sequenceName)) { - return; - } - String old = this.sequenceName; - this.sequenceName = sequenceName; - this.sequenceNameAdapter.setValue(sequenceName); - this.firePropertyChanged(SEQUENCE_NAME_PROPERTY, old, sequenceName); - } - - private String buildSequenceName(CompilationUnit astRoot) { - return this.sequenceNameAdapter.getValue(astRoot); - } - - public TextRange getSequenceNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(SEQUENCE_NAME_ADAPTER, astRoot); - } - - public boolean sequenceNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(SEQUENCE_NAME_ADAPTER, pos, astRoot); - } - - - // ********** static methods ********** - - protected static DeclarationAnnotationElementAdapter<String> buildAdapter(String elementName) { - return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - protected static DeclarationAnnotationElementAdapter<Integer> buildIntegerAdapter(String elementName) { - return buildIntegerAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableAnnotation.java deleted file mode 100644 index 546ebe3e49..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableAnnotation.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.TableAnnotation; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Table - */ -public final class SourceTableAnnotation - extends SourceBaseTableAnnotation - implements TableAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__NAME); - - private static final DeclarationAnnotationElementAdapter<String> SCHEMA_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__SCHEMA); - - private static final DeclarationAnnotationElementAdapter<String> CATALOG_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__CATALOG); - - - public SourceTableAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** AbstractBaseTableAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @Table is never nested - return NAME_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String> getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @Table is never nested - return SCHEMA_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<String> getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @Table is never nested - return CATALOG_ADAPTER; - } - - @Override - String getUniqueConstraintsElementName() { - return JPA.TABLE__UNIQUE_CONSTRAINTS; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java deleted file mode 100644 index 328cdf6727..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java +++ /dev/null @@ -1,440 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraintAnnotation; -import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.TableGenerator - */ -public final class SourceTableGeneratorAnnotation - extends SourceGeneratorAnnotation - implements TableGeneratorAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__NAME); - - private static final DeclarationAnnotationElementAdapter<Integer> INITIAL_VALUE_ADAPTER = buildIntegerAdapter(JPA.TABLE_GENERATOR__INITIAL_VALUE); - - private static final DeclarationAnnotationElementAdapter<Integer> ALLOCATION_SIZE_ADAPTER = buildIntegerAdapter(JPA.TABLE_GENERATOR__ALLOCATION_SIZE); - - private static final DeclarationAnnotationElementAdapter<String> TABLE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__TABLE); - private final AnnotationElementAdapter<String> tableAdapter; - private String table; - - private static final DeclarationAnnotationElementAdapter<String> SCHEMA_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__SCHEMA); - private final AnnotationElementAdapter<String> schemaAdapter; - private String schema; - - private static final DeclarationAnnotationElementAdapter<String> CATALOG_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__CATALOG); - private final AnnotationElementAdapter<String> catalogAdapter; - private String catalog; - - private static final DeclarationAnnotationElementAdapter<String> PK_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_NAME); - private final AnnotationElementAdapter<String> pkColumnNameAdapter; - private String pkColumnName; - - private static final DeclarationAnnotationElementAdapter<String> VALUE_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__VALUE_COLUMN_NAME); - private final AnnotationElementAdapter<String> valueColumnNameAdapter; - private String valueColumnName; - - private static final DeclarationAnnotationElementAdapter<String> PK_COLUMN_VALUE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_VALUE); - private final AnnotationElementAdapter<String> pkColumnValueAdapter; - private String pkColumnValue; - - private final Vector<NestableUniqueConstraintAnnotation> uniqueConstraints = new Vector<NestableUniqueConstraintAnnotation>(); - private final UniqueConstraintsAnnotationContainer uniqueConstraintsContainer = new UniqueConstraintsAnnotationContainer(); - - - public SourceTableGeneratorAnnotation(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.tableAdapter = this.buildAdapter(TABLE_ADAPTER); - this.catalogAdapter = this.buildAdapter(CATALOG_ADAPTER); - this.schemaAdapter = this.buildAdapter(SCHEMA_ADAPTER); - this.pkColumnNameAdapter = this.buildAdapter(PK_COLUMN_NAME_ADAPTER); - this.valueColumnNameAdapter = this.buildAdapter(VALUE_COLUMN_NAME_ADAPTER); - this.pkColumnValueAdapter = this.buildAdapter(PK_COLUMN_VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.table = this.buildTable(astRoot); - this.schema = this.buildSchema(astRoot); - this.catalog = this.buildCatalog(astRoot); - this.pkColumnName = this.buildPkColumnName(astRoot); - this.valueColumnName = this.buildValueColumnName(astRoot); - this.pkColumnValue = this.buildPkColumnValue(astRoot); - AnnotationContainerTools.initialize(this.uniqueConstraintsContainer, astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setTable(this.buildTable(astRoot)); - this.setSchema(this.buildSchema(astRoot)); - this.setCatalog(this.buildCatalog(astRoot)); - this.setPkColumnName(this.buildPkColumnName(astRoot)); - this.setValueColumnName(this.buildValueColumnName(astRoot)); - this.setPkColumnValue(this.buildPkColumnValue(astRoot)); - AnnotationContainerTools.update(this.uniqueConstraintsContainer, astRoot); - } - - - // ********** AbstractGeneratorAnnotation implementation ********** - - @Override - DeclarationAnnotationElementAdapter<String> getNameAdapter() { - return NAME_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<Integer> getInitialValueAdapter() { - return INITIAL_VALUE_ADAPTER; - } - - @Override - DeclarationAnnotationElementAdapter<Integer> getAllocationSizeAdapter() { - return ALLOCATION_SIZE_ADAPTER; - } - - - // ********** TableGeneratorAnnotation implementation ********** - - // ***** table - public String getTable() { - return this.table; - } - - public void setTable(String table) { - if (this.attributeValueHasNotChanged(this.table, table)) { - return; - } - String old = this.table; - this.table = table; - this.tableAdapter.setValue(table); - this.firePropertyChanged(TABLE_PROPERTY, old, table); - } - - private String buildTable(CompilationUnit astRoot) { - return this.tableAdapter.getValue(astRoot); - } - - public TextRange getTableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(TABLE_ADAPTER, astRoot); - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(TABLE_ADAPTER, pos, astRoot); - } - - // ***** schema - public String getSchema() { - return this.schema; - } - - public void setSchema(String schema) { - if (this.attributeValueHasNotChanged(this.schema, schema)) { - return; - } - String old = this.schema; - this.schema = schema; - this.schemaAdapter.setValue(schema); - this.firePropertyChanged(SCHEMA_PROPERTY, old, schema); - } - - private String buildSchema(CompilationUnit astRoot) { - return this.schemaAdapter.getValue(astRoot); - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(SCHEMA_ADAPTER, astRoot); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(SCHEMA_ADAPTER, pos, astRoot); - } - - // ***** catalog - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String catalog) { - if (this.attributeValueHasNotChanged(this.catalog, catalog)) { - return; - } - String old = this.catalog; - this.catalog = catalog; - this.catalogAdapter.setValue(catalog); - this.firePropertyChanged(CATALOG_PROPERTY, old, catalog); - } - - private String buildCatalog(CompilationUnit astRoot) { - return this.catalogAdapter.getValue(astRoot); - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(CATALOG_ADAPTER, astRoot); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(CATALOG_ADAPTER, pos, astRoot); - } - - // ***** pk column name - public String getPkColumnName() { - return this.pkColumnName; - } - - public void setPkColumnName(String pkColumnName) { - if (this.attributeValueHasNotChanged(this.pkColumnName, pkColumnName)) { - return; - } - String old = this.pkColumnName; - this.pkColumnName = pkColumnName; - this.pkColumnNameAdapter.setValue(pkColumnName); - this.firePropertyChanged(PK_COLUMN_NAME_PROPERTY, old, pkColumnName); - } - - private String buildPkColumnName(CompilationUnit astRoot) { - return this.pkColumnNameAdapter.getValue(astRoot); - } - - public TextRange getPkColumnNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(PK_COLUMN_NAME_ADAPTER, astRoot); - } - - public boolean pkColumnNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(PK_COLUMN_NAME_ADAPTER, pos, astRoot); - } - - // ***** value column name - public String getValueColumnName() { - return this.valueColumnName; - } - - public void setValueColumnName(String valueColumnName) { - if (this.attributeValueHasNotChanged(this.valueColumnName, valueColumnName)) { - return; - } - String old = this.valueColumnName; - this.valueColumnName = valueColumnName; - this.valueColumnNameAdapter.setValue(valueColumnName); - this.firePropertyChanged(VALUE_COLUMN_NAME_PROPERTY, old, valueColumnName); - } - - private String buildValueColumnName(CompilationUnit astRoot) { - return this.valueColumnNameAdapter.getValue(astRoot); - } - - public TextRange getValueColumnNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_COLUMN_NAME_ADAPTER, astRoot); - } - - public boolean valueColumnNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(VALUE_COLUMN_NAME_ADAPTER, pos, astRoot); - } - - // ***** pk column value - public String getPkColumnValue() { - return this.pkColumnValue; - } - - public void setPkColumnValue(String pkColumnValue) { - if (this.attributeValueHasNotChanged(this.pkColumnValue, pkColumnValue)) { - return; - } - String old = this.pkColumnValue; - this.pkColumnValue = pkColumnValue; - this.pkColumnValueAdapter.setValue(pkColumnValue); - this.firePropertyChanged(PK_COLUMN_VALUE_PROPERTY, old, pkColumnValue); - } - - private String buildPkColumnValue(CompilationUnit astRoot) { - return this.pkColumnValueAdapter.getValue(astRoot); - } - - public TextRange getPkColumnValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(PK_COLUMN_VALUE_ADAPTER, astRoot); - } - - public boolean pkColumnValueTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(PK_COLUMN_VALUE_ADAPTER, pos, astRoot); - } - - // ***** unique constraints - public ListIterator<UniqueConstraintAnnotation> uniqueConstraints() { - return new CloneListIterator<UniqueConstraintAnnotation>(this.uniqueConstraints); - } - - ListIterator<NestableUniqueConstraintAnnotation> nestableUniqueConstraints() { - return new CloneListIterator<NestableUniqueConstraintAnnotation>(this.uniqueConstraints); - } - - public int uniqueConstraintsSize() { - return this.uniqueConstraints.size(); - } - - public NestableUniqueConstraintAnnotation uniqueConstraintAt(int index) { - return this.uniqueConstraints.get(index); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - return this.uniqueConstraints.indexOf(uniqueConstraint); - } - - public NestableUniqueConstraintAnnotation addUniqueConstraint(int index) { - return (NestableUniqueConstraintAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation addUniqueConstraintInternal() { - NestableUniqueConstraintAnnotation uniqueConstraint = this.buildUniqueConstraint(this.uniqueConstraints.size()); - this.uniqueConstraints.add(uniqueConstraint); - return uniqueConstraint; - } - - NestableUniqueConstraintAnnotation buildUniqueConstraint(int index) { - return new SourceUniqueConstraintAnnotation(this, this.member, buildUniqueConstraintAnnotationAdapter(index)); - } - - IndexedDeclarationAnnotationAdapter buildUniqueConstraintAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(this.daa, JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); - } - - void uniqueConstraintAdded(int index, NestableUniqueConstraintAnnotation constraint) { - this.fireItemAdded(UNIQUE_CONSTRAINTS_LIST, index, constraint); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation moveUniqueConstraintInternal(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.uniqueConstraints, targetIndex, sourceIndex).get(targetIndex); - } - - void uniqueConstraintMoved(int targetIndex, int sourceIndex) { - this.fireItemMoved(UNIQUE_CONSTRAINTS_LIST, targetIndex, sourceIndex); - } - - public void removeUniqueConstraint(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.uniqueConstraintsContainer); - } - - NestableUniqueConstraintAnnotation removeUniqueConstraintInternal(int index) { - return this.uniqueConstraints.remove(index); - } - - void uniqueConstraintRemoved(int index, NestableUniqueConstraintAnnotation constraint) { - this.fireItemRemoved(UNIQUE_CONSTRAINTS_LIST, index, constraint); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildAdapter(String elementName) { - return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - private static DeclarationAnnotationElementAdapter<Integer> buildIntegerAdapter(String elementName) { - return buildIntegerAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - - // ********** unique constraint container ********** - - /** - * adapt the AnnotationContainer interface to the table generator's unique constraints - */ - class UniqueConstraintsAnnotationContainer - implements AnnotationContainer<NestableUniqueConstraintAnnotation> - { - public String getContainerAnnotationName() { - return SourceTableGeneratorAnnotation.this.getAnnotationName(); - } - - public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { - return SourceTableGeneratorAnnotation.this.getJdtAnnotation(astRoot); - } - - public String getElementName() { - return JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS; - } - - public String getNestableAnnotationName() { - return UniqueConstraintAnnotation.ANNOTATION_NAME; - } - - public ListIterator<NestableUniqueConstraintAnnotation> nestedAnnotations() { - return SourceTableGeneratorAnnotation.this.nestableUniqueConstraints(); - } - - public int nestedAnnotationsSize() { - return SourceTableGeneratorAnnotation.this.uniqueConstraintsSize(); - } - - public NestableUniqueConstraintAnnotation addNestedAnnotationInternal() { - return SourceTableGeneratorAnnotation.this.addUniqueConstraintInternal(); - } - - public void nestedAnnotationAdded(int index, NestableUniqueConstraintAnnotation nestedAnnotation) { - SourceTableGeneratorAnnotation.this.uniqueConstraintAdded(index, nestedAnnotation); - } - - public NestableUniqueConstraintAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { - return SourceTableGeneratorAnnotation.this.moveUniqueConstraintInternal(targetIndex, sourceIndex); - } - - public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { - SourceTableGeneratorAnnotation.this.uniqueConstraintMoved(targetIndex, sourceIndex); - } - - public NestableUniqueConstraintAnnotation removeNestedAnnotationInternal(int index) { - return SourceTableGeneratorAnnotation.this.removeUniqueConstraintInternal(index); - } - - public void nestedAnnotationRemoved(int index, NestableUniqueConstraintAnnotation nestedAnnotation) { - SourceTableGeneratorAnnotation.this.uniqueConstraintRemoved(index, nestedAnnotation); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTemporalAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTemporalAnnotation.java deleted file mode 100644 index e2811269a1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTemporalAnnotation.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; -import org.eclipse.jpt.core.resource.java.TemporalType; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.Temporal - */ -public final class SourceTemporalAnnotation - extends SourceAnnotation<Attribute> - implements TemporalAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private TemporalType value; - - - public SourceTemporalAnnotation(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** TemporalAnnotation implementation ********** - - // ***** value - public TemporalType getValue() { - return this.value; - } - - public void setValue(TemporalType value) { - if (this.attributeValueHasNotChanged(this.value, value)) { - return; - } - TemporalType old = this.value; - this.value = value; - this.valueAdapter.setValue(TemporalType.toJavaAnnotationValue(value)); - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private TemporalType buildValue(CompilationUnit astRoot) { - return TemporalType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.TEMPORAL__VALUE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java deleted file mode 100644 index b41ff19a6e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.TransientAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Transient - */ -public final class SourceTransientAnnotation - extends SourceAnnotation<Attribute> - implements TransientAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceTransientAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void update(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java deleted file mode 100644 index 334eb0b608..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import java.util.Arrays; -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitArrayAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraintAnnotation; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.ExpressionConverter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.UniqueConstraint - */ -public final class SourceUniqueConstraintAnnotation - extends SourceAnnotation<Member> - implements NestableUniqueConstraintAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.UNIQUE_CONSTRAINT); - - private final DeclarationAnnotationElementAdapter<String[]> columnNamesDeclarationAdapter; - private final AnnotationElementAdapter<String[]> columnNamesAdapter; - private final Vector<String> columnNames = new Vector<String>(); - - - public SourceUniqueConstraintAnnotation(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { - super(parent, member, idaa, new MemberIndexedAnnotationAdapter(member, idaa)); - this.columnNamesDeclarationAdapter = buildArrayAnnotationElementAdapter(idaa, JPA.UNIQUE_CONSTRAINT__COLUMN_NAMES); - this.columnNamesAdapter = this.buildAnnotationElementAdapter(this.columnNamesDeclarationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - private AnnotationElementAdapter<String[]> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String[]> daea) { - return new ShortCircuitArrayAnnotationElementAdapter<String>(this.member, daea); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, AnnotationStringArrayExpressionConverter.forStrings()); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String[]> converter) { - return new ConversionDeclarationAnnotationElementAdapter<String[]>(annotationAdapter, elementName, false, converter); - } - - public void initialize(CompilationUnit astRoot) { - String[] javaColumnNames = this.columnNamesAdapter.getValue(astRoot); - for (int i = 0; i < javaColumnNames.length; i++) { - this.columnNames.add(javaColumnNames[i]); - } - } - - public void update(CompilationUnit astRoot) { - this.updateColumnNames(astRoot); - } - - private void updateColumnNames(CompilationUnit astRoot) { - String[] javaColumnNames = this.columnNamesAdapter.getValue(astRoot); - this.synchronizeList(Arrays.asList(javaColumnNames), this.columnNames, COLUMN_NAMES_LIST); - } - - public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.columnNames); - } - - - // ********** UniqueConstraintAnnotation implementation ********** - - // ***** column names - public ListIterator<String> columnNames() { - return new CloneListIterator<String>(this.columnNames); - } - - public int columnNamesSize() { - return this.columnNames.size(); - } - - public void addColumnName(String columnName) { - this.addColumnName(this.columnNames.size(), columnName); - } - - public void addColumnName(int index, String columnName) { - this.addColumnName_(index, columnName); - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); - } - - private void addColumnName_(int index, String columnName) { - this.addItemToList(index, columnName, this.columnNames, COLUMN_NAMES_LIST); - } - - public void moveColumnName(int targetIndex, int sourceIndex) { - this.moveItemInList(targetIndex, sourceIndex, this.columnNames, COLUMN_NAMES_LIST); - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); - } - - public boolean columnNamesTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.columnNamesDeclarationAdapter, pos, astRoot); - } - - public void removeColumnName(String columnName) { - this.removeItemFromList(columnName, this.columnNames, COLUMN_NAMES_LIST); - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); - } - - public void removeColumnName(int index) { - this.removeItemFromList(index, this.columnNames, COLUMN_NAMES_LIST); - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); - } - - - // ********** NestableAnnotation implementation ********** - - public void initializeFrom(NestableAnnotation oldAnnotation) { - UniqueConstraintAnnotation oldConstraint = (UniqueConstraintAnnotation) oldAnnotation; - for (String columnName : CollectionTools.iterable(oldConstraint.columnNames())) { - this.addColumnName(columnName); - } - } - - public void moveAnnotation(int newIndex) { - this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java deleted file mode 100644 index 2b27d2c6c4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.VersionAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.Version - */ -public final class SourceVersionAnnotation - extends SourceAnnotation<Attribute> - implements VersionAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceVersionAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public void update(CompilationUnit astRoot) { - // nothing to update - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/orm/OrmXmlResourceProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/orm/OrmXmlResourceProvider.java deleted file mode 100644 index a7d8735eac..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/orm/OrmXmlResourceProvider.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.orm; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.AbstractXmlResourceProvider; -import org.eclipse.jpt.core.resource.orm.JPA; -import org.eclipse.jpt.core.resource.orm.OrmFactory; -import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; - -public class OrmXmlResourceProvider - extends AbstractXmlResourceProvider -{ - /** - * (Convenience method) Returns an ORM resource model provider for - * the given file. - */ - public static OrmXmlResourceProvider getXmlResourceProvider(IFile file) { - return getXmlResourceProvider_(file.getProject(), file.getFullPath().toString()); - } - - /** - * (Convenience method) Returns an ORM resource model provider for - * the given project in the specified deploy location - */ - public static OrmXmlResourceProvider getXmlResourceProvider(IProject project, String deployLocation) { - return getXmlResourceProvider_(project, JptCorePlugin.getDeploymentURI(project, deployLocation)); - } - - /** - * (Convenience method) Returns an ORM resource model provider for - * the given project in the default deploy location - */ - public static OrmXmlResourceProvider getDefaultXmlResourceProvider(IProject project) { - return getXmlResourceProvider(project, JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH); - } - - private static OrmXmlResourceProvider getXmlResourceProvider_(IProject project, String location) { - return new OrmXmlResourceProvider(project, new Path(location)); - } - - - public OrmXmlResourceProvider(IProject project) { - this(project, new Path(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH)); - } - - public OrmXmlResourceProvider(IProject project, IPath filePath) { - super(project, filePath, JptCorePlugin.ORM_XML_CONTENT_TYPE); - } - - @Override - protected void populateRoot() { - XmlEntityMappings entityMappings = OrmFactory.eINSTANCE.createXmlEntityMappings(); - entityMappings.setVersion(JPA.SCHEMA_VERSION); - getResourceContents().add(entityMappings); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/persistence/PersistenceXmlResourceProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/persistence/PersistenceXmlResourceProvider.java deleted file mode 100644 index e4000d950a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/persistence/PersistenceXmlResourceProvider.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.persistence; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.AbstractXmlResourceProvider; -import org.eclipse.jpt.core.resource.persistence.JPA; -import org.eclipse.jpt.core.resource.persistence.PersistenceFactory; -import org.eclipse.jpt.core.resource.persistence.XmlPersistence; -import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit; - -public class PersistenceXmlResourceProvider - extends AbstractXmlResourceProvider -{ - /** - * (Convenience method) Returns a persistence resource model provider for - * the given file. - */ - public static PersistenceXmlResourceProvider getXmlResourceProvider(IFile file) { - return getXmlResourceProvider_(file.getProject(), file.getFullPath().toString()); - } - - /** - * (Convenience method) Returns an persistence resource model provider for - * the given project in the specified deploy location - */ - public static PersistenceXmlResourceProvider getXmlResourceProvider(IProject project, String deployLocation) { - return getXmlResourceProvider_(project, JptCorePlugin.getDeploymentURI(project, deployLocation)); - } - - /** - * (Convenience method) Returns a persistence resource model provider for - * the given project in the default deploy location - */ - public static PersistenceXmlResourceProvider getDefaultXmlResourceProvider(IProject project) { - return getXmlResourceProvider(project, JptCorePlugin.DEFAULT_PERSISTENCE_XML_FILE_PATH); - } - - private static PersistenceXmlResourceProvider getXmlResourceProvider_(IProject project, String location) { - return new PersistenceXmlResourceProvider(project, new Path(location)); - } - - - public PersistenceXmlResourceProvider(IProject project) { - this(project, new Path(JptCorePlugin.DEFAULT_PERSISTENCE_XML_FILE_PATH)); - } - - public PersistenceXmlResourceProvider(IProject project, IPath filePath) { - super(project, filePath, JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE); - } - - @Override - protected void populateRoot() { - XmlPersistence persistence = PersistenceFactory.eINSTANCE.createXmlPersistence(); - persistence.setVersion(JPA.SCHEMA_VERSION); - XmlPersistenceUnit persistenceUnit = PersistenceFactory.eINSTANCE.createXmlPersistenceUnit(); - persistenceUnit.setName(getProject().getName()); - persistence.getPersistenceUnits().add(persistenceUnit); - getResourceContents().add(persistence); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/XMLRootElementVersionContentDescriber.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/XMLRootElementVersionContentDescriber.java deleted file mode 100644 index daca1e1ac9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/XMLRootElementVersionContentDescriber.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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 - * Jesper Steen Moeller - added namespace support - *******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.xml; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import javax.xml.parsers.ParserConfigurationException; -import org.eclipse.core.internal.content.ContentMessages; -import org.eclipse.core.internal.runtime.RuntimeLog; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.content.XMLContentDescriber; -import org.eclipse.osgi.util.NLS; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -//TODO bug 263976 - copied from org.eclipse.core.runtime.content.XMLRootElementContentDescriber2 -/** - * A content describer for detecting the name of the top-level element, - * its namespace and the DTD system identifier in an XML file. - * <p> - * This executable extension supports "element" parameter, that - * can be specified more than once. If the - * <code>":-"</code> method is used, then the value is treated as - * "element" (always just one) - * </p> - * <p> - * The value of "element" is specified using such a format - * <code>{namespace}name/dtd:version</code>. The namespace or dtd part - * can be omitted and accepted are values like <code>name/dtd</code>, - * <code>{ns}name</code> and <code>name</code>. - * </p> - * <p> - * The describer will detect a document, if it matches at least one "element" - * what means, that dtd, namespace (if specified) and name in "element" - * match those in the document. - * </p> - * <p> - * If the "element" name part is "*", e.g. <code>{namespace}*</code>, - * it denotes a wildcard match. If the "element" namespace part is empty, - * e.g. <code>{}name</code>, only these documents with the root element - * that belong to the unnamed namespace <code><elem xmlns=""></code> - * will be detected. - * </p> - * <p> - * This class should be used instead of {@link XMLRootElementVersionContentDescriber} - * which doesn't detect namespaces and doesn't allow to specify - * more than one set of dtds, root element names and namespaces which - * should be detected. - * </p> - * <p> - * This class is not intended to be subclassed or instantiated by clients, - * only to be referenced by the "describer" configuration element in - * extensions to the <code>org.eclipse.core.runtime.contentTypes</code> - * extension point. - * </p> - * - * @since org.eclipse.core.contenttype 3.3 - */ -public final class XMLRootElementVersionContentDescriber extends XMLContentDescriber implements IExecutableExtension { - private static final String ELEMENT_TO_FIND = "element"; //$NON-NLS-1$ - - /* (Intentionally not included in javadoc) - * The top-level elements we are looking for. This value will be initialized - * by the <code>setInitializationData</code> method. If no value is - * provided, then this means that we don't care what the top-level element - * will be. The list is a collection of <code>QualifiedElement</code>. - */ - private QualifiedElement[] elementsToFind = null; - - /* (Intentionally not included in javadoc) - * Simple value holder for root element name, its namespace and dtd. - */ - static class QualifiedElement { - private String namespace; - private String element; - private String dtd; - private String version; - - QualifiedElement(String namespace, String element, String dtd, String version) { - this.namespace = namespace; - this.element = element; - this.dtd = dtd; - this.version = version; - } - - QualifiedElement(String qualifiedElement) { - // Extract namespace part - int openBrace = qualifiedElement.indexOf('{'); - int closeBrace = qualifiedElement.indexOf('}'); - if (openBrace == 0 && closeBrace >=1 ) { - namespace = qualifiedElement.substring(1, closeBrace); - qualifiedElement = qualifiedElement.substring(closeBrace+1); - } - // Extract dtd part - int dtdSlash = qualifiedElement.indexOf('/'); - if (dtdSlash > 0) { - dtd = qualifiedElement.substring(dtdSlash+1); - qualifiedElement = qualifiedElement.substring(0, dtdSlash); - } - // Extract version part - int versionSlash = qualifiedElement.indexOf(':'); - if (versionSlash > 0) { - version = qualifiedElement.substring(versionSlash + 1); - qualifiedElement = qualifiedElement.substring(0, versionSlash); - } - - // Check if the name is a wildcard - element = ("*".equals(qualifiedElement) ? null : qualifiedElement); - } - - public String getNamespace() { - return namespace; - } - - public String getElement() { - return element; - } - public String getDTD() { - return dtd; - } - - public String getVersion() { - return version; - } - - public boolean matches(String someNamespace, String someElement, String someDtd, String someVersion) { - boolean nsMatch = this.namespace != null ? this.namespace.equals(someNamespace) : true; - boolean elementEquals = this.element != null ? this.element.equals(someElement) : true; - boolean dtdEquals = this.dtd != null ? this.dtd.equals(someDtd) : true; - boolean versionEquals = this.version != null ? this.version.equals(someVersion) : true; - return nsMatch && elementEquals && dtdEquals && versionEquals; - } - } - - /* (Intentionally not included in javadoc) - * Determines the validation status for the given contents. - * - * @param contents the contents to be evaluated - * @return one of the following:<ul> - * <li><code>VALID</code></li>, - * <li><code>INVALID</code></li>, - * <li><code>INDETERMINATE</code></li> - * </ul> - * @throws IOException - */ - private int checkCriteria(InputSource contents) throws IOException { - XMLRootHandler xmlHandler = new XMLRootHandler(elementsToFind != null); - try { - if (!xmlHandler.parseContents(contents)) - return INDETERMINATE; - } catch (SAXException e) { - // we may be handed any kind of contents... it is normal we fail to parse - return INDETERMINATE; - } catch (ParserConfigurationException e) { - // some bad thing happened - force this describer to be disabled - String message = ContentMessages.content_parserConfiguration; - RuntimeLog.log(new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, e)); - throw new RuntimeException(message); - } - // Check to see if we matched our criteria. - if (elementsToFind != null) { - boolean foundOne = false; - for (int i = 0; i < elementsToFind.length && !foundOne; ++i) { - foundOne |= elementsToFind[i].matches(xmlHandler.getRootNamespace(), xmlHandler.getRootName(), xmlHandler.getDTD(), xmlHandler.getVersion()); - } - if (!foundOne) - return INDETERMINATE; - } - // We must be okay then. - return VALID; - } - - /* (Intentionally not included in javadoc) - * @see IContentDescriber#describe(InputStream, IContentDescription) - */ - @Override - public int describe(InputStream contents, IContentDescription description) throws IOException { - // call the basic XML describer to do basic recognition - if (super.describe(contents, description) == INVALID) - return INVALID; - // super.describe will have consumed some chars, need to rewind - contents.reset(); - // Check to see if we matched our criteria. - return checkCriteria(new InputSource(contents)); - } - - /* (Intentionally not included in javadoc) - * @see IContentDescriber#describe(Reader, IContentDescription) - */ - @Override - public int describe(Reader contents, IContentDescription description) throws IOException { - // call the basic XML describer to do basic recognition - if (super.describe(contents, description) == INVALID) - return INVALID; - // super.describe will have consumed some chars, need to rewind - contents.reset(); - // Check to see if we matched our criteria. - return checkCriteria(new InputSource(contents)); - } - - /* (Intentionally not included in javadoc) - * @see IExecutableExtension#setInitializationData - */ - public void setInitializationData(final IConfigurationElement config, final String propertyName, final Object data) throws CoreException { - if (data instanceof String) - elementsToFind = new QualifiedElement[] {new QualifiedElement((String) data)}; - else if (data instanceof Hashtable) { - List elements = null; - - // the describer parameters have to be read again, because "element" parameter can be specified multiple times - // and the given hashtable carries only one of them - IConfigurationElement describerElement = config.getChildren("describer")[0]; //$NON-NLS-1$ - IConfigurationElement[] params = describerElement.getChildren("parameter"); //$NON-NLS-1$ - String pname = null; - for (int i = 0; i < params.length; i++) { - pname = params[i].getAttribute("name"); //$NON-NLS-1$ - if (ELEMENT_TO_FIND.equals(pname)) { - if (elements == null) - elements = new LinkedList(); - elements.add(new QualifiedElement(params[i].getAttribute("value"))); //$NON-NLS-1$ - } - } - - List qualifiedElements = new ArrayList(); - - // create list of qualified elements - if (elements != null) { - for (Iterator it = elements.iterator(); it.hasNext();) { - qualifiedElements.add(it.next()); - } - } - elementsToFind = (QualifiedElement[]) qualifiedElements.toArray(new QualifiedElement[qualifiedElements.size()]); - } - - if (elementsToFind.length == 0) { - String message = NLS.bind(ContentMessages.content_badInitializationData, XMLRootElementVersionContentDescriber.class.getName()); - throw new CoreException(new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, null)); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/XMLRootHandler.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/XMLRootHandler.java deleted file mode 100644 index f2acd33948..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/XMLRootHandler.java +++ /dev/null @@ -1,270 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008 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 - *******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.xml; - -import java.io.IOException; -import java.io.StringReader; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import org.eclipse.jpt.core.JptCorePlugin; -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.XMLReader; -import org.xml.sax.ext.LexicalHandler; -import org.xml.sax.helpers.DefaultHandler; - -//TODO bug 263976 - copied from org.eclipse.core.internal.content.XMLRootHandler -/** - * A content describer for detecting the name of the top-level element of the - * DTD system identifier in an XML file. This supports two parameters: - * <code>DTD_TO_FIND</code> and <code>ELEMENT_TO_FIND</code>. This is done - * using the <code>IExecutableExtension</code> mechanism. If the - * <code>":-"</code> method is used, then the value is treated as the - * <code>ELEMENT_TO_FIND</code>. - * - * @since 3.0 - */ -public final class XMLRootHandler extends DefaultHandler implements LexicalHandler { - /** - * An exception indicating that the parsing should stop. This is usually - * triggered when the top-level element has been found. - * - * @since 3.0 - */ - static class StopParsingException extends SAXException { - /** - * All serializable objects should have a stable serialVersionUID - */ - private static final long serialVersionUID = 1L; - - /** - * Constructs an instance of <code>StopParsingException</code> with a - * <code>null</code> detail message. - */ - public StopParsingException() { - super((String) null); - } - } - - - /** - * Should we check the root element? - */ - private boolean checkRoot; - /** - * The system identifier for the DTD that was found while parsing the XML. - * This member variable is <code>null</code> unless the file has been - * parsed successful to the point of finding the DTD's system identifier. - */ - private String dtdFound = null; - /** - * This is the name of the top-level element found in the XML file. This - * member variable is <code>null</code> unless the file has been parsed - * successful to the point of finding the top-level element. - */ - private String elementFound = null; - - /** - * This is the namespace of the top-level element found in the XML file. This - * member variable is <code>null</code> unless the file has been parsed - * successful to the point of finding the top-level element. - */ - private String namespaceFound = null; - - private String versionFound = null; - - public XMLRootHandler(boolean checkRoot) { - this.checkRoot = checkRoot; - } - - /* - * (non-Javadoc) - * - * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int) - */ - public final void comment(final char[] ch, final int start, final int length) { - // Not interested. - } - - /** - * Creates a new SAX parser for use within this instance. - * - * @return The newly created parser. - * - * @throws ParserConfigurationException - * If a parser of the given configuration cannot be created. - * @throws SAXException - * If something in general goes wrong when creating the parser. - * @throws SAXNotRecognizedException - * If the <code>XMLReader</code> does not recognize the - * lexical handler configuration option. - * @throws SAXNotSupportedException - * If the <code>XMLReader</code> does not support the lexical - * handler configuration option. - */ - private final SAXParser createParser(SAXParserFactory parserFactory) throws ParserConfigurationException, SAXException, SAXNotRecognizedException, SAXNotSupportedException { - // Initialize the parser. - final SAXParser parser = parserFactory.newSAXParser(); - final XMLReader reader = parser.getXMLReader(); - reader.setProperty("http://xml.org/sax/properties/lexical-handler", this); //$NON-NLS-1$ - // disable DTD validation (bug 63625) - try { - // be sure validation is "off" or the feature to ignore DTD's will not apply - reader.setFeature("http://xml.org/sax/features/validation", false); //$NON-NLS-1$ - reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); //$NON-NLS-1$ - } catch (SAXNotRecognizedException e) { - // not a big deal if the parser does not recognize the features - } catch (SAXNotSupportedException e) { - // not a big deal if the parser does not support the features - } - return parser; - } - - /* - * (non-Javadoc) - * - * @see org.xml.sax.ext.LexicalHandler#endCDATA() - */ - public final void endCDATA() { - // Not interested. - } - - /* - * (non-Javadoc) - * - * @see org.xml.sax.ext.LexicalHandler#endDTD() - */ - public final void endDTD() { - // Not interested. - } - - /* - * (non-Javadoc) - * - * @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String) - */ - public final void endEntity(final String name) { - // Not interested. - } - - public String getDTD() { - return dtdFound; - } - - public String getRootName() { - return elementFound; - } - - /** - * @since org.eclipse.core.contenttype 3.3 - */ - public String getRootNamespace() { - return namespaceFound; - } - - public String getVersion() { - return this.versionFound; - } - - - public boolean parseContents(InputSource contents) throws IOException, - ParserConfigurationException, SAXException { - // Parse the file into we have what we need (or an error occurs). - SAXParser parser = null; - - /* - * set context class loader while factories instantiate classes (for - * minimal time) so proper classes, and classloaders, are used in IBM - * JRE, with Xerces on the classpath. See bug 283721. - * (https://bugs.eclipse.org/bugs/show_bug.cgi?id=283721) - */ - ClassLoader savedClassLoader = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); - SAXParserFactory factory = JptCorePlugin.instance().getSAXParserFactory(); - if (factory == null) - return false; - parser = createParser(factory); - } finally { - Thread.currentThread().setContextClassLoader(savedClassLoader); - } - // to support external entities specified as relative URIs (see - // bug 63298) - contents.setSystemId("/"); //$NON-NLS-1$ - try { - parser.parse(contents, this); - } catch (StopParsingException e) { - // Abort the parsing normally. Fall through... - } - - return true; - } - - /* - * Resolve external entity definitions to an empty string. This is to speed - * up processing of files with external DTDs. Not resolving the contents - * of the DTD is ok, as only the System ID of the DTD declaration is used. - * @see org.xml.sax.helpers.DefaultHandler#resolveEntity(java.lang.String, java.lang.String) - */ - @Override - public InputSource resolveEntity(String publicId, String systemId) throws SAXException { - return new InputSource(new StringReader("")); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.xml.sax.ext.LexicalHandler#startCDATA() - */ - public final void startCDATA() { - // Not interested. - } - - /* - * (non-Javadoc) - * - * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, - * java.lang.String, java.lang.String) - */ - public final void startDTD(final String name, final String publicId, final String systemId) throws SAXException { - dtdFound = systemId; - // If we don't care about the top-level element, we can stop here. - if (!checkRoot) - throw new StopParsingException(); - } - - /* - * (non-Javadoc) - * - * @see org.xml.sax.ContentHandler#startElement(java.lang.String, - * java.lang.String, java.lang.String, org.xml.sax.Attributes) - */ - @Override - public final void startElement(final String uri, final String elementName, final String qualifiedName, final Attributes attributes) throws SAXException { - elementFound = elementName; - namespaceFound = uri; - versionFound = attributes.getValue("version"); - throw new StopParsingException(); - } - - /* - * (non-Javadoc) - * - * @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String) - */ - public final void startEntity(final String name) { - // Not interested. - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/BooleanTranslator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/BooleanTranslator.java deleted file mode 100644 index bd843f0a1b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/BooleanTranslator.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.xml.translators; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.wst.common.internal.emf.resource.Translator; - -public class BooleanTranslator - extends Translator -{ - public BooleanTranslator(String domPathAndNames, EStructuralFeature structuralFeature) { - super(domPathAndNames, structuralFeature, BOOLEAN_FEATURE | BOOLEAN_LOWERCASE); - } - - public BooleanTranslator(String domPathAndNames, EStructuralFeature structuralFeature, int style) { - super(domPathAndNames, structuralFeature, BOOLEAN_FEATURE | BOOLEAN_LOWERCASE | style); - } - - @Override - public Object convertStringToValue(String string, EObject owner) { - return Boolean.valueOf(string); - } - - @Override - public String convertValueToString(Object value, EObject owner) { - return ((Boolean) value).toString(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/EmptyTagBooleanTranslator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/EmptyTagBooleanTranslator.java deleted file mode 100644 index 18e56ca0eb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/EmptyTagBooleanTranslator.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.xml.translators; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.wst.common.internal.emf.resource.Translator; - -/** - * This translator is to be used for empty xml tags that correspond - * to a boolean attribute in the emf model. - * cascade-persist is an example from the orm.xsd: - * - * <persistence-unit-defaults> - * <cascade-persist/> - * </persistence-unit-defaults> ==> cascadePersist == true - * - * vs. - * - * <persistence-unit-defaults> - * </persistence-unit-defaults> ==> cascadePersist == false - * - */ -public class EmptyTagBooleanTranslator - extends Translator -{ - public EmptyTagBooleanTranslator(String domPathAndNames, EStructuralFeature structuralFeature) { - super(domPathAndNames, structuralFeature, EMPTY_TAG | BOOLEAN_FEATURE); - } - - public EmptyTagBooleanTranslator(String domPathAndNames, EStructuralFeature structuralFeature, int style) { - super(domPathAndNames, structuralFeature, style | EMPTY_TAG | BOOLEAN_FEATURE); - } - - @Override - public Object getMOFValue(EObject mofObject) { - // I am overriding this method. This is so the tag will be removed when - // the value is false. - // I'm not sure if this is a bug in the ecore or maybe in the translators, - // but I really don't think that we should have to depend on the boolean - // being "unset" to remove the tag. - Boolean value = (Boolean) super.getMOFValue(mofObject); - return (value == null) ? null : value.booleanValue() ? value : null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/SimpleRootTranslator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/SimpleRootTranslator.java deleted file mode 100644 index 5e29735fff..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/SimpleRootTranslator.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.xml.translators; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.jpt.utility.internal.ArrayTools; -import org.eclipse.wst.common.internal.emf.resource.RootTranslator; -import org.eclipse.wst.common.internal.emf.resource.Translator; - -/** - * Root translator that contains a list of child translators and no special - * behavior. - */ -public class SimpleRootTranslator - extends RootTranslator -{ - protected Translator[] children; - - public SimpleRootTranslator(String domPathAndNames, EClass eClass) { - super(domPathAndNames, eClass); - } - - public SimpleRootTranslator(String domPathAndNames, EClass eClass, Translator[] children) { - super(domPathAndNames, eClass); - this.children = children; - } - - /** - * Widen method access to 'public'. - */ - @Override - public Translator[] getChildren() { - return this.children; - } - - protected Translator[] getChildren_() { - return (this.children == null) ? EMPTY_TRANSLATOR_ARRAY : this.children; - } - protected static final Translator[] EMPTY_TRANSLATOR_ARRAY = new Translator[0]; - - /** - * Set the translator's children. - * Return the translator. - */ - public void setChildren(Translator[] children) { - this.children = children; - } - - /** - * Add the specified translator to the translator's list of children. - * Return the translator for method chaining. - */ - public SimpleRootTranslator addChild(Translator translator) { - this.children = ArrayTools.add(this.getChildren_(), translator); - return this; - } - - /** - * Add the specified translators to the translator's list of children. - * Return the translator for method chaining. - */ - public SimpleRootTranslator addChildren(Translator[] translators) { - this.children = ArrayTools.addAll(this.getChildren_(), translators); - return this; - } - - /** - * Remove the specified translator from the translator's list of children. - * Return the translator for method chaining. - */ - public SimpleRootTranslator removeChild(Translator translator) { - this.children = ArrayTools.remove(this.children, translator); - return this; - } - - /** - * Remove the specified translators from the translator's list of children. - * Return the translator for method chaining. - */ - public SimpleRootTranslator removeChildren(Translator[] translators) { - this.children = ArrayTools.removeAll(this.children, (Object[]) translators); - return this; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/SimpleTranslator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/SimpleTranslator.java deleted file mode 100644 index 6132344e1e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/translators/SimpleTranslator.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.core.internal.resource.xml.translators; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jpt.utility.internal.ArrayTools; -import org.eclipse.wst.common.internal.emf.resource.Translator; -import org.eclipse.wst.common.internal.emf.resource.TranslatorPath; - -/** - * Translator that contains a list of child translators and no special - * behavior. - */ -public class SimpleTranslator - extends Translator -{ - protected Translator[] children; - - - // ********** constructors ********** - - public SimpleTranslator(String domPathAndNames, EClass eClass) { - super(domPathAndNames, eClass); - } - - public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature) { - super(domPathAndNames, eStructuralFeature); - } - - public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, Translator[] children) { - super(domPathAndNames, eStructuralFeature); - this.children = children; - } - - public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, EClass eClass) { - super(domPathAndNames, eStructuralFeature, eClass); - } - - public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, EClass eClass, Translator[] children) { - super(domPathAndNames, eStructuralFeature, eClass); - this.children = children; - } - - public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, TranslatorPath translatorPath) { - super(domPathAndNames, eStructuralFeature, translatorPath); - } - - public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, TranslatorPath[] translatorPaths) { - super(domPathAndNames, eStructuralFeature, translatorPaths); - } - - public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, int style) { - super(domPathAndNames, eStructuralFeature, style); - } - - public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, int style, Translator[] children) { - super(domPathAndNames, eStructuralFeature, style); - this.children = children; - } - - - // ********** children ********** - - /** - * Widen method access to 'public'. - */ - @Override - public Translator[] getChildren() { - return this.children; - } - - protected Translator[] getChildren_() { - return (this.children == null) ? EMPTY_TRANSLATOR_ARRAY : this.children; - } - protected static final Translator[] EMPTY_TRANSLATOR_ARRAY = new Translator[0]; - - /** - * Set the translator's children. - * Return the translator. - */ - public void setChildren(Translator[] children) { - this.children = children; - } - - /** - * Add the specified translator to the translator's list of children. - * Return the translator for method chaining. - */ - public SimpleTranslator addChild(Translator translator) { - this.children = ArrayTools.add(this.getChildren_(), translator); - return this; - } - - /** - * Add the specified translators to the translator's list of children. - * Return the translator for method chaining. - */ - public SimpleTranslator addChildren(Translator[] translators) { - this.children = ArrayTools.addAll(this.getChildren_(), translators); - return this; - } - - /** - * Remove the specified translator from the translator's list of children. - * Return the translator for method chaining. - */ - public SimpleTranslator removeChild(Translator translator) { - this.children = ArrayTools.remove(this.children, translator); - return this; - } - - /** - * Remove the specified translators from the translator's list of children. - * Return the translator for method chaining. - */ - public SimpleTranslator removeChildren(Translator[] translators) { - this.children = ArrayTools.removeAll(this.children, (Object[]) translators); - return this; - } - -} |