### Eclipse Workspace Patch 1.0 #P org.eclipse.jpt.eclipselink.core Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicCollectionImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicCollectionImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicCollectionImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicCollectionImpl.java 11 Nov 2008 15:47:18 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,75 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.BasicCollectionAnnotation; - - -public class BasicCollectionImpl extends AbstractResourceAnnotation implements BasicCollectionAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - protected BasicCollectionImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void update(CompilationUnit astRoot) { - } - - public static class BasicCollectionAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final BasicCollectionAnnotationDefinition INSTANCE = new BasicCollectionAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static BasicCollectionAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private BasicCollectionAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new BasicCollectionImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/JoinFetchImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/JoinFetchImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/JoinFetchImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/JoinFetchImpl.java 23 Oct 2008 19:04:13 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,123 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.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.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.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchAnnotation; -import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType; - - -public class JoinFetchImpl extends AbstractResourceAnnotation implements JoinFetchAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter valueAdapter; - - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - - private JoinFetchType value; - - protected JoinFetchImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(attribute, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** CacheAnnotation implementation **************** - - public JoinFetchType getValue() { - return this.value; - } - - public void setValue(JoinFetchType newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - JoinFetchType oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(JoinFetchType.toJavaAnnotationValue(newValue)); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected JoinFetchType value(CompilationUnit astRoot) { - return JoinFetchType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.JOIN_FETCH_VALUE, false); - } - - public static class JoinFetchAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final JoinFetchAnnotationDefinition INSTANCE = new JoinFetchAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static JoinFetchAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private JoinFetchAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new JoinFetchImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullJoinFetchAnnotation((JavaResourcePersistentAttribute) parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullWriteTransformerColumn.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullWriteTransformerColumn.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullWriteTransformerColumn.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullWriteTransformerColumn.java 5 Sep 2008 15:27:21 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.NullBaseColumn; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.eclipselink.core.resource.java.WriteTransformerAnnotation; - - -public class NullWriteTransformerColumn extends NullBaseColumn implements ColumnAnnotation, Annotation -{ - public NullWriteTransformerColumn(WriteTransformerAnnotation parent) { - super(parent); - } - - @Override - public WriteTransformerAnnotation getParent() { - return (WriteTransformerAnnotation) super.getParent(); - } - - public String getAnnotationName() { - return ColumnAnnotation.ANNOTATION_NAME; - } - - @Override - protected ColumnAnnotation createResourceColumn() { - return getParent().addColumn(); - } - - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - if (length != null) { - createResourceColumn().setLength(length); - } - } - - public Integer getScale() { - return null; - } - - public void setScale(Integer scale) { - if (scale != null) { - createResourceColumn().setScale(scale); - } - } - - public Integer getPrecision() { - return null; - } - - public void setPrecision(Integer precision) { - if (precision != null) { - createResourceColumn().setPrecision(precision); - } - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - return null; - } -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadOnlyImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadOnlyImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadOnlyImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadOnlyImpl.java 23 Oct 2008 19:04:13 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,77 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.eclipselink.core.resource.java.ReadOnlyAnnotation; - - -public class ReadOnlyImpl extends AbstractResourceAnnotation implements ReadOnlyAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected ReadOnlyImpl(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public void update(CompilationUnit astRoot) { - //nothing to update - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - public static class ReadOnlyAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final ReadOnlyAnnotationDefinition INSTANCE = new ReadOnlyAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ReadOnlyAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new ReadOnlyImpl(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullTransformation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullTransformation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullTransformation.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullTransformation.java 2 Sep 2008 17:55:14 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,93 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.eclipselink.core.resource.java.TransformationAnnotation; - - -public class NullTransformation extends AbstractJavaResourceNode implements BasicAnnotation, Annotation -{ - protected NullTransformation(JavaResourcePersistentMember parent) { - super(parent); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return TransformationAnnotation.ANNOTATION_NAME; - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - protected TransformationAnnotation createTransformationResource() { - getParent().setMappingAnnotation(getAnnotationName()); - return (TransformationAnnotation) getParent().getMappingAnnotation(); - } - - public FetchType getFetch() { - return null; - } - - public void setFetch(FetchType fetch) { - if (fetch != null) { - createTransformationResource().setFetch(fetch); - } - } - - public Boolean getOptional() { - return null; - } - - public void setOptional(Boolean optional) { - if (optional != null) { - createTransformationResource().setOptional(optional); - } - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return null; - } -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ObjectTypeConverterImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ObjectTypeConverterImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ObjectTypeConverterImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ObjectTypeConverterImpl.java 23 Oct 2008 19:04:13 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,392 +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.eclipselink.core.internal.resource.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -import org.eclipse.jpt.core.internal.resource.java.ContainerAnnotationTools; -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.internal.utility.jdt.StringExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.TypeStringExpressionConverter; -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.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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; -import org.eclipse.jpt.eclipselink.core.resource.java.ConversionValueAnnotation; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.NestableConversionValue; -import org.eclipse.jpt.eclipselink.core.resource.java.ObjectTypeConverterAnnotation; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - - -public class ObjectTypeConverterImpl extends AbstractResourceAnnotation implements ObjectTypeConverterAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter nameAdapter; - private final AnnotationElementAdapter dataTypeAdapter; - private final AnnotationElementAdapter objectTypeAdapter; - private final AnnotationElementAdapter defaultObjectValueAdapter; - - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildNameAdapter(); - private static final DeclarationAnnotationElementAdapter DATA_TYPE_ADAPTER = buildDataTypeAdapter(); - private static final DeclarationAnnotationElementAdapter OBJECT_TYPE_ADAPTER = buildObjectTypeAdapter(); - private static final DeclarationAnnotationElementAdapter DEFAULT_OBJECT_VALUE_ADAPTER = buildDefaultObjectValueAdapter(); - - - private String name; - private String dataType; - private String objectType; - private String defaultObjectValue; - - protected final List conversionValues; - private final ConversionValuesContainerAnnotation conversionValuesContainerAnnotation; - - protected ObjectTypeConverterImpl(JavaResourcePersistentMember parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter(member, NAME_ADAPTER); - this.dataTypeAdapter = new ShortCircuitAnnotationElementAdapter(member, DATA_TYPE_ADAPTER); - this.objectTypeAdapter = new ShortCircuitAnnotationElementAdapter(member, OBJECT_TYPE_ADAPTER); - this.defaultObjectValueAdapter = new ShortCircuitAnnotationElementAdapter(member, DEFAULT_OBJECT_VALUE_ADAPTER); - this.conversionValues = new ArrayList(); - this.conversionValuesContainerAnnotation = new ConversionValuesContainerAnnotation(); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - this.dataType = this.dataType(astRoot); - this.objectType = this.objectType(astRoot); - this.defaultObjectValue = this.defaultObjectValue(astRoot); - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this.conversionValuesContainerAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** ObjectTypeConverter implementation **************** - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public String getDataType() { - return this.dataType; - } - - public void setDataType(String newDataType) { - if (attributeValueHasNotChanged(this.dataType, newDataType)) { - return; - } - String oldDataType = this.dataType; - this.dataType = newDataType; - this.dataTypeAdapter.setValue(newDataType); - firePropertyChanged(DATA_TYPE_PROPERTY, oldDataType, newDataType); - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String newObjectType) { - if (attributeValueHasNotChanged(this.objectType, newObjectType)) { - return; - } - String oldObjectType = this.objectType; - this.objectType = newObjectType; - this.objectTypeAdapter.setValue(newObjectType); - firePropertyChanged(OBJECT_TYPE_PROPERTY, oldObjectType, newObjectType); - } - - public String getDefaultObjectValue() { - return this.defaultObjectValue; - } - - public void setDefaultObjectValue(String newDefaultObjectValue) { - if (attributeValueHasNotChanged(this.defaultObjectValue, newDefaultObjectValue)) { - return; - } - String oldDefaultObjectValue = this.defaultObjectValue; - this.defaultObjectValue = newDefaultObjectValue; - this.defaultObjectValueAdapter.setValue(newDefaultObjectValue); - firePropertyChanged(DEFAULT_OBJECT_VALUE_PROPERTY, oldDefaultObjectValue, newDefaultObjectValue); - } - - public ListIterator conversionValues() { - return new CloneListIterator(this.conversionValues); - } - - public int conversionValuesSize() { - return this.conversionValues.size(); - } - - public NestableConversionValue conversionValueAt(int index) { - return this.conversionValues.get(index); - } - - public int indexOfConversionValue(ConversionValueAnnotation conversionValue) { - return this.conversionValues.indexOf(conversionValue); - } - - public NestableConversionValue addConversionValue(int index) { - NestableConversionValue conversionValue = (NestableConversionValue) ContainerAnnotationTools.addNestedAnnotation(index, this.conversionValuesContainerAnnotation); - fireItemAdded(AssociationOverrideAnnotation.JOIN_COLUMNS_LIST, index, conversionValue); - return conversionValue; - } - - protected void addConversionValue(int index, NestableConversionValue conversionValue) { - addItemToList(index, conversionValue, this.conversionValues, AssociationOverrideAnnotation.JOIN_COLUMNS_LIST); - } - - public void removeConversionValue(int index) { - NestableConversionValue conversionValue = this.conversionValues.get(index); - removeConversionValue(conversionValue); - conversionValue.removeAnnotation(); - ContainerAnnotationTools.synchAnnotationsAfterRemove(index, this.conversionValuesContainerAnnotation); - } - - protected void removeConversionValue(NestableConversionValue conversionValue) { - removeItemFromList(conversionValue, this.conversionValues, AssociationOverrideAnnotation.JOIN_COLUMNS_LIST); - } - - public void moveConversionValue(int targetIndex, int sourceIndex) { - moveConversionValueInternal(targetIndex, sourceIndex); - ContainerAnnotationTools.synchAnnotationsAfterMove(targetIndex, sourceIndex, this.conversionValuesContainerAnnotation); - fireItemMoved(AssociationOverrideAnnotation.JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - protected void moveConversionValueInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.conversionValues, targetIndex, sourceIndex); - } - - protected NestableConversionValue createConversionValue(int index) { - return ConversionValueImpl.createConversionValue(this, getMember(), getDeclarationAnnotationAdapter(), index); - } - - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(NAME_ADAPTER, astRoot); - } - - public TextRange getDataTypeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(DATA_TYPE_ADAPTER, astRoot); - } - - public TextRange getObjectTypeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(OBJECT_TYPE_ADAPTER, astRoot); - } - - public TextRange getDefaultObjectValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(DEFAULT_OBJECT_VALUE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - this.setDataType(this.dataType(astRoot)); - this.setObjectType(this.objectType(astRoot)); - this.setDefaultObjectValue(this.defaultObjectValue(astRoot)); - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this.conversionValuesContainerAnnotation); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - protected String dataType(CompilationUnit astRoot) { - return this.dataTypeAdapter.getValue(astRoot); - } - - protected String objectType(CompilationUnit astRoot) { - return this.objectTypeAdapter.getValue(astRoot); - } - - protected String defaultObjectValue(CompilationUnit astRoot) { - return this.defaultObjectValueAdapter.getValue(astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildNameAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.OBJECT_TYPE_CONVERTER__NAME, false, StringExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildDataTypeAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.OBJECT_TYPE_CONVERTER__DATE_TYPE, false, TypeStringExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildObjectTypeAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.OBJECT_TYPE_CONVERTER__OBJECT_TYPE, false, TypeStringExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildDefaultObjectValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.OBJECT_TYPE_CONVERTER__DEFAULT_OBJECT_VALUE, false, StringExpressionConverter.instance()); - } - - public static class ObjectTypeConverterAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final ObjectTypeConverterAnnotationDefinition INSTANCE = new ObjectTypeConverterAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static ObjectTypeConverterAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ObjectTypeConverterAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new ObjectTypeConverterImpl(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - private class ConversionValuesContainerAnnotation extends AbstractJavaResourceNode - implements ContainerAnnotation - { - public ConversionValuesContainerAnnotation() { - super(ObjectTypeConverterImpl.this); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public NestableConversionValue addInternal(int index) { - NestableConversionValue conversionValue = ObjectTypeConverterImpl.this.createConversionValue(index); - ObjectTypeConverterImpl.this.conversionValues.add(index, conversionValue); - return conversionValue; - } - - public NestableConversionValue add(int index) { - NestableConversionValue conversionValue = ObjectTypeConverterImpl.this.createConversionValue(index); - ObjectTypeConverterImpl.this.addConversionValue(index, conversionValue); - return conversionValue; - } - - public int indexOf(NestableConversionValue conversionValue) { - return ObjectTypeConverterImpl.this.indexOfConversionValue(conversionValue); - } - - public void move(int targetIndex, int sourceIndex) { - ObjectTypeConverterImpl.this.moveConversionValue(targetIndex, sourceIndex); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - ObjectTypeConverterImpl.this.moveConversionValueInternal(targetIndex, sourceIndex); - } - - public NestableConversionValue nestedAnnotationAt(int index) { - return ObjectTypeConverterImpl.this.conversionValueAt(index); - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(ObjectTypeConverterImpl.this.conversionValues); - } - - public int nestedAnnotationsSize() { - return conversionValuesSize(); - } - - public void remove(int index) { - this.remove(nestedAnnotationAt(index)); - } - - public void remove(NestableConversionValue conversionValue) { - ObjectTypeConverterImpl.this.removeConversionValue(conversionValue); - } - - public String getAnnotationName() { - return ObjectTypeConverterImpl.this.getAnnotationName(); - } - - public String getNestableAnnotationName() { - return EclipseLinkJPA.CONVERSION_VALUE; - } - - public NestableConversionValue nestedAnnotationFor(org.eclipse.jdt.core.dom.Annotation jdtAnnotation) { - for (NestableConversionValue conversionValue : CollectionTools.iterable(nestedAnnotations())) { - if (jdtAnnotation == conversionValue.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return conversionValue; - } - } - return null; - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return ObjectTypeConverterImpl.this.getJdtAnnotation(astRoot); - } - - public void newAnnotation() { - ObjectTypeConverterImpl.this.newAnnotation(); - } - - public void removeAnnotation() { - ObjectTypeConverterImpl.this.removeAnnotation(); - } - - public void update(CompilationUnit astRoot) { - ObjectTypeConverterImpl.this.update(astRoot); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return ObjectTypeConverterImpl.this.getTextRange(astRoot); - } - - public String getElementName() { - return EclipseLinkJPA.OBJECT_TYPE_CONVERTER__CONVERSION_VALUES; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getAnnotationName()); - } - - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TransformationImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TransformationImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TransformationImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TransformationImpl.java 23 Oct 2008 19:04:13 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,156 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.TransformationAnnotation; - - -public class TransformationImpl extends AbstractResourceAnnotation implements TransformationAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter optionalAdapter; - - private final AnnotationElementAdapter fetchAdapter; - - private static final DeclarationAnnotationElementAdapter OPTIONAL_ADAPTER = buildOptionalAdapter(); - - private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); - - private Boolean optional; - - private FetchType fetch; - - protected TransformationImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.optionalAdapter = new ShortCircuitAnnotationElementAdapter(attribute, OPTIONAL_ADAPTER); - this.fetchAdapter = new ShortCircuitAnnotationElementAdapter(attribute, FETCH_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.optional = this.optional(astRoot); - this.fetch = this.fetch(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** Transformation implementation **************** - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean newOptional) { - if (attributeValueHasNotChanged(this.optional, newOptional)) { - return; - } - Boolean oldOptional = this.optional; - this.optional = newOptional; - this.optionalAdapter.setValue(newOptional); - firePropertyChanged(OPTIONAL_PROPERTY, oldOptional, newOptional); - } - - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType newFetch) { - if (attributeValueHasNotChanged(this.fetch, newFetch)) { - return; - } - FetchType oldFetch = this.fetch; - this.fetch = newFetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(newFetch)); - firePropertyChanged(FETCH_PROPERTY, oldFetch, newFetch); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(FETCH_ADAPTER, astRoot); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(OPTIONAL_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setOptional(this.optional(astRoot)); - this.setFetch(this.fetch(astRoot)); - } - - protected FetchType fetch(CompilationUnit astRoot) { - return FetchType.fromJavaAnnotationValue(this.fetchAdapter.getValue(astRoot)); - } - - protected Boolean optional(CompilationUnit astRoot) { - return this.optionalAdapter.getValue(astRoot); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildOptionalAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.TRANSFORMATION__OPTIONAL, false, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildFetchAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.TRANSFORMATION__FETCH, false); - } - - public static class TransformationAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final TransformationAnnotationDefinition INSTANCE = new TransformationAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static TransformationAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TransformationAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new TransformationImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullTransformation(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ExistenceCheckingImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ExistenceCheckingImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ExistenceCheckingImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ExistenceCheckingImpl.java 23 Oct 2008 19:04:13 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,123 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.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.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; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.ExistenceCheckingAnnotation; -import org.eclipse.jpt.eclipselink.core.resource.java.ExistenceType; - - -public class ExistenceCheckingImpl extends AbstractResourceAnnotation implements ExistenceCheckingAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter valueAdapter; - - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - - private ExistenceType value; - - protected ExistenceCheckingImpl(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(type, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** CacheAnnotation implementation **************** - - public ExistenceType getValue() { - return this.value; - } - - public void setValue(ExistenceType newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - ExistenceType oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(ExistenceType.toJavaAnnotationValue(newValue)); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected ExistenceType value(CompilationUnit astRoot) { - return ExistenceType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.EXISTENCE_CHECKING__VALUE, false); - } - - public static class ExistenceCheckingAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final ExistenceCheckingAnnotationDefinition INSTANCE = new ExistenceCheckingAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static ExistenceCheckingAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ExistenceCheckingAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new ExistenceCheckingImpl((JavaResourcePersistentType) parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/WriteTransformerImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/WriteTransformerImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/WriteTransformerImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/WriteTransformerImpl.java 23 Oct 2008 19:04:13 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,220 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -import org.eclipse.jpt.core.internal.resource.java.ColumnImpl; -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.NestedDeclarationAnnotationAdapter; -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.WriteTransformerAnnotation; - - -public class WriteTransformerImpl extends AbstractResourceAnnotation implements WriteTransformerAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter transformerClassAdapter; - private final AnnotationElementAdapter methodAdapter; - private final MemberAnnotationAdapter columnAdapter; - - private static final DeclarationAnnotationElementAdapter TRANSFORMER_CLASS_ADAPTER = buildTransformerClassAdapter(); - private static final DeclarationAnnotationElementAdapter METHOD_ADAPTER = buildMethodAdapter(); - - private String transformerClass; - private String method; - private ColumnImpl column; - - - protected WriteTransformerImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.transformerClassAdapter = new ShortCircuitAnnotationElementAdapter(attribute, TRANSFORMER_CLASS_ADAPTER); - this.methodAdapter = new ShortCircuitAnnotationElementAdapter(attribute, METHOD_ADAPTER); - this.columnAdapter = new MemberAnnotationAdapter(getMember(), buildColumnAnnotationAdapter(getDeclarationAnnotationAdapter())); - } - - public void initialize(CompilationUnit astRoot) { - this.transformerClass = this.transformerClass(astRoot); - this.method = this.method(astRoot); - if (this.columnAdapter.getAnnotation(astRoot) != null) { - this.column = createColumn(this, getMember(), getDeclarationAnnotationAdapter()); - this.column.initialize(astRoot); - } - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** WriteTransformer implementation **************** - public String getTransformerClass() { - return this.transformerClass; - } - - public void setTransformerClass(String newTransformerClass) { - if (attributeValueHasNotChanged(this.transformerClass, newTransformerClass)) { - return; - } - String oldTransformerClass = this.transformerClass; - this.transformerClass = newTransformerClass; - this.transformerClassAdapter.setValue(newTransformerClass); - firePropertyChanged(TRANSFORMER_CLASS_PROPERTY, oldTransformerClass, newTransformerClass); - } - - public String getMethod() { - return this.method; - } - - public void setMethod(String newMethod) { - if (attributeValueHasNotChanged(this.method, newMethod)) { - return; - } - String oldMethod = this.method; - this.method = newMethod; - this.methodAdapter.setValue(newMethod); - firePropertyChanged(METHOD_PROPERTY, oldMethod, newMethod); - } - - public ColumnAnnotation getNonNullColumn() { - return (getColumn() != null) ? getColumn() : new NullWriteTransformerColumn(this); - } - - public ColumnAnnotation getColumn() { - return this.column; - } - - public ColumnAnnotation addColumn() { - ColumnImpl column = createColumn(this, getMember(), getDeclarationAnnotationAdapter()); - column.newAnnotation(); - setColumn(column); - return column; - } - - public void removeColumn() { - this.column.removeAnnotation(); - setColumn(null); - } - - protected void setColumn(ColumnImpl newColumn) { - ColumnImpl oldColumn = this.column; - this.column = newColumn; - firePropertyChanged(WriteTransformerAnnotation.COLUMN_PROPERTY, oldColumn, newColumn); - } - - - public TextRange getTransformerClassTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(TRANSFORMER_CLASS_ADAPTER, astRoot); - } - - public TextRange getMethodTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(METHOD_ADAPTER, astRoot); - } - - public TextRange getColumnTextRange(CompilationUnit astRoot) { - if (this.column != null) { - return this.column.getTextRange(astRoot); - } - return getTextRange(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setTransformerClass(this.transformerClass(astRoot)); - this.setMethod(this.method(astRoot)); - if (this.columnAdapter.getAnnotation(astRoot) == null) { - this.setColumn(null); - } - else { - if (getColumn() != null) { - getColumn().update(astRoot); - } - else { - ColumnImpl column = createColumn(this, getMember(), getDeclarationAnnotationAdapter()); - column.initialize(astRoot); - this.setColumn(column); - } - } - } - - protected String transformerClass(CompilationUnit astRoot) { - return this.transformerClassAdapter.getValue(astRoot); - } - - protected String method(CompilationUnit astRoot) { - return this.methodAdapter.getValue(astRoot); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildTransformerClassAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.WRITE_TRANSFORMER__TRANSFORMER_CLASS, false, SimpleTypeStringExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildMethodAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.WRITE_TRANSFORMER__METHOD, false); - } - - private static DeclarationAnnotationAdapter buildColumnAnnotationAdapter(DeclarationAnnotationAdapter writeTransformerAnnotationAdapter) { - return new NestedDeclarationAnnotationAdapter(writeTransformerAnnotationAdapter, EclipseLinkJPA.WRITE_TRANSFORMER__COLUMN, JPA.COLUMN, false); - } - - private static ColumnImpl createColumn(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter writeTransformerAnnotationAdapter) { - return new ColumnImpl(parent, member, buildColumnAnnotationAdapter(writeTransformerAnnotationAdapter)); - } - - public static class WriteTransformerAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final WriteTransformerAnnotationDefinition INSTANCE = new WriteTransformerAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static WriteTransformerAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private WriteTransformerAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new WriteTransformerImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/VariableOneToOneImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/VariableOneToOneImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/VariableOneToOneImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/VariableOneToOneImpl.java 6 Jan 2009 22:48:26 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.VariableOneToOneAnnotation; - - -public class VariableOneToOneImpl extends AbstractResourceAnnotation implements VariableOneToOneAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - protected VariableOneToOneImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void update(CompilationUnit astRoot) { - } - - public static class VariableOneToOneAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final VariableOneToOneAnnotationDefinition INSTANCE = new VariableOneToOneAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static VariableOneToOneAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private VariableOneToOneAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new VariableOneToOneImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/MutableImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/MutableImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/MutableImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/MutableImpl.java 23 Oct 2008 19:04:13 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,121 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.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.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.MutableAnnotation; - - -public class MutableImpl extends AbstractResourceAnnotation implements MutableAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter valueAdapter; - - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - - private Boolean value; - - protected MutableImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(attribute, VALUE_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** Mutable implementation **************** - public Boolean getValue() { - return this.value; - } - - public void setValue(Boolean newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - Boolean oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(newValue); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected Boolean value(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.MUTABLE__VALUE, false, BooleanExpressionConverter.instance()); - } - - - public static class MutableAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final MutableAnnotationDefinition INSTANCE = new MutableAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static MutableAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MutableAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new MutableImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java 23 Oct 2008 19:04:13 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,423 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; -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.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.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; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; -import org.eclipse.jpt.eclipselink.core.resource.java.CacheCoordinationType; -import org.eclipse.jpt.eclipselink.core.resource.java.CacheType; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; - - -public class CacheImpl extends AbstractResourceAnnotation implements CacheAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter typeAdapter; - private final AnnotationElementAdapter sizeAdapter; - private final AnnotationElementAdapter sharedAdapter; - private final AnnotationElementAdapter expiryAdapter; - private final AnnotationElementAdapter alwaysRefreshAdapter; - private final AnnotationElementAdapter refreshOnlyIfNewerAdapter; - private final AnnotationElementAdapter disableHitsAdapter; - private final AnnotationElementAdapter coordinationTypeAdapter; - private final MemberAnnotationAdapter expiryTimeOfDayAdapter; - - private static final DeclarationAnnotationElementAdapter TYPE_ADAPTER = buildTypeAdapter(); - private static final DeclarationAnnotationElementAdapter SIZE_ADAPTER = buildSizeAdapter(); - private static final DeclarationAnnotationElementAdapter SHARED_ADAPTER = buildSharedAdapter(); - private static final DeclarationAnnotationElementAdapter EXPIRY_ADAPTER = buildExpiryAdapter(); - private static final DeclarationAnnotationElementAdapter ALWAYS_REFRESH_ADAPTER = buildAlwaysRefreshAdapter(); - private static final DeclarationAnnotationElementAdapter REFRESH_ONLY_IF_NEWER_ADAPTER = buildRefreshOnlyIfNewerAdapter(); - private static final DeclarationAnnotationElementAdapter DISABLE_HITS_ADAPTER = buildDisableHitsAdapter(); - private static final DeclarationAnnotationElementAdapter COORDINATION_TYPE_ADAPTER = buildCoordinationTypeAdapter(); - private static final NestedDeclarationAnnotationAdapter EXPIRY_TIME_OF_DAY_ADAPTER = buildExpiryTimeOfDayAnnotationAdapter(); - - - private CacheType type; - private Integer size; - private Boolean shared; - private Integer expiry; - private TimeOfDayAnnotation expiryTimeOfDay; - private Boolean alwaysRefresh; - private Boolean refreshOnlyIfNewer; - private Boolean disableHits; - private CacheCoordinationType coordinationType; - - protected CacheImpl(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.typeAdapter = new ShortCircuitAnnotationElementAdapter(type, TYPE_ADAPTER); - this.sizeAdapter = new ShortCircuitAnnotationElementAdapter(type, SIZE_ADAPTER); - this.sharedAdapter = new ShortCircuitAnnotationElementAdapter(type, SHARED_ADAPTER); - this.expiryAdapter = new ShortCircuitAnnotationElementAdapter(type, EXPIRY_ADAPTER); - this.alwaysRefreshAdapter = new ShortCircuitAnnotationElementAdapter(type, ALWAYS_REFRESH_ADAPTER); - this.refreshOnlyIfNewerAdapter = new ShortCircuitAnnotationElementAdapter(type, REFRESH_ONLY_IF_NEWER_ADAPTER); - this.disableHitsAdapter = new ShortCircuitAnnotationElementAdapter(type, DISABLE_HITS_ADAPTER); - this.coordinationTypeAdapter = new ShortCircuitAnnotationElementAdapter(type, COORDINATION_TYPE_ADAPTER); - this.expiryTimeOfDayAdapter = new MemberAnnotationAdapter(type, EXPIRY_TIME_OF_DAY_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** CacheAnnotation implementation **************** - - public CacheType getType() { - return this.type; - } - - public void setType(CacheType newType) { - if (attributeValueHasNotChanged(this.type, newType)) { - return; - } - CacheType oldType = this.type; - this.type = newType; - this.typeAdapter.setValue(CacheType.toJavaAnnotationValue(newType)); - firePropertyChanged(TYPE_PROPERTY, oldType, newType); - } - - public Integer getSize() { - return this.size; - } - - public void setSize(Integer newSize) { - if (attributeValueHasNotChanged(this.size, newSize)) { - return; - } - Integer oldSize = this.size; - this.size = newSize; - this.sizeAdapter.setValue(newSize); - firePropertyChanged(SIZE_PROPERTY, oldSize, newSize); - } - - public Boolean getShared() { - return this.shared; - } - - public void setShared(Boolean newShared) { - if (attributeValueHasNotChanged(this.shared, newShared)) { - return; - } - Boolean oldShared = this.shared; - this.shared = newShared; - this.sharedAdapter.setValue(newShared); - firePropertyChanged(SHARED_PROPERTY, oldShared, newShared); - } - - public Integer getExpiry() { - return this.expiry; - } - - public void setExpiry(Integer newExpiry) { - if (attributeValueHasNotChanged(this.expiry, newExpiry)) { - return; - } - Integer oldExpiry = this.expiry; - this.expiry = newExpiry; - this.expiryAdapter.setValue(newExpiry); - firePropertyChanged(EXPIRY_PROPERTY, oldExpiry, newExpiry); - } - - public TimeOfDayAnnotation getExpiryTimeOfDay() { - return this.expiryTimeOfDay; - } - - public TimeOfDayAnnotation addExpiryTimeOfDay() { - if (this.expiryTimeOfDay != null) { - throw new IllegalStateException("ExpiryTimeOfDay element already exists"); //$NON-NLS-1$ - } - this.expiryTimeOfDay = createTimeOfDayAnnotation(); - this.expiryTimeOfDayAdapter.newMarkerAnnotation(); - firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, null, this.expiryTimeOfDay); - return this.expiryTimeOfDay; - } - - public void removeExpiryTimeOfDay() { - if (this.expiryTimeOfDay == null) { - throw new IllegalStateException("No expiryTimeOfDay element exists"); //$NON-NLS-1$ - } - this.expiryTimeOfDay = null; - this.expiryTimeOfDayAdapter.removeAnnotation(); - firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, this.expiryTimeOfDay, null); - } - - protected void setExpiryTimeOfDay(TimeOfDayAnnotation newExpiryTimeOfDay) { - TimeOfDayAnnotation oldExpiryTimeOfDay = this.expiryTimeOfDay; - this.expiryTimeOfDay = newExpiryTimeOfDay; - firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, oldExpiryTimeOfDay, newExpiryTimeOfDay); - } - - public Boolean getAlwaysRefresh() { - return this.alwaysRefresh; - } - - public void setAlwaysRefresh(Boolean newAlwaysRefresh) { - if (attributeValueHasNotChanged(this.alwaysRefresh, newAlwaysRefresh)) { - return; - } - Boolean oldAlwaysRefresh = this.alwaysRefresh; - this.alwaysRefresh = newAlwaysRefresh; - this.alwaysRefreshAdapter.setValue(newAlwaysRefresh); - firePropertyChanged(ALWAYS_REFRESH_PROPERTY, oldAlwaysRefresh, newAlwaysRefresh); - } - - public Boolean getRefreshOnlyIfNewer() { - return this.refreshOnlyIfNewer; - } - - public void setRefreshOnlyIfNewer(Boolean newRefreshOnlyIfNewer) { - if (attributeValueHasNotChanged(this.refreshOnlyIfNewer, newRefreshOnlyIfNewer)) { - return; - } - Boolean oldRefreshOnlyIfNewer = this.refreshOnlyIfNewer; - this.refreshOnlyIfNewer = newRefreshOnlyIfNewer; - this.refreshOnlyIfNewerAdapter.setValue(newRefreshOnlyIfNewer); - firePropertyChanged(REFRESH_ONLY_IF_NEWER_PROPERTY, oldRefreshOnlyIfNewer, newRefreshOnlyIfNewer); - } - - public Boolean getDisableHits() { - return this.disableHits; - } - - public void setDisableHits(Boolean newDisableHits) { - if (attributeValueHasNotChanged(this.disableHits, newDisableHits)) { - return; - } - Boolean oldDisableHits = this.disableHits; - this.disableHits = newDisableHits; - this.disableHitsAdapter.setValue(newDisableHits); - firePropertyChanged(DISABLE_HITS_PROPERTY, oldDisableHits, newDisableHits); - } - - public CacheCoordinationType getCoordinationType() { - return this.coordinationType; - } - - public void setCoordinationType(CacheCoordinationType newCoordinationType) { - if (attributeValueHasNotChanged(this.coordinationType, newCoordinationType)) { - return; - } - CacheCoordinationType oldCoordinationType = this.coordinationType; - this.coordinationType = newCoordinationType; - this.coordinationTypeAdapter.setValue(CacheCoordinationType.toJavaAnnotationValue(newCoordinationType)); - firePropertyChanged(TYPE_PROPERTY, oldCoordinationType, newCoordinationType); - } - - public TextRange getTypeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(TYPE_ADAPTER, astRoot); - } - - public TextRange getSizeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(SIZE_ADAPTER, astRoot); - } - - public TextRange getSharedTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(SHARED_ADAPTER, astRoot); - } - - public TextRange getExpiryTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(EXPIRY_ADAPTER, astRoot); - } - - public TextRange getExpiryTimeOfDayTextRange(CompilationUnit astRoot) { - return null;//TODO return this.getElementTextRange(EXPIRY_TIME_OF_DAY_ADAPTER, astRoot); - } - - public TextRange getAlwaysRefreshTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(ALWAYS_REFRESH_ADAPTER, astRoot); - } - - public TextRange getRefreshOnlyIfNewerTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(REFRESH_ONLY_IF_NEWER_ADAPTER, astRoot); - } - - public TextRange getDisablesHitsTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(DISABLE_HITS_ADAPTER, astRoot); - } - - public TextRange getCoordinationTypeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(COORDINATION_TYPE_ADAPTER, astRoot); - } - - public void initialize(CompilationUnit astRoot) { - this.type = this.type(astRoot); - this.size = this.size(astRoot); - this.shared = this.shared(astRoot); - this.expiry = this.expiry(astRoot); - this.initializeExpiryTimeOfDay(astRoot); - this.alwaysRefresh = this.alwaysRefresh(astRoot); - this.refreshOnlyIfNewer = this.refreshOnlyIfNewer(astRoot); - this.disableHits = this.disableHits(astRoot); - this.coordinationType = this.coordinationType(astRoot); - } - - protected void initializeExpiryTimeOfDay(CompilationUnit astRoot) { - if (this.expiryTimeOfDayAdapter.getAnnotation(astRoot) != null) { - this.expiryTimeOfDay = createTimeOfDayAnnotation(); - this.expiryTimeOfDay.initialize(astRoot); - } - } - - public void update(CompilationUnit astRoot) { - this.setType(this.type(astRoot)); - this.setSize(this.size(astRoot)); - this.setShared(this.shared(astRoot)); - this.setExpiry(this.expiry(astRoot)); - this.updateExpiryTimeOfDay(astRoot); - this.setAlwaysRefresh(this.alwaysRefresh(astRoot)); - this.setRefreshOnlyIfNewer(this.refreshOnlyIfNewer(astRoot)); - this.setDisableHits(this.disableHits(astRoot)); - this.setCoordinationType(this.coordinationType(astRoot)); - } - - protected void updateExpiryTimeOfDay(CompilationUnit astRoot) { - if (this.expiryTimeOfDayAdapter.getAnnotation(astRoot) == null) { - this.setExpiryTimeOfDay(null); - } - else { - if (getExpiryTimeOfDay() != null) { - getExpiryTimeOfDay().update(astRoot); - } - else { - TimeOfDayAnnotation expiryTimeOfDay = createTimeOfDayAnnotation(); - expiryTimeOfDay.initialize(astRoot); - setExpiryTimeOfDay(expiryTimeOfDay); - } - } - } - - protected CacheType type(CompilationUnit astRoot) { - return CacheType.fromJavaAnnotationValue(this.typeAdapter.getValue(astRoot)); - } - - protected Integer size(CompilationUnit astRoot) { - return this.sizeAdapter.getValue(astRoot); - } - - protected Boolean shared(CompilationUnit astRoot) { - return this.sharedAdapter.getValue(astRoot); - } - - protected Integer expiry(CompilationUnit astRoot) { - return this.expiryAdapter.getValue(astRoot); - } - - protected TimeOfDayAnnotation createTimeOfDayAnnotation() { - return new TimeOfDayImpl(this, getMember(), EXPIRY_TIME_OF_DAY_ADAPTER); - } - - protected Boolean alwaysRefresh(CompilationUnit astRoot) { - return this.alwaysRefreshAdapter.getValue(astRoot); - } - - protected Boolean refreshOnlyIfNewer(CompilationUnit astRoot) { - return this.refreshOnlyIfNewerAdapter.getValue(astRoot); - } - - protected Boolean disableHits(CompilationUnit astRoot) { - return this.disableHitsAdapter.getValue(astRoot); - } - - protected CacheCoordinationType coordinationType(CompilationUnit astRoot) { - return CacheCoordinationType.fromJavaAnnotationValue(this.coordinationTypeAdapter.getValue(astRoot)); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildTypeAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__TYPE); - } - - private static DeclarationAnnotationElementAdapter buildSizeAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__SIZE, NumberIntegerExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildSharedAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__SHARED, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildExpiryAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__EXPIRY, NumberIntegerExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildAlwaysRefreshAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__ALWAYS_REFRESH, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildRefreshOnlyIfNewerAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__REFRESH_ONLY_IF_NEWER, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildDisableHitsAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__DISABLE_HITS, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildCoordinationTypeAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__COORDINATION_TYPE); - } - - private static NestedDeclarationAnnotationAdapter buildExpiryTimeOfDayAnnotationAdapter() { - return new NestedDeclarationAnnotationAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__EXPIRY_TIME_OF_DAY, EclipseLinkJPA.TIME_OF_DAY); - } - - public static class CacheAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final CacheAnnotationDefinition INSTANCE = new CacheAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static CacheAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private CacheAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new CacheImpl((JavaResourcePersistentType) parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullCacheAnnotation((JavaResourcePersistentType) parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TimeOfDayImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TimeOfDayImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TimeOfDayImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TimeOfDayImpl.java 27 Aug 2008 18:13:55 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,183 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.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; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; - - -public class TimeOfDayImpl extends AbstractResourceAnnotation implements TimeOfDayAnnotation -{ - private final AnnotationElementAdapter hourAdapter; - private final AnnotationElementAdapter minuteAdapter; - private final AnnotationElementAdapter secondAdapter; - private final AnnotationElementAdapter millisecondAdapter; - - private final DeclarationAnnotationElementAdapter hourDeclarationAdapter; - private final DeclarationAnnotationElementAdapter minuteDeclarationAdapter; - private final DeclarationAnnotationElementAdapter secondDeclarationAdapter; - private final DeclarationAnnotationElementAdapter millisecondDeclarationAdapter; - - - private Integer hour; - private Integer minute; - private Integer second; - private Integer millisecond; - - protected TimeOfDayImpl(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa) { - super(parent, type, daa); - this.hourDeclarationAdapter = buildHourAdapter(daa); - this.hourAdapter = new ShortCircuitAnnotationElementAdapter(type, this.hourDeclarationAdapter); - this.minuteDeclarationAdapter = buildMinuteAdapter(daa); - this.minuteAdapter = new ShortCircuitAnnotationElementAdapter(type, this.minuteDeclarationAdapter); - this.secondDeclarationAdapter = buildSecondAdapter(daa); - this.secondAdapter = new ShortCircuitAnnotationElementAdapter(type, this.secondDeclarationAdapter); - this.millisecondDeclarationAdapter = buildMillisecondAdapter(daa); - this.millisecondAdapter = new ShortCircuitAnnotationElementAdapter(type, this.millisecondDeclarationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** TimeOfDayAnnotation implementation **************** - - public Integer getHour() { - return this.hour; - } - - public void setHour(Integer newHour) { - if (attributeValueHasNotChanged(this.hour, newHour)) { - return; - } - Integer oldHour = this.hour; - this.hour = newHour; - this.hourAdapter.setValue(newHour); - firePropertyChanged(HOUR_PROPERTY, oldHour, newHour); - } - - public Integer getMinute() { - return this.minute; - } - - public void setMinute(Integer newMinute) { - if (attributeValueHasNotChanged(this.minute, newMinute)) { - return; - } - Integer oldMinute = this.minute; - this.minute = newMinute; - this.minuteAdapter.setValue(newMinute); - firePropertyChanged(MINUTE_PROPERTY, oldMinute, newMinute); - } - - public Integer getSecond() { - return this.second; - } - - public void setSecond(Integer newSecond) { - if (attributeValueHasNotChanged(this.second, newSecond)) { - return; - } - Integer oldSecond = this.second; - this.second = newSecond; - this.secondAdapter.setValue(newSecond); - firePropertyChanged(SECOND_PROPERTY, oldSecond, newSecond); - } - - public Integer getMillisecond() { - return this.millisecond; - } - - public void setMillisecond(Integer newMillisecond) { - if (attributeValueHasNotChanged(this.millisecond, newMillisecond)) { - return; - } - Integer oldMillisecond = this.millisecond; - this.millisecond = newMillisecond; - this.millisecondAdapter.setValue(newMillisecond); - firePropertyChanged(MILLISECOND_PROPERTY, oldMillisecond, newMillisecond); - } - - public TextRange getHourTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.hourDeclarationAdapter, astRoot); - } - - public TextRange getMinuteTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.minuteDeclarationAdapter, astRoot); - } - - public TextRange getSecondTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.secondDeclarationAdapter, astRoot); - } - - public TextRange getMillisecondTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.millisecondDeclarationAdapter, astRoot); - } - - public void initialize(CompilationUnit astRoot) { - this.hour = this.hour(astRoot); - this.minute = this.minute(astRoot); - this.second = this.second(astRoot); - this.millisecond = this.millisecond(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setHour(this.hour(astRoot)); - this.setMinute(this.minute(astRoot)); - this.setSecond(this.second(astRoot)); - this.setMillisecond(this.millisecond(astRoot)); - } - - protected Integer hour(CompilationUnit astRoot) { - return this.hourAdapter.getValue(astRoot); - } - - protected Integer minute(CompilationUnit astRoot) { - return this.minuteAdapter.getValue(astRoot); - } - - protected Integer second(CompilationUnit astRoot) { - return this.secondAdapter.getValue(astRoot); - } - - protected Integer millisecond(CompilationUnit astRoot) { - return this.millisecondAdapter.getValue(astRoot); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildHourAdapter(DeclarationAnnotationAdapter daa) { - return new ConversionDeclarationAnnotationElementAdapter(daa, EclipseLinkJPA.TIME_OF_DAY__HOUR, false, NumberIntegerExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildMinuteAdapter(DeclarationAnnotationAdapter daa) { - return new ConversionDeclarationAnnotationElementAdapter(daa, EclipseLinkJPA.TIME_OF_DAY__MINUTE, false, NumberIntegerExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildSecondAdapter(DeclarationAnnotationAdapter daa) { - return new ConversionDeclarationAnnotationElementAdapter(daa, EclipseLinkJPA.TIME_OF_DAY__SECOND, false, NumberIntegerExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildMillisecondAdapter(DeclarationAnnotationAdapter daa) { - return new ConversionDeclarationAnnotationElementAdapter(daa, EclipseLinkJPA.TIME_OF_DAY__MILLISECOND, false, NumberIntegerExpressionConverter.instance()); - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConversionValueImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConversionValueImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConversionValueImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConversionValueImpl.java 2 Oct 2008 13:36:07 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,152 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.NestableAnnotation; -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.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.ConversionValueAnnotation; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.NestableConversionValue; -import org.eclipse.jpt.eclipselink.core.resource.java.ObjectTypeConverterAnnotation; - - -public class ConversionValueImpl extends AbstractResourceAnnotation implements ConversionValueAnnotation, NestableConversionValue -{ - // hold this so we can get the 'dataValue' text range - private final DeclarationAnnotationElementAdapter dataValueDeclarationAdapter; - // hold this so we can get the 'objectValue' text range - private final DeclarationAnnotationElementAdapter objectValueDeclarationAdapter; - - private final AnnotationElementAdapter dataValueAdapter; - private final AnnotationElementAdapter objectValueAdapter; - - - private String dataValue; - private String objectValue; - - public ConversionValueImpl(ObjectTypeConverterAnnotation parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { - super(parent, member, idaa, new MemberIndexedAnnotationAdapter(member, idaa)); - this.dataValueDeclarationAdapter = this.dataValueAdapter(idaa); - this.dataValueAdapter = this.buildAdapter(this.dataValueDeclarationAdapter); - this.objectValueDeclarationAdapter = this.objectValueAdapter(idaa); - this.objectValueAdapter = this.buildAdapter(this.objectValueDeclarationAdapter); - } - - // ********** initialization ********** - protected AnnotationElementAdapter buildAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(getMember(), daea); - } - - protected DeclarationAnnotationElementAdapter dataValueAdapter(DeclarationAnnotationAdapter daa) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, EclipseLinkJPA.CONVERSION_VALUE__DATA_VALUE, false); - } - - protected DeclarationAnnotationElementAdapter objectValueAdapter(DeclarationAnnotationAdapter daa) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, EclipseLinkJPA.CONVERSION_VALUE__OBJECT_VALUE, false); - } - - public void initialize(CompilationUnit astRoot) { - this.dataValue = this.dataValue(astRoot); - this.objectValue = this.objectValue(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public IndexedAnnotationAdapter getAnnotationAdapter() { - return (IndexedAnnotationAdapter) super.getAnnotationAdapter(); - } - - //*************** ConversionValue implementation **************** - public String getDataValue() { - return this.dataValue; - } - - public void setDataValue(String newDataValue) { - if (attributeValueHasNotChanged(this.dataValue, newDataValue)) { - return; - } - String oldDataValue = this.dataValue; - this.dataValue = newDataValue; - this.dataValueAdapter.setValue(newDataValue); - firePropertyChanged(DATA_VALUE_PROPERTY, oldDataValue, newDataValue); - } - - public String getObjectValue() { - return this.objectValue; - } - - public void setObjectValue(String newObjectValue) { - if (attributeValueHasNotChanged(this.objectValue, newObjectValue)) { - return; - } - String oldObjectValue = this.objectValue; - this.objectValue = newObjectValue; - this.objectValueAdapter.setValue(newObjectValue); - firePropertyChanged(OBJECT_VALUE_PROPERTY, oldObjectValue, newObjectValue); - } - - public TextRange getDataValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.dataValueDeclarationAdapter, astRoot); - } - - public TextRange getObjectValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.objectValueDeclarationAdapter, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setDataValue(this.dataValue(astRoot)); - this.setObjectValue(this.objectValue(astRoot)); - } - - protected String dataValue(CompilationUnit astRoot) { - return this.dataValueAdapter.getValue(astRoot); - } - - protected String objectValue(CompilationUnit astRoot) { - return this.objectValueAdapter.getValue(astRoot); - } - - //************ NestableAnnotation implementation - public void moveAnnotation(int newIndex) { - getAnnotationAdapter().moveAnnotation(newIndex); - } - - public void initializeFrom(NestableAnnotation oldAnnotation) { - ConversionValueAnnotation oldConversionValue = (ConversionValueAnnotation) oldAnnotation; - setDataValue(oldConversionValue.getDataValue()); - setObjectValue(oldConversionValue.getObjectValue()); - } - - // ********** static methods ********** - - static ConversionValueImpl createConversionValue(ObjectTypeConverterAnnotation parent, Member member, DeclarationAnnotationAdapter daa, int index) { - return new ConversionValueImpl(parent, member, buildConversionValueAnnotationAdapter(daa, index)); - } - - private static IndexedDeclarationAnnotationAdapter buildConversionValueAnnotationAdapter(DeclarationAnnotationAdapter daa, int index) { - return new NestedIndexedDeclarationAnnotationAdapter(daa, EclipseLinkJPA.OBJECT_TYPE_CONVERTER__CONVERSION_VALUES, index, EclipseLinkJPA.CONVERSION_VALUE, false); - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConvertImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConvertImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConvertImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConvertImpl.java 23 Oct 2008 19:04:13 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,121 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.internal.utility.jdt.StringExpressionConverter; -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.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.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.ConvertAnnotation; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; - - -public class ConvertImpl extends AbstractResourceAnnotation implements ConvertAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter valueAdapter; - - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - - private String value; - - protected ConvertImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(attribute, VALUE_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** Convert implementation **************** - public String getValue() { - return this.value; - } - - public void setValue(String newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - String oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(newValue); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected String value(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CONVERT__VALUE, false, StringExpressionConverter.instance()); - } - - - public static class ConvertAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final ConvertAnnotationDefinition INSTANCE = new ConvertAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static ConvertAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ConvertAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new ConvertImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TypeConverterImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TypeConverterImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TypeConverterImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TypeConverterImpl.java 23 Oct 2008 19:04:13 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,188 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.internal.utility.jdt.StringExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.TypeStringExpressionConverter; -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.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; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.TypeConverterAnnotation; - - -public class TypeConverterImpl extends AbstractResourceAnnotation implements TypeConverterAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter nameAdapter; - private final AnnotationElementAdapter dataTypeAdapter; - private final AnnotationElementAdapter objectTypeAdapter; - - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildNameAdapter(); - private static final DeclarationAnnotationElementAdapter DATA_TYPE_ADAPTER = buildDataTypeAdapter(); - private static final DeclarationAnnotationElementAdapter OBJECT_TYPE_ADAPTER = buildObjectTypeAdapter(); - - - private String name; - private String dataType; - private String objectType; - - protected TypeConverterImpl(JavaResourcePersistentMember parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter(member, NAME_ADAPTER); - this.dataTypeAdapter = new ShortCircuitAnnotationElementAdapter(member, DATA_TYPE_ADAPTER); - this.objectTypeAdapter = new ShortCircuitAnnotationElementAdapter(member, OBJECT_TYPE_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - this.dataType = this.dataType(astRoot); - this.objectType = this.objectType(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** TypeConverter implementation **************** - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public String getDataType() { - return this.dataType; - } - - public void setDataType(String newDataType) { - if (attributeValueHasNotChanged(this.dataType, newDataType)) { - return; - } - String oldDataType = this.dataType; - this.dataType = newDataType; - this.dataTypeAdapter.setValue(newDataType); - firePropertyChanged(DATA_TYPE_PROPERTY, oldDataType, newDataType); - } - - public String getObjectType() { - return this.objectType; - } - - public void setObjectType(String newObjectType) { - if (attributeValueHasNotChanged(this.objectType, newObjectType)) { - return; - } - String oldObjectType = this.objectType; - this.objectType = newObjectType; - this.objectTypeAdapter.setValue(newObjectType); - firePropertyChanged(OBJECT_TYPE_PROPERTY, oldObjectType, newObjectType); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(NAME_ADAPTER, astRoot); - } - - public TextRange getDataTypeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(DATA_TYPE_ADAPTER, astRoot); - } - - public TextRange getObjectTypeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(OBJECT_TYPE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - this.setDataType(this.dataType(astRoot)); - this.setObjectType(this.objectType(astRoot)); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - protected String dataType(CompilationUnit astRoot) { - return this.dataTypeAdapter.getValue(astRoot); - } - - protected String objectType(CompilationUnit astRoot) { - return this.objectTypeAdapter.getValue(astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildNameAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.TYPE_CONVERTER__NAME, false, StringExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildDataTypeAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.TYPE_CONVERTER__DATE_TYPE, false, TypeStringExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildObjectTypeAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.TYPE_CONVERTER__OBJECT_TYPE, false, TypeStringExpressionConverter.instance()); - } - - public static class TypeConverterAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final TypeConverterAnnotationDefinition INSTANCE = new TypeConverterAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static TypeConverterAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TypeConverterAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new TypeConverterImpl(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConverterImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConverterImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConverterImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConverterImpl.java 10 Mar 2009 04:12:12 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,163 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.internal.utility.jdt.StringExpressionConverter; -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.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; -import org.eclipse.jpt.eclipselink.core.resource.java.ConverterAnnotation; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; - - -public class ConverterImpl extends AbstractResourceAnnotation implements ConverterAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter nameAdapter; - private final AnnotationElementAdapter converterClassAdapter; - - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildNameAdapter(); - private static final DeclarationAnnotationElementAdapter CONVERTER_CLASS_ADAPTER = buildConverterClassAdapter(); - - - private String name; - private String converterClass; - - protected ConverterImpl(JavaResourcePersistentMember parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter(member, NAME_ADAPTER); - this.converterClassAdapter = new ShortCircuitAnnotationElementAdapter(member, CONVERTER_CLASS_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - this.converterClass = this.converterClass(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** ConverterAnnotation implementation **************** - - public boolean converterClassImplementsInterface(String interfaceName, CompilationUnit astRoot) { - return (this.converterClass != null) - && JDTTools.typeIsSubTypeOf(this.converterClassAdapter.getExpression(astRoot), interfaceName); - } - - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public String getConverterClass() { - return this.converterClass; - } - - public void setConverterClass(String newConverterClass) { - if (attributeValueHasNotChanged(this.converterClass, newConverterClass)) { - return; - } - String oldConverterClass = this.converterClass; - this.converterClass = newConverterClass; - this.converterClassAdapter.setValue(newConverterClass); - firePropertyChanged(CONVERTER_CLASS_PROPERTY, oldConverterClass, newConverterClass); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(NAME_ADAPTER, astRoot); - } - - public TextRange getConverterClassTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(CONVERTER_CLASS_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - this.setConverterClass(this.converterClass(astRoot)); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - protected String converterClass(CompilationUnit astRoot) { - return this.converterClassAdapter.getValue(astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildNameAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CONVERTER__NAME, false, StringExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildConverterClassAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CONVERTER__CONVERTER_CLASS, false, SimpleTypeStringExpressionConverter.instance()); - } - - public static class ConverterAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final ConverterAnnotationDefinition INSTANCE = new ConverterAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static ConverterAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ConverterAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new ConverterImpl(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CustomizerImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CustomizerImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CustomizerImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CustomizerImpl.java 10 Mar 2009 04:12:12 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,127 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.eclipselink.core.resource.java.CustomizerAnnotation; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; - - -public class CustomizerImpl extends AbstractResourceAnnotation implements CustomizerAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter valueAdapter; - - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - - private String value; - - protected CustomizerImpl(JavaResourcePersistentMember parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(type, VALUE_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** CustomizerAnnotation implementation **************** - - public boolean customizerClassImplementsInterface(String interfaceName, CompilationUnit astRoot) { - return (this.value != null) - && JDTTools.typeIsSubTypeOf(this.valueAdapter.getExpression(astRoot), interfaceName); - } - - public String getValue() { - return this.value; - } - - public void setValue(String newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - String oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(newValue); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected String value(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CUSTOMIZER__VALUE, false, SimpleTypeStringExpressionConverter.instance()); - } - - public static class CustomizerAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final CustomizerAnnotationDefinition INSTANCE = new CustomizerAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static CustomizerAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private CustomizerAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new CustomizerImpl(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicMapImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicMapImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicMapImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicMapImpl.java 11 Nov 2008 15:47:18 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,75 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.BasicMapAnnotation; - - -public class BasicMapImpl extends AbstractResourceAnnotation implements BasicMapAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - protected BasicMapImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void update(CompilationUnit astRoot) { - } - - public static class BasicMapAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final BasicMapAnnotationDefinition INSTANCE = new BasicMapAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static BasicMapAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private BasicMapAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new BasicMapImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/PrivateOwnedImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/PrivateOwnedImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/PrivateOwnedImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/PrivateOwnedImpl.java 23 Oct 2008 19:04:13 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,77 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.PrivateOwnedAnnotation; - - -public class PrivateOwnedImpl extends AbstractResourceAnnotation implements PrivateOwnedAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected PrivateOwnedImpl(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public void update(CompilationUnit astRoot) { - //nothing to update - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - public static class PrivateOwnedAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final PrivateOwnedAnnotationDefinition INSTANCE = new PrivateOwnedAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private PrivateOwnedAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new PrivateOwnedImpl(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullJoinFetchAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullJoinFetchAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 NullJoinFetchAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullJoinFetchAnnotation.java 20 Oct 2008 20:52:59 -0000 1.2 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullJoinFetchAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,70 +10,45 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; -import org.eclipse.jpt.core.resource.java.Annotation; +import org.eclipse.jpt.core.internal.resource.java.NullAnnotation; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.eclipselink.core.resource.java.ExistenceCheckingAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType; -public class NullJoinFetchAnnotation extends AbstractJavaResourceNode implements JoinFetchAnnotation, Annotation +/** + * org.eclipse.persistence.annotations.JoinFetch + */ +public class NullJoinFetchAnnotation + extends NullAnnotation + implements JoinFetchAnnotation { protected NullJoinFetchAnnotation(JavaResourcePersistentAttribute parent) { super(parent); } - - @Override - public JavaResourcePersistentType getParent() { - return (JavaResourcePersistentType) super.getParent(); - } - + public String getAnnotationName() { - return ExistenceCheckingAnnotation.ANNOTATION_NAME; + return ANNOTATION_NAME; } - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - protected JoinFetchAnnotation createJoinFetchAnnotation() { - return (JoinFetchAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); + @Override + protected JoinFetchAnnotation buildSupportingAnnotation() { + return (JoinFetchAnnotation) super.buildSupportingAnnotation(); } - + + // ***** value public JoinFetchType getValue() { return null; } - + public void setValue(JoinFetchType value) { if (value != null) { - createJoinFetchAnnotation().setValue(value); + this.buildSupportingAnnotation().setValue(value); } } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - + public TextRange getValueTextRange(CompilationUnit astRoot) { return null; } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } } Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java,v retrieving revision 1.4 diff -u -r1.4 NullCacheAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java 20 Oct 2008 20:52:58 -0000 1.4 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,8 +10,7 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; -import org.eclipse.jpt.core.resource.java.Annotation; +import org.eclipse.jpt.core.internal.resource.java.NullAnnotation; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; @@ -19,175 +18,162 @@ import org.eclipse.jpt.eclipselink.core.resource.java.CacheType; import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; -public class NullCacheAnnotation extends AbstractJavaResourceNode implements CacheAnnotation, Annotation +/** + * org.eclipse.persistence.annotations.Cache + */ +public class NullCacheAnnotation + extends NullAnnotation + implements CacheAnnotation { + protected NullCacheAnnotation(JavaResourcePersistentType parent) { super(parent); } - - @Override - public JavaResourcePersistentType getParent() { - return (JavaResourcePersistentType) super.getParent(); - } - + public String getAnnotationName() { - return CacheAnnotation.ANNOTATION_NAME; + return ANNOTATION_NAME; } - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - protected CacheAnnotation createCacheResource() { - return (CacheAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); + @Override + protected CacheAnnotation buildSupportingAnnotation() { + return (CacheAnnotation) super.buildSupportingAnnotation(); } - + + // ***** type public CacheType getType() { return null; } - + public void setType(CacheType type) { if (type != null) { - createCacheResource().setType(type); + this.buildSupportingAnnotation().setType(type); } } + public TextRange getTypeTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** size public Integer getSize() { return null; } - + public void setSize(Integer size) { if (size != null) { - createCacheResource().setSize(size); + this.buildSupportingAnnotation().setSize(size); } } - + + public TextRange getSizeTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** shared public Boolean getShared() { return null; } - + public void setShared(Boolean shared) { if (shared != null) { - createCacheResource().setShared(shared); + this.buildSupportingAnnotation().setShared(shared); } } - + + public TextRange getSharedTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** expiry public Integer getExpiry() { return null; } - + public void setExpiry(Integer expiry) { if (expiry != null) { - createCacheResource().setExpiry(expiry); - } + this.buildSupportingAnnotation().setExpiry(expiry); + } + } + + public TextRange getExpiryTextRange(CompilationUnit astRoot) { + return null; } - + + // ***** expiry time of day public TimeOfDayAnnotation getExpiryTimeOfDay() { return null; } - + public TimeOfDayAnnotation addExpiryTimeOfDay() { - return createCacheResource().addExpiryTimeOfDay(); + return this.buildSupportingAnnotation().addExpiryTimeOfDay(); } - + public void removeExpiryTimeOfDay() { - + // do nothing } - + + public TextRange getExpiryTimeOfDayTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** always refresh public Boolean getAlwaysRefresh() { return null; } - + public void setAlwaysRefresh(Boolean alwaysRefresh) { if (alwaysRefresh != null) { - createCacheResource().setAlwaysRefresh(alwaysRefresh); + this.buildSupportingAnnotation().setAlwaysRefresh(alwaysRefresh); } } - + + public TextRange getAlwaysRefreshTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** refresh only if newer public Boolean getRefreshOnlyIfNewer() { return null; } - + public void setRefreshOnlyIfNewer(Boolean refreshOnlyIfNewer) { if (refreshOnlyIfNewer != null) { - createCacheResource().setRefreshOnlyIfNewer(refreshOnlyIfNewer); + this.buildSupportingAnnotation().setRefreshOnlyIfNewer(refreshOnlyIfNewer); } } - + + public TextRange getRefreshOnlyIfNewerTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** disable hits public Boolean getDisableHits() { return null; } - + public void setDisableHits(Boolean disableHits) { if (disableHits != null) { - createCacheResource().setDisableHits(disableHits); + this.buildSupportingAnnotation().setDisableHits(disableHits); } } - + + public TextRange getDisablesHitsTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** coordination type public CacheCoordinationType getCoordinationType() { return null; } - + public void setCoordinationType(CacheCoordinationType coordinationType) { if (coordinationType != null) { - createCacheResource().setCoordinationType(coordinationType); + this.buildSupportingAnnotation().setCoordinationType(coordinationType); } } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getTypeTextRange(CompilationUnit astRoot) { - return null; - } - public TextRange getSizeTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getSharedTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getExpiryTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getExpiryTimeOfDayTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getAlwaysRefreshTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getRefreshOnlyIfNewerTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getDisablesHitsTextRange(CompilationUnit astRoot) { - return null; - } - public TextRange getCoordinationTypeTextRange(CompilationUnit astRoot) { return null; } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } } Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ChangeTrackingImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ChangeTrackingImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ChangeTrackingImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ChangeTrackingImpl.java 23 Oct 2008 19:04:13 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,123 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.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.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; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingAnnotation; -import org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; - - -public class ChangeTrackingImpl extends AbstractResourceAnnotation implements ChangeTrackingAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter valueAdapter; - - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - - private ChangeTrackingType value; - - protected ChangeTrackingImpl(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(type, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** CacheAnnotation implementation **************** - - public ChangeTrackingType getValue() { - return this.value; - } - - public void setValue(ChangeTrackingType newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - ChangeTrackingType oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(ChangeTrackingType.toJavaAnnotationValue(newValue)); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected ChangeTrackingType value(CompilationUnit astRoot) { - return ChangeTrackingType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CHANGE_TRACKING__VALUE, false); - } - - public static class ChangeTrackingAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final ChangeTrackingAnnotationDefinition INSTANCE = new ChangeTrackingAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static ChangeTrackingAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ChangeTrackingAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new ChangeTrackingImpl((JavaResourcePersistentType) parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadTransformerImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadTransformerImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadTransformerImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadTransformerImpl.java 23 Oct 2008 19:04:13 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,152 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.internal.utility.jdt.SimpleTypeStringExpressionConverter; -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.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.Member; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.ReadTransformerAnnotation; - - -public class ReadTransformerImpl extends AbstractResourceAnnotation implements ReadTransformerAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter transformerClassAdapter; - private final AnnotationElementAdapter methodAdapter; - - private static final DeclarationAnnotationElementAdapter TRANSFORMER_CLASS_ADAPTER = buildTransformerClassAdapter(); - private static final DeclarationAnnotationElementAdapter METHOD_ADAPTER = buildMethodAdapter(); - - - private String transformerClass; - private String method; - - protected ReadTransformerImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.transformerClassAdapter = new ShortCircuitAnnotationElementAdapter(attribute, TRANSFORMER_CLASS_ADAPTER); - this.methodAdapter = new ShortCircuitAnnotationElementAdapter(attribute, METHOD_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.transformerClass = this.transformerClass(astRoot); - this.method = this.method(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** ReadTransformer implementation **************** - public String getTransformerClass() { - return this.transformerClass; - } - - public void setTransformerClass(String newTransformerClass) { - if (attributeValueHasNotChanged(this.transformerClass, newTransformerClass)) { - return; - } - String oldTransformerClass = this.transformerClass; - this.transformerClass = newTransformerClass; - this.transformerClassAdapter.setValue(newTransformerClass); - firePropertyChanged(TRANSFORMER_CLASS_PROPERTY, oldTransformerClass, newTransformerClass); - } - - public String getMethod() { - return this.method; - } - - public void setMethod(String newMethod) { - if (attributeValueHasNotChanged(this.method, newMethod)) { - return; - } - String oldMethod = this.method; - this.method = newMethod; - this.methodAdapter.setValue(newMethod); - firePropertyChanged(METHOD_PROPERTY, oldMethod, newMethod); - } - - public TextRange getTransformerClassTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(TRANSFORMER_CLASS_ADAPTER, astRoot); - } - - public TextRange getMethodTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(METHOD_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setTransformerClass(this.transformerClass(astRoot)); - this.setMethod(this.method(astRoot)); - } - - protected String transformerClass(CompilationUnit astRoot) { - return this.transformerClassAdapter.getValue(astRoot); - } - - protected String method(CompilationUnit astRoot) { - return this.methodAdapter.getValue(astRoot); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildTransformerClassAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.READ_TRANSFORMER__TRANSFORMER_CLASS, false, SimpleTypeStringExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildMethodAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.READ_TRANSFORMER__METHOD, false); - } - - public static class ReadTransformerAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final ReadTransformerAnnotationDefinition INSTANCE = new ReadTransformerAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static ReadTransformerAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ReadTransformerAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new ReadTransformerImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/StructConverterImpl.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/StructConverterImpl.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/StructConverterImpl.java --- src/org/eclipse/jpt/eclipselink/core/internal/resource/java/StructConverterImpl.java 29 Oct 2008 21:29:03 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,155 +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.eclipselink.core.internal.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; -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.internal.utility.jdt.StringExpressionConverter; -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.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; -import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; -import org.eclipse.jpt.eclipselink.core.resource.java.StructConverterAnnotation; - - -public class StructConverterImpl extends AbstractResourceAnnotation implements StructConverterAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter nameAdapter; - private final AnnotationElementAdapter converterAdapter; - - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildNameAdapter(); - private static final DeclarationAnnotationElementAdapter CONVERTER_ADAPTER = buildConverterAdapter(); - - - private String name; - private String converter; - - protected StructConverterImpl(JavaResourcePersistentMember parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter(member, NAME_ADAPTER); - this.converterAdapter = new ShortCircuitAnnotationElementAdapter(member, CONVERTER_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - this.converter = this.converter(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** CustomConverter implementation **************** - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public String getConverter() { - return this.converter; - } - - public void setConverter(String newConverter) { - if (attributeValueHasNotChanged(this.converter, newConverter)) { - return; - } - String oldConverter = this.converter; - this.converter = newConverter; - this.converterAdapter.setValue(newConverter); - firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(NAME_ADAPTER, astRoot); - } - - public TextRange getConverterTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(CONVERTER_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - this.setConverter(this.converter(astRoot)); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - protected String converter(CompilationUnit astRoot) { - return this.converterAdapter.getValue(astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildNameAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.STRUCT_CONVERTER__NAME, false, StringExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildConverterAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.STRUCT_CONVERTER__CONVERTER, false, StringExpressionConverter.instance()); - } - - public static class StructConverterAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final StructConverterAnnotationDefinition INSTANCE = new StructConverterAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static StructConverterAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private StructConverterAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new StructConverterImpl(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/eclipselink/core/resource/java/VariableOneToOneAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/VariableOneToOneAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 VariableOneToOneAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/VariableOneToOneAnnotation.java 6 Jan 2009 22:48:26 -0000 1.1 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/VariableOneToOneAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -9,11 +9,11 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.resource.java; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.VariableOneToOne + * Corresponds to EclipseLink annotation + * org.eclipse.persistence.annotations.VariableOneToOne * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -24,7 +24,8 @@ * @version 2.2 * @since 2.2 */ -public interface VariableOneToOneAnnotation extends JavaResourceNode +public interface VariableOneToOneAnnotation + extends Annotation { String ANNOTATION_NAME = EclipseLinkJPA.VARIABLE_ONE_TO_ONE; } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/TimeOfDayAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/TimeOfDayAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 TimeOfDayAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/TimeOfDayAnnotation.java 29 Sep 2008 21:47:24 -0000 1.2 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/TimeOfDayAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,12 +10,12 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** - * Resource model interface that represents the - * org.eclipse.persistence.annotations.TimeOfDay annotation + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.TimeOfDay * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -26,88 +26,88 @@ * @version 2.1 * @since 2.1 */ -public interface TimeOfDayAnnotation extends JavaResourceNode +public interface TimeOfDayAnnotation + extends Annotation { - String ANNOTATION_NAME = EclipseLinkJPA.TIME_OF_DAY; - + /** - * Corresponds to the hour element of the TimeOfDay annotation. - * Returns null if the hour valuePair does not exist in the annotation + * Corresponds to the 'hour' element of the TimeOfDay annotation. + * Return null if the element does not exist in the annotation. */ Integer getHour(); - + String HOUR_PROPERTY = "hour"; //$NON-NLS-1$ + /** - * Corresponds to the hour element of the TimeOfDay annotation. - * Set to null to remove the hour valuePair from the annotation + * Corresponds to the 'hour' element of the TimeOfDay annotation. + * Set to null to remove the element from the annotation */ void setHour(Integer hour); - String HOUR_PROPERTY = "hourProperty"; //$NON-NLS-1$ - + /** - * Corresponds to the minute element of the TimeOfDay annotation. - * Returns null if the minute valuePair does not exist in the annotation + * Return the {@link TextRange} for the 'hour' element. If the element + * does not exist return the {@link TextRange} for the TimeOfDay annotation. */ - Integer getMinute(); - + TextRange getHourTextRange(CompilationUnit astRoot); + + /** - * Corresponds to the minute element of the TimeOfDay annotation. - * Set to null to remove the minute valuePair from the annotation + * Corresponds to the 'minute' element of the TimeOfDay annotation. + * Return null if the element does not exist in the annotation. */ - void setMinute(Integer minute); - String MINUTE_PROPERTY = "minuteProperty"; //$NON-NLS-1$ - + Integer getMinute(); + String MINUTE_PROPERTY = "minute"; //$NON-NLS-1$ + /** - * Corresponds to the second element of the TimeOfDay annotation. - * Returns null if the second valuePair does not exist in the annotation + * Corresponds to the 'minute' element of the TimeOfDay annotation. + * Set to null to remove the element from the annotation */ - Integer getSecond(); - + void setMinute(Integer minute); + /** - * Corresponds to the second element of the TimeOfDay annotation. - * Set to null to remove the second valuePair from the annotation + * Return the {@link TextRange} for the 'minute' element. If the element + * does not exist return the {@link TextRange} for the TimeOfDay annotation. */ - void setSecond(Integer second); - String SECOND_PROPERTY = "secondProperty"; //$NON-NLS-1$ + TextRange getMinuteTextRange(CompilationUnit astRoot); + - /** - * Corresponds to the millisecond element of the TimeOfDay annotation. - * Returns null if the millisecond valuePair does not exist in the annotation + * Corresponds to the 'second' element of the TimeOfDay annotation. + * Return null if the element does not exist in the annotation. */ - Integer getMillisecond(); - + Integer getSecond(); + String SECOND_PROPERTY = "second"; //$NON-NLS-1$ + /** - * Corresponds to the millisecond element of the TimeOfDay annotation. - * Set to null to remove the millisecond valuePair from the annotation + * Corresponds to the 'second' element of the TimeOfDay annotation. + * Set to null to remove the element from the annotation */ - void setMillisecond(Integer millisecond); - String MILLISECOND_PROPERTY = "millisecondProperty"; //$NON-NLS-1$ - - + void setSecond(Integer second); + /** - * Return the {@link TextRange} for the hour element. If the hour element + * Return the {@link TextRange} for the 'second' element. If the element * does not exist return the {@link TextRange} for the TimeOfDay annotation. */ - TextRange getHourTextRange(CompilationUnit astRoot); - + TextRange getSecondTextRange(CompilationUnit astRoot); + + /** - * Return the {@link TextRange} for the minute element. If the minute element - * does not exist return the {@link TextRange} for the TimeOfDay annotation. + * Corresponds to the 'millisecond' element of the TimeOfDay annotation. + * Return null if the element does not exist in the annotation. */ - TextRange getMinuteTextRange(CompilationUnit astRoot); - + Integer getMillisecond(); + String MILLISECOND_PROPERTY = "millisecond"; //$NON-NLS-1$ + /** - * Return the {@link TextRange} for the second element. If the second element - * does not exist return the {@link TextRange} for the TimeOfDay annotation. + * Corresponds to the 'millisecond' element of the TimeOfDay annotation. + * Set to null to remove the element from the annotation */ - TextRange getSecondTextRange(CompilationUnit astRoot); - + void setMillisecond(Integer millisecond); + /** - * Return the {@link TextRange} for the millisecond element. If the millisecond element + * Return the {@link TextRange} for the 'millisecond' element. If the element * does not exist return the {@link TextRange} for the TimeOfDay annotation. */ TextRange getMillisecondTextRange(CompilationUnit astRoot); - } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/ConvertAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ConvertAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 ConvertAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/ConvertAnnotation.java 29 Sep 2008 21:47:24 -0000 1.2 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/ConvertAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,12 +10,12 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.Convert + * Corresponds to the Eclipselink annotation + * org.eclipse.persistence.annotations.Convert * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -26,27 +26,26 @@ * @version 2.1 * @since 2.1 */ -public interface ConvertAnnotation extends JavaResourceNode +public interface ConvertAnnotation + extends Annotation { - String ANNOTATION_NAME = EclipseLinkJPA.CONVERT; - /** - * Corresponds to the value element of the Convert annotation. - * Returns null if the value element does not exist in java. + * Corresponds to the 'value' element of the Convert annotation. + * Return null if the element does not exist in Java. */ String getValue(); + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Corresponds to the value element of the Convert annotation. - * Set to null to remove the value element. + * Corresponds to the 'value' element of the Convert annotation. + * Set to null to remove the element. */ void setValue(String value); - String VALUE_PROPERTY = "valueProperty"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the Convert annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/eclipselink/core/resource/java/CustomizerAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CustomizerAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 CustomizerAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/CustomizerAnnotation.java 30 Dec 2008 15:47:46 -0000 1.2 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/CustomizerAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,12 +10,12 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.Converter + * Corresponds to the Eclipselink annotation + * org.eclipse.persistence.annotations.Customizer * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -26,34 +26,34 @@ * @version 2.1 * @since 2.1 */ -public interface CustomizerAnnotation extends JavaResourceNode +public interface CustomizerAnnotation + extends Annotation { - String ANNOTATION_NAME = EclipseLinkJPA.CUSTOMIZER; /** - * Corresponds to the value element of the Customizer annotation. - * Returns null if the value element does not exist in java. + * Corresponds to the 'value' element of the Customizer annotation. + * Return null if the element does not exist in Java. */ String getValue(); - + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ + /** - * Corresponds to the value element of the Customizer annotation. - * Set to null to remove the value element. + * Corresponds to the 'value' element of the Customizer annotation. + * Set to null to remove the element. */ void setValue(String value); - String VALUE_PROPERTY = "valueProperty"; //$NON-NLS-1$ /** - * Return whether the converterClass implements the eclipselink Customizer interface - * @see org.eclipse.jpt.eclipselink.core.context.Customizer#ECLIPSELINK_DESCRIPTOR_CUSTOMIZER_CLASS_NAME + * Return the {@link TextRange} for the 'value' element. If the element + * does not exist return the {@link TextRange} for the Customizer annotation. */ - boolean customizerClassImplementsInterface(String interfaceName, CompilationUnit astRoot); + TextRange getValueTextRange(CompilationUnit astRoot); /** - * Return the {@link TextRange} for the value element. If the value element - * does not exist return the {@link TextRange} for the Customizer annotation. + * Return whether the customizer class implements the specified interface. + * @see org.eclipse.jpt.eclipselink.core.context.Customizer#ECLIPSELINK_DESCRIPTOR_CUSTOMIZER_CLASS_NAME */ - TextRange getValueTextRange(CompilationUnit astRoot); + boolean customizerClassImplementsInterface(String interfaceName, CompilationUnit astRoot); } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/ConversionValueAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ConversionValueAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 ConversionValueAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/ConversionValueAnnotation.java 29 Sep 2008 21:47:24 -0000 1.2 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/ConversionValueAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,12 +10,12 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.ConversionValue + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.ConversionValue * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -26,46 +26,46 @@ * @version 2.1 * @since 2.1 */ -public interface ConversionValueAnnotation extends JavaResourceNode +public interface ConversionValueAnnotation + extends Annotation { - String ANNOTATION_NAME = EclipseLinkJPA.CONVERSION_VALUE; - - + /** - * Corresponds to the dataValue element of the ConversionValue annotation. - * Returns null if the dataValue element does not exist in java. + * Corresponds to the 'dataValue' element of the ConversionValue annotation. + * Return null if the element does not exist in Java. */ String getDataValue(); - + String DATA_VALUE_PROPERTY = "dataValue"; //$NON-NLS-1$ + /** - * Corresponds to the dataValue element of the ConversionValue annotation. - * Set to null to remove the dataValue element. + * Corresponds to the 'dataValue' element of the ConversionValue annotation. + * Set to null to remove the element. */ void setDataValue(String dataValue); - String DATA_VALUE_PROPERTY = "dataValueProperty"; //$NON-NLS-1$ /** - * Corresponds to the objectValue element of the ConversionValue annotation. - * Returns null if the objectValue element does not exist in java. + * Return the {@link TextRange} for the 'dataValue' element. If the element + * does not exist return the {@link TextRange} for the ConversionValue annotation. */ - String getObjectValue(); - + TextRange getDataValueTextRange(CompilationUnit astRoot); + + /** - * Corresponds to the objectValue element of the ConversionValue annotation. - * Set to null to remove the objectValue element. + * Corresponds to the 'objectValue' element of the ConversionValue annotation. + * Return null if the element does not exist in Java. */ - void setObjectValue(String objectValue); - String OBJECT_VALUE_PROPERTY = "objectValueProperty"; //$NON-NLS-1$ - + String getObjectValue(); + String OBJECT_VALUE_PROPERTY = "objectValue"; //$NON-NLS-1$ + /** - * Return the {@link TextRange} for the dataValue element. If the dataValue element - * does not exist return the {@link TextRange} for the ConversionValue annotation. + * Corresponds to the 'objectValue' element of the ConversionValue annotation. + * Set to null to remove the element. */ - TextRange getDataValueTextRange(CompilationUnit astRoot); - + void setObjectValue(String objectValue); + /** - * Return the {@link TextRange} for the objectValue element. If the objectValue element + * Return the {@link TextRange} for the 'objectValue' element. If the element * does not exist return the {@link TextRange} for the ConversionValue annotation. */ TextRange getObjectValueTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/eclipselink/core/resource/java/NamedConverterAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/NamedConverterAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 NamedConverterAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/NamedConverterAnnotation.java 3 Nov 2008 16:58:54 -0000 1.2 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/NamedConverterAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,20 +1,25 @@ /******************************************************************************* - * 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 - *******************************************************************************/ + * 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.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** + * Common protocol among: + * org.eclipse.persistence.annotations.Converter + * org.eclipse.persistence.annotations.StructConverter + * org.eclipse.persistence.annotations.TypeConverter + * org.eclipse.persistence.annotations.ObjectTypeConverter + * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching * stability. It is available at this early stage to solicit feedback from @@ -24,24 +29,26 @@ * @version 2.1 * @since 2.1 */ -public interface NamedConverterAnnotation extends JavaResourceNode +public interface NamedConverterAnnotation + extends Annotation { /** - * Corresponds to the name element of the CustomConverter annotation. - * Returns null if the name element does not exist in java. + * Corresponds to the 'name' element of the *Converter annotation. + * Return null if the element does not exist in Java. */ String getName(); + String NAME_PROPERTY = "name"; //$NON-NLS-1$ /** - * Corresponds to the name element of the CustomConverter annotation. - * Set to null to remove the name element. + * Corresponds to the 'name' element of the *Converter annotation. + * Set to null to remove the element. */ void setName(String value); - String NAME_PROPERTY = "nameProperty"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the name element. If the name element + * Return the {@link TextRange} for the 'name' element. If the element * does not exist return the {@link TextRange} for the CustomConverter annotation. */ TextRange getNameTextRange(CompilationUnit astRoot); + } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/TypeConverterAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/TypeConverterAnnotation.java,v retrieving revision 1.3 diff -u -r1.3 TypeConverterAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/TypeConverterAnnotation.java 29 Oct 2008 21:29:03 -0000 1.3 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/TypeConverterAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -9,12 +9,9 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.resource.java; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.utility.TextRange; - /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.TypeConverter + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.TypeConverter * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -25,45 +22,8 @@ * @version 2.1 * @since 2.1 */ -public interface TypeConverterAnnotation extends NamedConverterAnnotation +public interface TypeConverterAnnotation + extends BaseTypeConverterAnnotation { String ANNOTATION_NAME = EclipseLinkJPA.TYPE_CONVERTER; - - /** - * Corresponds to the dataType element of the TypeConverter annotation. - * Returns null if the dataType element does not exist in java. - */ - String getDataType(); - - /** - * Corresponds to the dataType element of the TypeConverter annotation. - * Set to null to remove the dataType element. - */ - void setDataType(String value); - String DATA_TYPE_PROPERTY = "dataTypeProperty"; //$NON-NLS-1$ - - /** - * Corresponds to the objectType element of the TypeConverter annotation. - * Returns null if the objectType element does not exist in java. - */ - String getObjectType(); - - /** - * Corresponds to the objectType element of the TypeConverter annotation. - * Set to null to remove the objectType element. - */ - void setObjectType(String value); - String OBJECT_TYPE_PROPERTY = "objectTypeProperty"; //$NON-NLS-1$ - - /** - * Return the {@link TextRange} for the dataType element. If the dataType element - * does not exist return the {@link TextRange} for the TypeConverter annotation. - */ - TextRange getDataTypeTextRange(CompilationUnit astRoot); - - /** - * Return the {@link TextRange} for the objectType element. If the objectType element - * does not exist return the {@link TextRange} for the TypeConverter annotation. - */ - TextRange getObjectTypeTextRange(CompilationUnit astRoot); } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/ConverterAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ConverterAnnotation.java,v retrieving revision 1.5 diff -u -r1.5 ConverterAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/ConverterAnnotation.java 30 Dec 2008 15:47:46 -0000 1.5 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/ConverterAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -13,8 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.Converter + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.Converter * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -25,32 +25,34 @@ * @version 2.1 * @since 2.1 */ -public interface ConverterAnnotation extends NamedConverterAnnotation +public interface ConverterAnnotation + extends NamedConverterAnnotation { String ANNOTATION_NAME = EclipseLinkJPA.CONVERTER; /** - * Corresponds to the converterClass element of the CustomConverter annotation. - * Returns null if the converterClass element does not exist in java. + * Corresponds to the 'converterClass' element of the Converter annotation. + * Returns null if the element does not exist in java. */ String getConverterClass(); + String CONVERTER_CLASS_PROPERTY = "converterClass"; //$NON-NLS-1$ /** - * Corresponds to the converterClass element of the CustomConverter annotation. - * Set to null to remove the converterClass element. + * Corresponds to the 'converterClass' element of the Converter annotation. + * Set to null to remove the element. */ void setConverterClass(String value); - String CONVERTER_CLASS_PROPERTY = "converterClass"; //$NON-NLS-1$ /** - * Return whether the converterClass implements the eclipselink Converter interface - * @see org.eclipse.jpt.eclipselink.core.context.CustomConverter#ECLIPSELINK_CONVERTER_CLASS_NAME + * Return the {@link TextRange} for the 'converterClass' element. If the element + * does not exist return the {@link TextRange} for the Converter annotation. */ - boolean converterClassImplementsInterface(String interfaceName, CompilationUnit astRoot); + TextRange getConverterClassTextRange(CompilationUnit astRoot); /** - * Return the {@link TextRange} for the converterClass element. If the converterClass element - * does not exist return the {@link TextRange} for the CustomConverter annotation. + * Return whether the converter class implements the specified interface. + * @see org.eclipse.jpt.eclipselink.core.context.CustomConverter#ECLIPSELINK_CONVERTER_CLASS_NAME */ - TextRange getConverterClassTextRange(CompilationUnit astRoot); + boolean converterClassImplementsInterface(String interfaceName, CompilationUnit astRoot); + } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/BasicMapAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/BasicMapAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 BasicMapAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/BasicMapAnnotation.java 11 Nov 2008 15:47:18 -0000 1.1 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/BasicMapAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -9,11 +9,11 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.resource.java; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.BasicMap + * Corresponds to the Eclipselink annotation + * org.eclipse.persistence.annotations.BasicMap * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -24,7 +24,8 @@ * @version 2.1 * @since 2.1 */ -public interface BasicMapAnnotation extends JavaResourceNode +public interface BasicMapAnnotation + extends Annotation { String ANNOTATION_NAME = EclipseLinkJPA.BASIC_MAP; } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/NestableConversionValue.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/resource/java/NestableConversionValue.java diff -N src/org/eclipse/jpt/eclipselink/core/resource/java/NestableConversionValue.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/NestableConversionValue.java 3 Sep 2008 20:02:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.eclipselink.core.resource.java; - -import org.eclipse.jpt.core.resource.java.NestableAnnotation; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface NestableConversionValue extends ConversionValueAnnotation, NestableAnnotation -{ - // nothing yet -} Index: src/org/eclipse/jpt/eclipselink/core/resource/java/BasicCollectionAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/BasicCollectionAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 BasicCollectionAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/BasicCollectionAnnotation.java 11 Nov 2008 15:47:18 -0000 1.1 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/BasicCollectionAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -9,11 +9,11 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.resource.java; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.Transformation + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.BasicCollection * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -24,7 +24,8 @@ * @version 2.1 * @since 2.1 */ -public interface BasicCollectionAnnotation extends JavaResourceNode +public interface BasicCollectionAnnotation + extends Annotation { String ANNOTATION_NAME = EclipseLinkJPA.BASIC_COLLECTION; } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/ReadOnlyAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ReadOnlyAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 ReadOnlyAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/ReadOnlyAnnotation.java 7 Oct 2008 16:19:06 -0000 1.1 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/ReadOnlyAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -9,11 +9,11 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.resource.java; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; /** - * Resource model interface that represents the - * org.eclipse.persistence.annotations.PrivateOwned annotation + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.ReadOnly * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -24,8 +24,8 @@ * @version 2.1 * @since 2.1 */ -public interface ReadOnlyAnnotation extends JavaResourceNode +public interface ReadOnlyAnnotation + extends Annotation { String ANNOTATION_NAME = EclipseLinkJPA.READ_ONLY; - } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/TransformationAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/TransformationAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 TransformationAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/TransformationAnnotation.java 29 Sep 2008 21:47:24 -0000 1.2 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/TransformationAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,13 +10,13 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.core.utility.TextRange; /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.Transformation + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.Transformation * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -27,45 +27,46 @@ * @version 2.1 * @since 2.1 */ -public interface TransformationAnnotation extends JavaResourceNode +public interface TransformationAnnotation + extends Annotation { - String ANNOTATION_NAME = EclipseLinkJPA.TRANSFORMATION; - + /** - * Corresponds to the fetch element of the Transformation annotation. - * Returns null if the fetch element does not exist in java. + * Corresponds to the 'fetch' element of the Transformation annotation. + * Return null if the element does not exist in Java. */ FetchType getFetch(); - + String FETCH_PROPERTY = "fetch"; //$NON-NLS-1$ + /** - * Corresponds to the fetch element of the Transformation annotation. - * Set to null to remove the fetch element. + * Corresponds to the 'fetch' element of the Transformation annotation. + * Set to null to remove the element. */ void setFetch(FetchType fetch); - String FETCH_PROPERTY = "fetchProperty"; //$NON-NLS-1$ - + /** - * Corresponds to the optional element of the Transformation annotation. - * Returns null if the optional element does not exist in java. + * Return the {@link TextRange} for the 'fetch' element. If the element + * does not exist return the {@link TextRange} for the Transformation annotation. */ - Boolean getOptional(); - + TextRange getFetchTextRange(CompilationUnit astRoot); + + /** - * Corresponds to the optional element of the Transformation annotation. - * Set to null to remove the optional element. + * Corresponds to the 'optional' element of the Transformation annotation. + * Return null if the element does not exist in Java. */ - void setOptional(Boolean optional); - String OPTIONAL_PROPERTY = "optionalProperty"; //$NON-NLS-1$ - + Boolean getOptional(); + String OPTIONAL_PROPERTY = "optional"; //$NON-NLS-1$ + /** - * Return the {@link TextRange} for the fetch element. If the fetch element - * does not exist return the {@link TextRange} for the Transformation annotation. + * Corresponds to the 'optional' element of the Transformation annotation. + * Set to null to remove the element. */ - TextRange getFetchTextRange(CompilationUnit astRoot); - + void setOptional(Boolean optional); + /** - * Return the {@link TextRange} for the optional element. If the optional element + * Return the {@link TextRange} for the 'optional' element. If the element * does not exist return the {@link TextRange} for the Transformation annotation. */ TextRange getOptionalTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/eclipselink/core/resource/java/ChangeTrackingAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ChangeTrackingAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 ChangeTrackingAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/ChangeTrackingAnnotation.java 9 Oct 2008 17:38:39 -0000 1.1 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/ChangeTrackingAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,12 +10,12 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** - * Resource model interface that represents the - * org.eclipse.persistence.annotations.ChangeTracking annotation + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.ChangeTracking * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -26,30 +26,28 @@ * @version 2.1 * @since 2.1 */ -public interface ChangeTrackingAnnotation extends JavaResourceNode +public interface ChangeTrackingAnnotation + extends Annotation { - String ANNOTATION_NAME = EclipseLinkJPA.CHANGE_TRACKING; - + /** - * Corresponds to the value element of the ChangeTracking annotation. - * Returns null if the value element does not exist in java. + * Corresponds to the 'value' element of the ChangeTracking annotation. + * Return null if the element does not exist in Java. */ ChangeTrackingType getValue(); - + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ + /** - * Corresponds to the value element of the ChangeTracking annotation. - * Set to null to remove the value element. + * Corresponds to the 'value' element of the ChangeTracking annotation. + * Set to null to remove the element. */ void setValue(ChangeTrackingType value); - String VALUE_PROPERTY = "valueProperty"; //$NON-NLS-1$ - - + /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the ChangeTracking annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); - } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/TransformerAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/TransformerAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 TransformerAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/TransformerAnnotation.java 29 Sep 2008 21:47:24 -0000 1.2 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/TransformerAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,10 +10,14 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** + * Common protocol among: + * org.eclipse.persistence.annotations.ReadTransformer + * org.eclipse.persistence.annotations.WriteTransformer + * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching * stability. It is available at this early stage to solicit feedback from @@ -23,48 +27,49 @@ * @version 2.1 * @since 2.1 */ -public interface TransformerAnnotation extends JavaResourceNode +public interface TransformerAnnotation + extends Annotation { - /** - * Corresponds to the transformerClass element of the *Transformer annotation. - * Returns null if the transformerClass element does not exist in java. - * Returns the portion of the transformerClass preceding the .class. - *

+ * Corresponds to the 'transformerClass' element of the *Transformer annotation. + * Return null if the element does not exist in Java. + * Return the portion of the value preceding ".class". + *

 	 *     @ReadTransformer(transformerClass=Employee.class)
-	 * 

- * will return "Employee" - **/ + *
+ * will return "Employee". + */ String getTransformerClass(); - + String TRANSFORMER_CLASS_PROPERTY = "transformerClass"; //$NON-NLS-1$ + /** - * Corresponds to the transformerClass element of the *Transformer annotation. - * Set to null to remove the transformerClass element. + * Corresponds to the 'transformerClass' element of the *Transformer annotation. + * Set to null to remove the element. */ void setTransformerClass(String transformerClass); - String TRANSFORMER_CLASS_PROPERTY = "transformerClassProperty"; //$NON-NLS-1$ /** - * Corresponds to the method element of the *Transformer annotation. - * Returns null if the method element does not exist in java. - **/ - String getMethod(); - + * Return the {@link TextRange} for the 'transformerClass' element. If the element + * does not exist return the {@link TextRange} for the *Transformer annotation. + */ + TextRange getTransformerClassTextRange(CompilationUnit astRoot); + + /** - * Corresponds to the method element of the *Transformer annotation. - * Set to null to remove the method element. + * Corresponds to the 'method' element of the *Transformer annotation. + * Return null if the element does not exist in Java. */ - void setMethod(String method); - String METHOD_PROPERTY = "methodProperty"; //$NON-NLS-1$ - + String getMethod(); + String METHOD_PROPERTY = "method"; //$NON-NLS-1$ + /** - * Return the {@link TextRange} for the transformerClass element. If the transformerClass element - * does not exist return the {@link TextRange} for the *Transformer annotation. + * Corresponds to the 'method' element of the *Transformer annotation. + * Set to null to remove the element. */ - TextRange getTransformerClassTextRange(CompilationUnit astRoot); - + void setMethod(String method); + /** - * Return the {@link TextRange} for the method element. If the method element + * Return the {@link TextRange} for the 'method' element. If the element * does not exist return the {@link TextRange} for the *Transformer annotation. */ TextRange getMethodTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/eclipselink/core/resource/java/EclipseLinkJPA.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/EclipseLinkJPA.java,v retrieving revision 1.12 diff -u -r1.12 EclipseLinkJPA.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/EclipseLinkJPA.java 6 Jan 2009 22:48:26 -0000 1.12 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/EclipseLinkJPA.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -9,9 +9,8 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.resource.java; - /** - * EclipseLink JPA Java-related stuff (annotations etc.) + * EclipseLink Java-related stuff (annotations etc.) * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -25,18 +24,16 @@ @SuppressWarnings("nls") public interface EclipseLinkJPA { - // EclipseLink JPA package + // EclipseLink package String PACKAGE = "org.eclipse.persistence.annotations"; //$NON-NLS-1$ String PACKAGE_ = PACKAGE + "."; // ********** API ********** - // JPA annotations + // EclispeLink annotations String BASIC_COLLECTION = PACKAGE_ + "BasicCollection"; - String BASIC_MAP = PACKAGE_ + "BasicMap"; - String CACHE = PACKAGE_ + "Cache"; String CACHE__SHARED = "shared"; String CACHE__EXPIRY = "expiry"; @@ -47,111 +44,89 @@ String CACHE__REFRESH_ONLY_IF_NEWER = "refreshOnlyIfNewer"; String CACHE__DISABLE_HITS = "disableHits"; String CACHE__COORDINATION_TYPE = "coordinationType"; - String CACHE_TYPE = PACKAGE_ + "CacheType"; - String CACHE_TYPE_ = CACHE_TYPE + "."; - String CACHE_TYPE__FULL = CACHE_TYPE_ + "FULL"; - String CACHE_TYPE__WEAK = CACHE_TYPE_ + "WEAK"; - String CACHE_TYPE__SOFT = CACHE_TYPE_ + "SOFT"; - String CACHE_TYPE__SOFT_WEAK = CACHE_TYPE_ + "SOFT_WEAK"; - String CACHE_TYPE__HARD_WEAK = CACHE_TYPE_ + "HARD_WEAK"; - String CACHE_TYPE__CACHE = CACHE_TYPE_ + "CACHE"; - String CACHE_TYPE__NONE = CACHE_TYPE_ + "NONE"; - - String CACHE_COORDINATION_TYPE = PACKAGE_ + "CacheCoordinationType"; - String CACHE_COORDINATION_TYPE_ = CACHE_COORDINATION_TYPE + "."; - String CACHE_COORDINATION_TYPE__SEND_OBJECT_CHANGES = CACHE_COORDINATION_TYPE_ + "SEND_OBJECT_CHANGES"; - String CACHE_COORDINATION_TYPE__INVALIDATE_CHANGED_OBJECTS = CACHE_COORDINATION_TYPE_ + "INVALIDATE_CHANGED_OBJECTS"; - String CACHE_COORDINATION_TYPE__SEND_NEW_OBJECTS_WITH_CHANGES = CACHE_COORDINATION_TYPE_ + "SEND_NEW_OBJECTS_WITH_CHANGES"; - String CACHE_COORDINATION_TYPE__NONE = CACHE_COORDINATION_TYPE_ + "NONE"; - String CHANGE_TRACKING = PACKAGE_ + "ChangeTracking"; String CHANGE_TRACKING__VALUE = "value"; - - String CHANGE_TRACKING_TYPE = PACKAGE_ + "ChangeTrackingType"; - String CHANGE_TRACKING_TYPE_ = CHANGE_TRACKING_TYPE + "."; - String CHANGE_TRACKING_TYPE__ATTRIBUTE = CHANGE_TRACKING_TYPE_ + "ATTRIBUTE"; - String CHANGE_TRACKING_TYPE__OBJECT = CHANGE_TRACKING_TYPE_ + "OBJECT"; - String CHANGE_TRACKING_TYPE__DEFERRED = CHANGE_TRACKING_TYPE_ + "DEFERRED"; - String CHANGE_TRACKING_TYPE__AUTO = CHANGE_TRACKING_TYPE_ + "AUTO"; - - String CONVERSION_VALUE = PACKAGE_ + "ConversionValue"; String CONVERSION_VALUE__DATA_VALUE = "dataValue"; String CONVERSION_VALUE__OBJECT_VALUE = "objectValue"; - String CONVERT = PACKAGE_ + "Convert"; String CONVERT__VALUE = "value"; - String CONVERTER = PACKAGE_ + "Converter"; String CONVERTER__NAME = "name"; String CONVERTER__CONVERTER_CLASS = "converterClass"; - String CUSTOMIZER = PACKAGE_ + "Customizer"; String CUSTOMIZER__VALUE = "value"; - String EXISTENCE_CHECKING = PACKAGE_ + "ExistenceChecking"; String EXISTENCE_CHECKING__VALUE = "value"; - - String EXISTENCE_TYPE = PACKAGE_ + "ExistenceType"; - String EXISTENCE_TYPE_ = EXISTENCE_TYPE + "."; - String EXISTENCE_TYPE__CHECK_CACHE = EXISTENCE_TYPE_ + "CHECK_CACHE"; - String EXISTENCE_TYPE__CHECK_DATABASE = EXISTENCE_TYPE_ + "CHECK_DATABASE"; - String EXISTENCE_TYPE__ASSUME_EXISTENCE = EXISTENCE_TYPE_ + "ASSUME_EXISTENCE"; - String EXISTENCE_TYPE__ASSUME_NON_EXISTENCE = EXISTENCE_TYPE_ + "ASSUME_NON_EXISTENCE"; - String JOIN_FETCH = PACKAGE_ + "JoinFetch"; - String JOIN_FETCH_VALUE = "value"; - - String JOIN_FETCH_TYPE = PACKAGE_ + "JoinFetchType"; - String JOIN_FETCH_TYPE_ = JOIN_FETCH_TYPE + "."; - String JOIN_FETCH_TYPE__INNER = JOIN_FETCH_TYPE_ + "INNER"; - String JOIN_FETCH_TYPE__OUTER = JOIN_FETCH_TYPE_ + "OUTER"; - + String JOIN_FETCH__VALUE = "value"; String MUTABLE = PACKAGE_ + "Mutable"; String MUTABLE__VALUE = "value"; - String OBJECT_TYPE_CONVERTER = PACKAGE_ + "ObjectTypeConverter"; String OBJECT_TYPE_CONVERTER__NAME = "name"; - String OBJECT_TYPE_CONVERTER__DATE_TYPE = "dataType"; + String OBJECT_TYPE_CONVERTER__DATA_TYPE = "dataType"; String OBJECT_TYPE_CONVERTER__OBJECT_TYPE = "objectType"; String OBJECT_TYPE_CONVERTER__CONVERSION_VALUES = "conversionValues"; String OBJECT_TYPE_CONVERTER__DEFAULT_OBJECT_VALUE = "defaultObjectValue"; - String PRIVATE_OWNED = PACKAGE_ + "PrivateOwned"; - String READ_ONLY = PACKAGE_ + "ReadOnly"; - String READ_TRANSFORMER = PACKAGE_ + "ReadTransformer"; String READ_TRANSFORMER__TRANSFORMER_CLASS = "transformerClass"; String READ_TRANSFORMER__METHOD = "method"; - String STRUCT_CONVERTER = PACKAGE_ + "StructConverter"; String STRUCT_CONVERTER__NAME = "name"; String STRUCT_CONVERTER__CONVERTER = "converter"; - String TIME_OF_DAY = PACKAGE_ + "TimeOfDay"; String TIME_OF_DAY__HOUR = "hour"; String TIME_OF_DAY__MINUTE = "minute"; String TIME_OF_DAY__SECOND = "second"; String TIME_OF_DAY__MILLISECOND = "millisecond"; - String TRANSFORMATION = PACKAGE_ + "Transformation"; String TRANSFORMATION__FETCH = "fetch"; String TRANSFORMATION__OPTIONAL = "optional"; - String TYPE_CONVERTER = PACKAGE_ + "TypeConverter"; String TYPE_CONVERTER__NAME = "name"; - String TYPE_CONVERTER__DATE_TYPE = "dataType"; + String TYPE_CONVERTER__DATA_TYPE = "dataType"; String TYPE_CONVERTER__OBJECT_TYPE = "objectType"; - String VARIABLE_ONE_TO_ONE = PACKAGE_ + "VariableOneToOne"; - String WRITE_TRANSFORMER = PACKAGE_ + "WriteTransformer"; String WRITE_TRANSFORMER__TRANSFORMER_CLASS = "transformerClass"; String WRITE_TRANSFORMER__METHOD = "method"; String WRITE_TRANSFORMER__COLUMN = "column"; - String WRITE_TRANSFORMERS = PACKAGE_ + "WriteTransformers"; String WRITE_TRANSFORMERS__VALUE = "value"; + // EclipseLink enums + String CACHE_COORDINATION_TYPE = PACKAGE_ + "CacheCoordinationType"; + String CACHE_COORDINATION_TYPE_ = CACHE_COORDINATION_TYPE + "."; + String CACHE_COORDINATION_TYPE__SEND_OBJECT_CHANGES = CACHE_COORDINATION_TYPE_ + "SEND_OBJECT_CHANGES"; + String CACHE_COORDINATION_TYPE__INVALIDATE_CHANGED_OBJECTS = CACHE_COORDINATION_TYPE_ + "INVALIDATE_CHANGED_OBJECTS"; + String CACHE_COORDINATION_TYPE__SEND_NEW_OBJECTS_WITH_CHANGES = CACHE_COORDINATION_TYPE_ + "SEND_NEW_OBJECTS_WITH_CHANGES"; + String CACHE_COORDINATION_TYPE__NONE = CACHE_COORDINATION_TYPE_ + "NONE"; + String CACHE_TYPE = PACKAGE_ + "CacheType"; + String CACHE_TYPE_ = CACHE_TYPE + "."; + String CACHE_TYPE__FULL = CACHE_TYPE_ + "FULL"; + String CACHE_TYPE__WEAK = CACHE_TYPE_ + "WEAK"; + String CACHE_TYPE__SOFT = CACHE_TYPE_ + "SOFT"; + String CACHE_TYPE__SOFT_WEAK = CACHE_TYPE_ + "SOFT_WEAK"; + String CACHE_TYPE__HARD_WEAK = CACHE_TYPE_ + "HARD_WEAK"; + String CACHE_TYPE__CACHE = CACHE_TYPE_ + "CACHE"; + String CACHE_TYPE__NONE = CACHE_TYPE_ + "NONE"; + String CHANGE_TRACKING_TYPE = PACKAGE_ + "ChangeTrackingType"; + String CHANGE_TRACKING_TYPE_ = CHANGE_TRACKING_TYPE + "."; + String CHANGE_TRACKING_TYPE__ATTRIBUTE = CHANGE_TRACKING_TYPE_ + "ATTRIBUTE"; + String CHANGE_TRACKING_TYPE__OBJECT = CHANGE_TRACKING_TYPE_ + "OBJECT"; + String CHANGE_TRACKING_TYPE__DEFERRED = CHANGE_TRACKING_TYPE_ + "DEFERRED"; + String CHANGE_TRACKING_TYPE__AUTO = CHANGE_TRACKING_TYPE_ + "AUTO"; + String EXISTENCE_TYPE = PACKAGE_ + "ExistenceType"; + String EXISTENCE_TYPE_ = EXISTENCE_TYPE + "."; + String EXISTENCE_TYPE__CHECK_CACHE = EXISTENCE_TYPE_ + "CHECK_CACHE"; + String EXISTENCE_TYPE__CHECK_DATABASE = EXISTENCE_TYPE_ + "CHECK_DATABASE"; + String EXISTENCE_TYPE__ASSUME_EXISTENCE = EXISTENCE_TYPE_ + "ASSUME_EXISTENCE"; + String EXISTENCE_TYPE__ASSUME_NON_EXISTENCE = EXISTENCE_TYPE_ + "ASSUME_NON_EXISTENCE"; + String JOIN_FETCH_TYPE = PACKAGE_ + "JoinFetchType"; + String JOIN_FETCH_TYPE_ = JOIN_FETCH_TYPE + "."; + String JOIN_FETCH_TYPE__INNER = JOIN_FETCH_TYPE_ + "INNER"; + String JOIN_FETCH_TYPE__OUTER = JOIN_FETCH_TYPE_ + "OUTER"; + } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/JoinFetchAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/JoinFetchAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 JoinFetchAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/JoinFetchAnnotation.java 29 Sep 2008 21:47:24 -0000 1.2 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/JoinFetchAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,12 +10,12 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** - * Resource model interface that represents the - * org.eclipse.persistence.annotations.JoinFetch annotation + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.JoinFetch * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -26,30 +26,28 @@ * @version 2.1 * @since 2.1 */ -public interface JoinFetchAnnotation extends JavaResourceNode +public interface JoinFetchAnnotation + extends Annotation { - String ANNOTATION_NAME = EclipseLinkJPA.JOIN_FETCH; - + /** - * Corresponds to the value element of the JoinFetch annotation. - * Returns null if the value element does not exist in java. + * Corresponds to the 'value' element of the JoinFetch annotation. + * Return null if the element does not exist in Java. */ JoinFetchType getValue(); - + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ + /** - * Corresponds to the value element of the JoinFetch annotation. - * Set to null to remove the value element. + * Corresponds to the 'value' element of the JoinFetch annotation. + * Set to null to remove the element. */ void setValue(JoinFetchType value); - String VALUE_PROPERTY = "valueProperty"; //$NON-NLS-1$ - - + /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the JoinFetch annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); - } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/ExistenceCheckingAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ExistenceCheckingAnnotation.java,v retrieving revision 1.3 diff -u -r1.3 ExistenceCheckingAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/ExistenceCheckingAnnotation.java 29 Sep 2008 21:47:23 -0000 1.3 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/ExistenceCheckingAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,12 +10,12 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** - * Resource model interface that represents the - * org.eclipse.persistence.annotations.ExistenceChecking annotation + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.ExistenceChecking * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -26,30 +26,28 @@ * @version 2.1 * @since 2.1 */ -public interface ExistenceCheckingAnnotation extends JavaResourceNode +public interface ExistenceCheckingAnnotation + extends Annotation { - String ANNOTATION_NAME = EclipseLinkJPA.EXISTENCE_CHECKING; - + /** - * Corresponds to the value element of the ExistenceChecking annotation. - * Returns null if the value element does not exist in java. + * Corresponds to the 'value' element of the ExistenceChecking annotation. + * Return null if the element does not exist in Java. */ ExistenceType getValue(); - + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ + /** - * Corresponds to the value element of the ExistenceChecking annotation. - * Set to null to remove the value element. + * Corresponds to the 'value' element of the ExistenceChecking annotation. + * Set to null to remove the element. */ void setValue(ExistenceType value); - String VALUE_PROPERTY = "valueProperty"; //$NON-NLS-1$ - - + /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the ExistenceChecking annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); - } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/ObjectTypeConverterAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/ObjectTypeConverterAnnotation.java,v retrieving revision 1.3 diff -u -r1.3 ObjectTypeConverterAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/ObjectTypeConverterAnnotation.java 29 Oct 2008 21:29:03 -0000 1.3 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/ObjectTypeConverterAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -14,8 +14,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.ObjectTypeConverter + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.ObjectTypeConverter * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -26,46 +26,66 @@ * @version 2.1 * @since 2.1 */ -public interface ObjectTypeConverterAnnotation extends TypeConverterAnnotation +public interface ObjectTypeConverterAnnotation + extends BaseTypeConverterAnnotation { String ANNOTATION_NAME = EclipseLinkJPA.OBJECT_TYPE_CONVERTER; /** - * Corresponds to the conversionValues element of the ObjectTypeConverter annotation. - * Returns an empty iterator if the conversionValues element does not exist in java. + * Corresponds to the 'conversionValues' element of the ObjectTypeConverter annotation. + * Return an empty iterator if the element does not exist in Java. */ ListIterator conversionValues(); + String CONVERSION_VALUES_LIST = "conversionValues"; //$NON-NLS-1$ + /** + * Corresponds to the 'conversionValues' element of the ObjectTypeConverter annotation. + */ + int conversionValuesSize(); + + /** + * Corresponds to the 'conversionValues' element of the ObjectTypeConverter annotation. + */ ConversionValueAnnotation conversionValueAt(int index); + /** + * Corresponds to the 'conversionValues' element of the ObjectTypeConverter annotation. + */ int indexOfConversionValue(ConversionValueAnnotation conversionValue); - int conversionValuesSize(); - + /** + * Corresponds to the 'conversionValues' element of the ObjectTypeConverter annotation. + */ ConversionValueAnnotation addConversionValue(int index); - void removeConversionValue(int index); - + /** + * Corresponds to the 'conversionValues' element of the ObjectTypeConverter annotation. + */ void moveConversionValue(int targetIndex, int sourceIndex); - String CONVERSION_VALUES_LIST = "conversionValuesList"; //$NON-NLS-1$ - /** - * Corresponds to the defaultObjectValue element of the ObjectTypeConverter annotation. - * Returns null if the defaultObjectValue element does not exist in java. + * Corresponds to the 'conversionValues' element of the ObjectTypeConverter annotation. */ - String getDefaultObjectValue(); + void removeConversionValue(int index); + /** - * Corresponds to the defaultObjectValue element of the ObjectTypeConverter annotation. - * Set to null to remove the defaultObjectValue element. + * Corresponds to the 'defaultObjectValue' element of the ObjectTypeConverter annotation. + * Return null if the element does not exist in Java. + */ + String getDefaultObjectValue(); + String DEFAULT_OBJECT_VALUE_PROPERTY = "defaultObjectValue"; //$NON-NLS-1$ + + /** + * Corresponds to the 'defaultObjectValue' element of the ObjectTypeConverter annotation. + * Set to null to remove the element. */ void setDefaultObjectValue(String value); - String DEFAULT_OBJECT_VALUE_PROPERTY = "defaultObjectValueProperty"; //$NON-NLS-1$ - + /** - * Return the {@link TextRange} for the defaultObjectValue element. If the defaultObjectValue element + * Return the {@link TextRange} for the 'defaultObjectValue' element. If the element * does not exist return the {@link TextRange} for the ObjectTypeConverter annotation. */ TextRange getDefaultObjectValueTextRange(CompilationUnit astRoot); + } Index: src/org/eclipse/jpt/eclipselink/core/resource/java/MutableAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/MutableAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 MutableAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/MutableAnnotation.java 29 Sep 2008 21:47:24 -0000 1.2 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/MutableAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,12 +10,12 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** - * Java resource model interface that corresponds to the Eclipselink - * annotation org.eclipse.persistence.annotations.Mutable + * Corresponds to the Eclipselink annotation + * org.eclipse.persistence.annotations.Mutable * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -26,27 +26,26 @@ * @version 2.1 * @since 2.1 */ -public interface MutableAnnotation extends JavaResourceNode +public interface MutableAnnotation + extends Annotation { - String ANNOTATION_NAME = EclipseLinkJPA.MUTABLE; - /** - * Corresponds to the value element of the Mutable annotation. - * Returns null if the value element does not exist in java. + * Corresponds to the 'value' element of the Mutable annotation. + * Return null if the element does not exist in Java. */ Boolean getValue(); + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Corresponds to the value element of the Mutable annotation. - * Set to null to remove the value element. + * Corresponds to the 'value' element of the Mutable annotation. + * Set to null to remove the element. */ void setValue(Boolean value); - String VALUE_PROPERTY = "valueProperty"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the Mutable annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java,v retrieving revision 1.4 diff -u -r1.4 CacheAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java 29 Sep 2008 21:47:24 -0000 1.4 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -10,12 +10,12 @@ package org.eclipse.jpt.eclipselink.core.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.utility.TextRange; /** - * Resource model interface that represents the - * org.eclipse.persistence.annotations.Cache annotation + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.Cache * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -26,173 +26,194 @@ * @version 2.1 * @since 2.1 */ -public interface CacheAnnotation extends JavaResourceNode +public interface CacheAnnotation + extends Annotation { - String ANNOTATION_NAME = EclipseLinkJPA.CACHE; - + /** - * Corresponds to the type element of the Cache annotation. - * Returns null if the type element does not exist in java. + * Corresponds to the 'type' element of the Cache annotation. + * Return null if the element does not exist in Java. */ CacheType getType(); + String TYPE_PROPERTY = "type"; //$NON-NLS-1$ /** - * Corresponds to the type element of the Cache annotation. - * Set to null to remove the type element. + * Corresponds to the 'type' element of the Cache annotation. + * Set to null to remove the element. */ void setType(CacheType type); - String TYPE_PROPERTY = "typeProperty"; //$NON-NLS-1$ /** - * Corresponds to the size element of the Cache annotation. - * Returns null if the size valuePair does not exist in the annotation + * Return the {@link TextRange} for the 'type' element. + * If the element does not exist return the {@link TextRange} + * for the Cache annotation. + */ + TextRange getTypeTextRange(CompilationUnit astRoot); + + + /** + * Corresponds to the 'size' element of the Cache annotation. + * Return null if the element does not exist in Java. */ Integer getSize(); + String SIZE_PROPERTY = "size"; //$NON-NLS-1$ /** - * Corresponds to the size element of the Cache annotation. - * Set to null to remove the size valuePair from the annotation + * Corresponds to the 'size' element of the Cache annotation. + * Set to null to remove the element. */ void setSize(Integer size); - String SIZE_PROPERTY = "sizeProperty"; //$NON-NLS-1$ /** - * Corresponds to the shared element of the Cache annotation. - * Returns null if the shared element does not exist in java. + * Return the {@link TextRange} for the 'size' element. + * If the element does not exist return the {@link TextRange} + * for the Cache annotation. + */ + TextRange getSizeTextRange(CompilationUnit astRoot); + + + /** + * Corresponds to the 'shared' element of the Cache annotation. + * Return null if the element does not exist in Java. */ Boolean getShared(); + String SHARED_PROPERTY = "shared"; //$NON-NLS-1$ /** - * Corresponds to the shared element of the Cache annotation. - * Set to null to remove the shared element. + * Corresponds to the 'shared' element of the Cache annotation. + * Set to null to remove the element. */ void setShared(Boolean shared); - String SHARED_PROPERTY = "sharedProperty"; //$NON-NLS-1$ - /** - * Corresponds to the expiry element of the Cache annotation. - * Returns null if the expiry valuePair does not exist in the annotation + * Return the {@link TextRange} for the 'shared' element. + * If the element does not exist return the {@link TextRange} + * for the Cache annotation. + */ + TextRange getSharedTextRange(CompilationUnit astRoot); + + + /** + * Corresponds to the 'expiry' element of the Cache annotation. + * Return null if the element does not exist in Java. */ Integer getExpiry(); + String EXPIRY_PROPERTY = "expiry"; //$NON-NLS-1$ /** - * Corresponds to the expiry element of the Cache annotation. - * Set to null to remove the expiry valuePair from the annotation + * Corresponds to the 'expiry' element of the Cache annotation. + * Set to null to remove the element. */ void setExpiry(Integer expiry); - String EXPIRY_PROPERTY = "expiryProperty"; //$NON-NLS-1$ - TimeOfDayAnnotation addExpiryTimeOfDay(); - void removeExpiryTimeOfDay(); - TimeOfDayAnnotation getExpiryTimeOfDay(); - String EXPIRY_TIME_OF_DAY_PROPERTY = "expiryTimeOfDayProperty"; //$NON-NLS-1$ - /** - * Corresponds to the alwaysRefresh element of the Cache annotation. - * Returns null if the alwaysRefresh element does not exist in java. + * Return the {@link TextRange} for the 'expiry' element. + * If the element does not exist return the {@link TextRange} + * for the Cache annotation. */ - Boolean getAlwaysRefresh(); + TextRange getExpiryTextRange(CompilationUnit astRoot); + /** - * Corresponds to the alwaysRefresh element of the Cache annotation. - * Set to null to remove the alwaysRefresh element. + * Corresponds to the 'expiryTimeOfDay' element of the Cache annotation. + * Return null if the element does not exist in Java. */ - void setAlwaysRefresh(Boolean alwaysRefresh); - String ALWAYS_REFRESH_PROPERTY = "alwaysRefreshProperty"; //$NON-NLS-1$ + TimeOfDayAnnotation getExpiryTimeOfDay(); + String EXPIRY_TIME_OF_DAY_PROPERTY = "expiryTimeOfDay"; //$NON-NLS-1$ + + TimeOfDayAnnotation addExpiryTimeOfDay(); + + void removeExpiryTimeOfDay(); /** - * Corresponds to the refreshOnlyIfNewer element of the Cache annotation. - * Returns null if the refreshOnlyIfNewer element does not exist in java. + * Return the {@link TextRange} for the 'expiryTimeOfDay' element. + * If the element does not exist return the {@link TextRange} + * for the Cache annotation. */ - Boolean getRefreshOnlyIfNewer(); + TextRange getExpiryTimeOfDayTextRange(CompilationUnit astRoot); + /** - * Corresponds to the refreshOnlyIfNewer element of the Cache annotation. - * Set to null to remove the refreshOnlyIfNewer element. - */ - void setRefreshOnlyIfNewer(Boolean refreshOnlyIfNewer); - String REFRESH_ONLY_IF_NEWER_PROPERTY = "refreshOnlyIfNewerProperty"; //$NON-NLS-1$ - - /** - * Corresponds to the disableHits element of the Cache annotation. - * Returns null if the disableHits element does not exist in java. + * Corresponds to the 'alwaysRefresh' element of the Cache annotation. + * Return null if the element does not exist in Java. */ - Boolean getDisableHits(); + Boolean getAlwaysRefresh(); + String ALWAYS_REFRESH_PROPERTY = "alwaysRefresh"; //$NON-NLS-1$ /** - * Corresponds to the disableHits element of the Cache annotation. - * Set to null to remove the disableHits element. + * Corresponds to the 'alwaysRefresh' element of the Cache annotation. + * Set to null to remove the element. */ - void setDisableHits(Boolean disableHits); - String DISABLE_HITS_PROPERTY = "disableHitsProperty"; //$NON-NLS-1$ + void setAlwaysRefresh(Boolean alwaysRefresh); /** - * Corresponds to the type element of the Cache annotation. - * Returns null if the type element does not exist in java. + * Return the {@link TextRange} for the 'alwaysRefresh' element. + * If the element does not exist return the {@link TextRange} + * for the Cache annotation. */ - CacheCoordinationType getCoordinationType(); + TextRange getAlwaysRefreshTextRange(CompilationUnit astRoot); - /** - * Corresponds to the type element of the Cache annotation. - * Set to null to remove the type element. - */ - void setCoordinationType(CacheCoordinationType coordinationType); - String COORDINATION_TYPE_PROPERTY = "coordinationTypeProperty"; //$NON-NLS-1$ - /** - * Return the {@link TextRange} for the type element. If the type element - * does not exist return the {@link TextRange} for the Cache annotation. + * Corresponds to the 'refreshOnlyIfNewer' element of the Cache annotation. + * Return null if the element does not exist in Java. */ - TextRange getTypeTextRange(CompilationUnit astRoot); + Boolean getRefreshOnlyIfNewer(); + String REFRESH_ONLY_IF_NEWER_PROPERTY = "refreshOnlyIfNewer"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the shared element. If the shared element - * does not exist return the {@link TextRange} for the Cache annotation. + * Corresponds to the 'refreshOnlyIfNewer' element of the Cache annotation. + * Set to null to remove the element. */ - TextRange getSizeTextRange(CompilationUnit astRoot); - + void setRefreshOnlyIfNewer(Boolean refreshOnlyIfNewer); + /** - * Return the {@link TextRange} for the shared element. If the shared element - * does not exist return the {@link TextRange} for the Cache annotation. + * Return the {@link TextRange} for the 'refreshOnlyIfNewer' element. + * If the element does not exist return the {@link TextRange} + * for the Cache annotation. */ - TextRange getSharedTextRange(CompilationUnit astRoot); + TextRange getRefreshOnlyIfNewerTextRange(CompilationUnit astRoot); + /** - * Return the {@link TextRange} for the expiry element. If the expiry element - * does not exist return the {@link TextRange} for the Cache annotation. + * Corresponds to the 'disableHits' element of the Cache annotation. + * Return null if the element does not exist in Java. */ - TextRange getExpiryTextRange(CompilationUnit astRoot); + Boolean getDisableHits(); + String DISABLE_HITS_PROPERTY = "disableHits"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the expiryTimeOfDay element. If the expiryTimeOfDay element - * does not exist return the {@link TextRange} for the Cache annotation. + * Corresponds to the 'disableHits' element of the Cache annotation. + * Set to null to remove the element. */ - TextRange getExpiryTimeOfDayTextRange(CompilationUnit astRoot); - + void setDisableHits(Boolean disableHits); + /** - * Return the {@link TextRange} for the alwaysRefresh element. If the alwaysRefresh element - * does not exist return the {@link TextRange} for the Cache annotation. + * Return the {@link TextRange} for the 'disableHits' element. + * If the element does not exist return the {@link TextRange} + * for the Cache annotation. */ - TextRange getAlwaysRefreshTextRange(CompilationUnit astRoot); + TextRange getDisablesHitsTextRange(CompilationUnit astRoot); + /** - * Return the {@link TextRange} for the refreshOnlyIfNewer element. If the refreshOnlyIfNewer element - * does not exist return the {@link TextRange} for the Cache annotation. + * Corresponds to the 'coordinationType' element of the Cache annotation. + * Return null if the element does not exist in Java. */ - TextRange getRefreshOnlyIfNewerTextRange(CompilationUnit astRoot); + CacheCoordinationType getCoordinationType(); + String COORDINATION_TYPE_PROPERTY = "coordinationType"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the disableHits element. If the disableHits element - * does not exist return the {@link TextRange} for the Cache annotation. + * Corresponds to the 'coordinationType' element of the Cache annotation. + * Set to null to remove the element. */ - TextRange getDisablesHitsTextRange(CompilationUnit astRoot); - + void setCoordinationType(CacheCoordinationType coordinationType); + /** - * Return the {@link TextRange} for the coordinationType element. If the coordinationType element - * does not exist return the {@link TextRange} for the Cache annotation. + * Return the {@link TextRange} for the 'coordinationType' element. + * If the element does not exist return the {@link TextRange} + * for the Cache annotation. */ TextRange getCoordinationTypeTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/eclipselink/core/resource/java/PrivateOwnedAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/PrivateOwnedAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 PrivateOwnedAnnotation.java --- src/org/eclipse/jpt/eclipselink/core/resource/java/PrivateOwnedAnnotation.java 26 Sep 2008 19:34:14 -0000 1.1 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/PrivateOwnedAnnotation.java 6 Apr 2009 20:58:57 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * 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. @@ -9,11 +9,11 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.resource.java; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; /** - * Resource model interface that represents the - * org.eclipse.persistence.annotations.PrivateOwned annotation + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.PrivateOwned * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -24,8 +24,8 @@ * @version 2.1 * @since 2.1 */ -public interface PrivateOwnedAnnotation extends JavaResourceNode +public interface PrivateOwnedAnnotation + extends Annotation { String ANNOTATION_NAME = EclipseLinkJPA.PRIVATE_OWNED; - } Index: src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaAnnotationDefinitionProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaAnnotationDefinitionProvider.java,v retrieving revision 1.1 diff -u -r1.1 EclipseLinkJpaAnnotationDefinitionProvider.java --- src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaAnnotationDefinitionProvider.java 15 Jan 2009 17:59:32 -0000 1.1 +++ src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaAnnotationDefinitionProvider.java 6 Apr 2009 20:58:57 -0000 @@ -13,25 +13,25 @@ import org.eclipse.jpt.core.JpaAnnotationDefinitionProvider; import org.eclipse.jpt.core.internal.platform.AbstractJpaAnnotationDefintionProvider; import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.BasicCollectionImpl.BasicCollectionAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.BasicMapImpl.BasicMapAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.CacheImpl.CacheAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.ChangeTrackingImpl.ChangeTrackingAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.ConvertImpl.ConvertAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.ConverterImpl.ConverterAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.CustomizerImpl.CustomizerAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.ExistenceCheckingImpl.ExistenceCheckingAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.JoinFetchImpl.JoinFetchAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.MutableImpl.MutableAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.ObjectTypeConverterImpl.ObjectTypeConverterAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.PrivateOwnedImpl.PrivateOwnedAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.ReadOnlyImpl.ReadOnlyAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.ReadTransformerImpl.ReadTransformerAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.StructConverterImpl.StructConverterAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.TransformationImpl.TransformationAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.TypeConverterImpl.TypeConverterAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.VariableOneToOneImpl.VariableOneToOneAnnotationDefinition; -import org.eclipse.jpt.eclipselink.core.internal.resource.java.WriteTransformerImpl.WriteTransformerAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.BasicCollectionAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.BasicMapAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.CacheAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.ChangeTrackingAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.ConvertAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.ConverterAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.CustomizerAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.ExistenceCheckingAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.JoinFetchAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.MutableAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.ObjectTypeConverterAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.PrivateOwnedAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.ReadOnlyAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.ReadTransformerAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.StructConverterAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.TransformationAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.TypeConverterAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.VariableOneToOneAnnotationDefinition; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.WriteTransformerAnnotationDefinition; /** * Provides annotations for 1.0 EclipseLink platform which includes JPA annotations and Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.eclipselink.core/META-INF/MANIFEST.MF,v retrieving revision 1.26 diff -u -r1.26 MANIFEST.MF --- META-INF/MANIFEST.MF 12 Feb 2009 23:14:33 -0000 1.26 +++ META-INF/MANIFEST.MF 6 Apr 2009 20:58:57 -0000 @@ -46,11 +46,13 @@ org.eclipse.jpt.eclipselink.core.internal.ddlgen;x-internal:=true, org.eclipse.jpt.eclipselink.core.internal.operations;x-internal:=true, org.eclipse.jpt.eclipselink.core.internal.resource.java;x-internal:=true, + org.eclipse.jpt.eclipselink.core.internal.resource.java.binary;x-internal:=true, + org.eclipse.jpt.eclipselink.core.internal.resource.java.source;x-internal:=true, org.eclipse.jpt.eclipselink.core.internal.resource.orm;x-internal:=true, org.eclipse.jpt.eclipselink.core.internal.resource.orm.translators;x-internal:=true, org.eclipse.jpt.eclipselink.core.resource.java, org.eclipse.jpt.eclipselink.core.resource.orm, - org.eclipse.jpt.eclipselink1_1.core.internal.resource.orm.translators, + org.eclipse.jpt.eclipselink1_1.core.internal.resource.orm.translators;x-internal:=true, org.eclipse.jpt.eclipselink1_1.core.resource.orm, org.eclipse.jpt.eclipselink1_1.core.resource.orm.util Bundle-RequiredExecutionEnvironment: J2SE-1.5 Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ObjectTypeConverterAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ObjectTypeConverterAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ObjectTypeConverterAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ObjectTypeConverterAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryObjectTypeConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceObjectTypeConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ObjectTypeConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.ObjectTypeConverter + */ +public class ObjectTypeConverterAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new ObjectTypeConverterAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private ObjectTypeConverterAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceObjectTypeConverterAnnotation(parent, member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryObjectTypeConverterAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ObjectTypeConverterAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryVariableOneToOneAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryVariableOneToOneAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryVariableOneToOneAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryVariableOneToOneAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.eclipselink.core.resource.java.VariableOneToOneAnnotation; + +/** + * org.eclipse.persistence.annotations.VariableOneToOne + */ +public class BinaryVariableOneToOneAnnotation + extends BinaryAnnotation + implements VariableOneToOneAnnotation +{ + public BinaryVariableOneToOneAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceExistenceCheckingAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceExistenceCheckingAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceExistenceCheckingAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceExistenceCheckingAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,96 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.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; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.ExistenceCheckingAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ExistenceType; + +/** + * org.eclipse.persistence.annotations.ExistenceChecking + */ +public final class SourceExistenceCheckingAnnotation + extends SourceAnnotation + implements ExistenceCheckingAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private ExistenceType value; + + + public SourceExistenceCheckingAnnotation(JavaResourcePersistentType parent, Type type) { + super(parent, type, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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); + } + + + // ********** ExistenceCheckingAnnotation implementation ********** + + // ***** value + public ExistenceType getValue() { + return this.value; + } + + public void setValue(ExistenceType value) { + if (this.attributeValueHasNotChanged(this.value, value)) { + return; + } + ExistenceType old = this.value; + this.value = value; + this.valueAdapter.setValue(ExistenceType.toJavaAnnotationValue(value)); + this.firePropertyChanged(VALUE_PROPERTY, old, value); + } + + private ExistenceType buildValue(CompilationUnit astRoot) { + return ExistenceType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(VALUE_ADAPTER, astRoot); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildValueAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.EXISTENCE_CHECKING__VALUE, false); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullTransformationAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullTransformationAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullTransformationAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullTransformationAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.NullAnnotation; +import org.eclipse.jpt.core.resource.java.FetchType; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.TransformationAnnotation; + +/** + * org.eclipse.persistence.annotations.Transformation + */ +public class NullTransformationAnnotation + extends NullAnnotation + implements TransformationAnnotation +{ + protected NullTransformationAnnotation(JavaResourcePersistentAttribute parent) { + super(parent); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + protected TransformationAnnotation buildMappingAnnotation() { + return (TransformationAnnotation) super.buildMappingAnnotation(); + } + + // ***** fetch + public FetchType getFetch() { + return null; + } + + public void setFetch(FetchType fetch) { + if (fetch != null) { + this.buildMappingAnnotation().setFetch(fetch); + } + } + + public TextRange getFetchTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** optional + public Boolean getOptional() { + return null; + } + + public void setOptional(Boolean optional) { + if (optional != null) { + this.buildMappingAnnotation().setOptional(optional); + } + } + + public TextRange getOptionalTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBaseTypeConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBaseTypeConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBaseTypeConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBaseTypeConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,96 @@ +/******************************************************************************* + * 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.eclipselink.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.JavaResourcePersistentMember; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.BaseTypeConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.ObjectTypeConverter + * org.eclipse.persistence.annotations.TypeConverter + */ +abstract class BinaryBaseTypeConverterAnnotation + extends BinaryNamedConverterAnnotation + implements BaseTypeConverterAnnotation +{ + String dataType; + String objectType; + + + BinaryBaseTypeConverterAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.dataType = this.buildDataType(); + this.objectType = this.buildObjectType(); + } + + @Override + public void update() { + super.update(); + this.setDataType_(this.buildDataType()); + this.setObjectType_(this.buildObjectType()); + } + + + // ********** ObjectTypeConverterAnnotation implementation ********** + + // ***** data type + public String getDataType() { + return this.dataType; + } + + public void setDataType(String dataType) { + throw new UnsupportedOperationException(); + } + + private void setDataType_(String dataType) { + String old = this.dataType; + this.dataType = dataType; + this.firePropertyChanged(DATA_TYPE_PROPERTY, old, dataType); + } + + private String buildDataType() { + return (String) this.getJdtMemberValue(this.getDataTypeElementName()); + } + + public TextRange getDataTypeTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + abstract String getDataTypeElementName(); + + // ***** object type + public String getObjectType() { + return this.objectType; + } + + public void setObjectType(String objectType) { + throw new UnsupportedOperationException(); + } + + private void setObjectType_(String objectType) { + String old = this.objectType; + this.objectType = objectType; + this.firePropertyChanged(OBJECT_TYPE_PROPERTY, old, objectType); + } + + private String buildObjectType() { + return (String) this.getJdtMemberValue(this.getObjectTypeElementName()); + } + + public TextRange getObjectTypeTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + abstract String getObjectTypeElementName(); + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryStructConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryStructConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryStructConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryStructConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,78 @@ +/******************************************************************************* + * 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.eclipselink.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.JavaResourcePersistentMember; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.StructConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.StructConverter + */ +public final class BinaryStructConverterAnnotation + extends BinaryNamedConverterAnnotation + implements StructConverterAnnotation +{ + private String converter; + + + public BinaryStructConverterAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.converter = this.buildConverter(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + public void update() { + super.update(); + this.setConverter_(this.buildConverter()); + } + + + // ********** BinaryNamedConverterAnnotation implementation ********** + + @Override + String getNameElementName() { + return EclipseLinkJPA.STRUCT_CONVERTER__NAME; + } + + + // ********** StructConverterAnnotation implementation ********** + + // ***** converter + public String getConverter() { + return this.converter; + } + + public void setConverter(String converter) { + throw new UnsupportedOperationException(); + } + + private void setConverter_(String converter) { + String old = this.converter; + this.converter = converter; + this.firePropertyChanged(CONVERTER_PROPERTY, old, converter); + } + + private String buildConverter() { + return (String) this.getJdtMemberValue(EclipseLinkJPA.STRUCT_CONVERTER__CONVERTER); + } + + public TextRange getConverterTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CustomizerAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CustomizerAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CustomizerAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CustomizerAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Member; +import org.eclipse.jpt.core.utility.jdt.Type; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryCustomizerAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceCustomizerAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.CustomizerAnnotation; + +/** + * org.eclipse.persistence.annotations.Customizer + */ +public class CustomizerAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new CustomizerAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private CustomizerAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceCustomizerAnnotation(parent, (Type) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryCustomizerAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return CustomizerAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBasicCollectionAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBasicCollectionAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBasicCollectionAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBasicCollectionAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.eclipselink.core.resource.java.BasicCollectionAnnotation; + +/** + * org.eclipse.persistence.annotations.BasicCollection + */ +public final class BinaryBasicCollectionAnnotation + extends BinaryAnnotation + implements BasicCollectionAnnotation +{ + public BinaryBasicCollectionAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourcePrivateOwnedAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourcePrivateOwnedAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourcePrivateOwnedAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourcePrivateOwnedAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; +import org.eclipse.jpt.eclipselink.core.resource.java.PrivateOwnedAnnotation; + +/** + * org.eclipse.persistence.annotations.PrivateOwned + */ +public final class SourcePrivateOwnedAnnotation + extends SourceAnnotation + implements PrivateOwnedAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + + public SourcePrivateOwnedAnnotation(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 + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConverterAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConverterAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConverterAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConverterAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.Converter + */ +public class ConverterAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new ConverterAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private ConverterAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceConverterAnnotation(parent, member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryConverterAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ConverterAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTimeOfDayAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTimeOfDayAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTimeOfDayAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTimeOfDayAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,149 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; + +/** + * org.eclipse.persistence.annotations.TimeOfDay + */ +public final class BinaryTimeOfDayAnnotation + extends BinaryAnnotation + implements TimeOfDayAnnotation +{ + private Integer hour; + private Integer minute; + private Integer second; + private Integer millisecond; + + + public BinaryTimeOfDayAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.hour = this.buildHour(); + this.minute = this.buildMinute(); + this.second = this.buildSecond(); + this.millisecond = this.buildMillisecond(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + public void update() { + super.update(); + this.setHour_(this.buildHour()); + this.setMinute_(this.buildMinute()); + this.setSecond_(this.buildSecond()); + this.setMillisecond_(this.buildMillisecond()); + } + + + // ********** TimeOfDayAnnotation implementation ********** + + // ***** hour + public Integer getHour() { + return this.hour; + } + + public void setHour(Integer hour) { + throw new UnsupportedOperationException(); + } + + private void setHour_(Integer hour) { + Integer old = this.hour; + this.hour = hour; + this.firePropertyChanged(HOUR_PROPERTY, old, hour); + } + + private Integer buildHour() { + return (Integer) this.getJdtMemberValue(EclipseLinkJPA.TIME_OF_DAY__HOUR); + } + + public TextRange getHourTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** minute + public Integer getMinute() { + return this.minute; + } + + public void setMinute(Integer newMinute) { + throw new UnsupportedOperationException(); + } + + private void setMinute_(Integer newMinute) { + Integer oldMinute = this.minute; + this.minute = newMinute; + this.firePropertyChanged(MINUTE_PROPERTY, oldMinute, newMinute); + } + + private Integer buildMinute() { + return (Integer) this.getJdtMemberValue(EclipseLinkJPA.TIME_OF_DAY__MINUTE); + } + + public TextRange getMinuteTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** second + public Integer getSecond() { + return this.second; + } + + public void setSecond(Integer newSecond) { + throw new UnsupportedOperationException(); + } + + private void setSecond_(Integer newSecond) { + Integer oldSecond = this.second; + this.second = newSecond; + this.firePropertyChanged(SECOND_PROPERTY, oldSecond, newSecond); + } + + private Integer buildSecond() { + return (Integer) this.getJdtMemberValue(EclipseLinkJPA.TIME_OF_DAY__SECOND); + } + + public TextRange getSecondTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** millisecond + public Integer getMillisecond() { + return this.millisecond; + } + + public void setMillisecond(Integer newMillisecond) { + throw new UnsupportedOperationException(); + } + + private void setMillisecond_(Integer newMillisecond) { + Integer oldMillisecond = this.millisecond; + this.millisecond = newMillisecond; + this.firePropertyChanged(MILLISECOND_PROPERTY, oldMillisecond, newMillisecond); + } + + private Integer buildMillisecond() { + return (Integer) this.getJdtMemberValue(EclipseLinkJPA.TIME_OF_DAY__MILLISECOND); + } + + public TextRange getMillisecondTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceReadOnlyAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceReadOnlyAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceReadOnlyAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceReadOnlyAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; +import org.eclipse.jpt.core.utility.jdt.Type; +import org.eclipse.jpt.eclipselink.core.resource.java.ReadOnlyAnnotation; + +/** + * org.eclipse.persistence.annotations.ReadOnly + */ +public final class SourceReadOnlyAnnotation + extends SourceAnnotation + implements ReadOnlyAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + + public SourceReadOnlyAnnotation(JavaResourceNode 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 + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryReadOnlyAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryReadOnlyAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryReadOnlyAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryReadOnlyAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.eclipselink.core.resource.java.ReadOnlyAnnotation; + +/** + * org.eclipse.persistence.annotations.ReadOnly + */ +public final class BinaryReadOnlyAnnotation + extends BinaryAnnotation + implements ReadOnlyAnnotation +{ + + public BinaryReadOnlyAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceObjectTypeConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceObjectTypeConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceObjectTypeConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceObjectTypeConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,258 @@ +/******************************************************************************* + * 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.eclipselink.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.resource.java.source.AnnotationContainerTools; +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.internal.utility.jdt.StringExpressionConverter; +import org.eclipse.jpt.core.resource.java.AnnotationContainer; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +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; +import org.eclipse.jpt.eclipselink.core.resource.java.ConversionValueAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.NestableConversionValueAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ObjectTypeConverterAnnotation; +import org.eclipse.jpt.utility.internal.CollectionTools; +import org.eclipse.jpt.utility.internal.StringTools; +import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; + +/** + * org.eclipse.persistence.annotations.ObjectTypeConverter + */ +public final class SourceObjectTypeConverterAnnotation + extends SourceBaseTypeConverterAnnotation + implements ObjectTypeConverterAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter DEFAULT_OBJECT_VALUE_ADAPTER = buildDefaultObjectValueAdapter(); + private final AnnotationElementAdapter defaultObjectValueAdapter; + private String defaultObjectValue; + + private final Vector conversionValues = new Vector(); + private final ConversionValuesAnnotationContainer conversionValuesContainer = new ConversionValuesAnnotationContainer(); + + + public SourceObjectTypeConverterAnnotation(JavaResourcePersistentMember parent, Member member) { + super(parent, member, DECLARATION_ANNOTATION_ADAPTER); + this.defaultObjectValueAdapter = new ShortCircuitAnnotationElementAdapter(member, DEFAULT_OBJECT_VALUE_ADAPTER); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + public void initialize(CompilationUnit astRoot) { + super.initialize(astRoot); + this.defaultObjectValue = this.buildDefaultObjectValue(astRoot); + AnnotationContainerTools.initialize(this.conversionValuesContainer, astRoot); + } + + @Override + public void update(CompilationUnit astRoot) { + super.update(astRoot); + this.setDefaultObjectValue(this.buildDefaultObjectValue(astRoot)); + AnnotationContainerTools.update(this.conversionValuesContainer, astRoot); + } + + + // ********** SourceNamedConverterAnnotation implementation ********** + + @Override + String getNameElementName() { + return EclipseLinkJPA.OBJECT_TYPE_CONVERTER__NAME; + } + + + // ********** SourceBaseTypeConverterAnnotation implementation ********** + + @Override + String getDataTypeElementName() { + return EclipseLinkJPA.OBJECT_TYPE_CONVERTER__DATA_TYPE; + } + + @Override + String getObjectTypeElementName() { + return EclipseLinkJPA.OBJECT_TYPE_CONVERTER__OBJECT_TYPE; + } + + + // ********** ObjectTypeConverterAnnotation implementation ********** + + // ***** default object value + public String getDefaultObjectValue() { + return this.defaultObjectValue; + } + + public void setDefaultObjectValue(String defaultObjectValue) { + if (this.attributeValueHasNotChanged(this.defaultObjectValue, defaultObjectValue)) { + return; + } + String old = this.defaultObjectValue; + this.defaultObjectValue = defaultObjectValue; + this.defaultObjectValueAdapter.setValue(defaultObjectValue); + this.firePropertyChanged(DEFAULT_OBJECT_VALUE_PROPERTY, old, defaultObjectValue); + } + + private String buildDefaultObjectValue(CompilationUnit astRoot) { + return this.defaultObjectValueAdapter.getValue(astRoot); + } + + public TextRange getDefaultObjectValueTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(DEFAULT_OBJECT_VALUE_ADAPTER, astRoot); + } + + // ***** conversion values + public ListIterator conversionValues() { + return new CloneListIterator(this.conversionValues); + } + + ListIterator nestableConversionValues() { + return new CloneListIterator(this.conversionValues); + } + + public int conversionValuesSize() { + return this.conversionValues.size(); + } + + public NestableConversionValueAnnotation conversionValueAt(int index) { + return this.conversionValues.get(index); + } + + public int indexOfConversionValue(ConversionValueAnnotation conversionValue) { + return this.conversionValues.indexOf(conversionValue); + } + + public NestableConversionValueAnnotation addConversionValue(int index) { + return (NestableConversionValueAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.conversionValuesContainer); + } + + NestableConversionValueAnnotation addConversionValueInternal() { + NestableConversionValueAnnotation conversionValue = this.buildConversionValue(this.conversionValues.size()); + this.conversionValues.add(conversionValue); + return conversionValue; + } + + private NestableConversionValueAnnotation buildConversionValue(int index) { + return SourceConversionValueAnnotation.createConversionValue(this, this.member, this.daa, index); + } + + void conversionValueAdded(int index, NestableConversionValueAnnotation conversionValue) { + this.fireItemAdded(CONVERSION_VALUES_LIST, index, conversionValue); + } + + public void moveConversionValue(int targetIndex, int sourceIndex) { + AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.conversionValuesContainer); + } + + NestableConversionValueAnnotation moveConversionValueInternal(int targetIndex, int sourceIndex) { + return CollectionTools.move(this.conversionValues, targetIndex, sourceIndex).get(targetIndex); + } + + void conversionValueMoved(int targetIndex, int sourceIndex) { + this.fireItemMoved(CONVERSION_VALUES_LIST, targetIndex, sourceIndex); + } + + public void removeConversionValue(int index) { + AnnotationContainerTools.removeNestedAnnotation(index, this.conversionValuesContainer); + } + + NestableConversionValueAnnotation removeConversionValueInternal(int index) { + return this.conversionValues.remove(index); + } + + void conversionValueRemoved(int index, NestableConversionValueAnnotation conversionValue) { + this.fireItemRemoved(CONVERSION_VALUES_LIST, index, conversionValue); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildDefaultObjectValueAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.OBJECT_TYPE_CONVERTER__DEFAULT_OBJECT_VALUE, false, StringExpressionConverter.instance()); + } + + + // ********** conversion value container ********** + + /** + * adapt the AnnotationContainer interface to the object type converter's + * conversion values + */ + class ConversionValuesAnnotationContainer + implements AnnotationContainer + { + public String getContainerAnnotationName() { + return SourceObjectTypeConverterAnnotation.this.getAnnotationName(); + } + + public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) { + return SourceObjectTypeConverterAnnotation.this.getJdtAnnotation(astRoot); + } + + public String getElementName() { + return EclipseLinkJPA.OBJECT_TYPE_CONVERTER__CONVERSION_VALUES; + } + + public String getNestableAnnotationName() { + return ConversionValueAnnotation.ANNOTATION_NAME; + } + + public ListIterator nestedAnnotations() { + return SourceObjectTypeConverterAnnotation.this.nestableConversionValues(); + } + + public int nestedAnnotationsSize() { + return SourceObjectTypeConverterAnnotation.this.conversionValuesSize(); + } + + public NestableConversionValueAnnotation addNestedAnnotationInternal() { + return SourceObjectTypeConverterAnnotation.this.addConversionValueInternal(); + } + + public void nestedAnnotationAdded(int index, NestableConversionValueAnnotation nestedAnnotation) { + SourceObjectTypeConverterAnnotation.this.conversionValueAdded(index, nestedAnnotation); + } + + public NestableConversionValueAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) { + return SourceObjectTypeConverterAnnotation.this.moveConversionValueInternal(targetIndex, sourceIndex); + } + + public void nestedAnnotationMoved(int targetIndex, int sourceIndex) { + SourceObjectTypeConverterAnnotation.this.conversionValueMoved(targetIndex, sourceIndex); + } + + public NestableConversionValueAnnotation removeNestedAnnotationInternal(int index) { + return SourceObjectTypeConverterAnnotation.this.removeConversionValueInternal(index); + } + + public void nestedAnnotationRemoved(int index, NestableConversionValueAnnotation nestedAnnotation) { + SourceObjectTypeConverterAnnotation.this.conversionValueRemoved(index, nestedAnnotation); + } + + @Override + public String toString() { + return StringTools.buildToStringFor(this); + } + + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryPrivateOwnedAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryPrivateOwnedAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryPrivateOwnedAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryPrivateOwnedAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.eclipselink.core.resource.java.PrivateOwnedAnnotation; + +/** + * org.eclipse.persistence.annotations.PrivateOwned + */ +public final class BinaryPrivateOwnedAnnotation + extends BinaryAnnotation + implements PrivateOwnedAnnotation +{ + + public BinaryPrivateOwnedAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBasicMapAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBasicMapAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBasicMapAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryBasicMapAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.eclipselink.core.resource.java.BasicMapAnnotation; + +/** + * org.eclipse.persistence.annotations.BasicMap + */ +public final class BinaryBasicMapAnnotation + extends BinaryAnnotation + implements BasicMapAnnotation +{ + public BinaryBasicMapAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryExistenceCheckingAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryExistenceCheckingAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryExistenceCheckingAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryExistenceCheckingAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,72 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.ExistenceCheckingAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ExistenceType; + +/** + * org.eclipse.persistence.annotations.ExistenceChecking + */ +public final class BinaryExistenceCheckingAnnotation + extends BinaryAnnotation + implements ExistenceCheckingAnnotation +{ + private ExistenceType value; + + + public BinaryExistenceCheckingAnnotation(JavaResourcePersistentType 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()); + } + + + // ********** ExistenceCheckingAnnotation implementation ********** + + // ***** value + public ExistenceType getValue() { + return this.value; + } + + public void setValue(ExistenceType value) { + throw new UnsupportedOperationException(); + } + + private void setValue_(ExistenceType value) { + ExistenceType old = this.value; + this.value = value; + this.firePropertyChanged(VALUE_PROPERTY, old, value); + } + + private ExistenceType buildValue() { + return ExistenceType.fromJavaAnnotationValue(this.getJdtMemberValue(EclipseLinkJPA.EXISTENCE_CHECKING__VALUE)); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceWriteTransformerAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceWriteTransformerAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceWriteTransformerAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceWriteTransformerAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,137 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceColumnAnnotation; +import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; +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.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.core.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.NullWriteTransformerColumnAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.WriteTransformerAnnotation; + +/** + * org.eclipse.persistence.annotations.WriteTransformer + */ +public final class SourceWriteTransformerAnnotation + extends SourceTransformerAnnotation + implements WriteTransformerAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private final MemberAnnotationAdapter columnAdapter; + private ColumnAnnotation column; + + + public SourceWriteTransformerAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + this.columnAdapter = new MemberAnnotationAdapter(this.member, buildColumnAnnotationAdapter(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 = createColumn(this, this.member, this.daa); + this.column.initialize(astRoot); + } + } + + @Override + public void update(CompilationUnit astRoot) { + super.update(astRoot); + if (this.columnAdapter.getAnnotation(astRoot) == null) { + this.setColumn(null); + } else { + if (this.column == null) { + ColumnAnnotation col = createColumn(this, this.member, this.daa); + col.initialize(astRoot); + this.setColumn(col); + } else { + this.column.update(astRoot); + } + } + } + + + // ********** SourceTransformerAnnotation implementation ********** + + @Override + String getTransformerClassElementName() { + return EclipseLinkJPA.WRITE_TRANSFORMER__TRANSFORMER_CLASS; + } + + @Override + String getMethodElementName() { + return EclipseLinkJPA.WRITE_TRANSFORMER__METHOD; + } + + + // ********** WriteTransformerAnnotation implementation ********** + + // ***** column + public ColumnAnnotation getColumn() { + return this.column; + } + + public ColumnAnnotation getNonNullColumn() { + return (this.column != null) ? this.column : new NullWriteTransformerColumnAnnotation(this); + } + + public ColumnAnnotation addColumn() { + ColumnAnnotation col = createColumn(this, this.member, this.daa); + col.newAnnotation(); + this.setColumn(col); + return col; + } + + public void removeColumn() { + this.column.removeAnnotation(); + this.setColumn(null); + } + + private void setColumn(ColumnAnnotation newColumn) { + ColumnAnnotation old = this.column; + this.column = newColumn; + this.firePropertyChanged(COLUMN_PROPERTY, old, newColumn); + } + + public TextRange getColumnTextRange(CompilationUnit astRoot) { + if (this.column != null) { + return this.column.getTextRange(astRoot); + } + return getTextRange(astRoot); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationAdapter buildColumnAnnotationAdapter(DeclarationAnnotationAdapter writeTransformerAnnotationAdapter) { + return new NestedDeclarationAnnotationAdapter(writeTransformerAnnotationAdapter, EclipseLinkJPA.WRITE_TRANSFORMER__COLUMN, JPA.COLUMN, false); + } + + private static ColumnAnnotation createColumn(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter writeTransformerAnnotationAdapter) { + return new SourceColumnAnnotation(parent, member, buildColumnAnnotationAdapter(writeTransformerAnnotationAdapter)); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTimeOfDayAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTimeOfDayAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTimeOfDayAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTimeOfDayAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,194 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.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; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; + +/** + * org.eclipse.persistence.annotations.TimeOfDay + */ +public final class SourceTimeOfDayAnnotation + extends SourceAnnotation + implements TimeOfDayAnnotation +{ + private final DeclarationAnnotationElementAdapter hourDeclarationAdapter; + private final AnnotationElementAdapter hourAdapter; + private Integer hour; + + private final DeclarationAnnotationElementAdapter minuteDeclarationAdapter; + private final AnnotationElementAdapter minuteAdapter; + private Integer minute; + + private final DeclarationAnnotationElementAdapter secondDeclarationAdapter; + private final AnnotationElementAdapter secondAdapter; + private Integer second; + + private final DeclarationAnnotationElementAdapter millisecondDeclarationAdapter; + private final AnnotationElementAdapter millisecondAdapter; + private Integer millisecond; + + + public SourceTimeOfDayAnnotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa) { + super(parent, type, daa); + this.hourDeclarationAdapter = buildHourAdapter(daa); + this.hourAdapter = new ShortCircuitAnnotationElementAdapter(type, this.hourDeclarationAdapter); + this.minuteDeclarationAdapter = buildMinuteAdapter(daa); + this.minuteAdapter = new ShortCircuitAnnotationElementAdapter(type, this.minuteDeclarationAdapter); + this.secondDeclarationAdapter = buildSecondAdapter(daa); + this.secondAdapter = new ShortCircuitAnnotationElementAdapter(type, this.secondDeclarationAdapter); + this.millisecondDeclarationAdapter = buildMillisecondAdapter(daa); + this.millisecondAdapter = new ShortCircuitAnnotationElementAdapter(type, this.millisecondDeclarationAdapter); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public void initialize(CompilationUnit astRoot) { + this.hour = this.buildHour(astRoot); + this.minute = this.buildMinute(astRoot); + this.second = this.buildSecond(astRoot); + this.millisecond = this.buildMillisecond(astRoot); + } + + public void update(CompilationUnit astRoot) { + this.setHour(this.buildHour(astRoot)); + this.setMinute(this.buildMinute(astRoot)); + this.setSecond(this.buildSecond(astRoot)); + this.setMillisecond(this.buildMillisecond(astRoot)); + } + + + // ********** TimeOfDayAnnotation implementation ********** + + // ***** hour + public Integer getHour() { + return this.hour; + } + + public void setHour(Integer hour) { + if (this.attributeValueHasNotChanged(this.hour, hour)) { + return; + } + Integer old = this.hour; + this.hour = hour; + this.hourAdapter.setValue(hour); + this.firePropertyChanged(HOUR_PROPERTY, old, hour); + } + + private Integer buildHour(CompilationUnit astRoot) { + return this.hourAdapter.getValue(astRoot); + } + + public TextRange getHourTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.hourDeclarationAdapter, astRoot); + } + + // ***** minute + public Integer getMinute() { + return this.minute; + } + + public void setMinute(Integer newMinute) { + if (attributeValueHasNotChanged(this.minute, newMinute)) { + return; + } + Integer oldMinute = this.minute; + this.minute = newMinute; + this.minuteAdapter.setValue(newMinute); + firePropertyChanged(MINUTE_PROPERTY, oldMinute, newMinute); + } + + private Integer buildMinute(CompilationUnit astRoot) { + return this.minuteAdapter.getValue(astRoot); + } + + public TextRange getMinuteTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.minuteDeclarationAdapter, astRoot); + } + + // ***** second + public Integer getSecond() { + return this.second; + } + + public void setSecond(Integer newSecond) { + if (attributeValueHasNotChanged(this.second, newSecond)) { + return; + } + Integer oldSecond = this.second; + this.second = newSecond; + this.secondAdapter.setValue(newSecond); + firePropertyChanged(SECOND_PROPERTY, oldSecond, newSecond); + } + + private Integer buildSecond(CompilationUnit astRoot) { + return this.secondAdapter.getValue(astRoot); + } + + public TextRange getSecondTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.secondDeclarationAdapter, astRoot); + } + + // ***** millisecond + public Integer getMillisecond() { + return this.millisecond; + } + + public void setMillisecond(Integer newMillisecond) { + if (attributeValueHasNotChanged(this.millisecond, newMillisecond)) { + return; + } + Integer oldMillisecond = this.millisecond; + this.millisecond = newMillisecond; + this.millisecondAdapter.setValue(newMillisecond); + firePropertyChanged(MILLISECOND_PROPERTY, oldMillisecond, newMillisecond); + } + + private Integer buildMillisecond(CompilationUnit astRoot) { + return this.millisecondAdapter.getValue(astRoot); + } + + public TextRange getMillisecondTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.millisecondDeclarationAdapter, astRoot); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildHourAdapter(DeclarationAnnotationAdapter daa) { + return new ConversionDeclarationAnnotationElementAdapter(daa, EclipseLinkJPA.TIME_OF_DAY__HOUR, false, NumberIntegerExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildMinuteAdapter(DeclarationAnnotationAdapter daa) { + return new ConversionDeclarationAnnotationElementAdapter(daa, EclipseLinkJPA.TIME_OF_DAY__MINUTE, false, NumberIntegerExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildSecondAdapter(DeclarationAnnotationAdapter daa) { + return new ConversionDeclarationAnnotationElementAdapter(daa, EclipseLinkJPA.TIME_OF_DAY__SECOND, false, NumberIntegerExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildMillisecondAdapter(DeclarationAnnotationAdapter daa) { + return new ConversionDeclarationAnnotationElementAdapter(daa, EclipseLinkJPA.TIME_OF_DAY__MILLISECOND, false, NumberIntegerExpressionConverter.instance()); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTypeConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTypeConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTypeConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTypeConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.TypeConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.TypeConverter + */ +public final class BinaryTypeConverterAnnotation + extends BinaryBaseTypeConverterAnnotation + implements TypeConverterAnnotation +{ + public BinaryTypeConverterAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + + // ********** BinaryNamedConverterAnnotation implementation ********** + + @Override + String getNameElementName() { + return EclipseLinkJPA.TYPE_CONVERTER__NAME; + } + + + // ********** BinaryBaseTypeConverterAnnotation implementation ********** + + @Override + String getDataTypeElementName() { + return EclipseLinkJPA.TYPE_CONVERTER__DATA_TYPE; + } + + @Override + String getObjectTypeElementName() { + return EclipseLinkJPA.TYPE_CONVERTER__OBJECT_TYPE; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ExistenceCheckingAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ExistenceCheckingAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ExistenceCheckingAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ExistenceCheckingAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Member; +import org.eclipse.jpt.core.utility.jdt.Type; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryExistenceCheckingAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceExistenceCheckingAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ExistenceCheckingAnnotation; + +/** + * org.eclipse.persistence.annotations.ExistenceChecking + */ +public class ExistenceCheckingAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new ExistenceCheckingAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private ExistenceCheckingAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceExistenceCheckingAnnotation((JavaResourcePersistentType) parent, (Type) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryExistenceCheckingAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ExistenceCheckingAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceMutableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceMutableAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceMutableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceMutableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,96 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; +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; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.MutableAnnotation; + +/** + * org.eclipse.persistence.annotations.Mutable + */ +public final class SourceMutableAnnotation + extends SourceAnnotation + implements MutableAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private Boolean value; + + + public SourceMutableAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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); + } + + + // ********** MutableAnnotation implementation ********** + + // ***** value + public Boolean getValue() { + return this.value; + } + + public void setValue(Boolean value) { + if (this.attributeValueHasNotChanged(this.value, value)) { + return; + } + Boolean old = this.value; + this.value = value; + this.valueAdapter.setValue(value); + this.firePropertyChanged(VALUE_PROPERTY, old, value); + } + + private Boolean buildValue(CompilationUnit astRoot) { + return this.valueAdapter.getValue(astRoot); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(VALUE_ADAPTER, astRoot); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildValueAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.MUTABLE__VALUE, false, BooleanExpressionConverter.instance()); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/WriteTransformerAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/WriteTransformerAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/WriteTransformerAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/WriteTransformerAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryWriteTransformerAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceWriteTransformerAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.WriteTransformerAnnotation; + +/** + * org.eclipse.persistence.annotations.WriteTransformer + */ +public class WriteTransformerAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new WriteTransformerAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private WriteTransformerAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceWriteTransformerAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryWriteTransformerAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return WriteTransformerAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryCustomizerAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryCustomizerAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryCustomizerAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryCustomizerAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,75 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.CustomizerAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; + +/** + * org.eclipse.persistence.annotations.Customizer + */ +public final class BinaryCustomizerAnnotation + extends BinaryAnnotation + implements CustomizerAnnotation +{ + private String value; + + + public BinaryCustomizerAnnotation(JavaResourcePersistentMember 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()); + } + + + // ********** CustomizerAnnotation 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(EclipseLinkJPA.CUSTOMIZER__VALUE); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + public boolean customizerClassImplementsInterface(String interfaceName, CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadTransformerAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadTransformerAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadTransformerAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadTransformerAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryReadTransformerAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceReadTransformerAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ReadTransformerAnnotation; + +/** + * org.eclipse.persistence.annotations.ReadTransformer + */ +public class ReadTransformerAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new ReadTransformerAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private ReadTransformerAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceReadTransformerAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryReadTransformerAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ReadTransformerAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullWriteTransformerColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullWriteTransformerColumnAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullWriteTransformerColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullWriteTransformerColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jpt.core.internal.resource.java.NullColumnAnnotation; +import org.eclipse.jpt.core.resource.java.ColumnAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.WriteTransformerAnnotation; + +/** + * javax.persistence.Column + */ +public class NullWriteTransformerColumnAnnotation + extends NullColumnAnnotation +{ + public NullWriteTransformerColumnAnnotation(WriteTransformerAnnotation parent) { + super(parent); + } + + private WriteTransformerAnnotation getWriteTransformerAnnotation() { + return (WriteTransformerAnnotation) this.parent; + } + + @Override + protected ColumnAnnotation buildAnnotation() { + return this.getWriteTransformerAnnotation().addColumn(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadOnlyAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadOnlyAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadOnlyAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ReadOnlyAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Member; +import org.eclipse.jpt.core.utility.jdt.Type; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryReadOnlyAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceReadOnlyAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ReadOnlyAnnotation; + +/** + * org.eclipse.persistence.annotations.ReadOnly + */ +public class ReadOnlyAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new ReadOnlyAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private ReadOnlyAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceReadOnlyAnnotation(parent, (Type) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryReadOnlyAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ReadOnlyAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryObjectTypeConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryObjectTypeConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryObjectTypeConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryObjectTypeConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,140 @@ +/******************************************************************************* + * 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.eclipselink.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.JavaResourcePersistentMember; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.ConversionValueAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.ObjectTypeConverterAnnotation; +import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; + +/** + * org.eclipse.persistence.annotations.ObjectTypeConverter + */ +public final class BinaryObjectTypeConverterAnnotation + extends BinaryBaseTypeConverterAnnotation + implements ObjectTypeConverterAnnotation +{ + private String defaultObjectValue; + private final Vector conversionValues; + + + public BinaryObjectTypeConverterAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.defaultObjectValue = this.buildDefaultObjectValue(); + this.conversionValues = this.buildConversionValues(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + public void update() { + super.update(); + this.setDefaultObjectValue_(this.buildDefaultObjectValue()); + this.updateConversionValues(); + } + + + // ********** BinaryNamedConverterAnnotation implementation ********** + + @Override + String getNameElementName() { + return EclipseLinkJPA.OBJECT_TYPE_CONVERTER__NAME; + } + + // ********** BinaryBaseTypeConverterAnnotation implementation ********** + + @Override + String getDataTypeElementName() { + return EclipseLinkJPA.OBJECT_TYPE_CONVERTER__DATA_TYPE; + } + + @Override + String getObjectTypeElementName() { + return EclipseLinkJPA.OBJECT_TYPE_CONVERTER__OBJECT_TYPE; + } + + // ********** ObjectTypeConverterAnnotation implementation ********** + + // ***** default object value + public String getDefaultObjectValue() { + return this.defaultObjectValue; + } + + public void setDefaultObjectValue(String defaultObjectValue) { + throw new UnsupportedOperationException(); + } + + private void setDefaultObjectValue_(String defaultObjectValue) { + String old = this.defaultObjectValue; + this.defaultObjectValue = defaultObjectValue; + this.firePropertyChanged(DEFAULT_OBJECT_VALUE_PROPERTY, old, defaultObjectValue); + } + + private String buildDefaultObjectValue() { + return (String) this.getJdtMemberValue(EclipseLinkJPA.OBJECT_TYPE_CONVERTER__DEFAULT_OBJECT_VALUE); + } + + public TextRange getDefaultObjectValueTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** conversion values + public ListIterator conversionValues() { + return new CloneListIterator(this.conversionValues); + } + + public int conversionValuesSize() { + return this.conversionValues.size(); + } + + public ConversionValueAnnotation conversionValueAt(int index) { + return this.conversionValues.get(index); + } + + public int indexOfConversionValue(ConversionValueAnnotation conversionValue) { + return this.conversionValues.indexOf(conversionValue); + } + + public ConversionValueAnnotation addConversionValue(int index) { + throw new UnsupportedOperationException(); + } + + public void moveConversionValue(int targetIndex, int sourceIndex) { + throw new UnsupportedOperationException(); + } + + public void removeConversionValue(int index) { + throw new UnsupportedOperationException(); + } + + private Vector buildConversionValues() { + Object[] jdtConversionValues = this.getJdtMemberValues(EclipseLinkJPA.OBJECT_TYPE_CONVERTER__CONVERSION_VALUES); + Vector result = new Vector(jdtConversionValues.length); + for (Object jdtConversionValue : jdtConversionValues) { + result.add(new BinaryConversionValueAnnotation(this, (IAnnotation) jdtConversionValue)); + } + return result; + } + + // TODO + private void updateConversionValues() { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTransformerAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTransformerAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTransformerAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTransformerAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.TransformerAnnotation; + +/** + * org.eclipse.persistence.annotations.ReadTransformer + * org.eclipse.persistence.annotations.WriteTransformer + */ +abstract class BinaryTransformerAnnotation + extends BinaryAnnotation + implements TransformerAnnotation +{ + private String transformerClass; + private String method; + + + BinaryTransformerAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.transformerClass = this.buildTransformerClass(); + this.method = this.buildMethod(); + } + + @Override + public void update() { + super.update(); + this.setTransformerClass_(this.buildTransformerClass()); + this.setMethod_(this.buildMethod()); + } + + + // ********** TransformerAnnotation implementation ********** + + // ***** transformer class + public String getTransformerClass() { + return this.transformerClass; + } + + public void setTransformerClass(String transformerClass) { + throw new UnsupportedOperationException(); + } + + private void setTransformerClass_(String transformerClass) { + String old = this.transformerClass; + this.transformerClass = transformerClass; + this.firePropertyChanged(TRANSFORMER_CLASS_PROPERTY, old, transformerClass); + } + + private String buildTransformerClass() { + return (String) this.getJdtMemberValue(this.getTransformerClassElementName()); + } + + public TextRange getTransformerClassTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + abstract String getTransformerClassElementName(); + + // ***** method + public String getMethod() { + return this.method; + } + + public void setMethod(String method) { + throw new UnsupportedOperationException(); + } + + private void setMethod_(String method) { + String old = this.method; + this.method = method; + this.firePropertyChanged(METHOD_PROPERTY, old, method); + } + + private String buildMethod() { + return (String) this.getJdtMemberValue(this.getMethodElementName()); + } + + public TextRange getMethodTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + abstract String getMethodElementName(); + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/StructConverterAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/StructConverterAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/StructConverterAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/StructConverterAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryStructConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceStructConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.StructConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.StructConverter + */ +public class StructConverterAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new StructConverterAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private StructConverterAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceStructConverterAnnotation(parent, member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryStructConverterAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return StructConverterAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/resource/java/NestableConversionValueAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/resource/java/NestableConversionValueAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/resource/java/NestableConversionValueAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/NestableConversionValueAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.eclipselink.core.resource.java; + +import org.eclipse.jpt.core.resource.java.NestableAnnotation; + +/** + * Corresponds to the EclipseLink annotation + * org.eclipse.persistence.annotations.ConversionValue + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestableConversionValueAnnotation + extends ConversionValueAnnotation, NestableAnnotation +{ + // combine two interfaces +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTransformationAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTransformationAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTransformationAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryTransformationAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,98 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.FetchType; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.TransformationAnnotation; + +/** + * org.eclipse.persistence.annotations.Transformation + */ +public class BinaryTransformationAnnotation + extends BinaryAnnotation + implements TransformationAnnotation +{ + private FetchType fetch; + private Boolean optional; + + + public BinaryTransformationAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.fetch = this.buildFetch(); + this.optional = this.buildOptional(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + public void update() { + super.update(); + this.setFetch_(this.buildFetch()); + this.setOptional_(this.buildOptional()); + } + + + // ********** TransformationAnnotation implementation ********** + + // ***** 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(EclipseLinkJPA.TRANSFORMATION__FETCH)); + } + + public TextRange getFetchTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** 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(EclipseLinkJPA.TRANSFORMATION__OPTIONAL); + } + + public TextRange getOptionalTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,108 @@ +/******************************************************************************* + * 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.eclipselink.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.JavaResourcePersistentMember; +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; +import org.eclipse.jpt.eclipselink.core.resource.java.ConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; + +/** + * org.eclipse.persistence.annotations.Converter + */ +public final class SourceConverterAnnotation + extends SourceNamedConverterAnnotation + implements ConverterAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter CONVERTER_CLASS_ADAPTER = buildConverterClassAdapter(); + private final AnnotationElementAdapter converterClassAdapter; + private String converterClass; + + + public SourceConverterAnnotation(JavaResourcePersistentMember parent, Member member) { + super(parent, member, DECLARATION_ANNOTATION_ADAPTER); + this.converterClassAdapter = new ShortCircuitAnnotationElementAdapter(member, CONVERTER_CLASS_ADAPTER); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + public void initialize(CompilationUnit astRoot) { + super.initialize(astRoot); + this.converterClass = this.buildConverterClass(astRoot); + } + + @Override + public void update(CompilationUnit astRoot) { + super.update(astRoot); + this.setConverterClass(this.buildConverterClass(astRoot)); + } + + + // ********** SourceNamedConverterAnnotation implementation ********** + + @Override + String getNameElementName() { + return EclipseLinkJPA.CONVERTER__NAME; + } + + + // ********** ConverterAnnotation implementation ********** + + // ***** converter class + public String getConverterClass() { + return this.converterClass; + } + + public void setConverterClass(String converterClass) { + if (this.attributeValueHasNotChanged(this.converterClass, converterClass)) { + return; + } + String old = this.converterClass; + this.converterClass = converterClass; + this.converterClassAdapter.setValue(converterClass); + this.firePropertyChanged(CONVERTER_CLASS_PROPERTY, old, converterClass); + } + + private String buildConverterClass(CompilationUnit astRoot) { + return this.converterClassAdapter.getValue(astRoot); + } + + public TextRange getConverterClassTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(CONVERTER_CLASS_ADAPTER, astRoot); + } + + public boolean converterClassImplementsInterface(String interfaceName, CompilationUnit astRoot) { + return (this.converterClass != null) + && JDTTools.typeIsSubTypeOf(this.converterClassAdapter.getExpression(astRoot), interfaceName); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildConverterClassAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CONVERTER__CONVERTER_CLASS, false, SimpleTypeStringExpressionConverter.instance()); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTypeConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTypeConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTypeConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTypeConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,58 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.TypeConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.TypeConverter + */ +public final class SourceTypeConverterAnnotation + extends SourceBaseTypeConverterAnnotation + implements TypeConverterAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + + public SourceTypeConverterAnnotation(JavaResourcePersistentMember parent, Member member) { + super(parent, member, DECLARATION_ANNOTATION_ADAPTER); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + + // ********** SourceNamedConverterAnnotation implementation ********** + + @Override + String getNameElementName() { + return EclipseLinkJPA.TYPE_CONVERTER__NAME; + } + + + // ********** SourceBaseTypeConverterAnnotation implementation ********** + + @Override + String getDataTypeElementName() { + return EclipseLinkJPA.TYPE_CONVERTER__DATA_TYPE; + } + + @Override + String getObjectTypeElementName() { + return EclipseLinkJPA.TYPE_CONVERTER__OBJECT_TYPE; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBasicCollectionAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBasicCollectionAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBasicCollectionAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBasicCollectionAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; +import org.eclipse.jpt.eclipselink.core.resource.java.BasicCollectionAnnotation; + +/** + * org.eclipse.persistence.annotations.BasicCollection + */ +public final class SourceBasicCollectionAnnotation + extends SourceAnnotation + implements BasicCollectionAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + + public SourceBasicCollectionAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public void initialize(CompilationUnit astRoot) { + // do nothing + } + + public void update(CompilationUnit astRoot) { + // do nothing + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceVariableOneToOneAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceVariableOneToOneAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceVariableOneToOneAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceVariableOneToOneAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; +import org.eclipse.jpt.eclipselink.core.resource.java.VariableOneToOneAnnotation; + +/** + * org.eclipse.persistence.annotations.VariableOneToOne + */ +public final class SourceVariableOneToOneAnnotation + extends SourceAnnotation + implements VariableOneToOneAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + + public SourceVariableOneToOneAnnotation(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 + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBasicMapAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBasicMapAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBasicMapAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBasicMapAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; +import org.eclipse.jpt.eclipselink.core.resource.java.BasicMapAnnotation; + +/** + * org.eclipse.persistence.annotations.BasicMap + */ +public final class SourceBasicMapAnnotation + extends SourceAnnotation + implements BasicMapAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + + public SourceBasicMapAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public void initialize(CompilationUnit astRoot) { + // do nothing + } + + public void update(CompilationUnit astRoot) { + // do nothing + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ChangeTrackingAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ChangeTrackingAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ChangeTrackingAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ChangeTrackingAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Member; +import org.eclipse.jpt.core.utility.jdt.Type; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryChangeTrackingAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceChangeTrackingAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingAnnotation; + +/** + * org.eclipse.persistence.annotations.ChangeTracking + */ +public class ChangeTrackingAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new ChangeTrackingAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private ChangeTrackingAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceChangeTrackingAnnotation((JavaResourcePersistentType) parent, (Type) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryChangeTrackingAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ChangeTrackingAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/PrivateOwnedAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/PrivateOwnedAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/PrivateOwnedAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/PrivateOwnedAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryPrivateOwnedAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourcePrivateOwnedAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.PrivateOwnedAnnotation; + +/** + * org.eclipse.persistence.annotations.PrivateOwned + */ +public class PrivateOwnedAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new PrivateOwnedAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private PrivateOwnedAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourcePrivateOwnedAnnotation(parent, (Attribute) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryPrivateOwnedAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return PrivateOwnedAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,81 @@ +/******************************************************************************* + * 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.eclipselink.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.JavaResourcePersistentMember; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.ConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; + +/** + * org.eclipse.persistence.annotations.Converter + */ +public final class BinaryConverterAnnotation + extends BinaryNamedConverterAnnotation + implements ConverterAnnotation +{ + private String converterClass; + + + public BinaryConverterAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.converterClass = this.buildConverterClass(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + public void update() { + super.update(); + this.setConverterClass_(this.buildConverterClass()); + } + + + // ********** BinaryNamedConverterAnnotation implementation ********** + + @Override + String getNameElementName() { + return EclipseLinkJPA.CONVERTER__NAME; + } + + // ********** ConverterAnnotation implementation ********** + + // ***** converter class + public String getConverterClass() { + return this.converterClass; + } + + public void setConverterClass(String converterClass) { + throw new UnsupportedOperationException(); + } + + private void setConverterClass_(String converterClass) { + String old = this.converterClass; + this.converterClass = converterClass; + this.firePropertyChanged(CONVERTER_CLASS_PROPERTY, old, converterClass); + } + + private String buildConverterClass() { + return (String) this.getJdtMemberValue(EclipseLinkJPA.CONVERTER__CONVERTER_CLASS); + } + + public TextRange getConverterClassTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + public boolean converterClassImplementsInterface(String interfaceName, CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryWriteTransformerAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryWriteTransformerAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryWriteTransformerAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryWriteTransformerAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,118 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryColumnAnnotation; +import org.eclipse.jpt.core.resource.java.ColumnAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.NullWriteTransformerColumnAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.WriteTransformerAnnotation; + +/** + * org.eclipse.persistence.annotations.ReadTransformer + */ +public class BinaryWriteTransformerAnnotation + extends BinaryTransformerAnnotation + implements WriteTransformerAnnotation +{ + private ColumnAnnotation column; + + + public BinaryWriteTransformerAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.column = this.buildColumn(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + public void update() { + super.update(); + this.updateColumn(); + } + + + // ********** BinaryTransformerAnnotation implementation ********** + + @Override + String getTransformerClassElementName() { + return EclipseLinkJPA.WRITE_TRANSFORMER__TRANSFORMER_CLASS; + } + + @Override + String getMethodElementName() { + return EclipseLinkJPA.WRITE_TRANSFORMER__METHOD; + } + + + // ********** WriteTransformerAnnotation implementation ********** + + // ***** column + public ColumnAnnotation getColumn() { + return this.column; + } + + public ColumnAnnotation getNonNullColumn() { + return (this.column != null) ? this.column : new NullWriteTransformerColumnAnnotation(this); + } + + public ColumnAnnotation addColumn() { + throw new UnsupportedOperationException(); + } + + public void removeColumn() { + throw new UnsupportedOperationException(); + } + + public TextRange getColumnTextRange(CompilationUnit astRoot) { + 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(EclipseLinkJPA.WRITE_TRANSFORMER__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); +// } +// } + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryCacheAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryCacheAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryCacheAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryCacheAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,311 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheCoordinationType; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheType; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; + +/** + * org.eclipse.persistence.annotations.Cache + */ +public final class BinaryCacheAnnotation + extends BinaryAnnotation + implements CacheAnnotation +{ + private CacheType type; + private Integer size; + private Boolean shared; + private Integer expiry; + private TimeOfDayAnnotation expiryTimeOfDay; + private Boolean alwaysRefresh; + private Boolean refreshOnlyIfNewer; + private Boolean disableHits; + private CacheCoordinationType coordinationType; + + + public BinaryCacheAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.type = this.buildType(); + this.size = this.buildSize(); + this.shared = this.buildShared(); + this.expiry = this.buildExpiry(); + this.expiryTimeOfDay = this.buildExpiryTimeOfDay(); + this.alwaysRefresh = this.buildAlwaysRefresh(); + this.refreshOnlyIfNewer = this.buildRefreshOnlyIfNewer(); + this.disableHits = this.buildDisableHits(); + this.coordinationType = this.buildCoordinationType(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + // TODO + @Override + public void update() { + super.update(); + this.setType_(this.buildType()); + this.setSize_(this.buildSize()); + this.setShared_(this.buildShared()); + this.setExpiry_(this.buildExpiry()); + this.updateExpiryTimeOfDay(); + this.setAlwaysRefresh_(this.buildAlwaysRefresh()); + this.setRefreshOnlyIfNewer_(this.buildRefreshOnlyIfNewer()); + this.setDisableHits_(this.buildDisableHits()); + this.setCoordinationType_(this.buildCoordinationType()); + } + + + // ********** CacheAnnotation implementation ********** + + // ***** type + public CacheType getType() { + return this.type; + } + + public void setType(CacheType type) { + throw new UnsupportedOperationException(); + } + + private void setType_(CacheType type) { + CacheType old = this.type; + this.type = type; + this.firePropertyChanged(TYPE_PROPERTY, old, type); + } + + private CacheType buildType() { + return CacheType.fromJavaAnnotationValue(this.getJdtMemberValue(EclipseLinkJPA.CACHE__TYPE)); + } + + public TextRange getTypeTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** size + public Integer getSize() { + return this.size; + } + + public void setSize(Integer size) { + throw new UnsupportedOperationException(); + } + + private void setSize_(Integer size) { + Integer old = this.size; + this.size = size; + this.firePropertyChanged(SIZE_PROPERTY, old, size); + } + + private Integer buildSize() { + return (Integer) this.getJdtMemberValue(EclipseLinkJPA.CACHE__SIZE); + } + + public TextRange getSizeTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** shared + public Boolean getShared() { + return this.shared; + } + + public void setShared(Boolean shared) { + throw new UnsupportedOperationException(); + } + + private void setShared_(Boolean shared) { + Boolean old = this.shared; + this.shared = shared; + this.firePropertyChanged(SHARED_PROPERTY, old, shared); + } + + private Boolean buildShared() { + return (Boolean) this.getJdtMemberValue(EclipseLinkJPA.CACHE__SHARED); + } + + public TextRange getSharedTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** expiry + public Integer getExpiry() { + return this.expiry; + } + + public void setExpiry(Integer expiry) { + throw new UnsupportedOperationException(); + } + + private void setExpiry_(Integer expiry) { + Integer old = this.expiry; + this.expiry = expiry; + this.firePropertyChanged(EXPIRY_PROPERTY, old, expiry); + } + + private Integer buildExpiry() { + return (Integer) this.getJdtMemberValue(EclipseLinkJPA.CACHE__EXPIRY); + } + + public TextRange getExpiryTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** expiry time of day + public TimeOfDayAnnotation getExpiryTimeOfDay() { + return this.expiryTimeOfDay; + } + + public TimeOfDayAnnotation addExpiryTimeOfDay() { + throw new UnsupportedOperationException(); + } + + public void removeExpiryTimeOfDay() { + throw new UnsupportedOperationException(); + } + + private TimeOfDayAnnotation buildExpiryTimeOfDay() { + IAnnotation jdtTimeOfDay = this.getJdtExpiryTimeOfDay(); + return (jdtTimeOfDay == null) ? null : this.buildTimeOfDay(jdtTimeOfDay); + } + + private TimeOfDayAnnotation buildTimeOfDay(IAnnotation jdtTimeOfDay) { + return new BinaryTimeOfDayAnnotation(this, jdtTimeOfDay); + } + + private IAnnotation getJdtExpiryTimeOfDay() { + return (IAnnotation) this.getJdtMemberValue(EclipseLinkJPA.CACHE__EXPIRY_TIME_OF_DAY); + } + + private void setExpiryTimeOfDay(TimeOfDayAnnotation expiryTimeOfDay) { + TimeOfDayAnnotation old = this.expiryTimeOfDay; + this.expiryTimeOfDay = expiryTimeOfDay; + this.firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, old, expiryTimeOfDay); + } + + // TODO + private void updateExpiryTimeOfDay() { + throw new UnsupportedOperationException(); +// IAnnotation jdtTimeOfDay = this.getJdtExpiryTimeOfDay(); +// if (jdtTimeOfDay == null) { +// this.setExpiryTimeOfDay(null); +// } else { +// if (this.expiryTimeOfDay == null) { +// this.setExpiryTimeOfDay(this.buildTimeOfDay(jdtTimeOfDay)); +// } else { +// this.expiryTimeOfDay.update(jdtTimeOfDay); +// } +// } + } + + public TextRange getExpiryTimeOfDayTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** always refresh + public Boolean getAlwaysRefresh() { + return this.alwaysRefresh; + } + + public void setAlwaysRefresh(Boolean alwaysRefresh) { + throw new UnsupportedOperationException(); + } + + private void setAlwaysRefresh_(Boolean alwaysRefresh) { + Boolean old = this.alwaysRefresh; + this.alwaysRefresh = alwaysRefresh; + this.firePropertyChanged(ALWAYS_REFRESH_PROPERTY, old, alwaysRefresh); + } + + private Boolean buildAlwaysRefresh() { + return (Boolean) this.getJdtMemberValue(EclipseLinkJPA.CACHE__ALWAYS_REFRESH); + } + + public TextRange getAlwaysRefreshTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** refresh only if newer + public Boolean getRefreshOnlyIfNewer() { + return this.refreshOnlyIfNewer; + } + + public void setRefreshOnlyIfNewer(Boolean refreshOnlyIfNewer) { + throw new UnsupportedOperationException(); + } + + private void setRefreshOnlyIfNewer_(Boolean refreshOnlyIfNewer) { + Boolean old = this.refreshOnlyIfNewer; + this.refreshOnlyIfNewer = refreshOnlyIfNewer; + this.firePropertyChanged(REFRESH_ONLY_IF_NEWER_PROPERTY, old, refreshOnlyIfNewer); + } + + private Boolean buildRefreshOnlyIfNewer() { + return (Boolean) this.getJdtMemberValue(EclipseLinkJPA.CACHE__REFRESH_ONLY_IF_NEWER); + } + + public TextRange getRefreshOnlyIfNewerTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** disable hits + public Boolean getDisableHits() { + return this.disableHits; + } + + public void setDisableHits(Boolean disableHits) { + throw new UnsupportedOperationException(); + } + + private void setDisableHits_(Boolean disableHits) { + Boolean old = this.disableHits; + this.disableHits = disableHits; + this.firePropertyChanged(DISABLE_HITS_PROPERTY, old, disableHits); + } + + private Boolean buildDisableHits() { + return (Boolean) this.getJdtMemberValue(EclipseLinkJPA.CACHE__DISABLE_HITS); + } + + public TextRange getDisablesHitsTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** coordination type + public CacheCoordinationType getCoordinationType() { + return this.coordinationType; + } + + public void setCoordinationType(CacheCoordinationType coordinationType) { + throw new UnsupportedOperationException(); + } + + private void setCoordinationType_(CacheCoordinationType coordinationType) { + CacheCoordinationType old = this.coordinationType; + this.coordinationType = coordinationType; + this.firePropertyChanged(TYPE_PROPERTY, old, coordinationType); + } + + private CacheCoordinationType buildCoordinationType() { + return CacheCoordinationType.fromJavaAnnotationValue(this.getJdtMemberValue(EclipseLinkJPA.CACHE__COORDINATION_TYPE)); + } + + public TextRange getCoordinationTypeTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/VariableOneToOneAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/VariableOneToOneAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/VariableOneToOneAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/VariableOneToOneAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryVariableOneToOneAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceVariableOneToOneAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.VariableOneToOneAnnotation; + +/** + * org.eclipse.persistence.annotations.VariableOneToOne + */ +public class VariableOneToOneAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new VariableOneToOneAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private VariableOneToOneAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceVariableOneToOneAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryVariableOneToOneAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return VariableOneToOneAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConvertAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConvertAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConvertAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/ConvertAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryConvertAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceConvertAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ConvertAnnotation; + +/** + * org.eclipse.persistence.annotations.Convert + */ +public class ConvertAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new ConvertAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private ConvertAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceConvertAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryConvertAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ConvertAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceCustomizerAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceCustomizerAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceCustomizerAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceCustomizerAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,102 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.JavaResourcePersistentMember; +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; +import org.eclipse.jpt.eclipselink.core.resource.java.CustomizerAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; + +/** + * org.eclipse.persistence.annotations.Customizer + */ +public final class SourceCustomizerAnnotation + extends SourceAnnotation + implements CustomizerAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private String value; + + + public SourceCustomizerAnnotation(JavaResourcePersistentMember parent, Type type) { + super(parent, type, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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); + } + + + // ********** CustomizerAnnotation 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); + } + + public boolean customizerClassImplementsInterface(String interfaceName, CompilationUnit astRoot) { + return (this.value != null) + && JDTTools.typeIsSubTypeOf(this.valueAdapter.getExpression(astRoot), interfaceName); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildValueAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CUSTOMIZER__VALUE, false, SimpleTypeStringExpressionConverter.instance()); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Member; +import org.eclipse.jpt.core.utility.jdt.Type; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryCacheAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceCacheAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; + +/** + * org.eclipse.persistence.annotations.Cache + */ +public class CacheAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new CacheAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private CacheAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceCacheAnnotation((JavaResourcePersistentType) parent, (Type) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + return new NullCacheAnnotation((JavaResourcePersistentType) parent); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryCacheAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return CacheAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/resource/java/BaseTypeConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/resource/java/BaseTypeConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/resource/java/BaseTypeConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/resource/java/BaseTypeConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,68 @@ +/******************************************************************************* + * 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.eclipselink.core.resource.java; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.utility.TextRange; + +/** + * Common protocol among: + * org.eclipse.persistence.annotations.TypeConverter + * org.eclipse.persistence.annotations.ObjectTypeConverter + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface BaseTypeConverterAnnotation + extends NamedConverterAnnotation +{ + /** + * Corresponds to the 'dataType' element of the TypeConverter annotation. + * Returns null if the element does not exist in Java. + */ + String getDataType(); + String DATA_TYPE_PROPERTY = "dataType"; //$NON-NLS-1$ + + /** + * Corresponds to the 'dataType' element of the TypeConverter annotation. + * Set to null to remove the element. + */ + void setDataType(String dataType); + + /** + * Return the {@link TextRange} for the 'dataType' element. If the element + * does not exist return the {@link TextRange} for the TypeConverter annotation. + */ + TextRange getDataTypeTextRange(CompilationUnit astRoot); + + + /** + * Corresponds to the 'objectType' element of the TypeConverter annotation. + * Returns null if the element does not exist in Java. + */ + String getObjectType(); + String OBJECT_TYPE_PROPERTY = "objectType"; //$NON-NLS-1$ + + /** + * Corresponds to the 'objectType' element of the TypeConverter annotation. + * Set to null to remove the element. + */ + void setObjectType(String objectType); + + /** + * Return the {@link TextRange} for the 'objectType' element. If the element + * does not exist return the {@link TextRange} for the TypeConverter annotation. + */ + TextRange getObjectTypeTextRange(CompilationUnit astRoot); + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/JoinFetchAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/JoinFetchAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/JoinFetchAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/JoinFetchAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryJoinFetchAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceJoinFetchAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchAnnotation; + +/** + * org.eclipse.persistence.annotations.JoinFetch + */ +public class JoinFetchAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new JoinFetchAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private JoinFetchAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceJoinFetchAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + return new NullJoinFetchAnnotation((JavaResourcePersistentAttribute) parent); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryJoinFetchAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return JoinFetchAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryNamedConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryNamedConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryNamedConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryNamedConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,75 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.NamedConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.Converter + * org.eclipse.persistence.annotations.StructConverter + * org.eclipse.persistence.annotations.TypeConverter + * org.eclipse.persistence.annotations.ObjectTypeConverter + */ +abstract class BinaryNamedConverterAnnotation + extends BinaryAnnotation + implements NamedConverterAnnotation +{ + String name; + + BinaryNamedConverterAnnotation(JavaResourcePersistentMember 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); + } + + + // ********** NamedConverterAnnotation 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()); + } + + public TextRange getNameTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + abstract String getNameElementName(); + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBaseTypeConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBaseTypeConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBaseTypeConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceBaseTypeConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,122 @@ +/******************************************************************************* + * 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.eclipselink.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.TypeStringExpressionConverter; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +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; +import org.eclipse.jpt.eclipselink.core.resource.java.BaseTypeConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.TypeConverter + * org.eclipse.persistence.annotations.ObjectTypeConverter + */ +abstract class SourceBaseTypeConverterAnnotation + extends SourceNamedConverterAnnotation + implements BaseTypeConverterAnnotation +{ + final DeclarationAnnotationElementAdapter dataTypeDeclarationAdapter; + final AnnotationElementAdapter dataTypeAdapter; + String dataType; + + final DeclarationAnnotationElementAdapter objectTypeDeclarationAdapter; + final AnnotationElementAdapter objectTypeAdapter; + String objectType; + + + SourceBaseTypeConverterAnnotation(JavaResourcePersistentMember parent, Member member, DeclarationAnnotationAdapter daa) { + super(parent, member, daa); + this.dataTypeDeclarationAdapter = this.buildTypeAdapter(this.getDataTypeElementName()); + this.dataTypeAdapter = new ShortCircuitAnnotationElementAdapter(this.member, this.dataTypeDeclarationAdapter); + + this.objectTypeDeclarationAdapter = this.buildTypeAdapter(this.getObjectTypeElementName()); + this.objectTypeAdapter = new ShortCircuitAnnotationElementAdapter(this.member, this.objectTypeDeclarationAdapter); + } + + private DeclarationAnnotationElementAdapter buildTypeAdapter(String elementName) { + // false = do not remove annotation when empty + return new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName, false, TypeStringExpressionConverter.instance()); + } + + @Override + public void initialize(CompilationUnit astRoot) { + super.initialize(astRoot); + this.dataType = this.buildDataType(astRoot); + this.objectType = this.buildObjectType(astRoot); + } + + @Override + public void update(CompilationUnit astRoot) { + super.update(astRoot); + this.setDataType(this.buildDataType(astRoot)); + this.setObjectType(this.buildObjectType(astRoot)); + } + + + // ********** BaseTypeConverterAnnotation implementation ********** + + // ***** data type + public String getDataType() { + return this.dataType; + } + + public void setDataType(String dataType) { + if (this.attributeValueHasNotChanged(this.dataType, dataType)) { + return; + } + String old = this.dataType; + this.dataType = dataType; + this.dataTypeAdapter.setValue(dataType); + this.firePropertyChanged(DATA_TYPE_PROPERTY, old, dataType); + } + + private String buildDataType(CompilationUnit astRoot) { + return this.dataTypeAdapter.getValue(astRoot); + } + + public TextRange getDataTypeTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.dataTypeDeclarationAdapter, astRoot); + } + + abstract String getDataTypeElementName(); + + // ***** object type + public String getObjectType() { + return this.objectType; + } + + public void setObjectType(String objectType) { + if (this.attributeValueHasNotChanged(this.objectType, objectType)) { + return; + } + String old = this.objectType; + this.objectType = objectType; + this.objectTypeAdapter.setValue(objectType); + this.firePropertyChanged(OBJECT_TYPE_PROPERTY, old, objectType); + } + + public TextRange getObjectTypeTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.objectTypeDeclarationAdapter, astRoot); + } + + private String buildObjectType(CompilationUnit astRoot) { + return this.objectTypeAdapter.getValue(astRoot); + } + + abstract String getObjectTypeElementName(); + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceChangeTrackingAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceChangeTrackingAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceChangeTrackingAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceChangeTrackingAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,96 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.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; +import org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; + +/** + * org.eclipse.persistence.annotations.ChangeTracking + */ +public final class SourceChangeTrackingAnnotation + extends SourceAnnotation + implements ChangeTrackingAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private ChangeTrackingType value; + + + public SourceChangeTrackingAnnotation(JavaResourcePersistentType parent, Type type) { + super(parent, type, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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); + } + + + // ********** ChangeTrackingAnnotation implementation ********** + + // ***** value + public ChangeTrackingType getValue() { + return this.value; + } + + public void setValue(ChangeTrackingType value) { + if (this.attributeValueHasNotChanged(this.value, value)) { + return; + } + ChangeTrackingType old = this.value; + this.value = value; + this.valueAdapter.setValue(ChangeTrackingType.toJavaAnnotationValue(value)); + this.firePropertyChanged(VALUE_PROPERTY, old, value); + } + + private ChangeTrackingType buildValue(CompilationUnit astRoot) { + return ChangeTrackingType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(VALUE_ADAPTER, astRoot); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildValueAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CHANGE_TRACKING__VALUE, false); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConversionValueAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConversionValueAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConversionValueAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConversionValueAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,165 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.NestableAnnotation; +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.Member; +import org.eclipse.jpt.eclipselink.core.resource.java.ConversionValueAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.NestableConversionValueAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ObjectTypeConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.ConversionValue + */ +final class SourceConversionValueAnnotation + extends SourceAnnotation + implements NestableConversionValueAnnotation +{ + private final DeclarationAnnotationElementAdapter dataValueDeclarationAdapter; + private final AnnotationElementAdapter dataValueAdapter; + private String dataValue; + + private final DeclarationAnnotationElementAdapter objectValueDeclarationAdapter; + private final AnnotationElementAdapter objectValueAdapter; + private String objectValue; + + + SourceConversionValueAnnotation(ObjectTypeConverterAnnotation parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { + super(parent, member, idaa, new MemberIndexedAnnotationAdapter(member, idaa)); + this.dataValueDeclarationAdapter = this.buildDataValueAdapter(idaa); + this.dataValueAdapter = this.buildAdapter(this.dataValueDeclarationAdapter); + this.objectValueDeclarationAdapter = this.buildObjectValueAdapter(idaa); + this.objectValueAdapter = this.buildAdapter(this.objectValueDeclarationAdapter); + } + + private AnnotationElementAdapter buildAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(this.member, daea); + } + + private DeclarationAnnotationElementAdapter buildDataValueAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, EclipseLinkJPA.CONVERSION_VALUE__DATA_VALUE, false); + } + + private DeclarationAnnotationElementAdapter buildObjectValueAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, EclipseLinkJPA.CONVERSION_VALUE__OBJECT_VALUE, false); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public void initialize(CompilationUnit astRoot) { + this.dataValue = this.buildDataValue(astRoot); + this.objectValue = this.buildObjectValue(astRoot); + } + + public void update(CompilationUnit astRoot) { + this.setDataValue(this.buildDataValue(astRoot)); + this.setObjectValue(this.buildObjectValue(astRoot)); + } + + public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { + return (IndexedAnnotationAdapter) this.annotationAdapter; + } + + @Override + public void toString(StringBuilder sb) { + sb.append(this.dataValue); + sb.append("=>"); //$NON-NLS-1$ + sb.append(this.objectValue); + } + + + // ********** ConversionValueAnnotation implementation ********** + + // ***** data value + public String getDataValue() { + return this.dataValue; + } + + public void setDataValue(String dataValue) { + if (this.attributeValueHasNotChanged(this.dataValue, dataValue)) { + return; + } + String old = this.dataValue; + this.dataValue = dataValue; + this.dataValueAdapter.setValue(dataValue); + this.firePropertyChanged(DATA_VALUE_PROPERTY, old, dataValue); + } + + private String buildDataValue(CompilationUnit astRoot) { + return this.dataValueAdapter.getValue(astRoot); + } + + public TextRange getDataValueTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.dataValueDeclarationAdapter, astRoot); + } + + // ***** object value + public String getObjectValue() { + return this.objectValue; + } + + public void setObjectValue(String objectValue) { + if (this.attributeValueHasNotChanged(this.objectValue, objectValue)) { + return; + } + String old = this.objectValue; + this.objectValue = objectValue; + this.objectValueAdapter.setValue(objectValue); + this.firePropertyChanged(OBJECT_VALUE_PROPERTY, old, objectValue); + } + + private String buildObjectValue(CompilationUnit astRoot) { + return this.objectValueAdapter.getValue(astRoot); + } + + public TextRange getObjectValueTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.objectValueDeclarationAdapter, astRoot); + } + + + //************ NestableAnnotation implementation + + public void initializeFrom(NestableAnnotation oldAnnotation) { + ConversionValueAnnotation oldConversionValue = (ConversionValueAnnotation) oldAnnotation; + this.setDataValue(oldConversionValue.getDataValue()); + this.setObjectValue(oldConversionValue.getObjectValue()); + } + + public void moveAnnotation(int newIndex) { + this.getIndexedAnnotationAdapter().moveAnnotation(newIndex); + } + + + // ********** static methods ********** + + static NestableConversionValueAnnotation createConversionValue(ObjectTypeConverterAnnotation parent, Member member, DeclarationAnnotationAdapter daa, int index) { + return new SourceConversionValueAnnotation(parent, member, buildConversionValueAnnotationAdapter(daa, index)); + } + + private static IndexedDeclarationAnnotationAdapter buildConversionValueAnnotationAdapter(DeclarationAnnotationAdapter daa, int index) { + return new NestedIndexedDeclarationAnnotationAdapter(daa, EclipseLinkJPA.OBJECT_TYPE_CONVERTER__CONVERSION_VALUES, index, EclipseLinkJPA.CONVERSION_VALUE, false); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicCollectionAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicCollectionAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicCollectionAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicCollectionAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryBasicCollectionAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceBasicCollectionAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.BasicCollectionAnnotation; + +/** + * org.eclipse.persistence.annotations.BasicCollection + */ +public class BasicCollectionAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new BasicCollectionAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private BasicCollectionAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceBasicCollectionAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryBasicCollectionAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return BasicCollectionAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConvertAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConvertAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConvertAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConvertAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.ConvertAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; + +/** + * org.eclipse.persistence.annotations.Convert + */ +public final class BinaryConvertAnnotation + extends BinaryAnnotation + implements ConvertAnnotation +{ + private String value; + + public BinaryConvertAnnotation(JavaResourcePersistentAttribute 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()); + } + + + // ********** ConvertAnnotation 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(EclipseLinkJPA.CONVERT__VALUE); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceReadTransformerAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceReadTransformerAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceReadTransformerAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceReadTransformerAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,50 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.ReadTransformerAnnotation; + +/** + * org.eclipse.persistence.annotations.ReadTransformer + */ +public final class SourceReadTransformerAnnotation + extends SourceTransformerAnnotation + implements ReadTransformerAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + + public SourceReadTransformerAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + + // ********** SourceTransformerAnnotation implementation ********** + + @Override + String getTransformerClassElementName() { + return EclipseLinkJPA.READ_TRANSFORMER__TRANSFORMER_CLASS; + } + + @Override + String getMethodElementName() { + return EclipseLinkJPA.READ_TRANSFORMER__METHOD; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceJoinFetchAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceJoinFetchAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceJoinFetchAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceJoinFetchAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,96 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.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; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType; + +/** + * org.eclipse.persistence.annotations.JoinFetch + */ +public final class SourceJoinFetchAnnotation + extends SourceAnnotation + implements JoinFetchAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private JoinFetchType value; + + + public SourceJoinFetchAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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); + } + + + // ********** JoinFetchAnnotation implementation ********** + + // ***** value + public JoinFetchType getValue() { + return this.value; + } + + public void setValue(JoinFetchType value) { + if (this.attributeValueHasNotChanged(this.value, value)) { + return; + } + JoinFetchType old = this.value; + this.value = value; + this.valueAdapter.setValue(JoinFetchType.toJavaAnnotationValue(value)); + this.firePropertyChanged(VALUE_PROPERTY, old, value); + } + + private JoinFetchType buildValue(CompilationUnit astRoot) { + return JoinFetchType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(VALUE_ADAPTER, astRoot); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildValueAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.JOIN_FETCH__VALUE, false); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryJoinFetchAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryJoinFetchAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryJoinFetchAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryJoinFetchAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,72 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchType; + +/** + * org.eclipse.persistence.annotations.JoinFetch + */ +public final class BinaryJoinFetchAnnotation + extends BinaryAnnotation + implements JoinFetchAnnotation +{ + private JoinFetchType value; + + + public BinaryJoinFetchAnnotation(JavaResourcePersistentAttribute 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()); + } + + + // ********** BinaryJoinFetchAnnotation implementation ********** + + // ***** value + public JoinFetchType getValue() { + return this.value; + } + + public void setValue(JoinFetchType value) { + throw new UnsupportedOperationException(); + } + + private void setValue_(JoinFetchType value) { + JoinFetchType old = this.value; + this.value = value; + this.firePropertyChanged(VALUE_PROPERTY, old, value); + } + + private JoinFetchType buildValue() { + return JoinFetchType.fromJavaAnnotationValue(this.getJdtMemberValue(EclipseLinkJPA.JOIN_FETCH__VALUE)); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TypeConverterAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TypeConverterAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TypeConverterAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TypeConverterAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryTypeConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceTypeConverterAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.TypeConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.TypeConverter + */ +public class TypeConverterAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new TypeConverterAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private TypeConverterAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceTypeConverterAnnotation(parent, member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryTypeConverterAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return TypeConverterAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicMapAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicMapAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicMapAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/BasicMapAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryBasicMapAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceBasicMapAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.BasicMapAnnotation; + +/** + * org.eclipse.persistence.annotations.BasicMap + */ +public class BasicMapAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new BasicMapAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private BasicMapAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceBasicMapAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryBasicMapAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return BasicMapAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceStructConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceStructConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceStructConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceStructConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,102 @@ +/******************************************************************************* + * 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.eclipselink.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.internal.utility.jdt.StringExpressionConverter; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +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; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.StructConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.StructConverter + */ +public final class SourceStructConverterAnnotation + extends SourceNamedConverterAnnotation + implements StructConverterAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter CONVERTER_ADAPTER = buildConverterAdapter(); + private final AnnotationElementAdapter converterAdapter; + private String converter; + + + public SourceStructConverterAnnotation(JavaResourcePersistentMember parent, Member member) { + super(parent, member, DECLARATION_ANNOTATION_ADAPTER); + this.converterAdapter = new ShortCircuitAnnotationElementAdapter(member, CONVERTER_ADAPTER); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + public void initialize(CompilationUnit astRoot) { + super.initialize(astRoot); + this.converter = this.buildConverter(astRoot); + } + + @Override + public void update(CompilationUnit astRoot) { + super.update(astRoot); + this.setConverter(this.buildConverter(astRoot)); + } + + + // ********** SourceNamedConverterAnnotation implementation ********** + + @Override + String getNameElementName() { + return EclipseLinkJPA.STRUCT_CONVERTER__NAME; + } + + + // ********** StructConverterAnnotation implementation ********** + + // ***** converter + public String getConverter() { + return this.converter; + } + + public void setConverter(String converter) { + if (this.attributeValueHasNotChanged(this.converter, converter)) { + return; + } + String old = this.converter; + this.converter = converter; + this.converterAdapter.setValue(converter); + this.firePropertyChanged(CONVERTER_PROPERTY, old, converter); + } + + private String buildConverter(CompilationUnit astRoot) { + return this.converterAdapter.getValue(astRoot); + } + + public TextRange getConverterTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(CONVERTER_ADAPTER, astRoot); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildConverterAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.STRUCT_CONVERTER__CONVERTER, false, StringExpressionConverter.instance()); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryReadTransformerAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryReadTransformerAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryReadTransformerAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryReadTransformerAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.ReadTransformerAnnotation; + +/** + * org.eclipse.persistence.annotations.ReadTransformer + */ +public final class BinaryReadTransformerAnnotation + extends BinaryTransformerAnnotation + implements ReadTransformerAnnotation +{ + + public BinaryReadTransformerAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + + // ********** BinaryTransformerAnnotation implementation ********** + + @Override + String getTransformerClassElementName() { + return EclipseLinkJPA.READ_TRANSFORMER__TRANSFORMER_CLASS; + } + + @Override + String getMethodElementName() { + return EclipseLinkJPA.READ_TRANSFORMER__METHOD; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceCacheAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceCacheAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceCacheAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceCacheAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,411 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.MemberAnnotationAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; +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.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; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheCoordinationType; +import org.eclipse.jpt.eclipselink.core.resource.java.CacheType; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; + +/** + * org.eclipse.persistence.annotations.Cache + */ +public final class SourceCacheAnnotation + extends SourceAnnotation + implements CacheAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter TYPE_ADAPTER = buildTypeAdapter(); + private final AnnotationElementAdapter typeAdapter; + private CacheType type; + + private static final DeclarationAnnotationElementAdapter SIZE_ADAPTER = buildSizeAdapter(); + private final AnnotationElementAdapter sizeAdapter; + private Integer size; + + private static final DeclarationAnnotationElementAdapter SHARED_ADAPTER = buildSharedAdapter(); + private final AnnotationElementAdapter sharedAdapter; + private Boolean shared; + + private static final DeclarationAnnotationElementAdapter EXPIRY_ADAPTER = buildExpiryAdapter(); + private final AnnotationElementAdapter expiryAdapter; + private Integer expiry; + + private static final DeclarationAnnotationElementAdapter ALWAYS_REFRESH_ADAPTER = buildAlwaysRefreshAdapter(); + private final AnnotationElementAdapter alwaysRefreshAdapter; + private TimeOfDayAnnotation expiryTimeOfDay; + + private static final DeclarationAnnotationElementAdapter REFRESH_ONLY_IF_NEWER_ADAPTER = buildRefreshOnlyIfNewerAdapter(); + private final AnnotationElementAdapter refreshOnlyIfNewerAdapter; + private Boolean alwaysRefresh; + + private static final DeclarationAnnotationElementAdapter DISABLE_HITS_ADAPTER = buildDisableHitsAdapter(); + private final AnnotationElementAdapter disableHitsAdapter; + private Boolean refreshOnlyIfNewer; + + private static final DeclarationAnnotationElementAdapter COORDINATION_TYPE_ADAPTER = buildCoordinationTypeAdapter(); + private final AnnotationElementAdapter coordinationTypeAdapter; + private Boolean disableHits; + + private static final NestedDeclarationAnnotationAdapter EXPIRY_TIME_OF_DAY_ADAPTER = buildExpiryTimeOfDayAdapter(); + private final MemberAnnotationAdapter expiryTimeOfDayAdapter; + private CacheCoordinationType coordinationType; + + + public SourceCacheAnnotation(JavaResourcePersistentType parent, Type type) { + super(parent, type, DECLARATION_ANNOTATION_ADAPTER); + this.typeAdapter = new ShortCircuitAnnotationElementAdapter(type, TYPE_ADAPTER); + this.sizeAdapter = new ShortCircuitAnnotationElementAdapter(type, SIZE_ADAPTER); + this.sharedAdapter = new ShortCircuitAnnotationElementAdapter(type, SHARED_ADAPTER); + this.expiryAdapter = new ShortCircuitAnnotationElementAdapter(type, EXPIRY_ADAPTER); + this.alwaysRefreshAdapter = new ShortCircuitAnnotationElementAdapter(type, ALWAYS_REFRESH_ADAPTER); + this.refreshOnlyIfNewerAdapter = new ShortCircuitAnnotationElementAdapter(type, REFRESH_ONLY_IF_NEWER_ADAPTER); + this.disableHitsAdapter = new ShortCircuitAnnotationElementAdapter(type, DISABLE_HITS_ADAPTER); + this.coordinationTypeAdapter = new ShortCircuitAnnotationElementAdapter(type, COORDINATION_TYPE_ADAPTER); + this.expiryTimeOfDayAdapter = new MemberAnnotationAdapter(type, EXPIRY_TIME_OF_DAY_ADAPTER); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public void initialize(CompilationUnit astRoot) { + this.type = this.buildType(astRoot); + this.size = this.buildSize(astRoot); + this.shared = this.buildShared(astRoot); + this.expiry = this.buildExpiry(astRoot); + this.initializeExpiryTimeOfDay(astRoot); + this.alwaysRefresh = this.buildAlwaysRefresh(astRoot); + this.refreshOnlyIfNewer = this.buildRefreshOnlyIfNewer(astRoot); + this.disableHits = this.buildDisableHits(astRoot); + this.coordinationType = this.buildCoordinationType(astRoot); + } + + private void initializeExpiryTimeOfDay(CompilationUnit astRoot) { + if (this.expiryTimeOfDayAdapter.getAnnotation(astRoot) != null) { + this.expiryTimeOfDay = this.buildExpiryTimeOfDay(); + this.expiryTimeOfDay.initialize(astRoot); + } + } + + public void update(CompilationUnit astRoot) { + this.setType(this.buildType(astRoot)); + this.setSize(this.buildSize(astRoot)); + this.setShared(this.buildShared(astRoot)); + this.setExpiry(this.buildExpiry(astRoot)); + this.updateExpiryTimeOfDay(astRoot); + this.setAlwaysRefresh(this.buildAlwaysRefresh(astRoot)); + this.setRefreshOnlyIfNewer(this.buildRefreshOnlyIfNewer(astRoot)); + this.setDisableHits(this.buildDisableHits(astRoot)); + this.setCoordinationType(this.buildCoordinationType(astRoot)); + } + + private void updateExpiryTimeOfDay(CompilationUnit astRoot) { + if (this.expiryTimeOfDayAdapter.getAnnotation(astRoot) == null) { + this.setExpiryTimeOfDay(null); + } else { + if (this.getExpiryTimeOfDay() == null) { + TimeOfDayAnnotation etod = this.buildExpiryTimeOfDay(); + etod.initialize(astRoot); + this.setExpiryTimeOfDay(etod); + } else { + this.getExpiryTimeOfDay().update(astRoot); + } + } + } + + @Override + public void toString(StringBuilder sb) { + sb.append(this.type); + } + + + // ********** CacheAnnotation implementation ********** + + // ***** type + public CacheType getType() { + return this.type; + } + + public void setType(CacheType type) { + if (this.attributeValueHasNotChanged(this.type, type)) { + return; + } + CacheType old = this.type; + this.type = type; + this.typeAdapter.setValue(CacheType.toJavaAnnotationValue(type)); + this.firePropertyChanged(TYPE_PROPERTY, old, type); + } + + private CacheType buildType(CompilationUnit astRoot) { + return CacheType.fromJavaAnnotationValue(this.typeAdapter.getValue(astRoot)); + } + + public TextRange getTypeTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(TYPE_ADAPTER, astRoot); + } + + // ***** size + public Integer getSize() { + return this.size; + } + + public void setSize(Integer size) { + if (this.attributeValueHasNotChanged(this.size, size)) { + return; + } + Integer old = this.size; + this.size = size; + this.sizeAdapter.setValue(size); + this.firePropertyChanged(SIZE_PROPERTY, old, size); + } + + private Integer buildSize(CompilationUnit astRoot) { + return this.sizeAdapter.getValue(astRoot); + } + + public TextRange getSizeTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(SIZE_ADAPTER, astRoot); + } + + // ***** shared + public Boolean getShared() { + return this.shared; + } + + public void setShared(Boolean shared) { + if (this.attributeValueHasNotChanged(this.shared, shared)) { + return; + } + Boolean old = this.shared; + this.shared = shared; + this.sharedAdapter.setValue(shared); + this.firePropertyChanged(SHARED_PROPERTY, old, shared); + } + + private Boolean buildShared(CompilationUnit astRoot) { + return this.sharedAdapter.getValue(astRoot); + } + + public TextRange getSharedTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(SHARED_ADAPTER, astRoot); + } + + // ***** expiry + public Integer getExpiry() { + return this.expiry; + } + + public void setExpiry(Integer expiry) { + if (this.attributeValueHasNotChanged(this.expiry, expiry)) { + return; + } + Integer old = this.expiry; + this.expiry = expiry; + this.expiryAdapter.setValue(expiry); + this.firePropertyChanged(EXPIRY_PROPERTY, old, expiry); + } + + private Integer buildExpiry(CompilationUnit astRoot) { + return this.expiryAdapter.getValue(astRoot); + } + + public TextRange getExpiryTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(EXPIRY_ADAPTER, astRoot); + } + + // ***** expiry time of day + public TimeOfDayAnnotation getExpiryTimeOfDay() { + return this.expiryTimeOfDay; + } + + public TimeOfDayAnnotation addExpiryTimeOfDay() { + if (this.expiryTimeOfDay != null) { + throw new IllegalStateException("'expiryTimeOfDay' element already exists"); //$NON-NLS-1$ + } + this.expiryTimeOfDay = this.buildExpiryTimeOfDay(); + this.expiryTimeOfDayAdapter.newMarkerAnnotation(); + this.firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, null, this.expiryTimeOfDay); + return this.expiryTimeOfDay; + } + + public void removeExpiryTimeOfDay() { + if (this.expiryTimeOfDay == null) { + throw new IllegalStateException("No expiryTimeOfDay element exists"); //$NON-NLS-1$ + } + this.expiryTimeOfDay = null; + this.expiryTimeOfDayAdapter.removeAnnotation(); + this.firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, this.expiryTimeOfDay, null); + } + + private void setExpiryTimeOfDay(TimeOfDayAnnotation expiryTimeOfDay) { + TimeOfDayAnnotation old = this.expiryTimeOfDay; + this.expiryTimeOfDay = expiryTimeOfDay; + this.firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, old, expiryTimeOfDay); + } + + private TimeOfDayAnnotation buildExpiryTimeOfDay() { + return new SourceTimeOfDayAnnotation(this, this.member, EXPIRY_TIME_OF_DAY_ADAPTER); + } + + public TextRange getExpiryTimeOfDayTextRange(CompilationUnit astRoot) { + return null;//TODO return this.getElementTextRange(EXPIRY_TIME_OF_DAY_ADAPTER, astRoot); + } + + // ***** always refresh + public Boolean getAlwaysRefresh() { + return this.alwaysRefresh; + } + + public void setAlwaysRefresh(Boolean alwaysRefresh) { + if (this.attributeValueHasNotChanged(this.alwaysRefresh, alwaysRefresh)) { + return; + } + Boolean old = this.alwaysRefresh; + this.alwaysRefresh = alwaysRefresh; + this.alwaysRefreshAdapter.setValue(alwaysRefresh); + this.firePropertyChanged(ALWAYS_REFRESH_PROPERTY, old, alwaysRefresh); + } + + private Boolean buildAlwaysRefresh(CompilationUnit astRoot) { + return this.alwaysRefreshAdapter.getValue(astRoot); + } + + public TextRange getAlwaysRefreshTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(ALWAYS_REFRESH_ADAPTER, astRoot); + } + + // ***** refresh only if newer + public Boolean getRefreshOnlyIfNewer() { + return this.refreshOnlyIfNewer; + } + + public void setRefreshOnlyIfNewer(Boolean refreshOnlyIfNewer) { + if (this.attributeValueHasNotChanged(this.refreshOnlyIfNewer, refreshOnlyIfNewer)) { + return; + } + Boolean old = this.refreshOnlyIfNewer; + this.refreshOnlyIfNewer = refreshOnlyIfNewer; + this.refreshOnlyIfNewerAdapter.setValue(refreshOnlyIfNewer); + this.firePropertyChanged(REFRESH_ONLY_IF_NEWER_PROPERTY, old, refreshOnlyIfNewer); + } + + private Boolean buildRefreshOnlyIfNewer(CompilationUnit astRoot) { + return this.refreshOnlyIfNewerAdapter.getValue(astRoot); + } + + public TextRange getRefreshOnlyIfNewerTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(REFRESH_ONLY_IF_NEWER_ADAPTER, astRoot); + } + + // ***** disable hits + public Boolean getDisableHits() { + return this.disableHits; + } + + public void setDisableHits(Boolean disableHits) { + if (this.attributeValueHasNotChanged(this.disableHits, disableHits)) { + return; + } + Boolean old = this.disableHits; + this.disableHits = disableHits; + this.disableHitsAdapter.setValue(disableHits); + this.firePropertyChanged(DISABLE_HITS_PROPERTY, old, disableHits); + } + + private Boolean buildDisableHits(CompilationUnit astRoot) { + return this.disableHitsAdapter.getValue(astRoot); + } + + public TextRange getDisablesHitsTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(DISABLE_HITS_ADAPTER, astRoot); + } + + // ***** coordination type + public CacheCoordinationType getCoordinationType() { + return this.coordinationType; + } + + public void setCoordinationType(CacheCoordinationType coordinationType) { + if (this.attributeValueHasNotChanged(this.coordinationType, coordinationType)) { + return; + } + CacheCoordinationType old = this.coordinationType; + this.coordinationType = coordinationType; + this.coordinationTypeAdapter.setValue(CacheCoordinationType.toJavaAnnotationValue(coordinationType)); + this.firePropertyChanged(TYPE_PROPERTY, old, coordinationType); + } + + private CacheCoordinationType buildCoordinationType(CompilationUnit astRoot) { + return CacheCoordinationType.fromJavaAnnotationValue(this.coordinationTypeAdapter.getValue(astRoot)); + } + + public TextRange getCoordinationTypeTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(COORDINATION_TYPE_ADAPTER, astRoot); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildTypeAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__TYPE); + } + + private static DeclarationAnnotationElementAdapter buildSizeAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__SIZE, NumberIntegerExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildSharedAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__SHARED, BooleanExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildExpiryAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__EXPIRY, NumberIntegerExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildAlwaysRefreshAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__ALWAYS_REFRESH, BooleanExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildRefreshOnlyIfNewerAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__REFRESH_ONLY_IF_NEWER, BooleanExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildDisableHitsAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__DISABLE_HITS, BooleanExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildCoordinationTypeAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__COORDINATION_TYPE); + } + + private static NestedDeclarationAnnotationAdapter buildExpiryTimeOfDayAdapter() { + return new NestedDeclarationAnnotationAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CACHE__EXPIRY_TIME_OF_DAY, EclipseLinkJPA.TIME_OF_DAY); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryChangeTrackingAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryChangeTrackingAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryChangeTrackingAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryChangeTrackingAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,73 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.ChangeTrackingType; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; + +/** + * org.eclipse.persistence.annotations.ChangeTracking + */ +public final class BinaryChangeTrackingAnnotation + extends BinaryAnnotation + implements ChangeTrackingAnnotation +{ + private ChangeTrackingType value; + + + public BinaryChangeTrackingAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.value = this.buildValue(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + // TODO + @Override + public void update() { + super.update(); + this.setValue_(this.buildValue()); + } + + + // ********** ChangeTrackingAnnotation implementation ********** + + // ***** value + public ChangeTrackingType getValue() { + return this.value; + } + + public void setValue(ChangeTrackingType value) { + throw new UnsupportedOperationException(); + } + + private void setValue_(ChangeTrackingType value) { + ChangeTrackingType old = this.value; + this.value = value; + this.firePropertyChanged(VALUE_PROPERTY, old, value); + } + + private ChangeTrackingType buildValue() { + return ChangeTrackingType.fromJavaAnnotationValue(this.getJdtMemberValue(EclipseLinkJPA.CHANGE_TRACKING__VALUE)); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConversionValueAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConversionValueAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConversionValueAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryConversionValueAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.ConversionValueAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; + +/** + * org.eclipse.persistence.annotations.ConversionValue + */ +final class BinaryConversionValueAnnotation + extends BinaryAnnotation + implements ConversionValueAnnotation +{ + private String dataValue; + private String objectValue; + + + BinaryConversionValueAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.dataValue = this.buildDataValue(); + this.objectValue = this.buildObjectValue(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + public void update() { + super.update(); + this.setDataValue_(this.buildDataValue()); + this.setObjectValue_(this.buildObjectValue()); + } + + + // ********** ConversionValueAnnotation implementation ********** + + // ***** data value + public String getDataValue() { + return this.dataValue; + } + + public void setDataValue(String dataValue) { + throw new UnsupportedOperationException(); + } + + private void setDataValue_(String dataValue) { + String old = this.dataValue; + this.dataValue = dataValue; + this.firePropertyChanged(DATA_VALUE_PROPERTY, old, dataValue); + } + + private String buildDataValue() { + return (String) this.getJdtMemberValue(EclipseLinkJPA.CONVERSION_VALUE__DATA_VALUE); + } + + public TextRange getDataValueTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + // ***** object value + public String getObjectValue() { + return this.objectValue; + } + + public void setObjectValue(String objectValue) { + throw new UnsupportedOperationException(); + } + + private void setObjectValue_(String objectValue) { + String old = this.objectValue; + this.objectValue = objectValue; + this.firePropertyChanged(OBJECT_VALUE_PROPERTY, old, objectValue); + } + + private String buildObjectValue() { + return (String) this.getJdtMemberValue(EclipseLinkJPA.CONVERSION_VALUE__OBJECT_VALUE); + } + + public TextRange getObjectValueTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceNamedConverterAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceNamedConverterAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceNamedConverterAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceNamedConverterAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,93 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.OverrideAnnotation; +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; +import org.eclipse.jpt.eclipselink.core.resource.java.NamedConverterAnnotation; + +/** + * org.eclipse.persistence.annotations.Converter + * org.eclipse.persistence.annotations.StructConverter + * org.eclipse.persistence.annotations.TypeConverter + * org.eclipse.persistence.annotations.ObjectTypeConverter + */ +abstract class SourceNamedConverterAnnotation + extends SourceAnnotation + implements NamedConverterAnnotation +{ + final DeclarationAnnotationElementAdapter nameDeclarationAdapter; + final AnnotationElementAdapter nameAdapter; + String name; + + + // ********** construction/initialization ********** + + SourceNamedConverterAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { + super(parent, member, daa); + this.nameDeclarationAdapter = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, this.getNameElementName(), false); // false = do not remove annotation when empty + this.nameAdapter = new ShortCircuitAnnotationElementAdapter(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); + } + + + // ********** NamedConverterAnnotation 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); + } + + abstract String getNameElementName(); + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTransformerAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTransformerAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTransformerAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTransformerAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,119 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.SimpleTypeStringExpressionConverter; +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; +import org.eclipse.jpt.eclipselink.core.resource.java.TransformerAnnotation; + +/** + * org.eclipse.persistence.annotations.ReadTransformer + * org.eclipse.persistence.annotations.WriteTransformer + */ +abstract class SourceTransformerAnnotation + extends SourceAnnotation + implements TransformerAnnotation +{ + final DeclarationAnnotationElementAdapter transformerClassDeclarationAdapter; + final AnnotationElementAdapter transformerClassAdapter; + String transformerClass; + + final DeclarationAnnotationElementAdapter methodDeclarationAdapter; + final AnnotationElementAdapter methodAdapter; + String method; + + + SourceTransformerAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa) { + super(parent, attribute, daa); + this.transformerClassDeclarationAdapter = new ConversionDeclarationAnnotationElementAdapter(daa, this.getTransformerClassElementName(), false, SimpleTypeStringExpressionConverter.instance()); + this.transformerClassAdapter = new ShortCircuitAnnotationElementAdapter(attribute, this.transformerClassDeclarationAdapter); + + this.methodDeclarationAdapter = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, this.getMethodElementName(), false); + this.methodAdapter = new ShortCircuitAnnotationElementAdapter(attribute, this.methodDeclarationAdapter); + } + + public void initialize(CompilationUnit astRoot) { + this.transformerClass = this.buildTransformerClass(astRoot); + this.method = this.buildMethod(astRoot); + } + + public void update(CompilationUnit astRoot) { + this.setTransformerClass(this.buildTransformerClass(astRoot)); + this.setMethod(this.buildMethod(astRoot)); + } + + @Override + public void toString(StringBuilder sb) { + sb.append(this.transformerClass); + } + + + // ********** TransformerAnnotation implementation ********** + + // ***** transformer class + public String getTransformerClass() { + return this.transformerClass; + } + + public void setTransformerClass(String transformerClass) { + if (this.attributeValueHasNotChanged(this.transformerClass, transformerClass)) { + return; + } + String old = this.transformerClass; + this.transformerClass = transformerClass; + this.transformerClassAdapter.setValue(transformerClass); + this.firePropertyChanged(TRANSFORMER_CLASS_PROPERTY, old, transformerClass); + } + + private String buildTransformerClass(CompilationUnit astRoot) { + return this.transformerClassAdapter.getValue(astRoot); + } + + public TextRange getTransformerClassTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.transformerClassDeclarationAdapter, astRoot); + } + + abstract String getTransformerClassElementName(); + + // ***** method + public String getMethod() { + return this.method; + } + + public void setMethod(String method) { + if (this.attributeValueHasNotChanged(this.method, method)) { + return; + } + String old = this.method; + this.method = method; + this.methodAdapter.setValue(method); + this.firePropertyChanged(METHOD_PROPERTY, old, method); + } + + private String buildMethod(CompilationUnit astRoot) { + return this.methodAdapter.getValue(astRoot); + } + + public TextRange getMethodTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(this.methodDeclarationAdapter, astRoot); + } + + abstract String getMethodElementName(); + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConvertAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConvertAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConvertAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceConvertAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,96 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.internal.utility.jdt.StringExpressionConverter; +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; +import org.eclipse.jpt.eclipselink.core.resource.java.ConvertAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; + +/** + * org.eclipse.persistence.annotations.Convert + */ +public final class SourceConvertAnnotation + extends SourceAnnotation + implements ConvertAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private String value; + + + public SourceConvertAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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); + } + + + // ********** ConvertAnnotation 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 buildValueAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.CONVERT__VALUE, false, StringExpressionConverter.instance()); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTransformationAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTransformationAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTransformationAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/source/SourceTransformationAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,132 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.source; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; +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.FetchType; +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; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.TransformationAnnotation; + +/** + * org.eclipse.persistence.annotations.Transformation + */ +public final class SourceTransformationAnnotation + extends SourceAnnotation + implements TransformationAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); + private final AnnotationElementAdapter fetchAdapter; + private FetchType fetch; + + private static final DeclarationAnnotationElementAdapter OPTIONAL_ADAPTER = buildOptionalAdapter(); + private final AnnotationElementAdapter optionalAdapter; + private Boolean optional; + + + public SourceTransformationAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + this.fetchAdapter = new ShortCircuitAnnotationElementAdapter(attribute, FETCH_ADAPTER); + this.optionalAdapter = new ShortCircuitAnnotationElementAdapter(attribute, OPTIONAL_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); + } + + + // ********** TransformationAnnotation implementation ********** + + // ***** 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(FETCH_ADAPTER, 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 buildOptionalAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.TRANSFORMATION__OPTIONAL, false, BooleanExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildFetchAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, EclipseLinkJPA.TRANSFORMATION__FETCH, false); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryMutableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryMutableAnnotation.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryMutableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/binary/BinaryMutableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,71 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java.binary; + +import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.MutableAnnotation; + +/** + * org.eclipse.persistence.annotations.Mutable + */ +public final class BinaryMutableAnnotation + extends BinaryAnnotation + implements MutableAnnotation +{ + private Boolean value; + + + public BinaryMutableAnnotation(JavaResourcePersistentAttribute 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()); + } + + + // ********** MutableAnnotation implementation ********** + + // ***** value + public Boolean getValue() { + return this.value; + } + + public void setValue(Boolean value) { + throw new UnsupportedOperationException(); + } + + private void setValue_(Boolean value) { + Boolean old = this.value; + this.value = value; + this.firePropertyChanged(VALUE_PROPERTY, old, value); + } + + private Boolean buildValue() { + return (Boolean) this.getJdtMemberValue(EclipseLinkJPA.MUTABLE__VALUE); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/MutableAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/MutableAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/MutableAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/MutableAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryMutableAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceMutableAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.MutableAnnotation; + +/** + * org.eclipse.persistence.annotations.Mutable + */ +public class MutableAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new MutableAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private MutableAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceMutableAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryMutableAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return MutableAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TransformationAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TransformationAnnotationDefinition.java diff -N src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TransformationAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TransformationAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.eclipselink.core.internal.resource.java; + +import org.eclipse.jdt.core.IAnnotation; +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.utility.jdt.Attribute; +import org.eclipse.jpt.core.utility.jdt.Member; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.binary.BinaryTransformationAnnotation; +import org.eclipse.jpt.eclipselink.core.internal.resource.java.source.SourceTransformationAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.TransformationAnnotation; + +/** + * org.eclipse.persistence.annotations.Transformation + */ +public class TransformationAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new TransformationAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private TransformationAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceTransformationAnnotation((JavaResourcePersistentAttribute) parent, (Attribute) member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + return new NullTransformationAnnotation((JavaResourcePersistentAttribute) parent); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryTransformationAnnotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); + } + + public String getAnnotationName() { + return TransformationAnnotation.ANNOTATION_NAME; + } + +} #P org.eclipse.jpt.utility Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF,v retrieving revision 1.16 diff -u -r1.16 MANIFEST.MF --- META-INF/MANIFEST.MF 19 Aug 2008 22:50:15 -0000 1.16 +++ META-INF/MANIFEST.MF 6 Apr 2009 20:59:01 -0000 @@ -12,6 +12,12 @@ org.eclipse.jpt.db.ui, org.eclipse.jpt.gen, org.eclipse.jpt.ui", + org.eclipse.jpt.utility.internal.iterables; + x-friends:="org.eclipse.jpt.core, + org.eclipse.jpt.db, + org.eclipse.jpt.db.ui, + org.eclipse.jpt.gen, + org.eclipse.jpt.ui", org.eclipse.jpt.utility.internal.iterators; x-friends:="org.eclipse.jpt.core, org.eclipse.jpt.db, Index: src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java,v retrieving revision 1.17 diff -u -r1.17 ChangeSupport.java --- src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java 10 Mar 2009 04:12:01 -0000 1.17 +++ src/org/eclipse/jpt/utility/internal/model/ChangeSupport.java 6 Apr 2009 20:59:02 -0000 @@ -44,7 +44,7 @@ * It provides for state, property, collection, list, and tree change notifications to * listeners. * - * NB: There is lots of copy-n-paste code in this class. Nearly all of this duplication + * NB1: There is lots of copy-n-paste code in this class. Nearly all of this duplication * is an effort to prevent the unnecessary creation of new objects (typically event * objects). Since many events are fired when there are no listeners, we postpone * the creation of event objects until we know we have interested listeners. @@ -112,7 +112,7 @@ */ protected void addListener(Class listenerClass, T listener) { if (listener == null) { - throw new NullPointerException(); // better sooner than later + throw new NullPointerException(); // better sooner than later } synchronized (this) { GenericListenerList gll = this.getGenericListenerList(listenerClass); @@ -154,7 +154,7 @@ */ protected void addListener(String aspectName, Class listenerClass, T listener) { if ((aspectName == null) || (listener == null)) { - throw new NullPointerException(); // better sooner than later + throw new NullPointerException(); // better sooner than later } synchronized (this) { ChangeSupport child = this.getChild(aspectName); @@ -175,7 +175,7 @@ return null; } for (AspectChild aspectChild : this.aspectChildren) { - if (aspectChild.aspectName == aspectName) { + if (aspectChild.aspectName.equals(aspectName)) { return aspectChild.child; } } @@ -187,7 +187,7 @@ * Return the newly-built child change support. */ protected ChangeSupport addChild(String aspectName) { - ChangeSupport child = this.buildChildChangeSupport(); + ChangeSupport child = this.buildChild(); this.aspectChildren = CollectionTools.add(this.aspectChildren, new AspectChild(aspectName, child)); return child; } @@ -195,7 +195,7 @@ /** * Build and return a child change support to hold aspect-specific listeners. */ - protected ChangeSupport buildChildChangeSupport() { + protected ChangeSupport buildChild() { return new Child(this.source); } @@ -288,7 +288,7 @@ * dirty flag or validating the source's state. * The aspect ID will be null if a "state change" occurred. */ - protected void sourceChanged(@SuppressWarnings("unused") String aspectName) { + protected void aspectChanged(@SuppressWarnings("unused") String aspectName) { // the default is to do nothing } @@ -348,7 +348,7 @@ } } - this.sourceChanged(null); + this.aspectChanged(null); } /** @@ -384,7 +384,7 @@ } } - this.sourceChanged(null); + this.aspectChanged(null); } @@ -480,7 +480,7 @@ child.firePropertyChanged(event); } - this.sourceChanged(propertyName); + this.aspectChanged(propertyName); } /** @@ -531,7 +531,7 @@ } } - this.sourceChanged(propertyName); + this.aspectChanged(propertyName); } /** @@ -569,7 +569,7 @@ if (stillListening) { if (event == null) { // here's the reason for the duplicate code... - event = new PropertyChangeEvent(this.source, propertyName, new Integer(oldValue), new Integer(newValue)); + event = new PropertyChangeEvent(this.source, propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue)); } target.propertyChanged(event); } @@ -583,7 +583,7 @@ } } - this.sourceChanged(propertyName); + this.aspectChanged(propertyName); } /** @@ -635,7 +635,7 @@ } } - this.sourceChanged(propertyName); + this.aspectChanged(propertyName); } @@ -728,7 +728,7 @@ child.fireItemsAdded(event); } - this.sourceChanged(collectionName); + this.aspectChanged(collectionName); } /** @@ -776,7 +776,7 @@ } } - this.sourceChanged(collectionName); + this.aspectChanged(collectionName); } /** @@ -821,7 +821,7 @@ } } - this.sourceChanged(collectionName); + this.aspectChanged(collectionName); } /** @@ -860,7 +860,7 @@ child.fireItemsRemoved(event); } - this.sourceChanged(collectionName); + this.aspectChanged(collectionName); } /** @@ -908,7 +908,7 @@ } } - this.sourceChanged(collectionName); + this.aspectChanged(collectionName); } /** @@ -953,7 +953,7 @@ } } - this.sourceChanged(collectionName); + this.aspectChanged(collectionName); } /** @@ -988,7 +988,7 @@ child.fireCollectionCleared(event); } - this.sourceChanged(collectionName); + this.aspectChanged(collectionName); } /** @@ -1033,7 +1033,7 @@ } } - this.sourceChanged(collectionName); + this.aspectChanged(collectionName); } /** @@ -1068,7 +1068,7 @@ child.fireCollectionChanged(event); } - this.sourceChanged(collectionName); + this.aspectChanged(collectionName); } /** @@ -1113,7 +1113,7 @@ } } - this.sourceChanged(collectionName); + this.aspectChanged(collectionName); } /** @@ -1374,7 +1374,7 @@ } if (collection.isEmpty()) { - return this.addItemsToCollection(newCollection, collection, collectionName); + return this.addItemsToCollection_(newCollection.iterator(), collection, collectionName); } return this.synchronizeCollection_(newCollection, collection, collectionName); @@ -1391,7 +1391,7 @@ } if (collection.isEmpty()) { - return this.addItemsToCollection(newCollection, collection, collectionName); + return this.addItemsToCollection_(newCollection, collection, collectionName); } return this.synchronizeCollection_(CollectionTools.collection(newCollection), collection, collectionName); @@ -1503,7 +1503,7 @@ child.fireItemsAdded(event); } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1551,7 +1551,7 @@ } } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1596,7 +1596,7 @@ } } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1635,7 +1635,7 @@ child.fireItemsRemoved(event); } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1683,7 +1683,7 @@ } } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1728,7 +1728,7 @@ } } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1738,7 +1738,10 @@ if (event.itemsSize() == 0) { return; } - // TODO check that the items are actually different... + // TODO check that the items are actually different... ? +// if (this.elementsAreEqual(event.items(), event.replacedItems())) { +// return; +// } String listName = event.getListName(); @@ -1768,7 +1771,7 @@ child.fireItemsReplaced(event); } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1779,7 +1782,10 @@ if (newItems.isEmpty()) { return; } - // TODO check that the items are actually different... + // TODO check that the items are actually different... ? +// if (newItems.equals(replacedItems)) { +// return; +// } ListChangeListener[] targets = null; ChangeSupport child = null; @@ -1817,7 +1823,7 @@ } } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1825,7 +1831,10 @@ */ public void fireItemReplaced(String listName, int index, Object newItem, Object replacedItem) { // this.fireItemsReplaced(listName, index, Collections.singletonList(newItem), Collections.singletonList(replacedItem)); - // TODO check that the item is actually different... + // TODO check that the item is actually different... ? +// if (this.valuesAreEqual(newItem, replacedItem)) { +// return; +// } ListChangeListener[] targets = null; ChangeSupport child = null; @@ -1863,7 +1872,7 @@ } } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1873,6 +1882,7 @@ if (event.getTargetIndex() == event.getSourceIndex()) { return; } + // it's unlikely but possible the list is unchanged by the move... (e.g. any moves within ["foo", "foo", "foo"]...) String listName = event.getListName(); @@ -1902,7 +1912,7 @@ child.fireItemsMoved(event); } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1913,6 +1923,7 @@ if (targetIndex == sourceIndex) { return; } + // it's unlikely but possible the list is unchanged by the move... (e.g. any moves within ["foo", "foo", "foo"]...) ListChangeListener[] targets = null; ChangeSupport child = null; @@ -1950,7 +1961,7 @@ } } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -1992,7 +2003,7 @@ child.fireListCleared(event); } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -2037,7 +2048,7 @@ } } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -2072,7 +2083,7 @@ child.fireListChanged(event); } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -2117,7 +2128,7 @@ } } - this.sourceChanged(listName); + this.aspectChanged(listName); } /** @@ -2472,7 +2483,8 @@ } /** - * Replace the specified item in the specified bound list + * Replace the first occurrence of the specified item + * in the specified bound list * and fire the appropriate event if necessary. * Return the index of the replaced item. * Return -1 if the item was not found in the list. @@ -2734,7 +2746,7 @@ child.fireNodeAdded(event); } - this.sourceChanged(treeName); + this.aspectChanged(treeName); } /** @@ -2779,7 +2791,7 @@ } } - this.sourceChanged(treeName); + this.aspectChanged(treeName); } /** @@ -2814,7 +2826,7 @@ child.fireNodeRemoved(event); } - this.sourceChanged(treeName); + this.aspectChanged(treeName); } /** @@ -2859,7 +2871,7 @@ } } - this.sourceChanged(treeName); + this.aspectChanged(treeName); } /** @@ -2894,7 +2906,7 @@ child.fireTreeCleared(event); } - this.sourceChanged(treeName); + this.aspectChanged(treeName); } /** @@ -2939,7 +2951,7 @@ } } - this.sourceChanged(treeName); + this.aspectChanged(treeName); } /** @@ -2981,7 +2993,7 @@ child.fireTreeChanged(event); } - this.sourceChanged(treeName); + this.aspectChanged(treeName); } /** @@ -3026,7 +3038,7 @@ } } - this.sourceChanged(treeName); + this.aspectChanged(treeName); } /** @@ -3040,7 +3052,7 @@ // ********** convenience methods ********** /** - * Return whether the values are equal, with the appropriate null checks. + * Return whether the specified values are equal, with the appropriate null checks. * Convenience method for checking whether an attribute value has changed. */ public boolean valuesAreEqual(Object value1, Object value2) { @@ -3054,13 +3066,34 @@ } /** - * Return whether the values are different, with the appropriate null checks. + * Return whether the specified values are different, with the appropriate null checks. * Convenience method for checking whether an attribute value has changed. */ public boolean valuesAreDifferent(Object value1, Object value2) { return ! this.valuesAreEqual(value1, value2); } + /** + * Return whether the specified iterators return the same elements + * in the same order. + */ + public boolean elementsAreEqual(Iterator iterator1, Iterator iterator2) { + while (iterator1.hasNext() && iterator2.hasNext()) { + if (this.valuesAreDifferent(iterator1.next(), iterator2.next())) { + return false; + } + } + return ( ! iterator1.hasNext()) && ( ! iterator2.hasNext()); + } + + /** + * Return whether the specified iterators do not return the same elements + * in the same order. + */ + public boolean elementsAreDifferent(Iterator iterator1, Iterator iterator2) { + return ! this.elementsAreEqual(iterator1, iterator2); + } + // ********** standard methods ********** @@ -3209,7 +3242,7 @@ } @Override - protected ChangeSupport buildChildChangeSupport() { + protected ChangeSupport buildChild() { // there should be no grandchildren throw new UnsupportedOperationException(); } Index: src/org/eclipse/jpt/utility/internal/model/CallbackChangeSupport.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/CallbackChangeSupport.java,v retrieving revision 1.3 diff -u -r1.3 CallbackChangeSupport.java --- src/org/eclipse/jpt/utility/internal/model/CallbackChangeSupport.java 10 Mar 2009 04:12:01 -0000 1.3 +++ src/org/eclipse/jpt/utility/internal/model/CallbackChangeSupport.java 6 Apr 2009 20:59:01 -0000 @@ -41,8 +41,8 @@ } @Override - protected void sourceChanged(String aspectName) { - super.sourceChanged(aspectName); + protected void aspectChanged(String aspectName) { + super.aspectChanged(aspectName); for (Listener listener : this.listenerList.getListeners()) { listener.aspectChanged(aspectName); } Index: src/org/eclipse/jpt/utility/internal/iterables/LiveCloneIterable.java =================================================================== RCS file: src/org/eclipse/jpt/utility/internal/iterables/LiveCloneIterable.java diff -N src/org/eclipse/jpt/utility/internal/iterables/LiveCloneIterable.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/utility/internal/iterables/LiveCloneIterable.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,76 @@ +/******************************************************************************* + * 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.utility.internal.iterables; + +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.jpt.utility.internal.StringTools; +import org.eclipse.jpt.utility.internal.iterators.CloneIterator; + +/** + * A LiveCloneIterable returns an iterator on a current copy of a + * collection, allowing for concurrent access to the original collection. A + * copy of the collection is created every time #iterable() is + * called. As a result, the contents of the collection can be different with + * each call to #iterable(). + *

+ * The original collection passed to the LiveCloneIterabler's + * constructor should be synchronized (e.g. java.util.Vector); + * otherwise you run the risk of a corrupted collection. + *

+ * By default, the iterator returned by a LiveCloneIterable does not + * support the #remove() operation; this is because it does not + * have access to the original collection. But if the LiveCloneIterable + * is supplied with an CloneIterator.Mutator it will delegate the + * #remove() operation to the Mutator. + */ +public class LiveCloneIterable + implements Iterable +{ + private final Collection collection; + private final CloneIterator.Mutator mutator; + + + // ********** constructors ********** + + /** + * Construct a live iterable for the specified collection. + * The #remove() method will not be supported + * by the Iterator returned by #iterable(). + */ + public LiveCloneIterable(Collection collection) { + this(collection, CloneIterator.Mutator.ReadOnly.instance()); + } + + /** + * Construct a live iterable for the specified collection. + * Use the specified mutator to remove objects from the + * original collection. + */ + public LiveCloneIterable(Collection collection, CloneIterator.Mutator mutator) { + super(); + this.collection = collection; + this.mutator = mutator; + } + + + // ********** Iterable implementation ********** + + public Iterator iterator() { + return new CloneIterator(this.collection, this.mutator); + } + + @Override + public String toString() { + return StringTools.buildToStringFor(this); + } + +} Index: src/org/eclipse/jpt/utility/internal/iterables/CloneIterable.java =================================================================== RCS file: src/org/eclipse/jpt/utility/internal/iterables/CloneIterable.java diff -N src/org/eclipse/jpt/utility/internal/iterables/CloneIterable.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/utility/internal/iterables/CloneIterable.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,88 @@ +/******************************************************************************* + * 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.utility.internal.iterables; + +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.jpt.utility.internal.StringTools; +import org.eclipse.jpt.utility.internal.iterators.CloneIterator; + +/** + * A CloneIterable returns an iterator on a static copy of a + * collection, allowing for concurrent access to the original collection. A + * copy of the collection is created at construction time. + * As a result, the contents of the collection will be the same with + * every call to #iterable(). + *

+ * The original collection passed to the CloneIterabler's + * constructor should be synchronized (e.g. java.util.Vector); + * otherwise you run the risk of a corrupted collection. + *

+ * By default, the iterator returned by a CloneIterable does not + * support the #remove() operation; this is because it does not + * have access to the original collection. But if the CloneIterable + * is supplied with an CloneIterator.Mutator it will delegate the + * #remove() operation to the Mutator. + */ +public class CloneIterable + implements Iterable +{ + private final Object[] array; + private final CloneIterator.Mutator mutator; + + + // ********** constructors ********** + + /** + * Construct a static iterable for the specified collection. + * The #remove() method will not be supported + * by the Iterator returned by #iterable(). + */ + public CloneIterable(Collection collection) { + this(collection, CloneIterator.Mutator.ReadOnly.instance()); + } + + /** + * Construct a static iterable for the specified collection. + * Use the specified mutator to remove objects from the + * original collection. + */ + public CloneIterable(Collection collection, CloneIterator.Mutator mutator) { + super(); + this.array = collection.toArray(); + this.mutator = mutator; + } + + + // ********** Iterable implementation ********** + + public Iterator iterator() { + return new LocalCloneIterator(this.array, this.mutator); + } + + @Override + public String toString() { + return StringTools.buildToStringFor(this); + } + + + // ********** clone iterator ********** + + /** + * provide access to "internal" constructor + */ + protected static class LocalCloneIterator extends CloneIterator { + protected LocalCloneIterator(Object[] array, Mutator mutator) { + super(array, mutator); + } + } + +} #P org.eclipse.jpt.core.tests Index: src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java,v retrieving revision 1.15 diff -u -r1.15 NamedNativeQueriesTests.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java 3 Mar 2009 21:56:21 -0000 1.15 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueriesTests.java 6 Apr 2009 20:59:06 -0000 @@ -210,11 +210,11 @@ NamedNativeQueriesAnnotation namedQueries = (NamedNativeQueriesAnnotation) typeResource.getSupportingAnnotation(JPA.NAMED_NATIVE_QUERIES); NamedNativeQueryAnnotation namedQuery = namedQueries.nestedAnnotations().next(); assertNotNull(namedQuery.getResultClass()); - assertEquals("Result", namedQuery.getFullyQualifiedResultClass());//bug 196200 changed this + assertEquals("Result", namedQuery.getFullyQualifiedResultClassName());//bug 196200 changed this namedQuery.setResultClass(TYPE_NAME); - assertEquals(FULLY_QUALIFIED_TYPE_NAME, namedQuery.getFullyQualifiedResultClass()); + assertEquals(FULLY_QUALIFIED_TYPE_NAME, namedQuery.getFullyQualifiedResultClassName()); assertSourceContains("@NamedNativeQuery(resultClass = " + TYPE_NAME + ".class)", cu); } Index: src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java,v retrieving revision 1.10 diff -u -r1.10 JavaResourcePersistentTypeTests.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java 10 Mar 2009 04:11:50 -0000 1.10 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentTypeTests.java 6 Apr 2009 20:59:05 -0000 @@ -13,8 +13,8 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.EmbeddableImpl; -import org.eclipse.jpt.core.internal.resource.java.EntityImpl; +import org.eclipse.jpt.core.internal.resource.java.source.SourceEmbeddableAnnotation; +import org.eclipse.jpt.core.internal.resource.java.source.SourceEntityAnnotation; import org.eclipse.jpt.core.resource.java.AccessType; import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation; import org.eclipse.jpt.core.resource.java.EntityAnnotation; @@ -554,7 +554,7 @@ testType(cu).edit(new Editor() { public void edit(ModifiedDeclaration declaration) { - EntityImpl.DECLARATION_ANNOTATION_ADAPTER.removeAnnotation(declaration); + SourceEntityAnnotation.DECLARATION_ANNOTATION_ADAPTER.removeAnnotation(declaration); } }); @@ -562,7 +562,7 @@ this.testType(cu).edit(new Editor() { public void edit(ModifiedDeclaration declaration) { - EmbeddableImpl.DECLARATION_ANNOTATION_ADAPTER.newMarkerAnnotation(declaration); + SourceEmbeddableAnnotation.DECLARATION_ANNOTATION_ADAPTER.newMarkerAnnotation(declaration); } }); Index: src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java,v retrieving revision 1.22 diff -u -r1.22 JavaResourceModelTestCase.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java 16 Jan 2009 14:30:55 -0000 1.22 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourceModelTestCase.java 6 Apr 2009 20:59:04 -0000 @@ -18,7 +18,7 @@ import org.eclipse.jpt.core.JpaAnnotationProvider; import org.eclipse.jpt.core.internal.platform.GenericJpaAnnotationDefinitionProvider; import org.eclipse.jpt.core.internal.platform.GenericJpaAnnotationProvider; -import org.eclipse.jpt.core.internal.resource.java.JavaResourceCompilationUnitImpl; +import org.eclipse.jpt.core.internal.resource.java.source.SourceCompilationUnit; import org.eclipse.jpt.core.internal.utility.jdt.NullAnnotationEditFormatter; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; @@ -147,7 +147,7 @@ if (this.javaResourceCompilationUnit != null) { throw new IllegalStateException(); } - return new JavaResourceCompilationUnitImpl( + return new SourceCompilationUnit( cu, this.buildAnnotationProvider(), NullAnnotationEditFormatter.instance(), Index: src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java,v retrieving revision 1.11 diff -u -r1.11 OneToManyTests.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java 3 Mar 2009 21:56:22 -0000 1.11 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/OneToManyTests.java 6 Apr 2009 20:59:06 -0000 @@ -207,7 +207,7 @@ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToManyAnnotation oneToMany = (OneToManyAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_MANY); - assertEquals(FULLY_QUALIFIED_TYPE_NAME, oneToMany.getFullyQualifiedTargetEntity()); + assertEquals(FULLY_QUALIFIED_TYPE_NAME, oneToMany.getFullyQualifiedTargetEntityClassName()); oneToMany.setTargetEntity("Foo"); @@ -215,7 +215,7 @@ assertEquals("Foo", oneToMany.getTargetEntity()); - assertEquals("Foo", oneToMany.getFullyQualifiedTargetEntity()); //bug 196200 changed this + assertEquals("Foo", oneToMany.getFullyQualifiedTargetEntityClassName()); //bug 196200 changed this } public void testGetMappedBy() throws Exception { Index: src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java,v retrieving revision 1.13 diff -u -r1.13 SecondaryTablesTests.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java 3 Mar 2009 21:56:21 -0000 1.13 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/SecondaryTablesTests.java 6 Apr 2009 20:59:06 -0000 @@ -134,7 +134,7 @@ SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); assertNotNull(secondaryTables); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertEquals(TABLE_NAME, secondaryTable.getName()); } @@ -143,7 +143,7 @@ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertNull(secondaryTable.getName()); assertNull(secondaryTable.getCatalog()); assertNull(secondaryTable.getSchema()); @@ -154,7 +154,7 @@ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertNull(secondaryTable.getName()); @@ -169,7 +169,7 @@ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertEquals(TABLE_NAME, secondaryTable.getName()); secondaryTable.setName(null); @@ -183,7 +183,7 @@ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertEquals(CATALOG_NAME, secondaryTable.getCatalog()); } @@ -192,7 +192,7 @@ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertNull(secondaryTable.getCatalog()); secondaryTable.setCatalog("Foo"); @@ -206,7 +206,7 @@ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertEquals(CATALOG_NAME, secondaryTable.getCatalog()); secondaryTable.setCatalog(null); @@ -220,7 +220,7 @@ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertNotNull(secondaryTable); assertEquals(SCHEMA_NAME, secondaryTable.getSchema()); } @@ -230,7 +230,7 @@ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertNull(secondaryTable.getSchema()); secondaryTable.setSchema("Foo"); @@ -244,7 +244,7 @@ JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertEquals(SCHEMA_NAME, secondaryTable.getSchema()); secondaryTable.setSchema(null); @@ -258,7 +258,7 @@ ICompilationUnit cu = this.createTestSecondaryTables(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertEquals(0, secondaryTable.uniqueConstraintsSize()); } @@ -267,7 +267,7 @@ ICompilationUnit cu = this.createTestSecondaryTables(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); secondaryTable.addUniqueConstraint(0); secondaryTable.addUniqueConstraint(1); @@ -279,7 +279,7 @@ ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); assertEquals(2, secondaryTable.uniqueConstraintsSize()); } @@ -288,7 +288,7 @@ ICompilationUnit cu = this.createTestSecondaryTables(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); secondaryTable.addUniqueConstraint(0).addColumnName("FOO"); secondaryTable.addUniqueConstraint(1); @@ -305,7 +305,7 @@ ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); secondaryTable.addUniqueConstraint(0).addColumnName("FOO"); secondaryTable.removeUniqueConstraint(2); @@ -322,7 +322,7 @@ ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); secondaryTable.addUniqueConstraint(0).addColumnName("FOO"); assertEquals("FOO", secondaryTable.uniqueConstraintAt(0).columnNames().next()); @@ -340,7 +340,7 @@ ICompilationUnit cu = this.createTestSecondaryTableWithUniqueConstraints(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); SecondaryTablesAnnotation secondaryTables = (SecondaryTablesAnnotation) typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES); - SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotationAt(0); + SecondaryTableAnnotation secondaryTable = secondaryTables.nestedAnnotations().next(); secondaryTable.addUniqueConstraint(0).addColumnName("FOO"); assertEquals("FOO", secondaryTable.uniqueConstraintAt(0).columnNames().next()); @@ -363,7 +363,7 @@ SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addSupportingAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable.setName("BAR"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name = \"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames = \"BAR\")),@SecondaryTable(name = \"BAR\")})", cu); + assertSourceContains("@SecondaryTables({@SecondaryTable(name = \"FOO\", schema = \"BAZ\", catalog = \"BAR\", uniqueConstraints = @UniqueConstraint(columnNames = \"BAR\")),@SecondaryTable(name = \"BAR\")})", cu); assertNull(typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLE)); assertNotNull(typeResource.getSupportingAnnotation(JPA.SECONDARY_TABLES)); @@ -376,11 +376,11 @@ SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addSupportingAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable.setName("BAR"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name = \"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames = \"BAR\")),@SecondaryTable(name = \"BAR\")})", cu); + assertSourceContains("@SecondaryTables({@SecondaryTable(name = \"FOO\", schema = \"BAZ\", catalog = \"BAR\", uniqueConstraints = @UniqueConstraint(columnNames = \"BAR\")),@SecondaryTable(name = \"BAR\")})", cu); secondaryTable = (SecondaryTableAnnotation) typeResource.addSupportingAnnotation(0, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable.setName("BAZ"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name = \"BAZ\"),@SecondaryTable(name = \"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames = \"BAR\")), @SecondaryTable(name = \"BAR\")})", cu); + assertSourceContains("@SecondaryTables({@SecondaryTable(name = \"BAZ\"),@SecondaryTable(name = \"FOO\", schema = \"BAZ\", catalog = \"BAR\", uniqueConstraints = @UniqueConstraint(columnNames = \"BAR\")), @SecondaryTable(name = \"BAR\")})", cu); Iterator secondaryTables = typeResource.supportingAnnotations(JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); assertEquals("BAZ", ((SecondaryTableAnnotation) secondaryTables.next()).getName()); @@ -398,10 +398,10 @@ SecondaryTableAnnotation secondaryTable = (SecondaryTableAnnotation) typeResource.addSupportingAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); secondaryTable.setName("BAR"); - assertSourceContains("@SecondaryTables({@SecondaryTable(name = \"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames = \"BAR\")),@SecondaryTable(name = \"BAR\")})", cu); + assertSourceContains("@SecondaryTables({@SecondaryTable(name = \"FOO\", schema = \"BAZ\", catalog = \"BAR\", uniqueConstraints = @UniqueConstraint(columnNames = \"BAR\")),@SecondaryTable(name = \"BAR\")})", cu); typeResource.removeSupportingAnnotation(1, JPA.SECONDARY_TABLE, JPA.SECONDARY_TABLES); - assertSourceContains("@SecondaryTable(name = \"FOO\", catalog = \"BAR\", schema = \"BAZ\", uniqueConstraints = @UniqueConstraint(columnNames = \"BAR\"))", cu); + assertSourceContains("@SecondaryTable(name = \"FOO\", schema = \"BAZ\", catalog = \"BAR\", uniqueConstraints = @UniqueConstraint(columnNames = \"BAR\"))", cu); } Index: src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java,v retrieving revision 1.13 diff -u -r1.13 JavaResourcePersistentAttributeTests.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java 10 Mar 2009 04:11:50 -0000 1.13 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/JavaResourcePersistentAttributeTests.java 6 Apr 2009 20:59:04 -0000 @@ -14,8 +14,8 @@ import java.util.List; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.IdImpl; -import org.eclipse.jpt.core.internal.resource.java.OneToOneImpl; +import org.eclipse.jpt.core.internal.resource.java.source.SourceIdAnnotation; +import org.eclipse.jpt.core.internal.resource.java.source.SourceOneToOneAnnotation; import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; import org.eclipse.jpt.core.resource.java.BasicAnnotation; import org.eclipse.jpt.core.resource.java.ColumnAnnotation; @@ -500,7 +500,7 @@ idField(cu).edit(new Editor() { public void edit(ModifiedDeclaration declaration) { - IdImpl.DECLARATION_ANNOTATION_ADAPTER.removeAnnotation(declaration); + SourceIdAnnotation.DECLARATION_ANNOTATION_ADAPTER.removeAnnotation(declaration); } }); @@ -508,7 +508,7 @@ idField(cu).edit(new Editor() { public void edit(ModifiedDeclaration declaration) { - OneToOneImpl.DECLARATION_ANNOTATION_ADAPTER.newMarkerAnnotation(declaration); + SourceOneToOneAnnotation.DECLARATION_ANNOTATION_ADAPTER.newMarkerAnnotation(declaration); } }); Index: src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java,v retrieving revision 1.11 diff -u -r1.11 ManyToOneTests.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java 3 Mar 2009 21:56:22 -0000 1.11 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToOneTests.java 6 Apr 2009 20:59:05 -0000 @@ -207,7 +207,7 @@ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToOneAnnotation manyToOne = (ManyToOneAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_ONE); - assertEquals(FULLY_QUALIFIED_TYPE_NAME, manyToOne.getFullyQualifiedTargetEntity()); + assertEquals(FULLY_QUALIFIED_TYPE_NAME, manyToOne.getFullyQualifiedTargetEntityClassName()); manyToOne.setTargetEntity("Foo"); @@ -215,7 +215,7 @@ assertEquals("Foo", manyToOne.getTargetEntity()); - assertEquals("Foo", manyToOne.getFullyQualifiedTargetEntity());//bug 196200 changed this + assertEquals("Foo", manyToOne.getFullyQualifiedTargetEntityClassName());//bug 196200 changed this } public void testGetOptional() throws Exception { Index: src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java,v retrieving revision 1.12 diff -u -r1.12 NamedNativeQueryTests.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java 3 Mar 2009 21:56:22 -0000 1.12 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/NamedNativeQueryTests.java 6 Apr 2009 20:59:06 -0000 @@ -185,11 +185,11 @@ NamedNativeQueryAnnotation namedQuery = (NamedNativeQueryAnnotation) typeResource.getSupportingAnnotation(JPA.NAMED_NATIVE_QUERY); assertNotNull(namedQuery.getResultClass()); - assertEquals("Result", namedQuery.getFullyQualifiedResultClass());//bug 196200 changed this + assertEquals("Result", namedQuery.getFullyQualifiedResultClassName());//bug 196200 changed this namedQuery.setResultClass(TYPE_NAME); - assertEquals(FULLY_QUALIFIED_TYPE_NAME, namedQuery.getFullyQualifiedResultClass()); + assertEquals(FULLY_QUALIFIED_TYPE_NAME, namedQuery.getFullyQualifiedResultClassName()); assertSourceContains("@NamedNativeQuery(resultClass = " + TYPE_NAME + ".class)", cu); } Index: src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java,v retrieving revision 1.12 diff -u -r1.12 IdClassTests.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java 3 Mar 2009 21:56:21 -0000 1.12 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/IdClassTests.java 6 Apr 2009 20:59:04 -0000 @@ -94,12 +94,12 @@ IdClassAnnotation idClass = (IdClassAnnotation) typeResource.getSupportingAnnotation(JPA.ID_CLASS); assertNotNull(idClass.getValue()); - assertEquals("MyClass", idClass.getFullyQualifiedClass()); //bug 196200 changed this + assertEquals("MyClass", idClass.getFullyQualifiedClassName()); //bug 196200 changed this idClass.setValue(TYPE_NAME); - assertEquals(FULLY_QUALIFIED_TYPE_NAME, idClass.getFullyQualifiedClass()); + assertEquals(FULLY_QUALIFIED_TYPE_NAME, idClass.getFullyQualifiedClassName()); assertSourceContains("@IdClass(" + TYPE_NAME + ".class)", cu); } Index: src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java,v retrieving revision 1.11 diff -u -r1.11 OneToOneTests.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java 3 Mar 2009 21:56:22 -0000 1.11 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/OneToOneTests.java 6 Apr 2009 20:59:06 -0000 @@ -220,7 +220,7 @@ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); OneToOneAnnotation oneToOne = (OneToOneAnnotation) attributeResource.getMappingAnnotation(JPA.ONE_TO_ONE); - assertEquals(FULLY_QUALIFIED_TYPE_NAME, oneToOne.getFullyQualifiedTargetEntity()); + assertEquals(FULLY_QUALIFIED_TYPE_NAME, oneToOne.getFullyQualifiedTargetEntityClassName()); oneToOne.setTargetEntity("Foo"); @@ -228,7 +228,7 @@ assertEquals("Foo", oneToOne.getTargetEntity()); - assertEquals("Foo", oneToOne.getFullyQualifiedTargetEntity()); //bug 196200 changed this + assertEquals("Foo", oneToOne.getFullyQualifiedTargetEntityClassName()); //bug 196200 changed this } public void testGetOptional() throws Exception { Index: src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java,v retrieving revision 1.11 diff -u -r1.11 ManyToManyTests.java --- src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java 3 Mar 2009 21:56:22 -0000 1.11 +++ src/org/eclipse/jpt/core/tests/internal/resource/java/ManyToManyTests.java 6 Apr 2009 20:59:05 -0000 @@ -206,7 +206,7 @@ JavaResourcePersistentAttribute attributeResource = typeResource.fields().next(); ManyToManyAnnotation manyToMany = (ManyToManyAnnotation) attributeResource.getMappingAnnotation(JPA.MANY_TO_MANY); - assertEquals(FULLY_QUALIFIED_TYPE_NAME, manyToMany.getFullyQualifiedTargetEntity()); + assertEquals(FULLY_QUALIFIED_TYPE_NAME, manyToMany.getFullyQualifiedTargetEntityClassName()); manyToMany.setTargetEntity("Foo"); @@ -214,7 +214,7 @@ assertEquals("Foo", manyToMany.getTargetEntity()); - assertEquals("Foo", manyToMany.getFullyQualifiedTargetEntity()); //bug 196200 changed this + assertEquals("Foo", manyToMany.getFullyQualifiedTargetEntityClassName()); //bug 196200 changed this } public void testGetMappedBy() throws Exception { #P org.eclipse.jpt.utility.tests Index: src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java,v retrieving revision 1.5 diff -u -r1.5 NewEventTests.java --- src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java 10 Mar 2009 04:11:53 -0000 1.5 +++ src/org/eclipse/jpt/utility/tests/internal/model/NewEventTests.java 6 Apr 2009 20:59:08 -0000 @@ -180,7 +180,7 @@ } } } - this.sourceChanged(null); + this.aspectChanged(null); } } Index: src/org/eclipse/jpt/utility/tests/internal/model/AbstractModelTests.java =================================================================== RCS file: src/org/eclipse/jpt/utility/tests/internal/model/AbstractModelTests.java diff -N src/org/eclipse/jpt/utility/tests/internal/model/AbstractModelTests.java --- src/org/eclipse/jpt/utility/tests/internal/model/AbstractModelTests.java 9 Sep 2008 16:50:18 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,1721 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.utility.tests.internal.model; - -import java.io.Serializable; -import java.util.Arrays; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.ClassTools; -import org.eclipse.jpt.utility.internal.model.AbstractModel; -import org.eclipse.jpt.utility.internal.model.ChangeSupport; -import org.eclipse.jpt.utility.model.event.CollectionChangeEvent; -import org.eclipse.jpt.utility.model.event.ListChangeEvent; -import org.eclipse.jpt.utility.model.event.PropertyChangeEvent; -import org.eclipse.jpt.utility.model.event.StateChangeEvent; -import org.eclipse.jpt.utility.model.event.TreeChangeEvent; -import org.eclipse.jpt.utility.model.listener.ChangeListener; -import org.eclipse.jpt.utility.model.listener.CollectionChangeListener; -import org.eclipse.jpt.utility.model.listener.ListChangeAdapter; -import org.eclipse.jpt.utility.model.listener.ListChangeListener; -import org.eclipse.jpt.utility.model.listener.PropertyChangeListener; -import org.eclipse.jpt.utility.model.listener.StateChangeListener; -import org.eclipse.jpt.utility.model.listener.TreeChangeListener; -import org.eclipse.jpt.utility.tests.internal.TestTools; - -@SuppressWarnings("nls") -public class AbstractModelTests - extends TestCase - implements StateChangeListener, PropertyChangeListener, CollectionChangeListener, ListChangeListener, TreeChangeListener -{ - private TestModel testModel; - private static final String TEST_TO_STRING = "this is a test"; - - private StateChangeEvent stateChangeEvent; - private boolean stateChangedCalled = false; - - private PropertyChangeEvent propertyChangeEvent; - private boolean propertyChangeCalled = false; - private static final String PROPERTY_NAME = "propertyName"; - static final Object OLD_OBJECT_VALUE = new Object(); - static final Object NEW_OBJECT_VALUE = new Object(); - static final Integer OLD_INT_VALUE = new Integer(27); - static final Integer NEW_INT_VALUE = new Integer(42); - static final Boolean OLD_BOOLEAN_VALUE = Boolean.TRUE; - static final Boolean NEW_BOOLEAN_VALUE = Boolean.FALSE; - - private CollectionChangeEvent collectionChangeEvent; - private boolean itemsAddedCollectionCalled = false; - private boolean itemsRemovedCollectionCalled = false; - private boolean collectionChangedCalled = false; - private boolean collectionClearedCalled = false; - private static final String COLLECTION_NAME = "collectionName"; - static final Object ADDED_OBJECT_VALUE = new Object(); - static final Object REMOVED_OBJECT_VALUE = new Object(); - static final int TARGET_INDEX = 7; - static final int SOURCE_INDEX = 22; - - private ListChangeEvent listChangeEvent; - private boolean itemsAddedListCalled = false; - private boolean itemsRemovedListCalled = false; - private boolean itemsReplacedListCalled = false; - private boolean itemsMovedListCalled = false; - private boolean listChangedCalled = false; - private boolean listClearedCalled = false; - private static final String LIST_NAME = "listName"; - private static final int ADD_INDEX = 3; - private static final int REMOVE_INDEX = 5; - private static final int REPLACE_INDEX = 2; - - private TreeChangeEvent treeChangeEvent; - private boolean nodeAddedCalled = false; - private boolean nodeRemovedCalled = false; - private boolean treeChangedCalled = false; - private boolean treeClearedCalled = false; - private static final String TREE_NAME = "treeName"; - static final Object[] OBJECT_ARRAY_PATH = {new Object(), new Object(), new String()}; - static final Object[] EMPTY_PATH = {}; - - public AbstractModelTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - this.testModel = new TestModel(); - } - - @Override - protected void tearDown() throws Exception { - TestTools.clear(this); - super.tearDown(); - } - - public void testFireStateChange() { - this.stateChangeEvent = null; - this.stateChangedCalled = false; - this.testModel.addStateChangeListener(this); - this.testModel.testFireStateChange(); - assertNotNull(this.stateChangeEvent); - assertEquals(this.testModel, this.stateChangeEvent.getSource()); - assertTrue(this.stateChangedCalled); - } - - public void testFirePropertyChangeObjectObject() { - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.addPropertyChangeListener(this); - this.testModel.testFirePropertyChangeObjectObject(); - this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); - assertTrue(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.removePropertyChangeListener(this); - this.testModel.testFirePropertyChangeObjectObject(); - assertNull(this.propertyChangeEvent); - assertFalse(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); - this.testModel.testFirePropertyChangeObjectObject(); - this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); - assertTrue(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); - this.testModel.testFirePropertyChangeObjectObject(); - assertNull(this.propertyChangeEvent); - assertFalse(this.propertyChangeCalled); - } - - public void testFirePropertyChangeObject() { - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.addPropertyChangeListener(this); - this.testModel.testFirePropertyChangeObject(); - this.verifyPropertyChangeEvent(null, NEW_OBJECT_VALUE); - assertTrue(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.removePropertyChangeListener(this); - this.testModel.testFirePropertyChangeObject(); - assertNull(this.propertyChangeEvent); - assertFalse(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); - this.testModel.testFirePropertyChangeObject(); - this.verifyPropertyChangeEvent(null, NEW_OBJECT_VALUE); - assertTrue(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); - this.testModel.testFirePropertyChangeObject(); - assertNull(this.propertyChangeEvent); - assertFalse(this.propertyChangeCalled); - } - - public void testFirePropertyChangeIntInt() { - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.addPropertyChangeListener(this); - this.testModel.testFirePropertyChangeIntInt(); - this.verifyPropertyChangeEvent(OLD_INT_VALUE, NEW_INT_VALUE); - assertTrue(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.removePropertyChangeListener(this); - this.testModel.testFirePropertyChangeIntInt(); - assertNull(this.propertyChangeEvent); - assertFalse(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); - this.testModel.testFirePropertyChangeIntInt(); - this.verifyPropertyChangeEvent(OLD_INT_VALUE, NEW_INT_VALUE); - assertTrue(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); - this.testModel.testFirePropertyChangeIntInt(); - assertNull(this.propertyChangeEvent); - assertFalse(this.propertyChangeCalled); - } - - public void testFirePropertyChangeBooleanBoolean() { - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.addPropertyChangeListener(this); - this.testModel.testFirePropertyChangeBooleanBoolean(); - this.verifyPropertyChangeEvent(OLD_BOOLEAN_VALUE, NEW_BOOLEAN_VALUE); - assertTrue(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.removePropertyChangeListener(this); - this.testModel.testFirePropertyChangeBooleanBoolean(); - assertNull(this.propertyChangeEvent); - assertFalse(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); - this.testModel.testFirePropertyChangeBooleanBoolean(); - this.verifyPropertyChangeEvent(OLD_BOOLEAN_VALUE, NEW_BOOLEAN_VALUE); - assertTrue(this.propertyChangeCalled); - - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); - this.testModel.testFirePropertyChangeBooleanBoolean(); - assertNull(this.propertyChangeEvent); - assertFalse(this.propertyChangeCalled); - } - - public void testFireItemAddedCollection() { - this.collectionChangeEvent = null; - this.itemsAddedCollectionCalled = false; - this.testModel.addCollectionChangeListener(this); - this.testModel.testFireItemAddedCollection(); - this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); - assertTrue(this.itemsAddedCollectionCalled); - - this.collectionChangeEvent = null; - this.itemsAddedCollectionCalled = false; - this.testModel.removeCollectionChangeListener(this); - this.testModel.testFireItemAddedCollection(); - assertNull(this.collectionChangeEvent); - assertFalse(this.itemsAddedCollectionCalled); - - this.collectionChangeEvent = null; - this.itemsAddedCollectionCalled = false; - this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); - this.testModel.testFireItemAddedCollection(); - this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); - assertTrue(this.itemsAddedCollectionCalled); - - this.collectionChangeEvent = null; - this.itemsAddedCollectionCalled = false; - this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); - this.testModel.testFireItemAddedCollection(); - assertNull(this.collectionChangeEvent); - assertFalse(this.itemsAddedCollectionCalled); - } - - public void testFireItemRemovedCollection() { - this.collectionChangeEvent = null; - this.itemsRemovedCollectionCalled = false; - this.testModel.addCollectionChangeListener(this); - this.testModel.testFireItemRemovedCollection(); - this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); - assertTrue(this.itemsRemovedCollectionCalled); - - this.collectionChangeEvent = null; - this.itemsRemovedCollectionCalled = false; - this.testModel.removeCollectionChangeListener(this); - this.testModel.testFireItemRemovedCollection(); - assertNull(this.collectionChangeEvent); - assertFalse(this.itemsRemovedCollectionCalled); - - this.collectionChangeEvent = null; - this.itemsRemovedCollectionCalled = false; - this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); - this.testModel.testFireItemRemovedCollection(); - this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); - assertTrue(this.itemsRemovedCollectionCalled); - - this.collectionChangeEvent = null; - this.itemsRemovedCollectionCalled = false; - this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); - this.testModel.testFireItemRemovedCollection(); - assertNull(this.collectionChangeEvent); - assertFalse(this.itemsRemovedCollectionCalled); - } - - public void testFireCollectionCleared() { - this.collectionChangeEvent = null; - this.collectionClearedCalled = false; - this.testModel.addCollectionChangeListener(this); - this.testModel.testFireCollectionCleared(); - this.verifyCollectionChangeEvent(null); - assertTrue(this.collectionClearedCalled); - - this.collectionChangeEvent = null; - this.collectionClearedCalled = false; - this.testModel.removeCollectionChangeListener(this); - this.testModel.testFireCollectionCleared(); - assertNull(this.collectionChangeEvent); - assertFalse(this.collectionClearedCalled); - - this.collectionChangeEvent = null; - this.collectionClearedCalled = false; - this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); - this.testModel.testFireCollectionCleared(); - this.verifyCollectionChangeEvent(null); - assertTrue(this.collectionClearedCalled); - - this.collectionChangeEvent = null; - this.collectionClearedCalled = false; - this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); - this.testModel.testFireCollectionCleared(); - assertNull(this.collectionChangeEvent); - assertFalse(this.collectionClearedCalled); - } - - public void testFireCollectionChanged() { - this.collectionChangeEvent = null; - this.collectionChangedCalled = false; - this.testModel.addCollectionChangeListener(this); - this.testModel.testFireCollectionChanged(); - this.verifyCollectionChangeEvent(null); - assertTrue(this.collectionChangedCalled); - - this.collectionChangeEvent = null; - this.collectionChangedCalled = false; - this.testModel.removeCollectionChangeListener(this); - this.testModel.testFireCollectionChanged(); - assertNull(this.collectionChangeEvent); - assertFalse(this.collectionChangedCalled); - - this.collectionChangeEvent = null; - this.collectionChangedCalled = false; - this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); - this.testModel.testFireCollectionChanged(); - this.verifyCollectionChangeEvent(null); - assertTrue(this.collectionChangedCalled); - - this.collectionChangeEvent = null; - this.collectionChangedCalled = false; - this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); - this.testModel.testFireCollectionChanged(); - assertNull(this.collectionChangeEvent); - assertFalse(this.collectionChangedCalled); - } - - public void testFireItemAddedList() { - this.listChangeEvent = null; - this.itemsAddedListCalled = false; - this.testModel.addListChangeListener(this); - this.testModel.testFireItemAddedList(); - this.verifyListChangeEvent(ADD_INDEX, ADDED_OBJECT_VALUE); - assertTrue(this.itemsAddedListCalled); - - this.listChangeEvent = null; - this.itemsAddedListCalled = false; - this.testModel.removeListChangeListener(this); - this.testModel.testFireItemAddedList(); - assertNull(this.listChangeEvent); - assertFalse(this.itemsAddedListCalled); - - this.listChangeEvent = null; - this.itemsAddedListCalled = false; - this.testModel.addListChangeListener(LIST_NAME, this); - this.testModel.testFireItemAddedList(); - this.verifyListChangeEvent(ADD_INDEX, ADDED_OBJECT_VALUE); - assertTrue(this.itemsAddedListCalled); - - this.listChangeEvent = null; - this.itemsAddedListCalled = false; - this.testModel.removeListChangeListener(LIST_NAME, this); - this.testModel.testFireItemAddedList(); - assertNull(this.listChangeEvent); - assertFalse(this.itemsAddedListCalled); - } - - public void testFireItemRemovedList() { - this.listChangeEvent = null; - this.itemsRemovedListCalled = false; - this.testModel.addListChangeListener(this); - this.testModel.testFireItemRemovedList(); - this.verifyListChangeEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE); - assertTrue(this.itemsRemovedListCalled); - - this.listChangeEvent = null; - this.itemsRemovedListCalled = false; - this.testModel.removeListChangeListener(this); - this.testModel.testFireItemRemovedList(); - assertNull(this.listChangeEvent); - assertFalse(this.itemsRemovedListCalled); - - this.listChangeEvent = null; - this.itemsRemovedListCalled = false; - this.testModel.addListChangeListener(LIST_NAME, this); - this.testModel.testFireItemRemovedList(); - this.verifyListChangeEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE); - assertTrue(this.itemsRemovedListCalled); - - this.listChangeEvent = null; - this.itemsRemovedListCalled = false; - this.testModel.removeListChangeListener(LIST_NAME, this); - this.testModel.testFireItemRemovedList(); - assertNull(this.listChangeEvent); - assertFalse(this.itemsRemovedListCalled); - } - - public void testFireItemReplacedList() { - this.listChangeEvent = null; - this.itemsReplacedListCalled = false; - this.testModel.addListChangeListener(this); - this.testModel.testFireItemReplacedList(); - this.verifyListChangeEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE); - assertTrue(this.itemsReplacedListCalled); - - this.listChangeEvent = null; - this.itemsReplacedListCalled = false; - this.testModel.removeListChangeListener(this); - this.testModel.testFireItemReplacedList(); - assertNull(this.listChangeEvent); - assertFalse(this.itemsReplacedListCalled); - - this.listChangeEvent = null; - this.itemsReplacedListCalled = false; - this.testModel.addListChangeListener(LIST_NAME, this); - this.testModel.testFireItemReplacedList(); - this.verifyListChangeEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE); - assertTrue(this.itemsReplacedListCalled); - - this.listChangeEvent = null; - this.itemsReplacedListCalled = false; - this.testModel.removeListChangeListener(LIST_NAME, this); - this.testModel.testFireItemReplacedList(); - assertNull(this.listChangeEvent); - assertFalse(this.itemsReplacedListCalled); - } - - public void testFireItemMovedList() { - this.listChangeEvent = null; - this.itemsMovedListCalled = false; - this.testModel.addListChangeListener(this); - this.testModel.testFireItemMovedList(); - this.verifyListChangeEvent(TARGET_INDEX, SOURCE_INDEX); - assertTrue(this.itemsMovedListCalled); - - this.listChangeEvent = null; - this.itemsMovedListCalled = false; - this.testModel.removeListChangeListener(this); - this.testModel.testFireItemMovedList(); - assertNull(this.listChangeEvent); - assertFalse(this.itemsMovedListCalled); - - this.listChangeEvent = null; - this.itemsMovedListCalled = false; - this.testModel.addListChangeListener(LIST_NAME, this); - this.testModel.testFireItemMovedList(); - this.verifyListChangeEvent(TARGET_INDEX, SOURCE_INDEX); - assertTrue(this.itemsMovedListCalled); - - this.listChangeEvent = null; - this.itemsMovedListCalled = false; - this.testModel.removeListChangeListener(LIST_NAME, this); - this.testModel.testFireItemMovedList(); - assertNull(this.listChangeEvent); - assertFalse(this.itemsMovedListCalled); - } - - public void testFireListCleared() { - this.listChangeEvent = null; - this.listClearedCalled = false; - this.testModel.addListChangeListener(this); - this.testModel.testFireListCleared(); - this.verifyListChangeEvent(-1, null); - assertTrue(this.listClearedCalled); - - this.listChangeEvent = null; - this.listClearedCalled = false; - this.testModel.removeListChangeListener(this); - this.testModel.testFireListCleared(); - assertNull(this.listChangeEvent); - assertFalse(this.listClearedCalled); - - this.listChangeEvent = null; - this.listClearedCalled = false; - this.testModel.addListChangeListener(LIST_NAME, this); - this.testModel.testFireListCleared(); - this.verifyListChangeEvent(-1, null); - assertTrue(this.listClearedCalled); - - this.listChangeEvent = null; - this.listClearedCalled = false; - this.testModel.removeListChangeListener(LIST_NAME, this); - this.testModel.testFireListCleared(); - assertNull(this.listChangeEvent); - assertFalse(this.listClearedCalled); - } - - public void testFireListChanged() { - this.listChangeEvent = null; - this.listChangedCalled = false; - this.testModel.addListChangeListener(this); - this.testModel.testFireListChanged(); - this.verifyListChangeEvent(-1, null); - assertTrue(this.listChangedCalled); - - this.listChangeEvent = null; - this.listChangedCalled = false; - this.testModel.removeListChangeListener(this); - this.testModel.testFireListChanged(); - assertNull(this.listChangeEvent); - assertFalse(this.listChangedCalled); - - this.listChangeEvent = null; - this.listChangedCalled = false; - this.testModel.addListChangeListener(LIST_NAME, this); - this.testModel.testFireListChanged(); - this.verifyListChangeEvent(-1, null); - assertTrue(this.listChangedCalled); - - this.listChangeEvent = null; - this.listChangedCalled = false; - this.testModel.removeListChangeListener(LIST_NAME, this); - this.testModel.testFireListChanged(); - assertNull(this.listChangeEvent); - assertFalse(this.listChangedCalled); - } - - public void testFireNodeAddedObjectArrayPath() { - this.treeChangeEvent = null; - this.nodeAddedCalled = false; - this.testModel.addTreeChangeListener(this); - this.testModel.testFireNodeAddedObjectArrayPath(); - this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); - assertTrue(this.nodeAddedCalled); - - this.treeChangeEvent = null; - this.nodeAddedCalled = false; - this.testModel.removeTreeChangeListener(this); - this.testModel.testFireNodeAddedObjectArrayPath(); - assertNull(this.treeChangeEvent); - assertFalse(this.nodeAddedCalled); - - this.treeChangeEvent = null; - this.nodeAddedCalled = false; - this.testModel.addTreeChangeListener(TREE_NAME, this); - this.testModel.testFireNodeAddedObjectArrayPath(); - this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); - assertTrue(this.nodeAddedCalled); - - this.treeChangeEvent = null; - this.nodeAddedCalled = false; - this.testModel.removeTreeChangeListener(TREE_NAME, this); - this.testModel.testFireNodeAddedObjectArrayPath(); - assertNull(this.treeChangeEvent); - assertFalse(this.nodeAddedCalled); - } - - public void testFireNodeRemovedObjectArrayPath() { - this.treeChangeEvent = null; - this.nodeRemovedCalled = false; - this.testModel.addTreeChangeListener(this); - this.testModel.testFireNodeRemovedObjectArrayPath(); - this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); - assertTrue(this.nodeRemovedCalled); - - this.treeChangeEvent = null; - this.nodeRemovedCalled = false; - this.testModel.removeTreeChangeListener(this); - this.testModel.testFireNodeRemovedObjectArrayPath(); - assertNull(this.treeChangeEvent); - assertFalse(this.nodeRemovedCalled); - - this.treeChangeEvent = null; - this.nodeRemovedCalled = false; - this.testModel.addTreeChangeListener(TREE_NAME, this); - this.testModel.testFireNodeRemovedObjectArrayPath(); - this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); - assertTrue(this.nodeRemovedCalled); - - this.treeChangeEvent = null; - this.nodeRemovedCalled = false; - this.testModel.removeTreeChangeListener(TREE_NAME, this); - this.testModel.testFireNodeRemovedObjectArrayPath(); - assertNull(this.treeChangeEvent); - assertFalse(this.nodeRemovedCalled); - } - - public void testFireTreeCleared() { - this.treeChangeEvent = null; - this.treeClearedCalled = false; - this.testModel.addTreeChangeListener(this); - this.testModel.testFireTreeCleared(); - this.verifyTreeChangeEvent(EMPTY_PATH); - assertTrue(this.treeClearedCalled); - - this.treeChangeEvent = null; - this.treeClearedCalled = false; - this.testModel.removeTreeChangeListener(this); - this.testModel.testFireTreeCleared(); - assertNull(this.treeChangeEvent); - assertFalse(this.treeClearedCalled); - - this.treeChangeEvent = null; - this.treeClearedCalled = false; - this.testModel.addTreeChangeListener(TREE_NAME, this); - this.testModel.testFireTreeCleared(); - this.verifyTreeChangeEvent(EMPTY_PATH); - assertTrue(this.treeClearedCalled); - - this.treeChangeEvent = null; - this.treeClearedCalled = false; - this.testModel.removeTreeChangeListener(TREE_NAME, this); - this.testModel.testFireTreeCleared(); - assertNull(this.treeChangeEvent); - assertFalse(this.treeClearedCalled); - } - - public void testFireTreeChangedObjectArrayPath() { - this.treeChangeEvent = null; - this.treeChangedCalled = false; - this.testModel.addTreeChangeListener(this); - this.testModel.testFireTreeChangedObjectArrayPath(); - this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); - assertTrue(this.treeChangedCalled); - - this.treeChangeEvent = null; - this.treeChangedCalled = false; - this.testModel.removeTreeChangeListener(this); - this.testModel.testFireTreeChangedObjectArrayPath(); - assertNull(this.treeChangeEvent); - assertFalse(this.treeChangedCalled); - - this.treeChangeEvent = null; - this.treeChangedCalled = false; - this.testModel.addTreeChangeListener(TREE_NAME, this); - this.testModel.testFireTreeChangedObjectArrayPath(); - this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); - assertTrue(this.treeChangedCalled); - - this.treeChangeEvent = null; - this.treeChangedCalled = false; - this.testModel.removeTreeChangeListener(TREE_NAME, this); - this.testModel.testFireTreeChangedObjectArrayPath(); - assertNull(this.treeChangeEvent); - assertFalse(this.treeChangedCalled); - } - - public void testHasAnyChangeListeners() { - assertFalse(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); - this.testModel.addPropertyChangeListener(this); - assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); - this.testModel.removePropertyChangeListener(this); - - assertFalse(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); - this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); - assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); - this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); - - assertFalse(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME)); - this.testModel.addCollectionChangeListener(this); - assertTrue(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME)); - this.testModel.removeCollectionChangeListener(this); - - assertFalse(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME)); - this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); - assertTrue(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME)); - this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); - - assertFalse(this.testModel.hasAnyListChangeListeners(LIST_NAME)); - this.testModel.addListChangeListener(this); - assertTrue(this.testModel.hasAnyListChangeListeners(LIST_NAME)); - this.testModel.removeListChangeListener(this); - - assertFalse(this.testModel.hasAnyListChangeListeners(LIST_NAME)); - this.testModel.addListChangeListener(LIST_NAME, this); - assertTrue(this.testModel.hasAnyListChangeListeners(LIST_NAME)); - this.testModel.removeListChangeListener(LIST_NAME, this); - - assertFalse(this.testModel.hasAnyTreeChangeListeners(TREE_NAME)); - this.testModel.addTreeChangeListener(this); - assertTrue(this.testModel.hasAnyTreeChangeListeners(TREE_NAME)); - this.testModel.removeTreeChangeListener(this); - - assertFalse(this.testModel.hasAnyTreeChangeListeners(TREE_NAME)); - this.testModel.addTreeChangeListener(TREE_NAME, this); - assertTrue(this.testModel.hasAnyTreeChangeListeners(TREE_NAME)); - this.testModel.removeTreeChangeListener(TREE_NAME, this); - } - - public void testAttributeValueHasChanged() { - this.testModel.testAttributeValueHasChanged(); - } - - public void testClone() { - assertFalse(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); - this.testModel.addPropertyChangeListener(this); - assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); - - // verify that the clone does not have any listeners - TestModel clone = this.testModel.clone(); - assertFalse(clone.hasAnyPropertyChangeListeners(PROPERTY_NAME)); - clone.addPropertyChangeListener(this); - assertTrue(clone.hasAnyPropertyChangeListeners(PROPERTY_NAME)); - // check original - assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); - - // now test events fired by original - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - this.testModel.testFirePropertyChangeObjectObject(); - this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); - assertTrue(this.propertyChangeCalled); - - // now test events fired by clone - this.propertyChangeEvent = null; - this.propertyChangeCalled = false; - clone.testFirePropertyChangeObjectObject(); - this.verifyPropertyChangeEvent(clone, OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); - assertTrue(this.propertyChangeCalled); - } - - public void testAddNullStateListener() { - boolean exCaught = false; - try { - this.testModel.addStateChangeListener(null); - } catch (NullPointerException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testAddNullPropertyListener() { - boolean exCaught = false; - try { - this.testModel.addPropertyChangeListener(null); - } catch (NullPointerException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testAddNullCollectionListener() { - boolean exCaught = false; - try { - this.testModel.addCollectionChangeListener(null); - } catch (NullPointerException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testAddNullListListener() { - boolean exCaught = false; - try { - this.testModel.addListChangeListener(null); - } catch (NullPointerException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testAddNullTreeListener() { - boolean exCaught = false; - try { - this.testModel.addTreeChangeListener(null); - } catch (NullPointerException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testAddNullPropertyListenerName() { - boolean exCaught = false; - try { - this.testModel.addPropertyChangeListener("foo", null); - } catch (NullPointerException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testAddNullCollectionListenerName() { - boolean exCaught = false; - try { - this.testModel.addCollectionChangeListener("foo", null); - } catch (NullPointerException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testAddNullListListenerName() { - boolean exCaught = false; - try { - this.testModel.addListChangeListener("foo", null); - } catch (NullPointerException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testAddNullTreeListenerName() { - boolean exCaught = false; - try { - this.testModel.addTreeChangeListener("foo", null); - } catch (NullPointerException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testRemoveBogusStateListener() { - boolean exCaught = false; - try { - this.testModel.removeStateChangeListener(this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addPropertyChangeListener(this); - exCaught = false; - try { - this.testModel.removeStateChangeListener(this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addStateChangeListener(this); - exCaught = false; - try { - this.testModel.removeStateChangeListener(new AbstractModelTests("dummy")); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testRemoveBogusPropertyListener() { - boolean exCaught = false; - try { - this.testModel.removePropertyChangeListener(this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addCollectionChangeListener(this); - exCaught = false; - try { - this.testModel.removePropertyChangeListener(this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addPropertyChangeListener(this); - exCaught = false; - try { - this.testModel.removePropertyChangeListener(new AbstractModelTests("dummy")); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testRemoveBogusCollectionListener() { - boolean exCaught = false; - try { - this.testModel.removeCollectionChangeListener(this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addPropertyChangeListener(this); - exCaught = false; - try { - this.testModel.removeCollectionChangeListener(this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addCollectionChangeListener(this); - exCaught = false; - try { - this.testModel.removeCollectionChangeListener(new AbstractModelTests("dummy")); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testRemoveBogusListListener() { - boolean exCaught = false; - try { - this.testModel.removeListChangeListener(this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addPropertyChangeListener(this); - exCaught = false; - try { - this.testModel.removeListChangeListener(this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addListChangeListener(this); - exCaught = false; - try { - this.testModel.removeListChangeListener(new AbstractModelTests("dummy")); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testRemoveBogusTreeListener() { - boolean exCaught = false; - try { - this.testModel.removeTreeChangeListener(this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addPropertyChangeListener(this); - exCaught = false; - try { - this.testModel.removeTreeChangeListener(this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addTreeChangeListener(this); - exCaught = false; - try { - this.testModel.removeTreeChangeListener(new AbstractModelTests("dummy")); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testRemoveBogusPropertyListenerName() { - boolean exCaught = false; - try { - this.testModel.removePropertyChangeListener("foo", this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addCollectionChangeListener("foo", this); - exCaught = false; - try { - this.testModel.removePropertyChangeListener("foo", this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addPropertyChangeListener("foo", this); - exCaught = false; - try { - this.testModel.removePropertyChangeListener("foo", new AbstractModelTests("dummy")); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testRemoveBogusCollectionListenerName() { - boolean exCaught = false; - try { - this.testModel.removeCollectionChangeListener("foo", this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addPropertyChangeListener("foo", this); - exCaught = false; - try { - this.testModel.removeCollectionChangeListener("foo", this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addCollectionChangeListener("foo", this); - exCaught = false; - try { - this.testModel.removeCollectionChangeListener("foo", new AbstractModelTests("dummy")); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testRemoveBogusListListenerName() { - boolean exCaught = false; - try { - this.testModel.removeListChangeListener("foo", this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addPropertyChangeListener("foo", this); - exCaught = false; - try { - this.testModel.removeListChangeListener("foo", this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addListChangeListener("foo", this); - exCaught = false; - try { - this.testModel.removeListChangeListener("foo", new AbstractModelTests("dummy")); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testRemoveBogusTreeListenerName() { - boolean exCaught = false; - try { - this.testModel.removeTreeChangeListener("foo", this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addPropertyChangeListener("foo", this); - exCaught = false; - try { - this.testModel.removeTreeChangeListener("foo", this); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - - this.testModel.addTreeChangeListener("foo", this); - exCaught = false; - try { - this.testModel.removeTreeChangeListener("foo", new AbstractModelTests("dummy")); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testToString() { - assertTrue(this.testModel.toString().indexOf(TEST_TO_STRING) != -1); - } - -// ********** internal methods ********** - - private void verifyPropertyChangeEvent(Object oldValue, Object newValue) { - this.verifyPropertyChangeEvent(this.testModel, oldValue, newValue); - } - - private void verifyPropertyChangeEvent(Object source, Object oldValue, Object newValue) { - assertNotNull(this.propertyChangeEvent); - assertEquals(source, this.propertyChangeEvent.getSource()); - assertEquals(PROPERTY_NAME, this.propertyChangeEvent.getPropertyName()); - assertEquals(oldValue, this.propertyChangeEvent.getOldValue()); - assertEquals(newValue, this.propertyChangeEvent.getNewValue()); - } - - private void verifyCollectionChangeEvent(Object item) { - assertNotNull(this.collectionChangeEvent); - assertEquals(this.testModel, this.collectionChangeEvent.getSource()); - assertEquals(COLLECTION_NAME, this.collectionChangeEvent.getCollectionName()); - if (item == null) { - assertFalse(this.collectionChangeEvent.items().hasNext()); - } else { - assertEquals(item, this.collectionChangeEvent.items().next()); - } - } - - private void verifyListChangeEvent(int index, Object item) { - this.verifyListChangeEvent(index, item, null); - } - - private void verifyListChangeEvent(int targetIndex, int sourceIndex) { - assertNotNull(this.listChangeEvent); - assertEquals(this.testModel, this.listChangeEvent.getSource()); - assertEquals(LIST_NAME, this.listChangeEvent.getListName()); - assertEquals(targetIndex, this.listChangeEvent.getTargetIndex()); - assertEquals(sourceIndex, this.listChangeEvent.getSourceIndex()); - } - - private void verifyListChangeEvent(int index, Object item, Object replacedItem) { - assertNotNull(this.listChangeEvent); - assertEquals(this.testModel, this.listChangeEvent.getSource()); - assertEquals(LIST_NAME, this.listChangeEvent.getListName()); - assertEquals(index, this.listChangeEvent.getIndex()); - if (item == null) { - assertFalse(this.listChangeEvent.items().hasNext()); - } else { - assertEquals(item, this.listChangeEvent.items().next()); - } - if (replacedItem == null) { - assertFalse(this.listChangeEvent.replacedItems().hasNext()); - } else { - assertEquals(replacedItem, this.listChangeEvent.replacedItems().next()); - } - } - - private void verifyTreeChangeEvent(Object[] path) { - assertNotNull(this.treeChangeEvent); - assertEquals(this.testModel, this.treeChangeEvent.getSource()); - assertEquals(TREE_NAME, this.treeChangeEvent.getTreeName()); - assertTrue(Arrays.equals(path, this.treeChangeEvent.getPath())); - } - - public void testValuesAreEqual1() { - assertTrue(this.testModel.testValuesAreEqual(null, null)); - assertFalse(this.testModel.testValuesAreDifferent(null, null)); - } - - public void testValuesAreEqual2() { - assertTrue(this.testModel.testValuesAreEqual("foo", "foo")); - assertFalse(this.testModel.testValuesAreDifferent("foo", "foo")); - } - - public void testValuesAreEqual3() { - assertFalse(this.testModel.testValuesAreEqual("foo", null)); - assertTrue(this.testModel.testValuesAreDifferent("foo", null)); - } - - public void testValuesAreEqual4() { - assertFalse(this.testModel.testValuesAreEqual(null, "foo")); - assertTrue(this.testModel.testValuesAreDifferent(null, "foo")); - } - - public void testValuesAreEqual5() { - assertFalse(this.testModel.testValuesAreEqual("bar", "foo")); - assertTrue(this.testModel.testValuesAreDifferent("bar", "foo")); - } - - - // ********** listener implementations ********** - - public void stateChanged(StateChangeEvent e) { - this.stateChangedCalled = true; - this.stateChangeEvent = e; - } - - public void propertyChanged(PropertyChangeEvent e) { - this.propertyChangeCalled = true; - this.propertyChangeEvent = e; - } - - public void itemsAdded(CollectionChangeEvent e) { - this.itemsAddedCollectionCalled = true; - this.collectionChangeEvent = e; - } - public void itemsRemoved(CollectionChangeEvent e) { - this.itemsRemovedCollectionCalled = true; - this.collectionChangeEvent = e; - } - public void collectionCleared(CollectionChangeEvent e) { - this.collectionClearedCalled = true; - this.collectionChangeEvent = e; - } - public void collectionChanged(CollectionChangeEvent e) { - this.collectionChangedCalled = true; - this.collectionChangeEvent = e; - } - - public void itemsAdded(ListChangeEvent e) { - this.itemsAddedListCalled = true; - this.listChangeEvent = e; - } - public void itemsRemoved(ListChangeEvent e) { - this.itemsRemovedListCalled = true; - this.listChangeEvent = e; - } - public void itemsReplaced(ListChangeEvent e) { - this.itemsReplacedListCalled = true; - this.listChangeEvent = e; - } - public void itemsMoved(ListChangeEvent e) { - this.itemsMovedListCalled = true; - this.listChangeEvent = e; - } - public void listCleared(ListChangeEvent e) { - this.listClearedCalled = true; - this.listChangeEvent = e; - } - public void listChanged(ListChangeEvent e) { - this.listChangedCalled = true; - this.listChangeEvent = e; - } - - public void nodeAdded(TreeChangeEvent e) { - this.nodeAddedCalled = true; - this.treeChangeEvent = e; - } - public void nodeRemoved(TreeChangeEvent e) { - this.nodeRemovedCalled = true; - this.treeChangeEvent = e; - } - public void treeCleared(TreeChangeEvent e) { - this.treeClearedCalled = true; - this.treeChangeEvent = e; - } - public void treeChanged(TreeChangeEvent e) { - this.treeChangedCalled = true; - this.treeChangeEvent = e; - } - - // ********** inner class ********** - - private static class TestModel extends AbstractModel implements Cloneable { - TestModel() { - super(); - } - - public void testFireStateChange() { - this.fireStateChanged(); - } - - public void testFirePropertyChangeObjectObject() { - this.firePropertyChanged(PROPERTY_NAME, OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); - } - - public void testFirePropertyChangeObject() { - this.firePropertyChanged(PROPERTY_NAME, NEW_OBJECT_VALUE); - } - - public void testFirePropertyChangeIntInt() { - this.firePropertyChanged(PROPERTY_NAME, OLD_INT_VALUE.intValue(), NEW_INT_VALUE.intValue()); - } - - public void testFirePropertyChangeBooleanBoolean() { - this.firePropertyChanged(PROPERTY_NAME, OLD_BOOLEAN_VALUE.booleanValue(), NEW_BOOLEAN_VALUE.booleanValue()); - } - - public void testFireItemAddedCollection() { - this.fireItemAdded(COLLECTION_NAME, ADDED_OBJECT_VALUE); - } - - public void testFireItemRemovedCollection() { - this.fireItemRemoved(COLLECTION_NAME, REMOVED_OBJECT_VALUE); - } - - public void testFireCollectionCleared() { - this.fireCollectionCleared(COLLECTION_NAME); - } - - public void testFireCollectionChanged() { - this.fireCollectionChanged(COLLECTION_NAME); - } - - public void testFireItemAddedList() { - this.fireItemAdded(LIST_NAME, ADD_INDEX, ADDED_OBJECT_VALUE); - } - - public void testFireItemRemovedList() { - this.fireItemRemoved(LIST_NAME, REMOVE_INDEX, REMOVED_OBJECT_VALUE); - } - - public void testFireItemReplacedList() { - this.fireItemReplaced(LIST_NAME, REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE); - } - - public void testFireItemMovedList() { - this.fireItemMoved(LIST_NAME, TARGET_INDEX, SOURCE_INDEX); - } - - public void testFireListCleared() { - this.fireListCleared(LIST_NAME); - } - - public void testFireListChanged() { - this.fireListChanged(LIST_NAME); - } - - public void testFireNodeAddedObjectArrayPath() { - this.fireNodeAdded(TREE_NAME, OBJECT_ARRAY_PATH); - } - - public void testFireNodeRemovedObjectArrayPath() { - this.fireNodeRemoved(TREE_NAME, OBJECT_ARRAY_PATH); - } - - public void testFireTreeCleared() { - this.fireTreeCleared(TREE_NAME); - } - - public void testFireTreeChangedObjectArrayPath() { - this.fireTreeChanged(TREE_NAME, OBJECT_ARRAY_PATH); - } - - public void testAttributeValueHasChanged() { - assertTrue(this.attributeValueHasChanged(null, new Object())); - assertTrue(this.attributeValueHasChanged(new Object(), null)); - assertTrue(this.attributeValueHasChanged(new Object(), new Object())); - - Object same = new Object(); - assertFalse(this.attributeValueHasChanged(same, same)); - assertFalse(this.attributeValueHasChanged(null, null)); - } - - @Override - public TestModel clone() { - try { - return (TestModel) super.clone(); - } catch (CloneNotSupportedException ex) { - throw new InternalError(); - } - } - - public boolean testValuesAreDifferent(Object value1, Object value2) { - return this.valuesAreDifferent(value1, value2); - } - - public boolean testValuesAreEqual(Object value1, Object value2) { - return this.valuesAreEqual(value1, value2); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(TEST_TO_STRING); - } - - } - - - // ********** serialization test ********** - -//TODO - This test doesn't pass in the Eclipse build environment (Linux) for some reason -// public void testSerialization() throws IOException, ClassNotFoundException { -// LocalModel model1 = new LocalModel(); -// Foo foo1 = new Foo(); -// Bar bar1 = new Bar(); -// Joo joo1 = new Joo(); -// Jar jar1 = new Jar(); -// model1.addStateChangeListener(foo1); -// model1.addStateChangeListener(bar1); -// model1.addListChangeListener(joo1); -// model1.addListChangeListener(jar1); -// -// ChangeListener[] listeners1 = this.listeners(model1, StateChangeListener.class); -// assertEquals(2, listeners1.length); -// // the order of these could change... -// assertEquals(Foo.class, listeners1[0].getClass()); -// assertEquals(Bar.class, listeners1[1].getClass()); -// -// listeners1 = this.listeners(model1, ListChangeListener.class); -// assertEquals(2, listeners1.length); -// // the order of these could change... -// assertEquals(Joo.class, listeners1[0].getClass()); -// assertEquals(Jar.class, listeners1[1].getClass()); -// -// LocalModel model2 = TestTools.serialize(model1); -// -// ChangeListener[] listeners2 = this.listeners(model2, StateChangeListener.class); -// assertEquals(1, listeners2.length); -// assertEquals(Foo.class, listeners2[0].getClass()); -// -// listeners2 = this.listeners(model2, ListChangeListener.class); -// assertEquals(1, listeners2.length); -// assertEquals(Joo.class, listeners2[0].getClass()); -// } - -// >>>>>>>>>>>>>>>>> these methods are called by #testSerialization(), commented out above... - private ChangeListener[] listeners(LocalModel model, Class listenerClass) { - ChangeSupport changeSupport = (ChangeSupport) ClassTools.fieldValue(model, "changeSupport"); - return (ChangeListener[]) ClassTools.executeMethod(changeSupport, "listeners", Class.class, listenerClass); - } - - private static class LocalModel extends AbstractModel implements Serializable { - LocalModel() { - super(); - } - } - - private static class Foo implements Serializable, StateChangeListener { - Foo() { - super(); - } - public void stateChanged(StateChangeEvent event) { - // do nothing - } - } - - private static class Bar implements StateChangeListener { - Bar() { - super(); - } - public void stateChanged(StateChangeEvent event) { - // do nothing - } - } - - private static class Joo extends ListChangeAdapter implements Serializable { -// private static final ObjectStreamField[] serialPersistentFields = {new ObjectStreamField("changeSupport", ChangeSupport.class)}; - Joo() { - super(); - } - } - - private static class Jar extends ListChangeAdapter { - Jar() { - super(); - } - } - - - // ********** bug(?) test ********** - - private static final String ISE_MESSAGE = "this object is no longer listening to localA"; - - /** - * Test the following situation: - * - both B and C are listening to A - * - C is also listening to B - * - when B receives an event from A, it will fire an event to C - * - when C receives an event from B, it will STOP listening to A - * - the event from B to C may be preceded or followed (depending on - * the hash positions of listeners) by an event from A to C: - * - if the A to C event comes first, no problem - * - but if the A to B event comes first, the A to C event should NOT happen - */ - public void testIndirectRemoveStateListener() { - this.verifyIndirectRemoveListener( - new NotifyCommand() { - public void notifyListeners(LocalA localA) { - localA.notifyStateListeners(); - } - } - ); - } - - public void testIndirectRemovePropertyListener() { - this.verifyIndirectRemoveListener( - new NotifyCommand() { - public void notifyListeners(LocalA localA) { - localA.notifyPropertyListeners(); - } - } - ); - } - - public void testIndirectRemoveCollectionListener() { - this.verifyIndirectRemoveListener( - new NotifyCommand() { - public void notifyListeners(LocalA localA) { - localA.notifyCollectionListeners(); - } - } - ); - } - - public void testIndirectRemoveListListener() { - this.verifyIndirectRemoveListener( - new NotifyCommand() { - public void notifyListeners(LocalA localA) { - localA.notifyListListeners(); - } - } - ); - } - - public void testIndirectRemoveTreeListener() { - this.verifyIndirectRemoveListener( - new NotifyCommand() { - public void notifyListeners(LocalA localA) { - localA.notifyTreeListeners(); - } - } - ); - } - - public void verifyIndirectRemoveListener(NotifyCommand command) { - LocalA localA = new LocalA(); - LocalB localB = new LocalB(localA); - - // build a bunch of LocalCs so at least one of them is notified AFTER the LocalB; - // using 1000 seemed to fail very consistently before ChangeSupport was fixed - LocalC[] localCs = new LocalC[1000]; - for (int i = localCs.length; i-- > 0; ) { - localCs[i] = new LocalC(localA, localB); - } - - boolean exCaught = false; - try { - command.notifyListeners(localA); - } catch (IllegalStateException ex) { - if (ex.getMessage() == ISE_MESSAGE) { - exCaught = true; - } else { - throw ex; - } - } - assertFalse(exCaught); - - for (int i = localCs.length; i-- > 0; ) { - assertFalse(localCs[i].isListeningToLocalA()); - } - } - - private interface NotifyCommand { - void notifyListeners(LocalA localA); - } - - /** - * This object simply fires a state change event. Both LocalB and LocalC - * will be listeners. - */ - private static class LocalA extends AbstractModel { - LocalA() { - super(); - } - void notifyStateListeners() { - this.fireStateChanged(); - } - void notifyPropertyListeners() { - this.firePropertyChanged("foo", 1, 2); - } - void notifyCollectionListeners() { - this.fireCollectionChanged("foo"); - } - void notifyListListeners() { - this.fireListChanged("foo"); - } - void notifyTreeListeners() { - this.fireTreeChanged("foo"); - } - } - - /** - * This object will fire state change events whenever it receives - * a state change event from localA. - */ - private static class LocalB - extends AbstractModel - implements StateChangeListener, PropertyChangeListener, CollectionChangeListener, ListChangeListener, TreeChangeListener - { - LocalB(LocalA localA) { - super(); - localA.addStateChangeListener(this); - localA.addPropertyChangeListener(this); - localA.addCollectionChangeListener(this); - localA.addListChangeListener(this); - localA.addTreeChangeListener(this); - } - - public void stateChanged(StateChangeEvent e) { - this.fireStateChanged(); - } - - public void propertyChanged(PropertyChangeEvent evt) { - this.firePropertyChanged("bar", 1, 2); - } - - public void collectionChanged(CollectionChangeEvent e) { - this.fireCollectionChanged("bar"); - } - public void collectionCleared(CollectionChangeEvent e) {/*ignore*/} - public void itemsAdded(CollectionChangeEvent e) {/*ignore*/} - public void itemsRemoved(CollectionChangeEvent e) {/*ignore*/} - - public void listChanged(ListChangeEvent e) { - this.fireListChanged("bar"); - } - public void listCleared(ListChangeEvent e) {/*ignore*/} - public void itemsAdded(ListChangeEvent e) {/*ignore*/} - public void itemsRemoved(ListChangeEvent e) {/*ignore*/} - public void itemsReplaced(ListChangeEvent e) {/*ignore*/} - public void itemsMoved(ListChangeEvent e) {/*ignore*/} - - public void treeChanged(TreeChangeEvent e) { - this.fireTreeChanged("bar"); - } - public void treeCleared(TreeChangeEvent e) {/*ignore*/} - public void nodeAdded(TreeChangeEvent e) {/*ignore*/} - public void nodeRemoved(TreeChangeEvent e) {/*ignore*/} - - } - - /** - * This object will listen to two other objects, localA and localB. - * If this object receives notification from localB, it will stop listening to - * localA. If this object receives notification from localA, it will check to - * see whether it still listening to localA. If this object is no longer - * listening to localA, it will complain about receiving the event and - * throw an exception. - */ - private static class LocalC - extends AbstractModel - implements StateChangeListener, PropertyChangeListener, CollectionChangeListener, ListChangeListener, TreeChangeListener - { - private LocalA localA; - private LocalB localB; - private boolean listeningToLocalA; - - LocalC(LocalA localA, LocalB localB) { - super(); - this.localA = localA; - this.localB = localB; - - localA.addStateChangeListener(this); - localA.addPropertyChangeListener(this); - localA.addCollectionChangeListener(this); - localA.addListChangeListener(this); - localA.addTreeChangeListener(this); - this.listeningToLocalA = true; - - localB.addStateChangeListener(this); - localB.addPropertyChangeListener(this); - localB.addCollectionChangeListener(this); - localB.addListChangeListener(this); - localB.addTreeChangeListener(this); - } - boolean isListeningToLocalA() { - return this.listeningToLocalA; - } - - public void stateChanged(StateChangeEvent e) { - Object source = e.getSource(); - if (source == this.localA) { - if ( ! this.listeningToLocalA) { - throw new IllegalStateException(ISE_MESSAGE); - } - } else if (source == this.localB) { - this.localA.removeStateChangeListener(this); - this.listeningToLocalA = false; - } else { - throw new IllegalStateException("bogus event source: " + source); - } - } - - public void propertyChanged(PropertyChangeEvent e) { - Object source = e.getSource(); - if (source == this.localA) { - if ( ! this.listeningToLocalA) { - throw new IllegalStateException(ISE_MESSAGE); - } - } else if (source == this.localB) { - this.localA.removePropertyChangeListener(this); - this.listeningToLocalA = false; - } else { - throw new IllegalStateException("bogus event source: " + source); - } - } - - public void collectionChanged(CollectionChangeEvent e) { - Object source = e.getSource(); - if (source == this.localA) { - if ( ! this.listeningToLocalA) { - throw new IllegalStateException(ISE_MESSAGE); - } - } else if (source == this.localB) { - this.localA.removeCollectionChangeListener(this); - this.listeningToLocalA = false; - } else { - throw new IllegalStateException("bogus event source: " + source); - } - } - public void collectionCleared(CollectionChangeEvent e) {/*ignore*/} - public void itemsAdded(CollectionChangeEvent e) {/*ignore*/} - public void itemsRemoved(CollectionChangeEvent e) {/*ignore*/} - - public void listChanged(ListChangeEvent e) { - Object source = e.getSource(); - if (source == this.localA) { - if ( ! this.listeningToLocalA) { - throw new IllegalStateException(ISE_MESSAGE); - } - } else if (source == this.localB) { - this.localA.removeListChangeListener(this); - this.listeningToLocalA = false; - } else { - throw new IllegalStateException("bogus event source: " + source); - } - } - public void listCleared(ListChangeEvent e) {/*ignore*/} - public void itemsAdded(ListChangeEvent e) {/*ignore*/} - public void itemsRemoved(ListChangeEvent e) {/*ignore*/} - public void itemsReplaced(ListChangeEvent e) {/*ignore*/} - public void itemsMoved(ListChangeEvent e) {/*ignore*/} - - public void treeChanged(TreeChangeEvent e) { - Object source = e.getSource(); - if (source == this.localA) { - if ( ! this.listeningToLocalA) { - throw new IllegalStateException(ISE_MESSAGE); - } - } else if (source == this.localB) { - this.localA.removeTreeChangeListener(this); - this.listeningToLocalA = false; - } else { - throw new IllegalStateException("bogus event source: " + source); - } - } - public void treeCleared(TreeChangeEvent e) {/*ignore*/} - public void nodeAdded(TreeChangeEvent e) {/*ignore*/} - public void nodeRemoved(TreeChangeEvent e) {/*ignore*/} - - } - -} Index: src/org/eclipse/jpt/utility/tests/internal/model/JptUtilityModelTests.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/JptUtilityModelTests.java,v retrieving revision 1.4 diff -u -r1.4 JptUtilityModelTests.java --- src/org/eclipse/jpt/utility/tests/internal/model/JptUtilityModelTests.java 2 Oct 2008 21:25:38 -0000 1.4 +++ src/org/eclipse/jpt/utility/tests/internal/model/JptUtilityModelTests.java 6 Apr 2009 20:59:08 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -22,7 +22,7 @@ suite.addTest(JptUtilityModelListenerTests.suite()); suite.addTest(JptUtilityModelValueTests.suite()); - suite.addTestSuite(AbstractModelTests.class); + suite.addTestSuite(ChangeSupportTests.class); suite.addTestSuite(NewEventTests.class); return suite; Index: src/org/eclipse/jpt/utility/tests/internal/model/ChangeSupportTests.java =================================================================== RCS file: src/org/eclipse/jpt/utility/tests/internal/model/ChangeSupportTests.java diff -N src/org/eclipse/jpt/utility/tests/internal/model/ChangeSupportTests.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/utility/tests/internal/model/ChangeSupportTests.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,4177 @@ +/******************************************************************************* + * 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.utility.tests.internal.model; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +import junit.framework.TestCase; + +import org.eclipse.jpt.utility.internal.ClassTools; +import org.eclipse.jpt.utility.internal.CollectionTools; +import org.eclipse.jpt.utility.internal.model.AbstractModel; +import org.eclipse.jpt.utility.internal.model.ChangeSupport; +import org.eclipse.jpt.utility.model.event.CollectionChangeEvent; +import org.eclipse.jpt.utility.model.event.ListChangeEvent; +import org.eclipse.jpt.utility.model.event.PropertyChangeEvent; +import org.eclipse.jpt.utility.model.event.StateChangeEvent; +import org.eclipse.jpt.utility.model.event.TreeChangeEvent; +import org.eclipse.jpt.utility.model.listener.ChangeListener; +import org.eclipse.jpt.utility.model.listener.CollectionChangeAdapter; +import org.eclipse.jpt.utility.model.listener.CollectionChangeListener; +import org.eclipse.jpt.utility.model.listener.ListChangeAdapter; +import org.eclipse.jpt.utility.model.listener.ListChangeListener; +import org.eclipse.jpt.utility.model.listener.PropertyChangeAdapter; +import org.eclipse.jpt.utility.model.listener.PropertyChangeListener; +import org.eclipse.jpt.utility.model.listener.StateChangeAdapter; +import org.eclipse.jpt.utility.model.listener.StateChangeListener; +import org.eclipse.jpt.utility.model.listener.TreeChangeAdapter; +import org.eclipse.jpt.utility.model.listener.TreeChangeListener; +import org.eclipse.jpt.utility.tests.internal.TestTools; + +@SuppressWarnings("nls") +public class ChangeSupportTests + extends TestCase + implements StateChangeListener, PropertyChangeListener, CollectionChangeListener, ListChangeListener, TreeChangeListener +{ + private TestModel testModel; + private static final String TEST_TO_STRING = "this is a test"; + + private StateChangeEvent stateChangeEvent; + private boolean stateChangedCalled = false; + + private PropertyChangeEvent propertyChangeEvent; + private boolean propertyChangeCalled = false; + private static final String PROPERTY_NAME = "propertyName"; + static final Object OLD_OBJECT_VALUE = new Object(); + static final Object NEW_OBJECT_VALUE = new Object(); + static final Integer OLD_INT_VALUE = new Integer(27); + static final Boolean OLD_BOOLEAN_VALUE = Boolean.TRUE; + static final Integer NEW_INT_VALUE = new Integer(42); + static final Boolean NEW_BOOLEAN_VALUE = Boolean.FALSE; + + private CollectionChangeEvent collectionChangeEvent; + private boolean itemsAddedCollectionCalled = false; + private boolean itemsRemovedCollectionCalled = false; + private boolean collectionChangedCalled = false; + private boolean collectionClearedCalled = false; + private static final String COLLECTION_NAME = "collectionName"; + static final Object ADDED_OBJECT_VALUE = new Object(); + static final Object ADDED_OBJECT_VALUE_2 = new Object(); + static final Object REMOVED_OBJECT_VALUE = new Object(); + static final int TARGET_INDEX = 7; + static final int SOURCE_INDEX = 22; + + private ListChangeEvent listChangeEvent; + private boolean itemsAddedListCalled = false; + private boolean itemsRemovedListCalled = false; + private boolean itemsReplacedListCalled = false; + private boolean itemsMovedListCalled = false; + private boolean listChangedCalled = false; + private boolean listClearedCalled = false; + private static final String LIST_NAME = "listName"; + private static final int ADD_INDEX = 3; + private static final int REMOVE_INDEX = 5; + private static final int REPLACE_INDEX = 2; + + private TreeChangeEvent treeChangeEvent; + private boolean nodeAddedCalled = false; + private boolean nodeRemovedCalled = false; + private boolean treeChangedCalled = false; + private boolean treeClearedCalled = false; + private static final String TREE_NAME = "treeName"; + static final Object[] OBJECT_ARRAY_PATH = {new Object(), new Object(), new String()}; + static final Object[] EMPTY_PATH = {}; + + + public ChangeSupportTests(String name) { + super(name); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + this.testModel = new TestModel(); + } + + @Override + protected void tearDown() throws Exception { + TestTools.clear(this); + super.tearDown(); + } + + + // ********** general tests ********** + + public void testNullSource() { + boolean exCaught = false; + try { + ChangeSupport cs = new ChangeSupport(null); + fail("bogus change support: " + cs); + } catch (NullPointerException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + // ********** state change tests ********** + + public void testFireStateChange() { + this.stateChangeEvent = null; + this.stateChangedCalled = false; + this.testModel.addStateChangeListener(this); + this.testModel.testFireStateChange(); + assertNotNull(this.stateChangeEvent); + assertEquals(this.testModel, this.stateChangeEvent.getSource()); + assertTrue(this.stateChangedCalled); + } + + public void testHasAnyStateChangeListeners() { + assertTrue(this.testModel.hasNoStateChangeListeners()); + this.testModel.addStateChangeListener(this); + assertTrue(this.testModel.hasAnyStateChangeListeners()); + this.testModel.removeStateChangeListener(this); + assertTrue(this.testModel.hasNoStateChangeListeners()); + } + + public void testHasAnyStateChangeListenersDuplicate() { + assertTrue(this.testModel.hasNoStateChangeListeners()); + this.testModel.addStateChangeListener(this); + this.testModel.addStateChangeListener(this); + assertTrue(this.testModel.hasAnyStateChangeListeners()); + this.testModel.removeStateChangeListener(this); + assertTrue(this.testModel.hasAnyStateChangeListeners()); + this.testModel.removeStateChangeListener(this); + assertTrue(this.testModel.hasNoStateChangeListeners()); + } + + public void testAddNullStateListener() { + boolean exCaught = false; + try { + this.testModel.addStateChangeListener(null); + } catch (NullPointerException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testRemoveBogusStateListener() { + boolean exCaught = false; + try { + this.testModel.removeStateChangeListener(this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addPropertyChangeListener(this); + exCaught = false; + try { + this.testModel.removeStateChangeListener(this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addStateChangeListener(this); + exCaught = false; + try { + this.testModel.removeStateChangeListener(new ChangeSupportTests("dummy")); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + exCaught = false; + try { + this.testModel.removeStateChangeListener(new StateChangeAdapter()); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + + // ********** property change tests ********** + + public void testFirePropertyChangedEvent() { + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(this); + this.testModel.testFirePropertyChangedEvent(); + this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); + assertTrue(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(this); + this.testModel.testFirePropertyChangedEvent(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedEvent(); + this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); + assertTrue(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedEvent(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + } + + public void testFirePropertyChangedEventNoChange() { + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(this); + this.testModel.testFirePropertyChangedEventNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(this); + this.testModel.testFirePropertyChangedEventNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedEventNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedEventNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + } + + public void testFirePropertyChangedObjectObject() { + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(this); + this.testModel.testFirePropertyChangedObjectObject(); + this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); + assertTrue(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(this); + this.testModel.testFirePropertyChangedObjectObject(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedObjectObject(); + this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); + assertTrue(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedObjectObject(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + } + + public void testFirePropertyChangedObjectObjectNoChange() { + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(this); + this.testModel.testFirePropertyChangedObjectObjectNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(this); + this.testModel.testFirePropertyChangedObjectObjectNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedObjectObjectNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedObjectObjectNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + } + + public void testFirePropertyChangedObject() { + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(this); + this.testModel.testFirePropertyChangedObject(); + this.verifyPropertyChangeEvent(null, NEW_OBJECT_VALUE); + assertTrue(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(this); + this.testModel.testFirePropertyChangedObject(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedObject(); + this.verifyPropertyChangeEvent(null, NEW_OBJECT_VALUE); + assertTrue(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedObject(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + } + + public void testFirePropertyChangedObjectNoChange() { + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(this); + this.testModel.testFirePropertyChangedObjectNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(this); + this.testModel.testFirePropertyChangedObjectNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedObjectNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedObjectNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + } + + public void testFirePropertyChangedIntInt() { + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(this); + this.testModel.testFirePropertyChangedIntInt(); + this.verifyPropertyChangeEvent(OLD_INT_VALUE, NEW_INT_VALUE); + assertTrue(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(this); + this.testModel.testFirePropertyChangedIntInt(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedIntInt(); + this.verifyPropertyChangeEvent(OLD_INT_VALUE, NEW_INT_VALUE); + assertTrue(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedIntInt(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + } + + public void testFirePropertyChangedIntIntNoChange() { + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(this); + this.testModel.testFirePropertyChangedIntIntNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(this); + this.testModel.testFirePropertyChangedIntIntNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedIntIntNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedIntIntNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + } + + public void testFirePropertyChangedBooleanBoolean() { + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(this); + this.testModel.testFirePropertyChangedBooleanBoolean(); + this.verifyPropertyChangeEvent(OLD_BOOLEAN_VALUE, NEW_BOOLEAN_VALUE); + assertTrue(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(this); + this.testModel.testFirePropertyChangedBooleanBoolean(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedBooleanBoolean(); + this.verifyPropertyChangeEvent(OLD_BOOLEAN_VALUE, NEW_BOOLEAN_VALUE); + assertTrue(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedBooleanBoolean(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + } + + public void testFirePropertyChangedBooleanBooleanNoChange() { + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(this); + this.testModel.testFirePropertyChangedBooleanBooleanNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(this); + this.testModel.testFirePropertyChangedBooleanBooleanNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedBooleanBooleanNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + this.testModel.testFirePropertyChangedBooleanBooleanNoChange(); + assertNull(this.propertyChangeEvent); + assertFalse(this.propertyChangeCalled); + } + + public void testHasAnyPropertyChangeListeners() { + assertTrue(this.testModel.hasNoPropertyChangeListeners(PROPERTY_NAME)); + this.testModel.addPropertyChangeListener(this); + assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); + this.testModel.removePropertyChangeListener(this); + assertTrue(this.testModel.hasNoPropertyChangeListeners(PROPERTY_NAME)); + + assertTrue(this.testModel.hasNoPropertyChangeListeners(PROPERTY_NAME)); + this.testModel.addPropertyChangeListener(PROPERTY_NAME, this); + assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); + this.testModel.removePropertyChangeListener(PROPERTY_NAME, this); + assertTrue(this.testModel.hasNoPropertyChangeListeners(PROPERTY_NAME)); + } + + public void testAddNullPropertyListener() { + boolean exCaught = false; + try { + this.testModel.addPropertyChangeListener(null); + } catch (NullPointerException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testAddNullPropertyListenerName() { + boolean exCaught = false; + try { + this.testModel.addPropertyChangeListener("foo", null); + } catch (NullPointerException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testRemoveBogusPropertyListener() { + boolean exCaught = false; + try { + this.testModel.removePropertyChangeListener(this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addCollectionChangeListener(this); + exCaught = false; + try { + this.testModel.removePropertyChangeListener(this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addPropertyChangeListener(this); + exCaught = false; + try { + this.testModel.removePropertyChangeListener(new ChangeSupportTests("dummy")); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + exCaught = false; + try { + this.testModel.removePropertyChangeListener(new PropertyChangeAdapter()); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testRemoveBogusPropertyListenerName() { + boolean exCaught = false; + try { + this.testModel.removePropertyChangeListener("foo", this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addCollectionChangeListener("foo", this); + exCaught = false; + try { + this.testModel.removePropertyChangeListener("foo", this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addPropertyChangeListener("foo", this); + exCaught = false; + try { + this.testModel.removePropertyChangeListener("foo", new ChangeSupportTests("dummy")); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + exCaught = false; + try { + this.testModel.removePropertyChangeListener("foo", new PropertyChangeAdapter()); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + private void verifyPropertyChangeEvent(Object oldValue, Object newValue) { + this.verifyPropertyChangeEvent(this.testModel, oldValue, newValue); + } + + private void verifyPropertyChangeEvent(Object source, Object oldValue, Object newValue) { + assertNotNull(this.propertyChangeEvent); + assertEquals(source, this.propertyChangeEvent.getSource()); + assertEquals(PROPERTY_NAME, this.propertyChangeEvent.getPropertyName()); + assertEquals(oldValue, this.propertyChangeEvent.getOldValue()); + assertEquals(newValue, this.propertyChangeEvent.getNewValue()); + } + + + // ********** collection change tests ********** + + public void testFireItemsAddedCollectionEvent() { + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireItemsAddedCollectionEvent(); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireItemsAddedCollectionEvent(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsAddedCollectionEvent(); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsAddedCollectionEvent(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + } + + public void testFireItemsAddedCollectionEventNoChange() { + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireItemsAddedCollectionEventNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireItemsAddedCollectionEventNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsAddedCollectionEventNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsAddedCollectionEventNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + } + + public void testFireItemsAddedCollection() { + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireItemsAddedCollection(); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireItemsAddedCollection(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsAddedCollection(); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsAddedCollection(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + } + + public void testFireItemsAddedCollectionNoChange() { + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireItemsAddedCollectionNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireItemsAddedCollectionNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsAddedCollectionNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsAddedCollectionNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + } + + public void testFireItemAddedCollection() { + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireItemAddedCollection(); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireItemAddedCollection(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemAddedCollection(); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemAddedCollection(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + } + + public void testFireItemsRemovedCollectionEvent() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireItemsRemovedCollectionEvent(); + this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireItemsRemovedCollectionEvent(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsRemovedCollectionEvent(); + this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsRemovedCollectionEvent(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testFireItemsRemovedCollectionEventNoChange() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireItemsRemovedCollectionEventNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireItemsRemovedCollectionEventNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsRemovedCollectionEventNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsRemovedCollectionEventNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testFireItemsRemovedCollection() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireItemsRemovedCollection(); + this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireItemsRemovedCollection(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsRemovedCollection(); + this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsRemovedCollection(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testFireItemsRemovedCollectionNoChange() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireItemsRemovedCollectionNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireItemsRemovedCollectionNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsRemovedCollectionNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemsRemovedCollectionNoChange(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testFireItemRemovedCollection() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireItemRemovedCollection(); + this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireItemRemovedCollection(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemRemovedCollection(); + this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireItemRemovedCollection(); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testFireCollectionCleared() { + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireCollectionCleared(); + this.verifyCollectionChangeEvent(null); + assertTrue(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireCollectionCleared(); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireCollectionCleared(); + this.verifyCollectionChangeEvent(null); + assertTrue(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireCollectionCleared(); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionClearedCalled); + } + + public void testFireCollectionChangedEvent() { + this.collectionChangeEvent = null; + this.collectionChangedCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireCollectionChangedEvent(); + this.verifyCollectionChangeEvent(null); + assertTrue(this.collectionChangedCalled); + + this.collectionChangeEvent = null; + this.collectionChangedCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireCollectionChangedEvent(); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionChangedCalled); + + this.collectionChangeEvent = null; + this.collectionChangedCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireCollectionChangedEvent(); + this.verifyCollectionChangeEvent(null); + assertTrue(this.collectionChangedCalled); + + this.collectionChangeEvent = null; + this.collectionChangedCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireCollectionChangedEvent(); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionChangedCalled); + } + + public void testFireCollectionChanged() { + this.collectionChangeEvent = null; + this.collectionChangedCalled = false; + this.testModel.addCollectionChangeListener(this); + this.testModel.testFireCollectionChanged(); + this.verifyCollectionChangeEvent(null); + assertTrue(this.collectionChangedCalled); + + this.collectionChangeEvent = null; + this.collectionChangedCalled = false; + this.testModel.removeCollectionChangeListener(this); + this.testModel.testFireCollectionChanged(); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionChangedCalled); + + this.collectionChangeEvent = null; + this.collectionChangedCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireCollectionChanged(); + this.verifyCollectionChangeEvent(null); + assertTrue(this.collectionChangedCalled); + + this.collectionChangeEvent = null; + this.collectionChangedCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + this.testModel.testFireCollectionChanged(); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionChangedCalled); + } + + public void testAddItemToCollection() { + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertTrue(this.testModel.testAddItemToCollection()); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertTrue(this.testModel.testAddItemToCollection()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testAddItemToCollection()); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testAddItemToCollection()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + } + + public void testAddItemToCollectionNoChange() { + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertFalse(this.testModel.testAddItemToCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertFalse(this.testModel.testAddItemToCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testAddItemToCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testAddItemToCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + } + + public void testAddItemsToCollection() { + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertTrue(this.testModel.testAddItemsToCollection()); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertTrue(this.testModel.testAddItemsToCollection()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testAddItemsToCollection()); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testAddItemsToCollection()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + } + + public void testAddItemsToCollectionNoChange() { + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertFalse(this.testModel.testAddItemsToCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertFalse(this.testModel.testAddItemsToCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testAddItemsToCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testAddItemsToCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + } + + public void testAddItemsToCollectionMixed() { + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertTrue(this.testModel.testAddItemsToCollectionMixed()); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE_2); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertTrue(this.testModel.testAddItemsToCollectionMixed()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testAddItemsToCollectionMixed()); + this.verifyCollectionChangeEvent(ADDED_OBJECT_VALUE_2); + assertTrue(this.itemsAddedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsAddedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testAddItemsToCollectionMixed()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsAddedCollectionCalled); + } + + public void testRemoveItemFromCollection() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertTrue(this.testModel.testRemoveItemFromCollection()); + this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertTrue(this.testModel.testRemoveItemFromCollection()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testRemoveItemFromCollection()); + this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testRemoveItemFromCollection()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testRemoveItemFromCollectionNoChange() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertFalse(this.testModel.testRemoveItemFromCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertFalse(this.testModel.testRemoveItemFromCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRemoveItemFromCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRemoveItemFromCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testRemoveItemsFromCollection() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertTrue(this.testModel.testRemoveItemsFromCollection()); + this.verifyCollectionChangeEvent2(REMOVED_OBJECT_VALUE, "foo", "bar"); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertTrue(this.testModel.testRemoveItemsFromCollection()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testRemoveItemsFromCollection()); + this.verifyCollectionChangeEvent2(REMOVED_OBJECT_VALUE, "foo", "bar"); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testRemoveItemsFromCollection()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testRemoveItemsFromCollectionNoChange1() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange1()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange1()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange1()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange1()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testRemoveItemsFromCollectionNoChange2() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange2()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange2()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange2()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange2()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testRemoveItemsFromCollectionNoChange3() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange3()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange3()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange3()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange3()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testRetainItemsInCollection1() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertTrue(this.testModel.testRetainItemsInCollection1()); + this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertTrue(this.testModel.testRetainItemsInCollection1()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testRetainItemsInCollection1()); + this.verifyCollectionChangeEvent(REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testRetainItemsInCollection1()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + // collection cleared... + public void testRetainItemsInCollection2() { + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.addCollectionChangeListener(this); + assertTrue(this.testModel.testRetainItemsInCollection2()); + this.verifyCollectionChangeEvent(null); + assertTrue(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertTrue(this.testModel.testRetainItemsInCollection2()); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testRetainItemsInCollection2()); + this.verifyCollectionChangeEvent(null); + assertTrue(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testRetainItemsInCollection2()); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionClearedCalled); + } + + public void testRetainItemsInCollectionNoChange1() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertFalse(this.testModel.testRetainItemsInCollectionNoChange1()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertFalse(this.testModel.testRetainItemsInCollectionNoChange1()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRetainItemsInCollectionNoChange1()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRetainItemsInCollectionNoChange1()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testRetainItemsInCollectionNoChange2() { + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(this); + assertFalse(this.testModel.testRetainItemsInCollectionNoChange2()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertFalse(this.testModel.testRetainItemsInCollectionNoChange2()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRetainItemsInCollectionNoChange2()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + + this.collectionChangeEvent = null; + this.itemsRemovedCollectionCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testRetainItemsInCollectionNoChange2()); + assertNull(this.collectionChangeEvent); + assertFalse(this.itemsRemovedCollectionCalled); + } + + public void testClearCollection() { + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.addCollectionChangeListener(this); + assertTrue(this.testModel.testClearCollection()); + this.verifyCollectionChangeEvent(null); + assertTrue(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertTrue(this.testModel.testClearCollection()); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testClearCollection()); + this.verifyCollectionChangeEvent(null); + assertTrue(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.testClearCollection()); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionClearedCalled); + } + + public void testClearCollectionNoChange() { + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.addCollectionChangeListener(this); + assertFalse(this.testModel.testClearCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.removeCollectionChangeListener(this); + assertFalse(this.testModel.testClearCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testClearCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionClearedCalled); + + this.collectionChangeEvent = null; + this.collectionClearedCalled = false; + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertFalse(this.testModel.testClearCollectionNoChange()); + assertNull(this.collectionChangeEvent); + assertFalse(this.collectionClearedCalled); + } + + public void testSynchronizeCollection1() { + CollectionSynchListener csl = new CollectionSynchListener(); + this.testModel.addCollectionChangeListener(csl); + assertTrue(this.testModel.testSynchronizeCollection1()); + assertTrue(csl.itemsAdded); + assertTrue(csl.itemsRemoved); + assertFalse(csl.collectionChanged); + assertFalse(csl.collectionCleared); + assertEquals(2, csl.addedItems.size()); + assertTrue(CollectionTools.containsAll(csl.addedItems, new Object[] {"joo", "jar"})); + assertEquals(2, csl.removedItems.size()); + assertTrue(CollectionTools.containsAll(csl.removedItems, new Object[] {"foo", "bar"})); + } + + public void testSynchronizeCollection2() { + CollectionSynchListener csl = new CollectionSynchListener(); + this.testModel.addCollectionChangeListener(csl); + assertTrue(this.testModel.testSynchronizeCollection2()); + assertFalse(csl.itemsAdded); + assertFalse(csl.itemsRemoved); + assertFalse(csl.collectionChanged); + assertTrue(csl.collectionCleared); + assertTrue(csl.addedItems.isEmpty()); + assertTrue(csl.removedItems.isEmpty()); + } + + public void testSynchronizeCollection3() { + CollectionSynchListener csl = new CollectionSynchListener(); + this.testModel.addCollectionChangeListener(csl); + assertTrue(this.testModel.testSynchronizeCollection3()); + assertTrue(csl.itemsAdded); + assertFalse(csl.itemsRemoved); + assertFalse(csl.collectionChanged); + assertFalse(csl.collectionCleared); + assertEquals(3, csl.addedItems.size()); + assertTrue(CollectionTools.containsAll(csl.addedItems, new Object[] {"joo", "jar", "baz"})); + assertTrue(csl.removedItems.isEmpty()); + } + + class CollectionSynchListener implements CollectionChangeListener { + boolean itemsAdded = false; + boolean itemsRemoved = false; + boolean collectionChanged = false; + boolean collectionCleared = false; + Collection addedItems = new ArrayList(); + Collection removedItems = new ArrayList(); + public void collectionChanged(CollectionChangeEvent event) { + this.collectionChanged = true; + } + public void collectionCleared(CollectionChangeEvent event) { + this.collectionCleared = true; + } + public void itemsAdded(CollectionChangeEvent event) { + this.itemsAdded = true; + CollectionTools.addAll(this.addedItems, event.items()); + } + public void itemsRemoved(CollectionChangeEvent event) { + this.itemsRemoved = true; + CollectionTools.addAll(this.removedItems, event.items()); + } + } + + public void testHasAnyCollectionChangeListeners() { + assertTrue(this.testModel.hasNoCollectionChangeListeners(COLLECTION_NAME)); + this.testModel.addCollectionChangeListener(this); + assertTrue(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME)); + this.testModel.removeCollectionChangeListener(this); + assertTrue(this.testModel.hasNoCollectionChangeListeners(COLLECTION_NAME)); + + assertTrue(this.testModel.hasNoCollectionChangeListeners(COLLECTION_NAME)); + this.testModel.addCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME)); + this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this); + assertTrue(this.testModel.hasNoCollectionChangeListeners(COLLECTION_NAME)); + } + + public void testAddNullCollectionListener() { + boolean exCaught = false; + try { + this.testModel.addCollectionChangeListener(null); + } catch (NullPointerException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testAddNullCollectionListenerName() { + boolean exCaught = false; + try { + this.testModel.addCollectionChangeListener("foo", null); + } catch (NullPointerException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testRemoveBogusCollectionListener() { + boolean exCaught = false; + try { + this.testModel.removeCollectionChangeListener(this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addPropertyChangeListener(this); + exCaught = false; + try { + this.testModel.removeCollectionChangeListener(this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addCollectionChangeListener(this); + exCaught = false; + try { + this.testModel.removeCollectionChangeListener(new ChangeSupportTests("dummy")); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + exCaught = false; + try { + this.testModel.removeCollectionChangeListener(new CollectionChangeAdapter()); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testRemoveBogusCollectionListenerName() { + boolean exCaught = false; + try { + this.testModel.removeCollectionChangeListener("foo", this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addPropertyChangeListener("foo", this); + exCaught = false; + try { + this.testModel.removeCollectionChangeListener("foo", this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addCollectionChangeListener("foo", this); + exCaught = false; + try { + this.testModel.removeCollectionChangeListener("foo", new ChangeSupportTests("dummy")); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + exCaught = false; + try { + this.testModel.removeCollectionChangeListener("foo", new CollectionChangeAdapter()); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + private void verifyCollectionChangeEvent(Object item) { + assertNotNull(this.collectionChangeEvent); + assertEquals(this.testModel, this.collectionChangeEvent.getSource()); + assertEquals(COLLECTION_NAME, this.collectionChangeEvent.getCollectionName()); + if (item == null) { + assertFalse(this.collectionChangeEvent.items().hasNext()); + } else { + assertEquals(item, this.collectionChangeEvent.items().next()); + } + } + + private void verifyCollectionChangeEvent2(Object... items) { + assertNotNull(this.collectionChangeEvent); + assertEquals(this.testModel, this.collectionChangeEvent.getSource()); + assertEquals(COLLECTION_NAME, this.collectionChangeEvent.getCollectionName()); + assertEquals(items.length, this.collectionChangeEvent.itemsSize()); + for (Object item : items) { + assertTrue(CollectionTools.contains(this.collectionChangeEvent.items(), item)); + } + } + + + // ********** list change tests ********** + + public void testFireItemsAddedListEvent() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsAddedListEvent(); + this.verifyListChangeEvent(ADD_INDEX, ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsAddedListEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsAddedListEvent(); + this.verifyListChangeEvent(ADD_INDEX, ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsAddedListEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + + public void testFireItemsAddedListEventNoChange() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsAddedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsAddedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsAddedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsAddedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + + public void testFireItemsAddedList() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsAddedList(); + this.verifyListChangeEvent(ADD_INDEX, ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsAddedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsAddedList(); + this.verifyListChangeEvent(ADD_INDEX, ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsAddedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + + public void testFireItemsAddedListNoChange() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsAddedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsAddedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsAddedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsAddedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + + public void testFireItemAddedList() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemAddedList(); + this.verifyListChangeEvent(ADD_INDEX, ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemAddedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemAddedList(); + this.verifyListChangeEvent(ADD_INDEX, ADDED_OBJECT_VALUE); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemAddedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + + public void testFireItemsRemovedListEvent() { + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsRemovedListEvent(); + this.verifyListChangeEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsRemovedListEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsRemovedListEvent(); + this.verifyListChangeEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsRemovedListEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + } + + public void testFireItemsRemovedListEventNoChange() { + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsRemovedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsRemovedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsRemovedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsRemovedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + } + + public void testFireItemsRemovedList() { + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsRemovedList(); + this.verifyListChangeEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsRemovedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsRemovedList(); + this.verifyListChangeEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsRemovedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + } + + public void testFireItemsRemovedListNoChange() { + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsRemovedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsRemovedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsRemovedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsRemovedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + } + + public void testFireItemRemovedList() { + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemRemovedList(); + this.verifyListChangeEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemRemovedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemRemovedList(); + this.verifyListChangeEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsRemovedListCalled); + + this.listChangeEvent = null; + this.itemsRemovedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemRemovedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsRemovedListCalled); + } + + public void testFireItemsReplacedListEvent() { + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsReplacedListEvent(); + this.verifyListChangeEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsReplacedListEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsReplacedListEvent(); + this.verifyListChangeEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsReplacedListEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + } + + public void testFireItemsReplacedListEventNoChange() { + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsReplacedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsReplacedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsReplacedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsReplacedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + } + + public void testFireItemsReplacedList() { + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsReplacedList(); + this.verifyListChangeEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsReplacedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsReplacedList(); + this.verifyListChangeEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsReplacedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + } + + public void testFireItemsReplacedListNoChange() { + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsReplacedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsReplacedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsReplacedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsReplacedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + } + + public void testFireItemReplacedList() { + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemReplacedList(); + this.verifyListChangeEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemReplacedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemReplacedList(); + this.verifyListChangeEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE); + assertTrue(this.itemsReplacedListCalled); + + this.listChangeEvent = null; + this.itemsReplacedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemReplacedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsReplacedListCalled); + } + + public void testFireItemsMovedListEvent() { + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsMovedListEvent(); + this.verifyListChangeEvent(TARGET_INDEX, SOURCE_INDEX); + assertTrue(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsMovedListEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsMovedListEvent(); + this.verifyListChangeEvent(TARGET_INDEX, SOURCE_INDEX); + assertTrue(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsMovedListEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + } + + public void testFireItemsMovedListEventNoChange() { + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsMovedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsMovedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsMovedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsMovedListEventNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + } + + public void testFireItemsMovedList() { + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsMovedList(); + this.verifyListChangeEvent(TARGET_INDEX, SOURCE_INDEX); + assertTrue(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsMovedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsMovedList(); + this.verifyListChangeEvent(TARGET_INDEX, SOURCE_INDEX); + assertTrue(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsMovedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + } + + public void testFireItemsMovedListNoChange() { + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemsMovedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemsMovedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsMovedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemsMovedListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + } + + public void testFireItemMovedList() { + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireItemMovedList(); + this.verifyListChangeEvent(TARGET_INDEX, SOURCE_INDEX); + assertTrue(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireItemMovedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireItemMovedList(); + this.verifyListChangeEvent(TARGET_INDEX, SOURCE_INDEX); + assertTrue(this.itemsMovedListCalled); + + this.listChangeEvent = null; + this.itemsMovedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireItemMovedList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsMovedListCalled); + } + + public void testFireListClearedEvent() { + this.listChangeEvent = null; + this.listClearedCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireListClearedEvent(); + this.verifyListChangeEvent(-1, null); + assertTrue(this.listClearedCalled); + + this.listChangeEvent = null; + this.listClearedCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireListClearedEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.listClearedCalled); + + this.listChangeEvent = null; + this.listClearedCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireListClearedEvent(); + this.verifyListChangeEvent(-1, null); + assertTrue(this.listClearedCalled); + + this.listChangeEvent = null; + this.listClearedCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireListClearedEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.listClearedCalled); + } + + public void testFireListCleared() { + this.listChangeEvent = null; + this.listClearedCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireListCleared(); + this.verifyListChangeEvent(-1, null); + assertTrue(this.listClearedCalled); + + this.listChangeEvent = null; + this.listClearedCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireListCleared(); + assertNull(this.listChangeEvent); + assertFalse(this.listClearedCalled); + + this.listChangeEvent = null; + this.listClearedCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireListCleared(); + this.verifyListChangeEvent(-1, null); + assertTrue(this.listClearedCalled); + + this.listChangeEvent = null; + this.listClearedCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireListCleared(); + assertNull(this.listChangeEvent); + assertFalse(this.listClearedCalled); + } + + public void testFireListChangedEvent() { + this.listChangeEvent = null; + this.listChangedCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireListChangedEvent(); + this.verifyListChangeEvent(-1, null); + assertTrue(this.listChangedCalled); + + this.listChangeEvent = null; + this.listChangedCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireListChangedEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.listChangedCalled); + + this.listChangeEvent = null; + this.listChangedCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireListChangedEvent(); + this.verifyListChangeEvent(-1, null); + assertTrue(this.listChangedCalled); + + this.listChangeEvent = null; + this.listChangedCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireListChangedEvent(); + assertNull(this.listChangeEvent); + assertFalse(this.listChangedCalled); + } + + public void testFireListChanged() { + this.listChangeEvent = null; + this.listChangedCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testFireListChanged(); + this.verifyListChangeEvent(-1, null); + assertTrue(this.listChangedCalled); + + this.listChangeEvent = null; + this.listChangedCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testFireListChanged(); + assertNull(this.listChangeEvent); + assertFalse(this.listChangedCalled); + + this.listChangeEvent = null; + this.listChangedCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testFireListChanged(); + this.verifyListChangeEvent(-1, null); + assertTrue(this.listChangedCalled); + + this.listChangeEvent = null; + this.listChangedCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testFireListChanged(); + assertNull(this.listChangeEvent); + assertFalse(this.listChangedCalled); + } + + public void testAddItemToListIndex() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testAddItemToListIndex(); + this.verifyListChangeEvent(2, "joo"); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testAddItemToListIndex(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testAddItemToListIndex(); + this.verifyListChangeEvent(2, "joo"); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testAddItemToListIndex(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + + public void testAddItemToList() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testAddItemToList(); + this.verifyListChangeEvent(3, "joo"); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testAddItemToList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testAddItemToList(); + this.verifyListChangeEvent(3, "joo"); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testAddItemToList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + + public void testAddItemsToListIndex() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testAddItemsToListIndex(); + this.verifyListChangeEvent(2, "joo"); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testAddItemsToListIndex(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testAddItemsToListIndex(); + this.verifyListChangeEvent(2, "joo"); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testAddItemsToListIndex(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + + public void testAddItemsToListIndexNoChange() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testAddItemsToListIndexNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testAddItemsToListIndexNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testAddItemsToListIndexNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testAddItemsToListIndexNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + + public void testAddItemsToList() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testAddItemsToList(); + this.verifyListChangeEvent(3, "joo"); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testAddItemsToList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testAddItemsToList(); + this.verifyListChangeEvent(3, "joo"); + assertTrue(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testAddItemsToList(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + + public void testAddItemsToListNoChange() { + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(this); + this.testModel.testAddItemsToListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(this); + this.testModel.testAddItemsToListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.addListChangeListener(LIST_NAME, this); + this.testModel.testAddItemsToListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + + this.listChangeEvent = null; + this.itemsAddedListCalled = false; + this.testModel.removeListChangeListener(LIST_NAME, this); + this.testModel.testAddItemsToListNoChange(); + assertNull(this.listChangeEvent); + assertFalse(this.itemsAddedListCalled); + } + +// TODO remove +// TODO retain +// TODO replace +// TODO set +// TODO move +// TODO clear +// TODO synchronize + + public void testHasAnyListChangeListeners() { + assertTrue(this.testModel.hasNoListChangeListeners(LIST_NAME)); + this.testModel.addListChangeListener(this); + assertTrue(this.testModel.hasAnyListChangeListeners(LIST_NAME)); + this.testModel.removeListChangeListener(this); + assertTrue(this.testModel.hasNoListChangeListeners(LIST_NAME)); + + assertTrue(this.testModel.hasNoListChangeListeners(LIST_NAME)); + this.testModel.addListChangeListener(LIST_NAME, this); + assertTrue(this.testModel.hasAnyListChangeListeners(LIST_NAME)); + this.testModel.removeListChangeListener(LIST_NAME, this); + assertTrue(this.testModel.hasNoListChangeListeners(LIST_NAME)); + } + + public void testAddNullListListener() { + boolean exCaught = false; + try { + this.testModel.addListChangeListener(null); + } catch (NullPointerException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testAddNullListListenerName() { + boolean exCaught = false; + try { + this.testModel.addListChangeListener("foo", null); + } catch (NullPointerException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testRemoveBogusListListener() { + boolean exCaught = false; + try { + this.testModel.removeListChangeListener(this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addPropertyChangeListener(this); + exCaught = false; + try { + this.testModel.removeListChangeListener(this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addListChangeListener(this); + exCaught = false; + try { + this.testModel.removeListChangeListener(new ChangeSupportTests("dummy")); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + exCaught = false; + try { + this.testModel.removeListChangeListener(new ListChangeAdapter()); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testRemoveBogusListListenerName() { + boolean exCaught = false; + try { + this.testModel.removeListChangeListener("foo", this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addPropertyChangeListener("foo", this); + exCaught = false; + try { + this.testModel.removeListChangeListener("foo", this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addListChangeListener("foo", this); + exCaught = false; + try { + this.testModel.removeListChangeListener("foo", new ChangeSupportTests("dummy")); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + exCaught = false; + try { + this.testModel.removeListChangeListener("foo", new ListChangeAdapter()); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + private void verifyListChangeEvent(int index, Object item) { + this.verifyListChangeEvent(index, item, null); + } + + private void verifyListChangeEvent(int targetIndex, int sourceIndex) { + assertNotNull(this.listChangeEvent); + assertEquals(this.testModel, this.listChangeEvent.getSource()); + assertEquals(LIST_NAME, this.listChangeEvent.getListName()); + assertEquals(targetIndex, this.listChangeEvent.getTargetIndex()); + assertEquals(sourceIndex, this.listChangeEvent.getSourceIndex()); + } + + private void verifyListChangeEvent(int index, Object item, Object replacedItem) { + assertNotNull(this.listChangeEvent); + assertEquals(this.testModel, this.listChangeEvent.getSource()); + assertEquals(LIST_NAME, this.listChangeEvent.getListName()); + assertEquals(index, this.listChangeEvent.getIndex()); + if (item == null) { + assertFalse(this.listChangeEvent.items().hasNext()); + } else { + assertEquals(item, this.listChangeEvent.items().next()); + } + if (replacedItem == null) { + assertFalse(this.listChangeEvent.replacedItems().hasNext()); + } else { + assertEquals(replacedItem, this.listChangeEvent.replacedItems().next()); + } + } + + + // ********** tree change tests ********** + + public void testFireNodeAddedTree() { + this.treeChangeEvent = null; + this.nodeAddedCalled = false; + this.testModel.addTreeChangeListener(this); + this.testModel.testFireNodeAddedTree(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.nodeAddedCalled); + + this.treeChangeEvent = null; + this.nodeAddedCalled = false; + this.testModel.removeTreeChangeListener(this); + this.testModel.testFireNodeAddedTree(); + assertNull(this.treeChangeEvent); + assertFalse(this.nodeAddedCalled); + + this.treeChangeEvent = null; + this.nodeAddedCalled = false; + this.testModel.addTreeChangeListener(TREE_NAME, this); + this.testModel.testFireNodeAddedTree(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.nodeAddedCalled); + + this.treeChangeEvent = null; + this.nodeAddedCalled = false; + this.testModel.removeTreeChangeListener(TREE_NAME, this); + this.testModel.testFireNodeAddedTree(); + assertNull(this.treeChangeEvent); + assertFalse(this.nodeAddedCalled); + } + + public void testFireNodeAddedTreeEvent() { + this.treeChangeEvent = null; + this.nodeAddedCalled = false; + this.testModel.addTreeChangeListener(this); + this.testModel.testFireNodeAddedTreeEvent(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.nodeAddedCalled); + + this.treeChangeEvent = null; + this.nodeAddedCalled = false; + this.testModel.removeTreeChangeListener(this); + this.testModel.testFireNodeAddedTreeEvent(); + assertNull(this.treeChangeEvent); + assertFalse(this.nodeAddedCalled); + + this.treeChangeEvent = null; + this.nodeAddedCalled = false; + this.testModel.addTreeChangeListener(TREE_NAME, this); + this.testModel.testFireNodeAddedTreeEvent(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.nodeAddedCalled); + + this.treeChangeEvent = null; + this.nodeAddedCalled = false; + this.testModel.removeTreeChangeListener(TREE_NAME, this); + this.testModel.testFireNodeAddedTreeEvent(); + assertNull(this.treeChangeEvent); + assertFalse(this.nodeAddedCalled); + } + + public void testFireNodeRemovedTreeEvent() { + this.treeChangeEvent = null; + this.nodeRemovedCalled = false; + this.testModel.addTreeChangeListener(this); + this.testModel.testFireNodeRemovedTreeEvent(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.nodeRemovedCalled); + + this.treeChangeEvent = null; + this.nodeRemovedCalled = false; + this.testModel.removeTreeChangeListener(this); + this.testModel.testFireNodeRemovedTreeEvent(); + assertNull(this.treeChangeEvent); + assertFalse(this.nodeRemovedCalled); + + this.treeChangeEvent = null; + this.nodeRemovedCalled = false; + this.testModel.addTreeChangeListener(TREE_NAME, this); + this.testModel.testFireNodeRemovedTreeEvent(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.nodeRemovedCalled); + + this.treeChangeEvent = null; + this.nodeRemovedCalled = false; + this.testModel.removeTreeChangeListener(TREE_NAME, this); + this.testModel.testFireNodeRemovedTreeEvent(); + assertNull(this.treeChangeEvent); + assertFalse(this.nodeRemovedCalled); + } + + public void testFireNodeRemovedTree() { + this.treeChangeEvent = null; + this.nodeRemovedCalled = false; + this.testModel.addTreeChangeListener(this); + this.testModel.testFireNodeRemovedTree(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.nodeRemovedCalled); + + this.treeChangeEvent = null; + this.nodeRemovedCalled = false; + this.testModel.removeTreeChangeListener(this); + this.testModel.testFireNodeRemovedTree(); + assertNull(this.treeChangeEvent); + assertFalse(this.nodeRemovedCalled); + + this.treeChangeEvent = null; + this.nodeRemovedCalled = false; + this.testModel.addTreeChangeListener(TREE_NAME, this); + this.testModel.testFireNodeRemovedTree(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.nodeRemovedCalled); + + this.treeChangeEvent = null; + this.nodeRemovedCalled = false; + this.testModel.removeTreeChangeListener(TREE_NAME, this); + this.testModel.testFireNodeRemovedTree(); + assertNull(this.treeChangeEvent); + assertFalse(this.nodeRemovedCalled); + } + + public void testFireTreeClearedEvent() { + this.treeChangeEvent = null; + this.treeClearedCalled = false; + this.testModel.addTreeChangeListener(this); + this.testModel.testFireTreeClearedEvent(); + this.verifyTreeChangeEvent(EMPTY_PATH); + assertTrue(this.treeClearedCalled); + + this.treeChangeEvent = null; + this.treeClearedCalled = false; + this.testModel.removeTreeChangeListener(this); + this.testModel.testFireTreeClearedEvent(); + assertNull(this.treeChangeEvent); + assertFalse(this.treeClearedCalled); + + this.treeChangeEvent = null; + this.treeClearedCalled = false; + this.testModel.addTreeChangeListener(TREE_NAME, this); + this.testModel.testFireTreeClearedEvent(); + this.verifyTreeChangeEvent(EMPTY_PATH); + assertTrue(this.treeClearedCalled); + + this.treeChangeEvent = null; + this.treeClearedCalled = false; + this.testModel.removeTreeChangeListener(TREE_NAME, this); + this.testModel.testFireTreeClearedEvent(); + assertNull(this.treeChangeEvent); + assertFalse(this.treeClearedCalled); + } + + public void testFireTreeCleared() { + this.treeChangeEvent = null; + this.treeClearedCalled = false; + this.testModel.addTreeChangeListener(this); + this.testModel.testFireTreeCleared(); + this.verifyTreeChangeEvent(EMPTY_PATH); + assertTrue(this.treeClearedCalled); + + this.treeChangeEvent = null; + this.treeClearedCalled = false; + this.testModel.removeTreeChangeListener(this); + this.testModel.testFireTreeCleared(); + assertNull(this.treeChangeEvent); + assertFalse(this.treeClearedCalled); + + this.treeChangeEvent = null; + this.treeClearedCalled = false; + this.testModel.addTreeChangeListener(TREE_NAME, this); + this.testModel.testFireTreeCleared(); + this.verifyTreeChangeEvent(EMPTY_PATH); + assertTrue(this.treeClearedCalled); + + this.treeChangeEvent = null; + this.treeClearedCalled = false; + this.testModel.removeTreeChangeListener(TREE_NAME, this); + this.testModel.testFireTreeCleared(); + assertNull(this.treeChangeEvent); + assertFalse(this.treeClearedCalled); + } + + public void testFireTreeChangedEvent() { + this.treeChangeEvent = null; + this.treeChangedCalled = false; + this.testModel.addTreeChangeListener(this); + this.testModel.testFireTreeChangedEvent(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.treeChangedCalled); + + this.treeChangeEvent = null; + this.treeChangedCalled = false; + this.testModel.removeTreeChangeListener(this); + this.testModel.testFireTreeChangedEvent(); + assertNull(this.treeChangeEvent); + assertFalse(this.treeChangedCalled); + + this.treeChangeEvent = null; + this.treeChangedCalled = false; + this.testModel.addTreeChangeListener(TREE_NAME, this); + this.testModel.testFireTreeChangedEvent(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.treeChangedCalled); + + this.treeChangeEvent = null; + this.treeChangedCalled = false; + this.testModel.removeTreeChangeListener(TREE_NAME, this); + this.testModel.testFireTreeChangedEvent(); + assertNull(this.treeChangeEvent); + assertFalse(this.treeChangedCalled); + } + + public void testFireTreeChanged() { + this.treeChangeEvent = null; + this.treeChangedCalled = false; + this.testModel.addTreeChangeListener(this); + this.testModel.testFireTreeChanged(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.treeChangedCalled); + + this.treeChangeEvent = null; + this.treeChangedCalled = false; + this.testModel.removeTreeChangeListener(this); + this.testModel.testFireTreeChanged(); + assertNull(this.treeChangeEvent); + assertFalse(this.treeChangedCalled); + + this.treeChangeEvent = null; + this.treeChangedCalled = false; + this.testModel.addTreeChangeListener(TREE_NAME, this); + this.testModel.testFireTreeChanged(); + this.verifyTreeChangeEvent(OBJECT_ARRAY_PATH); + assertTrue(this.treeChangedCalled); + + this.treeChangeEvent = null; + this.treeChangedCalled = false; + this.testModel.removeTreeChangeListener(TREE_NAME, this); + this.testModel.testFireTreeChanged(); + assertNull(this.treeChangeEvent); + assertFalse(this.treeChangedCalled); + } + + public void testHasAnyTreeChangeListeners() { + assertTrue(this.testModel.hasNoTreeChangeListeners(TREE_NAME)); + this.testModel.addTreeChangeListener(this); + assertTrue(this.testModel.hasAnyTreeChangeListeners(TREE_NAME)); + this.testModel.removeTreeChangeListener(this); + assertTrue(this.testModel.hasNoTreeChangeListeners(TREE_NAME)); + + assertTrue(this.testModel.hasNoTreeChangeListeners(TREE_NAME)); + this.testModel.addTreeChangeListener(TREE_NAME, this); + assertTrue(this.testModel.hasAnyTreeChangeListeners(TREE_NAME)); + this.testModel.removeTreeChangeListener(TREE_NAME, this); + assertTrue(this.testModel.hasNoTreeChangeListeners(TREE_NAME)); + } + + public void testAddNullTreeListener() { + boolean exCaught = false; + try { + this.testModel.addTreeChangeListener(null); + } catch (NullPointerException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testAddNullTreeListenerName() { + boolean exCaught = false; + try { + this.testModel.addTreeChangeListener("foo", null); + } catch (NullPointerException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testRemoveBogusTreeListener() { + boolean exCaught = false; + try { + this.testModel.removeTreeChangeListener(this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addPropertyChangeListener(this); + exCaught = false; + try { + this.testModel.removeTreeChangeListener(this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addTreeChangeListener(this); + exCaught = false; + try { + this.testModel.removeTreeChangeListener(new ChangeSupportTests("dummy")); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + exCaught = false; + try { + this.testModel.removeTreeChangeListener(new TreeChangeAdapter()); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + public void testRemoveBogusTreeListenerName() { + boolean exCaught = false; + try { + this.testModel.removeTreeChangeListener("foo", this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addPropertyChangeListener("foo", this); + exCaught = false; + try { + this.testModel.removeTreeChangeListener("foo", this); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + this.testModel.addTreeChangeListener("foo", this); + exCaught = false; + try { + this.testModel.removeTreeChangeListener("foo", new ChangeSupportTests("dummy")); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + + exCaught = false; + try { + this.testModel.removeTreeChangeListener("foo", new TreeChangeAdapter()); + } catch (IllegalArgumentException ex) { + exCaught = true; + } + assertTrue(exCaught); + } + + private void verifyTreeChangeEvent(Object[] path) { + assertNotNull(this.treeChangeEvent); + assertEquals(this.testModel, this.treeChangeEvent.getSource()); + assertEquals(TREE_NAME, this.treeChangeEvent.getTreeName()); + assertTrue(Arrays.equals(path, this.treeChangeEvent.getPath())); + } + + + // ********** convenience method tests ********** + + public void testElementsAreEqual() { + Collection c1 = new ArrayList(); + c1.add("foo"); + c1.add("bar"); + c1.add("baz"); + Collection c2 = new ArrayList(); + c2.add("foo"); + c2.add("bar"); + c2.add("baz"); + assertTrue(this.testModel.testElementsAreEqual(c1.iterator(), c2.iterator())); + } + + public void testElementsAreDifferent() { + Collection c1 = new ArrayList(); + c1.add("foo"); + c1.add("bar"); + c1.add("baz"); + Collection c2 = new ArrayList(); + c2.add("baz"); + c2.add("bar"); + c2.add("foo"); + assertTrue(this.testModel.testElementsAreDifferent(c1.iterator(), c2.iterator())); + } + + + // ********** AbstractModel tests ********** + + public void testAbstractModelValuesAreEqual1() { + assertTrue(this.testModel.testValuesAreEqual(null, null)); + } + + public void testAbstractModelValuesAreEqual2() { + assertTrue(this.testModel.testValuesAreEqual("foo", "foo")); + } + + public void testAbstractModelValuesAreEqual3() { + assertFalse(this.testModel.testValuesAreEqual("foo", null)); + } + + public void testAbstractModelValuesAreEqual4() { + assertFalse(this.testModel.testValuesAreEqual(null, "foo")); + } + + public void testAbstractModelValuesAreEqual5() { + assertFalse(this.testModel.testValuesAreEqual("bar", "foo")); + } + + public void testAbstractModelValuesAreDifferent1() { + assertFalse(this.testModel.testValuesAreDifferent(null, null)); + } + + public void testAbstractModelValuesAreDifferent2() { + assertFalse(this.testModel.testValuesAreDifferent("foo", "foo")); + } + + public void testAbstractModelValuesAreDifferent3() { + assertTrue(this.testModel.testValuesAreDifferent("foo", null)); + } + + public void testAbstractModelValuesAreDifferent4() { + assertTrue(this.testModel.testValuesAreDifferent(null, "foo")); + } + + public void testAbstractModelValuesAreDifferent5() { + assertTrue(this.testModel.testValuesAreDifferent("bar", "foo")); + } + + public void testAbstractModelAttributeValueHasChanged1() { + assertFalse(this.testModel.testAttributeValueHasChanged(null, null)); + } + + public void testAbstractModelAttributeValueHasChanged2() { + assertFalse(this.testModel.testAttributeValueHasChanged("foo", "foo")); + } + + public void testAbstractModelAttributeValueHasChanged3() { + assertTrue(this.testModel.testAttributeValueHasChanged("foo", null)); + } + + public void testAbstractModelAttributeValueHasChanged4() { + assertTrue(this.testModel.testAttributeValueHasChanged(null, "foo")); + } + + public void testAbstractModelAttributeValueHasChanged5() { + assertTrue(this.testModel.testAttributeValueHasChanged("bar", "foo")); + } + + public void testAbstractModelAttributeValueHasNotChanged1() { + assertTrue(this.testModel.testAttributeValueHasNotChanged(null, null)); + } + + public void testAbstractModelAttributeValueHasNotChanged2() { + assertTrue(this.testModel.testAttributeValueHasNotChanged("foo", "foo")); + } + + public void testAbstractModelAttributeValueHasNotChanged3() { + assertFalse(this.testModel.testAttributeValueHasNotChanged("foo", null)); + } + + public void testAbstractModelAttributeValueHasNotChanged4() { + assertFalse(this.testModel.testAttributeValueHasNotChanged(null, "foo")); + } + + public void testAbstractModelAttributeValueHasNotChanged5() { + assertFalse(this.testModel.testAttributeValueHasNotChanged("bar", "foo")); + } + + public void testAbstractModelClone() { + assertFalse(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); + this.testModel.addPropertyChangeListener(this); + assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); + + // verify that the clone does not have any listeners + TestModel clone = this.testModel.clone(); + assertFalse(clone.hasAnyPropertyChangeListeners(PROPERTY_NAME)); + clone.addPropertyChangeListener(this); + assertTrue(clone.hasAnyPropertyChangeListeners(PROPERTY_NAME)); + // check original + assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME)); + + // now test events fired by original + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + this.testModel.testFirePropertyChangedObjectObject(); + this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); + assertTrue(this.propertyChangeCalled); + + // now test events fired by clone + this.propertyChangeEvent = null; + this.propertyChangeCalled = false; + clone.testFirePropertyChangedObjectObject(); + this.verifyPropertyChangeEvent(clone, OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); + assertTrue(this.propertyChangeCalled); + } + + public void testAbstractModelToString() { + assertTrue(this.testModel.toString().contains('(' + TEST_TO_STRING + ')')); + } + + + // ********** listener implementations ********** + + public void stateChanged(StateChangeEvent e) { + this.stateChangedCalled = true; + this.stateChangeEvent = e; + } + + public void propertyChanged(PropertyChangeEvent e) { + this.propertyChangeCalled = true; + this.propertyChangeEvent = e; + } + + public void itemsAdded(CollectionChangeEvent e) { + this.itemsAddedCollectionCalled = true; + this.collectionChangeEvent = e; + } + public void itemsRemoved(CollectionChangeEvent e) { + this.itemsRemovedCollectionCalled = true; + this.collectionChangeEvent = e; + } + public void collectionCleared(CollectionChangeEvent e) { + this.collectionClearedCalled = true; + this.collectionChangeEvent = e; + } + public void collectionChanged(CollectionChangeEvent e) { + this.collectionChangedCalled = true; + this.collectionChangeEvent = e; + } + + public void itemsAdded(ListChangeEvent e) { + this.itemsAddedListCalled = true; + this.listChangeEvent = e; + } + public void itemsRemoved(ListChangeEvent e) { + this.itemsRemovedListCalled = true; + this.listChangeEvent = e; + } + public void itemsReplaced(ListChangeEvent e) { + this.itemsReplacedListCalled = true; + this.listChangeEvent = e; + } + public void itemsMoved(ListChangeEvent e) { + this.itemsMovedListCalled = true; + this.listChangeEvent = e; + } + public void listCleared(ListChangeEvent e) { + this.listClearedCalled = true; + this.listChangeEvent = e; + } + public void listChanged(ListChangeEvent e) { + this.listChangedCalled = true; + this.listChangeEvent = e; + } + + public void nodeAdded(TreeChangeEvent e) { + this.nodeAddedCalled = true; + this.treeChangeEvent = e; + } + public void nodeRemoved(TreeChangeEvent e) { + this.nodeRemovedCalled = true; + this.treeChangeEvent = e; + } + public void treeCleared(TreeChangeEvent e) { + this.treeClearedCalled = true; + this.treeChangeEvent = e; + } + public void treeChanged(TreeChangeEvent e) { + this.treeChangedCalled = true; + this.treeChangeEvent = e; + } + + + // ********** inner class ********** + + private static class TestModel extends AbstractModel implements Cloneable { + TestModel() { + super(); + } + + // ***** state + public void testFireStateChange() { + this.fireStateChanged(); + } + + // ***** property + public void testFirePropertyChangedEvent() { + this.firePropertyChanged(new PropertyChangeEvent(this, PROPERTY_NAME, OLD_OBJECT_VALUE, NEW_OBJECT_VALUE)); + } + + public void testFirePropertyChangedEventNoChange() { + this.firePropertyChanged(new PropertyChangeEvent(this, PROPERTY_NAME, OLD_OBJECT_VALUE, OLD_OBJECT_VALUE)); + } + + public void testFirePropertyChangedObjectObject() { + this.firePropertyChanged(PROPERTY_NAME, OLD_OBJECT_VALUE, NEW_OBJECT_VALUE); + } + + public void testFirePropertyChangedObjectObjectNoChange() { + this.firePropertyChanged(PROPERTY_NAME, OLD_OBJECT_VALUE, OLD_OBJECT_VALUE); + } + + public void testFirePropertyChangedObject() { + this.firePropertyChanged(PROPERTY_NAME, NEW_OBJECT_VALUE); + } + + public void testFirePropertyChangedObjectNoChange() { + this.firePropertyChanged(PROPERTY_NAME, null); + } + + public void testFirePropertyChangedIntInt() { + this.firePropertyChanged(PROPERTY_NAME, OLD_INT_VALUE.intValue(), NEW_INT_VALUE.intValue()); + } + + public void testFirePropertyChangedIntIntNoChange() { + this.firePropertyChanged(PROPERTY_NAME, OLD_INT_VALUE.intValue(), OLD_INT_VALUE.intValue()); + } + + public void testFirePropertyChangedBooleanBoolean() { + this.firePropertyChanged(PROPERTY_NAME, OLD_BOOLEAN_VALUE.booleanValue(), NEW_BOOLEAN_VALUE.booleanValue()); + } + + public void testFirePropertyChangedBooleanBooleanNoChange() { + this.firePropertyChanged(PROPERTY_NAME, OLD_BOOLEAN_VALUE.booleanValue(), OLD_BOOLEAN_VALUE.booleanValue()); + } + + // ***** collection + public void testFireItemsAddedCollectionEvent() { + this.fireItemsAdded(new CollectionChangeEvent(this, COLLECTION_NAME, Collections.singleton(ADDED_OBJECT_VALUE))); + } + + public void testFireItemsAddedCollectionEventNoChange() { + this.fireItemsAdded(new CollectionChangeEvent(this, COLLECTION_NAME, Collections.emptySet())); + } + + public void testFireItemsAddedCollection() { + this.fireItemsAdded(COLLECTION_NAME, Collections.singleton(ADDED_OBJECT_VALUE)); + } + + public void testFireItemsAddedCollectionNoChange() { + this.fireItemsAdded(COLLECTION_NAME, Collections.emptySet()); + } + + public void testFireItemAddedCollection() { + this.fireItemAdded(COLLECTION_NAME, ADDED_OBJECT_VALUE); + } + + public void testFireItemsRemovedCollectionEvent() { + this.fireItemsRemoved(new CollectionChangeEvent(this, COLLECTION_NAME, Collections.singleton(REMOVED_OBJECT_VALUE))); + } + + public void testFireItemsRemovedCollectionEventNoChange() { + this.fireItemsRemoved(new CollectionChangeEvent(this, COLLECTION_NAME, Collections.emptySet())); + } + + public void testFireItemsRemovedCollection() { + this.fireItemsRemoved(COLLECTION_NAME, Collections.singleton(REMOVED_OBJECT_VALUE)); + } + + public void testFireItemsRemovedCollectionNoChange() { + this.fireItemsRemoved(COLLECTION_NAME, Collections.emptySet()); + } + + public void testFireItemRemovedCollection() { + this.fireItemRemoved(COLLECTION_NAME, REMOVED_OBJECT_VALUE); + } + + public void testFireCollectionCleared() { + this.fireCollectionCleared(COLLECTION_NAME); + } + + public void testFireCollectionChangedEvent() { + this.fireCollectionChanged(new CollectionChangeEvent(this, COLLECTION_NAME)); + } + + public void testFireCollectionChanged() { + this.fireCollectionChanged(COLLECTION_NAME); + } + + public boolean testAddItemToCollection() { + return this.addItemToCollection(ADDED_OBJECT_VALUE, new ArrayList(), COLLECTION_NAME); + } + + public boolean testAddItemToCollectionNoChange() { + Collection collection = new HashSet(); + collection.add(ADDED_OBJECT_VALUE); + return this.addItemToCollection(ADDED_OBJECT_VALUE, collection, COLLECTION_NAME); + } + + public boolean testAddItemsToCollection() { + return this.addItemsToCollection(Collections.singleton(ADDED_OBJECT_VALUE), new ArrayList(), COLLECTION_NAME); + } + + public boolean testAddItemsToCollectionNoChange() { + Collection collection = new HashSet(); + collection.add(ADDED_OBJECT_VALUE); + return this.addItemsToCollection(Collections.singleton(ADDED_OBJECT_VALUE), collection, COLLECTION_NAME); + } + + public boolean testAddItemsToCollectionMixed() { + Collection collection = new HashSet(); + collection.add(ADDED_OBJECT_VALUE); + return this.addItemsToCollection(new Object[] {ADDED_OBJECT_VALUE, ADDED_OBJECT_VALUE_2}, collection, COLLECTION_NAME); + } + + public boolean testRemoveItemFromCollection() { + Collection collection = new HashSet(); + collection.add(REMOVED_OBJECT_VALUE); + return this.removeItemFromCollection(REMOVED_OBJECT_VALUE, collection, COLLECTION_NAME); + } + + public boolean testRemoveItemFromCollectionNoChange() { + Collection collection = new HashSet(); + collection.add(REMOVED_OBJECT_VALUE); + return this.removeItemFromCollection("foo", collection, COLLECTION_NAME); + } + + public boolean testRemoveItemsFromCollection() { + Collection collection = new HashSet(); + collection.add(REMOVED_OBJECT_VALUE); + collection.add("foo"); + collection.add("bar"); + return this.removeItemsFromCollection(new Object[] {"foo", "bar", REMOVED_OBJECT_VALUE}, collection, COLLECTION_NAME); + } + + public boolean testRemoveItemsFromCollectionNoChange1() { + Collection collection = new HashSet(); + collection.add(REMOVED_OBJECT_VALUE); + return this.removeItemsFromCollection(Collections.emptySet(), collection, COLLECTION_NAME); + } + + public boolean testRemoveItemsFromCollectionNoChange2() { + Collection collection = new HashSet(); + return this.removeItemsFromCollection(Collections.singleton("foo"), collection, COLLECTION_NAME); + } + + public boolean testRemoveItemsFromCollectionNoChange3() { + Collection collection = new HashSet(); + collection.add(REMOVED_OBJECT_VALUE); + return this.removeItemsFromCollection(Collections.singleton("foo"), collection, COLLECTION_NAME); + } + + public boolean testRetainItemsInCollection1() { + Collection collection = new HashSet(); + collection.add(REMOVED_OBJECT_VALUE); + collection.add("foo"); + collection.add("bar"); + return this.retainItemsInCollection(new Object[] {"foo", "bar"}, collection, COLLECTION_NAME); + } + + public boolean testRetainItemsInCollection2() { + Collection collection = new HashSet(); + collection.add(REMOVED_OBJECT_VALUE); + collection.add("foo"); + collection.add("bar"); + return this.retainItemsInCollection(Collections.emptySet(), collection, COLLECTION_NAME); + } + + public boolean testRetainItemsInCollectionNoChange1() { + Collection collection = new HashSet(); + return this.retainItemsInCollection(new Object[] {"foo", "bar"}, collection, COLLECTION_NAME); + } + + public boolean testRetainItemsInCollectionNoChange2() { + Collection collection = new HashSet(); + collection.add(REMOVED_OBJECT_VALUE); + collection.add("foo"); + collection.add("bar"); + return this.retainItemsInCollection(new Object[] {"foo", "bar", REMOVED_OBJECT_VALUE}, collection, COLLECTION_NAME); + } + + public boolean testClearCollection() { + Collection collection = new HashSet(); + collection.add(REMOVED_OBJECT_VALUE); + collection.add("foo"); + collection.add("bar"); + return this.clearCollection(collection, COLLECTION_NAME); + } + + public boolean testClearCollectionNoChange() { + Collection collection = new HashSet(); + return this.clearCollection(collection, COLLECTION_NAME); + } + + public boolean testSynchronizeCollection1() { + Collection collection = new HashSet(); + collection.add("foo"); + collection.add("bar"); + collection.add("baz"); + Collection newCollection = new HashSet(); + newCollection.add("joo"); + newCollection.add("jar"); + newCollection.add("baz"); + boolean result = this.synchronizeCollection(newCollection, collection, COLLECTION_NAME); + assertEquals(newCollection, collection); + return result; + } + + public boolean testSynchronizeCollection2() { + Collection collection = new HashSet(); + collection.add("foo"); + collection.add("bar"); + collection.add("baz"); + Collection newCollection = new HashSet(); + boolean result = this.synchronizeCollection(newCollection, collection, COLLECTION_NAME); + assertEquals(newCollection, collection); + return result; + } + + public boolean testSynchronizeCollection3() { + Collection collection = new HashSet(); + Collection newCollection = new HashSet(); + newCollection.add("joo"); + newCollection.add("jar"); + newCollection.add("baz"); + boolean result = this.synchronizeCollection(newCollection, collection, COLLECTION_NAME); + assertEquals(newCollection, collection); + return result; + } + + // ***** list + public void testFireItemsAddedListEvent() { + this.fireItemsAdded(new ListChangeEvent(this, LIST_NAME, ADD_INDEX, Collections.singletonList(ADDED_OBJECT_VALUE))); + } + + public void testFireItemsAddedListEventNoChange() { + this.fireItemsAdded(new ListChangeEvent(this, LIST_NAME, ADD_INDEX, Collections.emptyList())); + } + + public void testFireItemsAddedList() { + this.fireItemsAdded(LIST_NAME, ADD_INDEX, Collections.singletonList(ADDED_OBJECT_VALUE)); + } + + public void testFireItemsAddedListNoChange() { + this.fireItemsAdded(LIST_NAME, ADD_INDEX, Collections.emptyList()); + } + + public void testFireItemAddedList() { + this.fireItemAdded(LIST_NAME, ADD_INDEX, ADDED_OBJECT_VALUE); + } + + public void testFireItemsRemovedListEvent() { + this.fireItemsRemoved(new ListChangeEvent(this, LIST_NAME, REMOVE_INDEX, Collections.singletonList(REMOVED_OBJECT_VALUE))); + } + + public void testFireItemsRemovedListEventNoChange() { + this.fireItemsRemoved(new ListChangeEvent(this, LIST_NAME, REMOVE_INDEX, Collections.emptyList())); + } + + public void testFireItemsRemovedList() { + this.fireItemsRemoved(LIST_NAME, REMOVE_INDEX, Collections.singletonList(REMOVED_OBJECT_VALUE)); + } + + public void testFireItemsRemovedListNoChange() { + this.fireItemsRemoved(LIST_NAME, REMOVE_INDEX, Collections.emptyList()); + } + + public void testFireItemRemovedList() { + this.fireItemRemoved(LIST_NAME, REMOVE_INDEX, REMOVED_OBJECT_VALUE); + } + + public void testFireItemsReplacedListEvent() { + this.fireItemsReplaced(new ListChangeEvent(this, LIST_NAME, REPLACE_INDEX, Collections.singletonList(ADDED_OBJECT_VALUE), Collections.singletonList(REMOVED_OBJECT_VALUE))); + } + + public void testFireItemsReplacedListEventNoChange() { + this.fireItemsReplaced(new ListChangeEvent(this, LIST_NAME, REPLACE_INDEX, Collections.emptyList(), Collections.emptyList())); + } + + public void testFireItemsReplacedList() { + this.fireItemsReplaced(LIST_NAME, REPLACE_INDEX, Collections.singletonList(ADDED_OBJECT_VALUE), Collections.singletonList(REMOVED_OBJECT_VALUE)); + } + + public void testFireItemsReplacedListNoChange() { + this.fireItemsReplaced(LIST_NAME, REPLACE_INDEX, Collections.emptyList(), Collections.emptyList()); + } + + public void testFireItemReplacedList() { + this.fireItemReplaced(LIST_NAME, REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE); + } + + public void testFireItemsMovedListEvent() { + this.fireItemsMoved(new ListChangeEvent(this, LIST_NAME, TARGET_INDEX, SOURCE_INDEX, 1)); + } + + public void testFireItemsMovedListEventNoChange() { + this.fireItemsMoved(new ListChangeEvent(this, LIST_NAME, SOURCE_INDEX, SOURCE_INDEX, 1)); + } + + public void testFireItemsMovedList() { + this.fireItemsMoved(LIST_NAME, TARGET_INDEX, SOURCE_INDEX, 1); + } + + public void testFireItemsMovedListNoChange() { + this.fireItemsMoved(LIST_NAME, SOURCE_INDEX, SOURCE_INDEX, 1); + } + + public void testFireItemMovedList() { + this.fireItemMoved(LIST_NAME, TARGET_INDEX, SOURCE_INDEX); + } + + public void testFireListClearedEvent() { + this.fireListCleared(new ListChangeEvent(this, LIST_NAME)); + } + + public void testFireListCleared() { + this.fireListCleared(LIST_NAME); + } + + public void testFireListChangedEvent() { + this.fireListChanged(new ListChangeEvent(this, LIST_NAME)); + } + + public void testFireListChanged() { + this.fireListChanged(LIST_NAME); + } + + public void testAddItemToListIndex() { + List list = new ArrayList(); + list.add("foo"); + list.add("bar"); + list.add("baz"); + this.addItemToList(2, "joo", list, LIST_NAME); + } + + public void testAddItemToList() { + List list = new ArrayList(); + list.add("foo"); + list.add("bar"); + list.add("baz"); + this.addItemToList("joo", list, LIST_NAME); + } + + public void testAddItemsToListIndex() { + List list = new ArrayList(); + list.add("foo"); + list.add("bar"); + list.add("baz"); + this.addItemsToList(2, Collections.singletonList("joo"), list, LIST_NAME); + } + + public void testAddItemsToListIndexNoChange() { + List list = new ArrayList(); + list.add("foo"); + list.add("bar"); + list.add("baz"); + this.addItemsToList(2, Collections.emptyList(), list, LIST_NAME); + } + + public void testAddItemsToList() { + List list = new ArrayList(); + list.add("foo"); + list.add("bar"); + list.add("baz"); + this.addItemsToList(Collections.singletonList("joo"), list, LIST_NAME); + } + + public void testAddItemsToListNoChange() { + List list = new ArrayList(); + list.add("foo"); + list.add("bar"); + list.add("baz"); + this.addItemsToList(Collections.emptyList(), list, LIST_NAME); + } + + // ***** tree + public void testFireNodeAddedTreeEvent() { + this.fireNodeAdded(new TreeChangeEvent(this, TREE_NAME, OBJECT_ARRAY_PATH)); + } + + public void testFireNodeAddedTree() { + this.fireNodeAdded(TREE_NAME, OBJECT_ARRAY_PATH); + } + + public void testFireNodeRemovedTreeEvent() { + this.fireNodeRemoved(new TreeChangeEvent(this, TREE_NAME, OBJECT_ARRAY_PATH)); + } + + public void testFireNodeRemovedTree() { + this.fireNodeRemoved(TREE_NAME, OBJECT_ARRAY_PATH); + } + + public void testFireTreeClearedEvent() { + this.fireTreeCleared(new TreeChangeEvent(this, TREE_NAME)); + } + + public void testFireTreeCleared() { + this.fireTreeCleared(TREE_NAME); + } + + public void testFireTreeChangedEvent() { + this.fireTreeChanged(new TreeChangeEvent(this, TREE_NAME, OBJECT_ARRAY_PATH)); + } + + public void testFireTreeChanged() { + this.fireTreeChanged(TREE_NAME, OBJECT_ARRAY_PATH); + } + + public boolean testAttributeValueHasChanged(Object value1, Object value2) { + return this.attributeValueHasChanged(value1, value2); + } + + public boolean testAttributeValueHasNotChanged(Object value1, Object value2) { + return this.attributeValueHasNotChanged(value1, value2); + } + + // ***** misc + @Override + public TestModel clone() { + try { + return (TestModel) super.clone(); + } catch (CloneNotSupportedException ex) { + throw new InternalError(); + } + } + + public boolean testValuesAreDifferent(Object value1, Object value2) { + return this.valuesAreDifferent(value1, value2); + } + + public boolean testValuesAreEqual(Object value1, Object value2) { + return this.valuesAreEqual(value1, value2); + } + + public boolean testElementsAreDifferent(Iterator iterator1, Iterator iterator2) { + return this.getChangeSupport().elementsAreDifferent(iterator1, iterator2); + } + + public boolean testElementsAreEqual(Iterator iterator1, Iterator iterator2) { + return this.getChangeSupport().elementsAreEqual(iterator1, iterator2); + } + + @Override + public void toString(StringBuilder sb) { + sb.append(TEST_TO_STRING); + } + + } + + + // ********** serialization test ********** + + public void testSerialization() throws java.io.IOException, ClassNotFoundException { + LocalModel model1 = new LocalModel(); + Foo foo1 = new Foo(); + Bar bar1 = new Bar(); + Joo joo1 = new Joo(); + Jar jar1 = new Jar(); + model1.addStateChangeListener(foo1); + model1.addStateChangeListener(bar1); + model1.addListChangeListener(joo1); + model1.addListChangeListener(jar1); + + ChangeListener[] listeners1 = this.listeners(model1, StateChangeListener.class); + assertEquals(2, listeners1.length); + // the order of these could change... + assertEquals(Foo.class, listeners1[0].getClass()); + assertEquals(Bar.class, listeners1[1].getClass()); + + listeners1 = this.listeners(model1, ListChangeListener.class); + assertEquals(2, listeners1.length); + // the order of these could change... + assertEquals(Joo.class, listeners1[0].getClass()); + assertEquals(Jar.class, listeners1[1].getClass()); + + LocalModel model2 = TestTools.serialize(model1); + + ChangeListener[] listeners2 = this.listeners(model2, StateChangeListener.class); + assertEquals(1, listeners2.length); + assertEquals(Foo.class, listeners2[0].getClass()); + + listeners2 = this.listeners(model2, ListChangeListener.class); + assertEquals(1, listeners2.length); + assertEquals(Joo.class, listeners2[0].getClass()); + } + + private ChangeListener[] listeners(LocalModel model, Class listenerClass) { + ChangeSupport changeSupport = (ChangeSupport) ClassTools.fieldValue(model, "changeSupport"); + return (ChangeListener[]) ClassTools.executeMethod(changeSupport, "getListeners", Class.class, listenerClass); + } + + private static class LocalModel extends AbstractModel { + LocalModel() { + super(); + } + } + + private static class Foo implements Serializable, StateChangeListener { + Foo() { + super(); + } + public void stateChanged(StateChangeEvent event) { + // do nothing + } + } + + private static class Bar implements StateChangeListener { + Bar() { + super(); + } + public void stateChanged(StateChangeEvent event) { + // do nothing + } + } + + private static class Joo extends ListChangeAdapter implements Serializable { +// private static final ObjectStreamField[] serialPersistentFields = {new ObjectStreamField("changeSupport", ChangeSupport.class)}; + Joo() { + super(); + } + } + + private static class Jar extends ListChangeAdapter { + Jar() { + super(); + } + } + + + // ********** bug(?) test ********** + + private static final String ISE_MESSAGE = "this object is no longer listening to localA"; + + /** + * Test the following situation: + * - both B and C are listening to A + * - C is also listening to B + * - when B receives an event from A, it will fire an event to C + * - when C receives an event from B, it will STOP listening to A + * - the event from B to C may be preceded or followed (depending on + * the hash positions of listeners) by an event from A to C: + * - if the A to C event comes first, no problem + * - but if the A to B event comes first, the A to C event should NOT happen + */ + public void testIndirectRemoveStateListener() { + this.verifyIndirectRemoveListener( + new NotifyCommand() { + public void notifyListeners(LocalA localA) { + localA.notifyStateListeners(); + } + } + ); + } + + public void testIndirectRemovePropertyListener() { + this.verifyIndirectRemoveListener( + new NotifyCommand() { + public void notifyListeners(LocalA localA) { + localA.notifyPropertyListeners(); + } + } + ); + } + + public void testIndirectRemoveCollectionListener() { + this.verifyIndirectRemoveListener( + new NotifyCommand() { + public void notifyListeners(LocalA localA) { + localA.notifyCollectionListeners(); + } + } + ); + } + + public void testIndirectRemoveListListener() { + this.verifyIndirectRemoveListener( + new NotifyCommand() { + public void notifyListeners(LocalA localA) { + localA.notifyListListeners(); + } + } + ); + } + + public void testIndirectRemoveTreeListener() { + this.verifyIndirectRemoveListener( + new NotifyCommand() { + public void notifyListeners(LocalA localA) { + localA.notifyTreeListeners(); + } + } + ); + } + + public void verifyIndirectRemoveListener(NotifyCommand command) { + LocalA localA = new LocalA(); + LocalB localB = new LocalB(localA); + + // build a bunch of LocalCs so at least one of them is notified AFTER the LocalB; + // using 1000 seemed to fail very consistently before ChangeSupport was fixed + LocalC[] localCs = new LocalC[1000]; + for (int i = localCs.length; i-- > 0; ) { + localCs[i] = new LocalC(localA, localB); + } + + boolean exCaught = false; + try { + command.notifyListeners(localA); + } catch (IllegalStateException ex) { + if (ex.getMessage() == ISE_MESSAGE) { + exCaught = true; + } else { + throw ex; + } + } + assertFalse(exCaught); + + for (int i = localCs.length; i-- > 0; ) { + assertFalse(localCs[i].isListeningToLocalA()); + } + } + + private interface NotifyCommand { + void notifyListeners(LocalA localA); + } + + /** + * This object simply fires a state change event. Both LocalB and LocalC + * will be listeners. + */ + private static class LocalA extends AbstractModel { + LocalA() { + super(); + } + void notifyStateListeners() { + this.fireStateChanged(); + } + void notifyPropertyListeners() { + this.firePropertyChanged("foo", 1, 2); + } + void notifyCollectionListeners() { + this.fireCollectionChanged("foo"); + } + void notifyListListeners() { + this.fireListChanged("foo"); + } + void notifyTreeListeners() { + this.fireTreeChanged("foo"); + } + } + + /** + * This object will fire state change events whenever it receives + * a state change event from localA. + */ + private static class LocalB + extends AbstractModel + implements StateChangeListener, PropertyChangeListener, CollectionChangeListener, ListChangeListener, TreeChangeListener + { + LocalB(LocalA localA) { + super(); + localA.addStateChangeListener(this); + localA.addPropertyChangeListener(this); + localA.addCollectionChangeListener(this); + localA.addListChangeListener(this); + localA.addTreeChangeListener(this); + } + + public void stateChanged(StateChangeEvent e) { + this.fireStateChanged(); + } + + public void propertyChanged(PropertyChangeEvent evt) { + this.firePropertyChanged("bar", 1, 2); + } + + public void collectionChanged(CollectionChangeEvent e) { + this.fireCollectionChanged("bar"); + } + public void collectionCleared(CollectionChangeEvent e) {/*ignore*/} + public void itemsAdded(CollectionChangeEvent e) {/*ignore*/} + public void itemsRemoved(CollectionChangeEvent e) {/*ignore*/} + + public void listChanged(ListChangeEvent e) { + this.fireListChanged("bar"); + } + public void listCleared(ListChangeEvent e) {/*ignore*/} + public void itemsAdded(ListChangeEvent e) {/*ignore*/} + public void itemsRemoved(ListChangeEvent e) {/*ignore*/} + public void itemsReplaced(ListChangeEvent e) {/*ignore*/} + public void itemsMoved(ListChangeEvent e) {/*ignore*/} + + public void treeChanged(TreeChangeEvent e) { + this.fireTreeChanged("bar"); + } + public void treeCleared(TreeChangeEvent e) {/*ignore*/} + public void nodeAdded(TreeChangeEvent e) {/*ignore*/} + public void nodeRemoved(TreeChangeEvent e) {/*ignore*/} + + } + + /** + * This object will listen to two other objects, localA and localB. + * If this object receives notification from localB, it will stop listening to + * localA. If this object receives notification from localA, it will check to + * see whether it still listening to localA. If this object is no longer + * listening to localA, it will complain about receiving the event and + * throw an exception. + */ + private static class LocalC + extends AbstractModel + implements StateChangeListener, PropertyChangeListener, CollectionChangeListener, ListChangeListener, TreeChangeListener + { + private LocalA localA; + private LocalB localB; + private boolean listeningToLocalA; + + LocalC(LocalA localA, LocalB localB) { + super(); + this.localA = localA; + this.localB = localB; + + localA.addStateChangeListener(this); + localA.addPropertyChangeListener(this); + localA.addCollectionChangeListener(this); + localA.addListChangeListener(this); + localA.addTreeChangeListener(this); + this.listeningToLocalA = true; + + localB.addStateChangeListener(this); + localB.addPropertyChangeListener(this); + localB.addCollectionChangeListener(this); + localB.addListChangeListener(this); + localB.addTreeChangeListener(this); + } + boolean isListeningToLocalA() { + return this.listeningToLocalA; + } + + public void stateChanged(StateChangeEvent e) { + Object source = e.getSource(); + if (source == this.localA) { + if ( ! this.listeningToLocalA) { + throw new IllegalStateException(ISE_MESSAGE); + } + } else if (source == this.localB) { + this.localA.removeStateChangeListener(this); + this.listeningToLocalA = false; + } else { + throw new IllegalStateException("bogus event source: " + source); + } + } + + public void propertyChanged(PropertyChangeEvent e) { + Object source = e.getSource(); + if (source == this.localA) { + if ( ! this.listeningToLocalA) { + throw new IllegalStateException(ISE_MESSAGE); + } + } else if (source == this.localB) { + this.localA.removePropertyChangeListener(this); + this.listeningToLocalA = false; + } else { + throw new IllegalStateException("bogus event source: " + source); + } + } + + public void collectionChanged(CollectionChangeEvent e) { + Object source = e.getSource(); + if (source == this.localA) { + if ( ! this.listeningToLocalA) { + throw new IllegalStateException(ISE_MESSAGE); + } + } else if (source == this.localB) { + this.localA.removeCollectionChangeListener(this); + this.listeningToLocalA = false; + } else { + throw new IllegalStateException("bogus event source: " + source); + } + } + public void collectionCleared(CollectionChangeEvent e) {/*ignore*/} + public void itemsAdded(CollectionChangeEvent e) {/*ignore*/} + public void itemsRemoved(CollectionChangeEvent e) {/*ignore*/} + + public void listChanged(ListChangeEvent e) { + Object source = e.getSource(); + if (source == this.localA) { + if ( ! this.listeningToLocalA) { + throw new IllegalStateException(ISE_MESSAGE); + } + } else if (source == this.localB) { + this.localA.removeListChangeListener(this); + this.listeningToLocalA = false; + } else { + throw new IllegalStateException("bogus event source: " + source); + } + } + public void listCleared(ListChangeEvent e) {/*ignore*/} + public void itemsAdded(ListChangeEvent e) {/*ignore*/} + public void itemsRemoved(ListChangeEvent e) {/*ignore*/} + public void itemsReplaced(ListChangeEvent e) {/*ignore*/} + public void itemsMoved(ListChangeEvent e) {/*ignore*/} + + public void treeChanged(TreeChangeEvent e) { + Object source = e.getSource(); + if (source == this.localA) { + if ( ! this.listeningToLocalA) { + throw new IllegalStateException(ISE_MESSAGE); + } + } else if (source == this.localB) { + this.localA.removeTreeChangeListener(this); + this.listeningToLocalA = false; + } else { + throw new IllegalStateException("bogus event source: " + source); + } + } + public void treeCleared(TreeChangeEvent e) {/*ignore*/} + public void nodeAdded(TreeChangeEvent e) {/*ignore*/} + public void nodeRemoved(TreeChangeEvent e) {/*ignore*/} + + } + +} #P org.eclipse.jpt.core Index: src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java,v retrieving revision 1.20 diff -u -r1.20 AbstractJavaTypeMapping.java --- src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java 12 Mar 2009 05:07:38 -0000 1.20 +++ src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java 6 Apr 2009 20:59:14 -0000 @@ -16,7 +16,7 @@ import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; import org.eclipse.jpt.core.context.java.JavaPersistentType; import org.eclipse.jpt.core.context.java.JavaTypeMapping; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.db.Schema; @@ -39,7 +39,7 @@ return (JavaPersistentType) super.getParent(); } - protected JavaResourceNode getResourceMapping() { + protected Annotation getResourceMappingAnnotation() { return this.javaResourcePersistentType.getMappingAnnotation(getAnnotationName()); } @@ -139,7 +139,7 @@ } public TextRange getValidationTextRange(CompilationUnit astRoot) { - TextRange textRange = this.getResourceMapping().getTextRange(astRoot); + TextRange textRange = this.getResourceMappingAnnotation().getTextRange(astRoot); return (textRange != null) ? textRange : this.getPersistentType().getValidationTextRange(astRoot); } Index: src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java,v retrieving revision 1.22 diff -u -r1.22 AbstractJavaRelationshipMapping.java --- src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java 24 Mar 2009 19:56:40 -0000 1.22 +++ src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java 6 Apr 2009 20:59:14 -0000 @@ -99,7 +99,7 @@ public void setSpecifiedTargetEntity(String targetEntity) { String old = this.specifiedTargetEntity; this.specifiedTargetEntity = targetEntity; - this.resourceMapping.setTargetEntity(targetEntity); + this.mappingAnnotation.setTargetEntity(targetEntity); this.firePropertyChanged(SPECIFIED_TARGET_ENTITY_PROPERTY, old, targetEntity); } @@ -157,7 +157,7 @@ public void setSpecifiedFetch(FetchType fetch) { FetchType old = this.specifiedFetch; this.specifiedFetch = fetch; - this.resourceMapping.setFetch(FetchType.toJavaResourceModel(fetch)); + this.mappingAnnotation.setFetch(FetchType.toJavaResourceModel(fetch)); this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch); } @@ -176,7 +176,7 @@ this.defaultTargetEntity = this.buildDefaultTargetEntity(); this.relationshipReference.initialize(); this.specifiedFetch = this.getResourceFetch(); - this.cascade.initialize(this.resourceMapping); + this.cascade.initialize(this.mappingAnnotation); this.specifiedTargetEntity = this.getResourceTargetEntity(); this.resolvedTargetEntity = this.buildResolvedTargetEntity(); } @@ -187,26 +187,26 @@ this.setDefaultTargetEntity(this.buildDefaultTargetEntity()); this.relationshipReference.update(); this.setSpecifiedFetch_(this.getResourceFetch()); - this.cascade.update(this.resourceMapping); + this.cascade.update(this.mappingAnnotation); this.setSpecifiedTargetEntity_(this.getResourceTargetEntity()); this.setResolvedTargetEntity(this.buildResolvedTargetEntity()); } protected FetchType getResourceFetch() { - return FetchType.fromJavaResourceModel(this.resourceMapping.getFetch()); + return FetchType.fromJavaResourceModel(this.mappingAnnotation.getFetch()); } protected String getResourceTargetEntity() { - return this.resourceMapping.getTargetEntity(); + return this.mappingAnnotation.getTargetEntity(); } protected abstract String buildDefaultTargetEntity(); protected Entity buildResolvedTargetEntity() { - String targetEntityName = (this.specifiedTargetEntity == null) ? + String targetEntityClassName = (this.specifiedTargetEntity == null) ? this.defaultTargetEntity : - this.resourceMapping.getFullyQualifiedTargetEntity(); - return (targetEntityName == null) ? null : this.getPersistenceUnit().getEntity(targetEntityName); + this.mappingAnnotation.getFullyQualifiedTargetEntityClassName(); + return (targetEntityClassName == null) ? null : this.getPersistenceUnit().getEntity(targetEntityClassName); } @@ -261,6 +261,6 @@ } protected TextRange getTargetEntityTextRange(CompilationUnit astRoot) { - return this.getTextRange(this.resourceMapping.getTargetEntityTextRange(astRoot), astRoot); + return this.getTextRange(this.mappingAnnotation.getTargetEntityTextRange(astRoot), astRoot); } } Index: src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMappingProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMappingProvider.java,v retrieving revision 1.8 diff -u -r1.8 JavaNullTypeMappingProvider.java --- src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMappingProvider.java 23 Oct 2008 19:04:08 -0000 1.8 +++ src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMappingProvider.java 6 Apr 2009 20:59:15 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Oracle. All rights reserved. + * 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. @@ -13,6 +13,7 @@ import org.eclipse.jpt.core.context.java.JavaPersistentType; import org.eclipse.jpt.core.context.java.JavaTypeMapping; import org.eclipse.jpt.core.context.java.JavaTypeMappingProvider; +import org.eclipse.jpt.utility.internal.StringTools; /** * This mapping provider implementation is used to create a JavaNullAttributeMapping. @@ -52,4 +53,9 @@ return factory.buildJavaNullTypeMapping(parent); } + @Override + public String toString() { + return StringTools.buildToStringFor(this, this.getAnnotationName()); + } + } Index: src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java,v retrieving revision 1.1 diff -u -r1.1 GenericJavaJoinColumnJoiningStrategy.java --- src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java 1 Apr 2009 14:36:19 -0000 1.1 +++ src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java 6 Apr 2009 20:59:14 -0000 @@ -1,19 +1,19 @@ /******************************************************************************* - * 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 - *******************************************************************************/ + * 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.context.java; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.ListIterator; + import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.context.BaseJoinColumn; import org.eclipse.jpt.core.context.Entity; @@ -24,7 +24,7 @@ import org.eclipse.jpt.core.context.java.JavaJoinColumnEnabledRelationshipReference; import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy; import org.eclipse.jpt.core.context.java.JavaRelationshipMapping; -import org.eclipse.jpt.core.internal.resource.java.NullJoinColumn; +import org.eclipse.jpt.core.internal.resource.java.NullJoinColumnAnnotation; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -175,7 +175,7 @@ //after removing the join column from the resource model. That causes problems //in the UI because the change notifications end up in the wrong order. this.defaultJoinColumn = buildJoinColumn( - new NullJoinColumn(this.resourcePersistentAttribute)); + new NullJoinColumnAnnotation(this.resourcePersistentAttribute)); } removeAnnotation(index); fireItemRemoved(SPECIFIED_JOIN_COLUMNS_LIST, index, removedJoinColumn); @@ -243,7 +243,7 @@ public void initializeDefaultJoinColumn() { if (mayHaveDefaultJoinColumn()) { this.defaultJoinColumn = - buildJoinColumn(new NullJoinColumn(this.resourcePersistentAttribute)); + buildJoinColumn(new NullJoinColumnAnnotation(this.resourcePersistentAttribute)); } } @@ -277,7 +277,7 @@ protected void updateDefaultJoinColumn() { if (mayHaveDefaultJoinColumn()) { JoinColumnAnnotation nullAnnotation = - new NullJoinColumn(this.resourcePersistentAttribute); + new NullJoinColumnAnnotation(this.resourcePersistentAttribute); if (this.defaultJoinColumn == null) { setDefaultJoinColumn(this.buildJoinColumn(nullAnnotation)); } Index: src/org/eclipse/jpt/core/internal/context/java/GenericJavaNullAttributeMapping.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaNullAttributeMapping.java,v retrieving revision 1.12 diff -u -r1.12 GenericJavaNullAttributeMapping.java --- src/org/eclipse/jpt/core/internal/context/java/GenericJavaNullAttributeMapping.java 12 Mar 2009 05:07:38 -0000 1.12 +++ src/org/eclipse/jpt/core/internal/context/java/GenericJavaNullAttributeMapping.java 6 Apr 2009 20:59:15 -0000 @@ -14,13 +14,13 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; import org.eclipse.wst.validation.internal.provisional.core.IMessage; import org.eclipse.wst.validation.internal.provisional.core.IReporter; -public class GenericJavaNullAttributeMapping +public class GenericJavaNullAttributeMapping extends AbstractJavaAttributeMapping { public GenericJavaNullAttributeMapping(JavaPersistentAttribute parent) { Index: src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneMapping.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneMapping.java,v retrieving revision 1.25 diff -u -r1.25 GenericJavaOneToOneMapping.java --- src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneMapping.java 12 Mar 2009 05:07:38 -0000 1.25 +++ src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneMapping.java 6 Apr 2009 20:59:15 -0000 @@ -63,12 +63,12 @@ @Override protected Boolean getResourceOptional() { - return this.resourceMapping.getOptional(); + return this.mappingAnnotation.getOptional(); } @Override protected void setOptionalOnResourceModel(Boolean newOptional) { - this.resourceMapping.setOptional(newOptional); + this.mappingAnnotation.setOptional(newOptional); } @Override Index: src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java,v retrieving revision 1.34 diff -u -r1.34 GenericJavaPersistentType.java --- src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java 12 Feb 2009 23:14:40 -0000 1.34 +++ src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentType.java 6 Apr 2009 20:59:15 -0000 @@ -30,7 +30,7 @@ return null; } - public void setSpecifiedAccess(@SuppressWarnings("unused") AccessType newSpecifiedAccess) { - throw new UnsupportedOperationException("specifiedAccess is not supported for GenericJavaPersistentType"); //$NON-NLS-1$ + public void setSpecifiedAccess(AccessType specifiedAccess) { + throw new UnsupportedOperationException(); } } Index: src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTable.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTable.java,v retrieving revision 1.27 diff -u -r1.27 GenericJavaJoinTable.java --- src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTable.java 1 Apr 2009 14:36:19 -0000 1.27 +++ src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTable.java 6 Apr 2009 20:59:15 -0000 @@ -25,7 +25,7 @@ import org.eclipse.jpt.core.context.java.JavaJoinTable; import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy; import org.eclipse.jpt.core.context.java.JavaRelationshipMapping; -import org.eclipse.jpt.core.internal.resource.java.NullJoinColumn; +import org.eclipse.jpt.core.internal.resource.java.NullJoinColumnAnnotation; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -198,7 +198,7 @@ //create the defaultJoinColumn now or this will happen during project update //after removing the join column from the resource model. That causes problems //in the UI because the change notifications end up in the wrong order. - this.defaultJoinColumn = buildJoinColumn(new NullJoinColumn(getResourceTable())); + this.defaultJoinColumn = buildJoinColumn(new NullJoinColumnAnnotation(getResourceTable())); } this.getResourceTable().removeJoinColumn(index); fireItemRemoved(JoinTable.SPECIFIED_JOIN_COLUMNS_LIST, index, removedJoinColumn); @@ -303,7 +303,7 @@ //create the defaultJoinColumn now or this will happen during project update //after removing the join column from the resource model. That causes problems //in the UI because the change notifications end up in the wrong order. - this.defaultInverseJoinColumn = buildInverseJoinColumn(new NullJoinColumn(getResourceTable())); + this.defaultInverseJoinColumn = buildInverseJoinColumn(new NullJoinColumnAnnotation(getResourceTable())); } this.getResourceTable().removeInverseJoinColumn(index); fireItemRemoved(JoinTable.SPECIFIED_INVERSE_JOIN_COLUMNS_LIST, index, removedJoinColumn); @@ -378,7 +378,7 @@ if (!shouldBuildDefaultJoinColumn()) { return; } - this.defaultJoinColumn = buildJoinColumn(new NullJoinColumn(joinTable)); + this.defaultJoinColumn = buildJoinColumn(new NullJoinColumnAnnotation(joinTable)); } protected void initializeSpecifiedInverseJoinColumns(JoinTableAnnotation joinTableResource) { @@ -397,7 +397,7 @@ if (!shouldBuildDefaultInverseJoinColumn()) { return; } - this.defaultInverseJoinColumn = buildInverseJoinColumn(new NullJoinColumn(joinTable)); + this.defaultInverseJoinColumn = buildInverseJoinColumn(new NullJoinColumnAnnotation(joinTable)); } public void update(JavaResourcePersistentAttribute jrpa) { @@ -435,10 +435,10 @@ return; } if (getDefaultJoinColumn() == null) { - this.setDefaultJoinColumn(buildJoinColumn(new NullJoinColumn(joinTable))); + this.setDefaultJoinColumn(buildJoinColumn(new NullJoinColumnAnnotation(joinTable))); } else { - this.defaultJoinColumn.update(new NullJoinColumn(joinTable)); + this.defaultJoinColumn.update(new NullJoinColumnAnnotation(joinTable)); } } @@ -467,10 +467,10 @@ return; } if (getDefaultInverseJoinColumn() == null) { - this.setDefaultInverseJoinColumn(buildInverseJoinColumn(new NullJoinColumn(joinTable))); + this.setDefaultInverseJoinColumn(buildInverseJoinColumn(new NullJoinColumnAnnotation(joinTable))); } else { - this.defaultInverseJoinColumn.update(new NullJoinColumn(joinTable)); + this.defaultInverseJoinColumn.update(new NullJoinColumnAnnotation(joinTable)); } } Index: src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassProvider.java,v retrieving revision 1.9 diff -u -r1.9 JavaMappedSuperclassProvider.java --- src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassProvider.java 23 Oct 2008 19:04:08 -0000 1.9 +++ src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassProvider.java 6 Apr 2009 20:59:15 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Oracle. All rights reserved. + * 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. @@ -15,6 +15,7 @@ import org.eclipse.jpt.core.context.java.JavaPersistentType; import org.eclipse.jpt.core.context.java.JavaTypeMappingProvider; import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation; +import org.eclipse.jpt.utility.internal.StringTools; public class JavaMappedSuperclassProvider implements JavaTypeMappingProvider @@ -49,4 +50,9 @@ return factory.buildJavaMappedSuperclass(parent); } + @Override + public String toString() { + return StringTools.buildToStringFor(this, this.getAnnotationName()); + } + } Index: src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java,v retrieving revision 1.21 diff -u -r1.21 AbstractJavaTable.java --- src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java 12 Sep 2008 05:20:06 -0000 1.21 +++ src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java 6 Apr 2009 20:59:14 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,12 +13,13 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; + import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.context.Table; import org.eclipse.jpt.core.context.UniqueConstraint; import org.eclipse.jpt.core.context.java.JavaJpaContextNode; import org.eclipse.jpt.core.context.java.JavaUniqueConstraint; -import org.eclipse.jpt.core.resource.java.TableAnnotation; +import org.eclipse.jpt.core.resource.java.BaseTableAnnotation; import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.db.Catalog; @@ -66,7 +67,7 @@ * Return the Java table annotation. Do not return null if the Java * annotation does not exist; return a null table annotation instead. */ - protected abstract TableAnnotation getResourceTable(); + protected abstract BaseTableAnnotation getResourceTable(); /** * Return the fully qualified name of the Java annotation. @@ -281,40 +282,40 @@ // ********** resource => context ********** - protected void initialize(TableAnnotation tableAnnotation) { + protected void initialize(BaseTableAnnotation baseTableAnnotation) { this.defaultName = this.buildDefaultName(); - this.specifiedName = tableAnnotation.getName(); + this.specifiedName = baseTableAnnotation.getName(); this.defaultSchema = this.buildDefaultSchema(); - this.specifiedSchema = tableAnnotation.getSchema(); + this.specifiedSchema = baseTableAnnotation.getSchema(); this.defaultCatalog = this.buildDefaultCatalog(); - this.specifiedCatalog = tableAnnotation.getCatalog(); + this.specifiedCatalog = baseTableAnnotation.getCatalog(); - this.initializeUniqueConstraints(tableAnnotation); + this.initializeUniqueConstraints(baseTableAnnotation); } - protected void initializeUniqueConstraints(TableAnnotation tableAnnotation) { - for (UniqueConstraintAnnotation uniqueConstraintAnnotation : CollectionTools.iterable(tableAnnotation.uniqueConstraints())) { + protected void initializeUniqueConstraints(BaseTableAnnotation baseTableAnnotation) { + for (UniqueConstraintAnnotation uniqueConstraintAnnotation : CollectionTools.iterable(baseTableAnnotation.uniqueConstraints())) { this.uniqueConstraints.add(buildUniqueConstraint(uniqueConstraintAnnotation)); } } - protected void update(TableAnnotation tableAnnotation) { + protected void update(BaseTableAnnotation baseTableAnnotation) { this.setDefaultName(this.buildDefaultName()); - this.setSpecifiedName_(tableAnnotation.getName()); + this.setSpecifiedName_(baseTableAnnotation.getName()); this.setDefaultSchema(this.buildDefaultSchema()); - this.setSpecifiedSchema_(tableAnnotation.getSchema()); + this.setSpecifiedSchema_(baseTableAnnotation.getSchema()); this.setDefaultCatalog(this.buildDefaultCatalog()); - this.setSpecifiedCatalog_(tableAnnotation.getCatalog()); + this.setSpecifiedCatalog_(baseTableAnnotation.getCatalog()); - this.updateUniqueConstraints(tableAnnotation); + this.updateUniqueConstraints(baseTableAnnotation); } - protected void updateUniqueConstraints(TableAnnotation tableAnnotation) { - ListIterator resourceConstraints = tableAnnotation.uniqueConstraints(); + protected void updateUniqueConstraints(BaseTableAnnotation baseTableAnnotation) { + ListIterator resourceConstraints = baseTableAnnotation.uniqueConstraints(); ListIterator contextConstraints = this.uniqueConstraints(); while (contextConstraints.hasNext()) { JavaUniqueConstraint uniqueConstraint = contextConstraints.next(); Index: src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java,v retrieving revision 1.22 diff -u -r1.22 AbstractJavaQuery.java --- src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java 28 Jan 2009 06:18:40 -0000 1.22 +++ src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java 6 Apr 2009 20:59:14 -0000 @@ -18,7 +18,7 @@ import org.eclipse.jpt.core.context.java.JavaJpaContextNode; import org.eclipse.jpt.core.context.java.JavaQuery; import org.eclipse.jpt.core.context.java.JavaQueryHint; -import org.eclipse.jpt.core.resource.java.QueryAnnotation; +import org.eclipse.jpt.core.resource.java.BaseNamedQueryAnnotation; import org.eclipse.jpt.core.resource.java.QueryHintAnnotation; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.utility.internal.CollectionTools; @@ -35,14 +35,14 @@ protected final List hints; - protected QueryAnnotation resourceQuery; + protected BaseNamedQueryAnnotation resourceQuery; protected AbstractJavaQuery(JavaJpaContextNode parent) { super(parent); this.hints = new ArrayList(); } - protected QueryAnnotation getResourceQuery() { + protected BaseNamedQueryAnnotation getResourceQuery() { return this.resourceQuery; } @@ -124,14 +124,14 @@ fireItemMoved(Query.HINTS_LIST, targetIndex, sourceIndex); } - protected void initialize(QueryAnnotation queryAnnotation) { + protected void initialize(BaseNamedQueryAnnotation queryAnnotation) { this.resourceQuery = queryAnnotation; this.name = queryAnnotation.getName(); this.query = queryAnnotation.getQuery(); this.initializeQueryHints(); } - protected void update(QueryAnnotation queryAnnotation) { + protected void update(BaseNamedQueryAnnotation queryAnnotation) { this.resourceQuery = queryAnnotation; this.setName_(queryAnnotation.getName()); this.setQuery_(queryAnnotation.getQuery()); Index: src/org/eclipse/jpt/core/internal/context/java/JavaEntityProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityProvider.java,v retrieving revision 1.9 diff -u -r1.9 JavaEntityProvider.java --- src/org/eclipse/jpt/core/internal/context/java/JavaEntityProvider.java 23 Oct 2008 19:04:08 -0000 1.9 +++ src/org/eclipse/jpt/core/internal/context/java/JavaEntityProvider.java 6 Apr 2009 20:59:15 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Oracle. All rights reserved. + * 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. @@ -15,6 +15,7 @@ import org.eclipse.jpt.core.context.java.JavaPersistentType; import org.eclipse.jpt.core.context.java.JavaTypeMappingProvider; import org.eclipse.jpt.core.resource.java.EntityAnnotation; +import org.eclipse.jpt.utility.internal.StringTools; /** * @@ -52,4 +53,9 @@ return factory.buildJavaEntity(parent); } + @Override + public String toString() { + return StringTools.buildToStringFor(this, this.getAnnotationName()); + } + } Index: src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java,v retrieving revision 1.5 diff -u -r1.5 AbstractJavaPersistentAttribute.java --- src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java 1 Apr 2009 14:36:18 -0000 1.5 +++ src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java 6 Apr 2009 20:59:14 -0000 @@ -11,6 +11,7 @@ import java.util.Iterator; import java.util.List; + import org.eclipse.core.runtime.content.IContentType; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.Modifier; @@ -26,7 +27,6 @@ import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; 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.utility.TextRange; import org.eclipse.jpt.utility.Filter; @@ -390,8 +390,8 @@ protected JavaAttributeMapping buildDefaultMapping() { JavaAttributeMapping mapping = this.getJpaPlatform().buildDefaultJavaAttributeMapping(this); - JavaResourceNode resourceMapping = this.resourcePersistentAttribute.getNullMappingAnnotation(mapping.getAnnotationName()); - mapping.initialize(resourceMapping); + Annotation annotation = this.resourcePersistentAttribute.getNullMappingAnnotation(mapping.getAnnotationName()); + mapping.initialize(annotation); return mapping; } @@ -502,7 +502,7 @@ } protected String getJavaMappingAnnotationName() { - Annotation mappingAnnotation = (Annotation) this.resourcePersistentAttribute.getMappingAnnotation(); + Annotation mappingAnnotation = this.resourcePersistentAttribute.getMappingAnnotation(); return (mappingAnnotation == null) ? null : mappingAnnotation.getAnnotationName(); } Index: src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java,v retrieving revision 1.8 diff -u -r1.8 AbstractJavaPersistentType.java --- src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java 11 Mar 2009 17:19:15 -0000 1.8 +++ src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java 6 Apr 2009 20:59:14 -0000 @@ -207,15 +207,15 @@ } private void addAttribute(int index, JavaPersistentAttribute attribute) { - addItemToList(index, attribute, this.attributes, PersistentType.SPECIFIED_ATTRIBUTES_LIST); + addItemToList(index, attribute, this.attributes, ATTRIBUTES_LIST); } private void removeAttribute(JavaPersistentAttribute attribute) { - removeItemFromList(attribute, this.attributes, PersistentType.SPECIFIED_ATTRIBUTES_LIST); + removeItemFromList(attribute, this.attributes, ATTRIBUTES_LIST); } private void moveAttribute(int index, JavaPersistentAttribute attribute) { - moveItemInList(index, this.attributes.indexOf(attribute), this.attributes, PersistentType.SPECIFIED_ATTRIBUTES_LIST); + moveItemInList(index, this.attributes.indexOf(attribute), this.attributes, ATTRIBUTES_LIST); } public Iterator attributeNames() { @@ -361,7 +361,7 @@ } protected void initializeMapping() { - this.mapping = this.getJpaPlatform().buildJavaTypeMappingFromAnnotation(this.javaMappingAnnotationName(), this); + this.mapping = this.getJpaPlatform().buildJavaTypeMappingFromAnnotation(this.getJavaMappingAnnotationName(), this); this.mapping.initialize(this.resourcePersistentType); } @@ -432,7 +432,7 @@ } protected void updateMapping() { - String javaMappingAnnotationName = this.javaMappingAnnotationName(); + String javaMappingAnnotationName = this.getJavaMappingAnnotationName(); if (this.getMapping().getAnnotationName() == javaMappingAnnotationName) { this.getMapping().update(this.resourcePersistentType); } else { @@ -450,8 +450,8 @@ return typeMapping; } - protected String javaMappingAnnotationName() { - Annotation mappingAnnotation = (Annotation) this.resourcePersistentType.getMappingAnnotation(); + protected String getJavaMappingAnnotationName() { + Annotation mappingAnnotation = this.resourcePersistentType.getMappingAnnotation(); return (mappingAnnotation == null) ? null : mappingAnnotation.getAnnotationName(); } Index: src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableProvider.java,v retrieving revision 1.9 diff -u -r1.9 JavaEmbeddableProvider.java --- src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableProvider.java 23 Oct 2008 19:04:08 -0000 1.9 +++ src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableProvider.java 6 Apr 2009 20:59:15 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Oracle. All rights reserved. + * 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. @@ -15,6 +15,7 @@ import org.eclipse.jpt.core.context.java.JavaPersistentType; import org.eclipse.jpt.core.context.java.JavaTypeMappingProvider; import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation; +import org.eclipse.jpt.utility.internal.StringTools; public class JavaEmbeddableProvider implements JavaTypeMappingProvider @@ -49,4 +50,9 @@ return factory.buildJavaEmbeddable(parent); } + @Override + public String toString() { + return StringTools.buildToStringFor(this, this.getAnnotationName()); + } + } Index: src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java,v retrieving revision 1.23 diff -u -r1.23 AbstractJavaAttributeMapping.java --- src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java 12 Mar 2009 05:07:38 -0000 1.23 +++ src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java 6 Apr 2009 20:59:12 -0000 @@ -17,7 +17,7 @@ import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.db.Table; @@ -25,13 +25,13 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter; -public abstract class AbstractJavaAttributeMapping +public abstract class AbstractJavaAttributeMapping extends AbstractJavaJpaContextNode implements JavaAttributeMapping { protected final JavaResourcePersistentAttribute resourcePersistentAttribute; - protected T resourceMapping; + protected T mappingAnnotation; protected AbstractJavaAttributeMapping(JavaPersistentAttribute parent) { super(parent); @@ -52,7 +52,7 @@ } public T getMappingAnnotation() { - return this.resourceMapping; + return this.mappingAnnotation; } /** @@ -100,8 +100,9 @@ return false; } - public void initialize(JavaResourceNode resourceMapping) { - this.resourceMapping = (T) resourceMapping; + @SuppressWarnings("unchecked") + public void initialize(Annotation annotation) { + this.mappingAnnotation = (T) annotation; this.initialize(); } @@ -109,8 +110,9 @@ // do nothing by default } - public void update(JavaResourceNode resourceMapping) { - this.resourceMapping = (T) resourceMapping; + @SuppressWarnings("unchecked") + public void update(Annotation annotation) { + this.mappingAnnotation = (T) annotation; this.update(); } @@ -147,7 +149,7 @@ } protected TextRange getResourceMappingTextRange(CompilationUnit astRoot) { - return (this.resourceMapping == null) ? null : this.resourceMapping.getTextRange(astRoot); + return (this.mappingAnnotation == null) ? null : this.mappingAnnotation.getTextRange(astRoot); } @Override Index: src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java,v retrieving revision 1.10 diff -u -r1.10 AbstractJavaEntity.java --- src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java 24 Mar 2009 19:56:40 -0000 1.10 +++ src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java 6 Apr 2009 20:59:13 -0000 @@ -53,8 +53,8 @@ import org.eclipse.jpt.core.context.java.JavaSequenceGenerator; import org.eclipse.jpt.core.context.java.JavaTable; import org.eclipse.jpt.core.context.java.JavaTableGenerator; -import org.eclipse.jpt.core.internal.resource.java.NullAssociationOverride; -import org.eclipse.jpt.core.internal.resource.java.NullPrimaryKeyJoinColumn; +import org.eclipse.jpt.core.internal.resource.java.NullAssociationOverrideAnnotation; +import org.eclipse.jpt.core.internal.resource.java.NullPrimaryKeyJoinColumnAnnotation; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; @@ -289,7 +289,7 @@ if (!shouldBuildDefaultPrimaryKeyJoinColumn()) { return; } - this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumn(this.javaResourcePersistentType)); + this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType)); } protected void initializeSpecifiedAttributeOverrides() { @@ -318,7 +318,7 @@ String associationName = i.next(); JavaAssociationOverride associationOverride = getAssociationOverrideNamed(associationName); if (associationOverride == null) { - this.virtualAssociationOverrides.add(buildAssociationOverride(new NullAssociationOverride(this.javaResourcePersistentType, associationName))); + this.virtualAssociationOverrides.add(buildAssociationOverride(new NullAssociationOverrideAnnotation(this.javaResourcePersistentType, associationName))); } } } @@ -355,8 +355,8 @@ } @Override - protected EntityAnnotation getResourceMapping() { - return (EntityAnnotation) super.getResourceMapping(); + protected EntityAnnotation getResourceMappingAnnotation() { + return (EntityAnnotation) super.getResourceMappingAnnotation(); } //****************** TypeMapping implemenation ******************* @@ -467,14 +467,14 @@ public void setSpecifiedName(String newSpecifiedName) { String oldSpecifiedName = this.specifiedName; this.specifiedName = newSpecifiedName; - this.getResourceMapping().setName(newSpecifiedName); - firePropertyChanged(Entity.SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName); + this.getResourceMappingAnnotation().setName(newSpecifiedName); + firePropertyChanged(SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName); } protected void setSpecifiedName_(String newSpecifiedName) { String oldSpecifiedName = this.specifiedName; this.specifiedName = newSpecifiedName; - firePropertyChanged(Entity.SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName); + firePropertyChanged(SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName); } public String getDefaultName() { @@ -484,7 +484,7 @@ protected/*private-protected*/ void setDefaultName(String newDefaultName) { String oldDefaultName = this.defaultName; this.defaultName = newDefaultName; - firePropertyChanged(Entity.DEFAULT_NAME_PROPERTY, oldDefaultName, newDefaultName); + firePropertyChanged(DEFAULT_NAME_PROPERTY, oldDefaultName, newDefaultName); } public JavaTable getTable() { @@ -504,7 +504,7 @@ this.specifiedSecondaryTables.add(index, secondaryTable); SecondaryTableAnnotation secondaryTableResource = (SecondaryTableAnnotation) this.javaResourcePersistentType.addSupportingAnnotation(index, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME); secondaryTable.initialize(secondaryTableResource); - fireItemAdded(Entity.SPECIFIED_SECONDARY_TABLES_LIST, index, secondaryTable); + fireItemAdded(SPECIFIED_SECONDARY_TABLES_LIST, index, secondaryTable); return secondaryTable; } @@ -513,7 +513,7 @@ } protected void addSpecifiedSecondaryTable(int index, JavaSecondaryTable secondaryTable) { - addItemToList(index, secondaryTable, this.specifiedSecondaryTables, Entity.SPECIFIED_SECONDARY_TABLES_LIST); + addItemToList(index, secondaryTable, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST); } protected void addSpecifiedSecondaryTable(JavaSecondaryTable secondaryTable) { @@ -527,17 +527,17 @@ public void removeSpecifiedSecondaryTable(int index) { JavaSecondaryTable removedSecondaryTable = this.specifiedSecondaryTables.remove(index); this.javaResourcePersistentType.removeSupportingAnnotation(index, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME); - fireItemRemoved(Entity.SPECIFIED_SECONDARY_TABLES_LIST, index, removedSecondaryTable); + fireItemRemoved(SPECIFIED_SECONDARY_TABLES_LIST, index, removedSecondaryTable); } protected void removeSpecifiedSecondaryTable_(JavaSecondaryTable secondaryTable) { - removeItemFromList(secondaryTable, this.specifiedSecondaryTables, Entity.SPECIFIED_SECONDARY_TABLES_LIST); + removeItemFromList(secondaryTable, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST); } public void moveSpecifiedSecondaryTable(int targetIndex, int sourceIndex) { CollectionTools.move(this.specifiedSecondaryTables, targetIndex, sourceIndex); this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex, SecondaryTablesAnnotation.ANNOTATION_NAME); - fireItemMoved(Entity.SPECIFIED_SECONDARY_TABLES_LIST, targetIndex, sourceIndex); + fireItemMoved(SPECIFIED_SECONDARY_TABLES_LIST, targetIndex, sourceIndex); } public ListIterator secondaryTables() { @@ -643,7 +643,7 @@ protected void setDiscriminatorValueIsUndefined(boolean discriminatorValueIsUndefined) { boolean old = this.discriminatorValueIsUndefined; this.discriminatorValueIsUndefined = discriminatorValueIsUndefined; - firePropertyChanged(Entity.DISCRIMINATOR_VALUE_IS_UNDEFINED_PROPERTY, old, discriminatorValueIsUndefined); + firePropertyChanged(DISCRIMINATOR_VALUE_IS_UNDEFINED_PROPERTY, old, discriminatorValueIsUndefined); } public boolean specifiedDiscriminatorColumnIsAllowed() { @@ -653,7 +653,7 @@ protected void setSpecifiedDiscriminatorColumnIsAllowed(boolean specifiedDiscriminatorColumnIsAllowed) { boolean old = this.specifiedDiscriminatorColumnIsAllowed; this.specifiedDiscriminatorColumnIsAllowed = specifiedDiscriminatorColumnIsAllowed; - firePropertyChanged(Entity.SPECIFIED_DISCRIMINATOR_COLUMN_IS_ALLOWED_PROPERTY, old, specifiedDiscriminatorColumnIsAllowed); + firePropertyChanged(SPECIFIED_DISCRIMINATOR_COLUMN_IS_ALLOWED_PROPERTY, old, specifiedDiscriminatorColumnIsAllowed); } public boolean discriminatorColumnIsUndefined() { @@ -663,7 +663,7 @@ protected void setDiscriminatorColumnIsUndefined(boolean discriminatorColumnIsUndefined) { boolean old = this.discriminatorColumnIsUndefined; this.discriminatorColumnIsUndefined = discriminatorColumnIsUndefined; - firePropertyChanged(Entity.DISCRIMINATOR_COLUMN_IS_UNDEFINED_PROPERTY, old, discriminatorColumnIsUndefined); + firePropertyChanged(DISCRIMINATOR_COLUMN_IS_UNDEFINED_PROPERTY, old, discriminatorColumnIsUndefined); } public boolean specifiedTableIsAllowed() { @@ -673,7 +673,7 @@ protected void setSpecifiedTableIsAllowed(boolean specifiedTableIsAllowed) { boolean old = this.specifiedTableIsAllowed; this.specifiedTableIsAllowed = specifiedTableIsAllowed; - firePropertyChanged(Entity.SPECIFIED_TABLE_IS_ALLOWED_PROPERTY, old, specifiedTableIsAllowed); + firePropertyChanged(SPECIFIED_TABLE_IS_ALLOWED_PROPERTY, old, specifiedTableIsAllowed); } public boolean tableIsUndefined() { @@ -683,7 +683,7 @@ protected void setTableIsUndefined(boolean tableIsUndefined) { boolean old = this.tableIsUndefined; this.tableIsUndefined = tableIsUndefined; - firePropertyChanged(Entity.TABLE_IS_UNDEFINED_PROPERTY, old, tableIsUndefined); + firePropertyChanged(TABLE_IS_UNDEFINED_PROPERTY, old, tableIsUndefined); } public JavaTableGenerator addTableGenerator() { @@ -790,7 +790,7 @@ protected void setDefaultPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn newPkJoinColumn) { JavaPrimaryKeyJoinColumn oldPkJoinColumn = this.defaultPrimaryKeyJoinColumn; this.defaultPrimaryKeyJoinColumn = newPkJoinColumn; - firePropertyChanged(Entity.DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldPkJoinColumn, newPkJoinColumn); + firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldPkJoinColumn, newPkJoinColumn); } protected ListIterator defaultPrimaryKeyJoinColumns() { @@ -817,15 +817,15 @@ this.specifiedPrimaryKeyJoinColumns.add(index, primaryKeyJoinColumn); PrimaryKeyJoinColumnAnnotation pkJoinColumnResource = (PrimaryKeyJoinColumnAnnotation) this.javaResourcePersistentType.addSupportingAnnotation(index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); primaryKeyJoinColumn.initialize(pkJoinColumnResource); - this.fireItemAdded(Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, primaryKeyJoinColumn); + this.fireItemAdded(SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, primaryKeyJoinColumn); if (oldDefaultPkJoinColumn != null) { - this.firePropertyChanged(Entity.DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldDefaultPkJoinColumn, null); + this.firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldDefaultPkJoinColumn, null); } return primaryKeyJoinColumn; } protected void addSpecifiedPrimaryKeyJoinColumn(int index, JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) { - addItemToList(index, primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST); + addItemToList(index, primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST); } protected void addSpecifiedPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) { @@ -842,23 +842,23 @@ //create the defaultJoinColumn now or this will happen during project update //after removing the join column from the resource model. That causes problems //in the UI because the change notifications end up in the wrong order. - this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumn(this.javaResourcePersistentType)); + this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType)); } this.javaResourcePersistentType.removeSupportingAnnotation(index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); - fireItemRemoved(Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, removedPrimaryKeyJoinColumn); + fireItemRemoved(SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, removedPrimaryKeyJoinColumn); if (this.defaultPrimaryKeyJoinColumn != null) { //fire change notification if a defaultJoinColumn was created above - this.firePropertyChanged(Entity.DEFAULT_PRIMARY_KEY_JOIN_COLUMN, null, this.defaultPrimaryKeyJoinColumn); + this.firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, null, this.defaultPrimaryKeyJoinColumn); } } protected void removeSpecifiedPrimaryKeyJoinColumn_(JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) { - removeItemFromList(primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST); + removeItemFromList(primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST); } public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) { this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME); - moveItemInList(targetIndex, sourceIndex, this.specifiedPrimaryKeyJoinColumns, Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST); + moveItemInList(targetIndex, sourceIndex, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST); } @SuppressWarnings("unchecked") @@ -891,7 +891,7 @@ this.specifiedAttributeOverrides.add(index, attributeOverride); AttributeOverrideAnnotation attributeOverrideResource = (AttributeOverrideAnnotation) this.javaResourcePersistentType.addSupportingAnnotation(index, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); attributeOverride.initialize(attributeOverrideResource); - this.fireItemAdded(Entity.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST, index, attributeOverride); + this.fireItemAdded(SPECIFIED_ATTRIBUTE_OVERRIDES_LIST, index, attributeOverride); return attributeOverride; } @@ -923,10 +923,10 @@ } this.javaResourcePersistentType.removeSupportingAnnotation(index, AttributeOverrideAnnotation.ANNOTATION_NAME, AttributeOverridesAnnotation.ANNOTATION_NAME); - fireItemRemoved(Entity.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST, index, attributeOverride); + fireItemRemoved(SPECIFIED_ATTRIBUTE_OVERRIDES_LIST, index, attributeOverride); if (virtualAttributeOverride != null) { - fireItemAdded(Entity.VIRTUAL_ATTRIBUTE_OVERRIDES_LIST, virtualAttributeOverridesSize() - 1, virtualAttributeOverride); + fireItemAdded(VIRTUAL_ATTRIBUTE_OVERRIDES_LIST, virtualAttributeOverridesSize() - 1, virtualAttributeOverride); } return virtualAttributeOverride; } @@ -945,8 +945,8 @@ newAttributeOverride.setName(oldAttributeOverride.getName()); newAttributeOverride.getColumn().setSpecifiedName(oldAttributeOverride.getColumn().getName()); - this.fireItemRemoved(Entity.VIRTUAL_ATTRIBUTE_OVERRIDES_LIST, defaultIndex, oldAttributeOverride); - this.fireItemAdded(Entity.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST, index, newAttributeOverride); + this.fireItemRemoved(VIRTUAL_ATTRIBUTE_OVERRIDES_LIST, defaultIndex, oldAttributeOverride); + this.fireItemAdded(SPECIFIED_ATTRIBUTE_OVERRIDES_LIST, index, newAttributeOverride); return newAttributeOverride; } @@ -956,7 +956,7 @@ } protected void addSpecifiedAttributeOverride(int index, JavaAttributeOverride attributeOverride) { - addItemToList(index, attributeOverride, this.specifiedAttributeOverrides, Entity.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST); + addItemToList(index, attributeOverride, this.specifiedAttributeOverrides, SPECIFIED_ATTRIBUTE_OVERRIDES_LIST); } protected void addSpecifiedAttributeOverride(JavaAttributeOverride attributeOverride) { @@ -964,21 +964,21 @@ } protected void removeSpecifiedAttributeOverride_(JavaAttributeOverride attributeOverride) { - removeItemFromList(attributeOverride, this.specifiedAttributeOverrides, Entity.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST); + removeItemFromList(attributeOverride, this.specifiedAttributeOverrides, SPECIFIED_ATTRIBUTE_OVERRIDES_LIST); } public void moveSpecifiedAttributeOverride(int targetIndex, int sourceIndex) { CollectionTools.move(this.specifiedAttributeOverrides, targetIndex, sourceIndex); this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex, AttributeOverridesAnnotation.ANNOTATION_NAME); - fireItemMoved(Entity.SPECIFIED_ATTRIBUTE_OVERRIDES_LIST, targetIndex, sourceIndex); + fireItemMoved(SPECIFIED_ATTRIBUTE_OVERRIDES_LIST, targetIndex, sourceIndex); } protected void addVirtualAttributeOverride(JavaAttributeOverride attributeOverride) { - addItemToList(attributeOverride, this.virtualAttributeOverrides, Entity.VIRTUAL_ATTRIBUTE_OVERRIDES_LIST); + addItemToList(attributeOverride, this.virtualAttributeOverrides, VIRTUAL_ATTRIBUTE_OVERRIDES_LIST); } protected void removeVirtualAttributeOverride(JavaAttributeOverride attributeOverride) { - removeItemFromList(attributeOverride, this.virtualAttributeOverrides, Entity.VIRTUAL_ATTRIBUTE_OVERRIDES_LIST); + removeItemFromList(attributeOverride, this.virtualAttributeOverrides, VIRTUAL_ATTRIBUTE_OVERRIDES_LIST); } public JavaAttributeOverride getAttributeOverrideNamed(String name) { @@ -1061,7 +1061,7 @@ this.specifiedAssociationOverrides.add(index, associationOverride); AssociationOverrideAnnotation associationOverrideResource = (AssociationOverrideAnnotation) this.javaResourcePersistentType.addSupportingAnnotation(index, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); associationOverride.initialize(associationOverrideResource); - this.fireItemAdded(Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST, index, associationOverride); + this.fireItemAdded(SPECIFIED_ASSOCIATION_OVERRIDES_LIST, index, associationOverride); return associationOverride; } @@ -1070,7 +1070,7 @@ } protected void addSpecifiedAssociationOverride(int index, JavaAssociationOverride associationOverride) { - addItemToList(index, associationOverride, this.specifiedAssociationOverrides, Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST); + addItemToList(index, associationOverride, this.specifiedAssociationOverrides, SPECIFIED_ASSOCIATION_OVERRIDES_LIST); } protected void addSpecifiedAssociationOverride(JavaAssociationOverride associationOverride) { @@ -1078,13 +1078,13 @@ } protected void removeSpecifiedAssociationOverride_(JavaAssociationOverride associationOverride) { - removeItemFromList(associationOverride, this.specifiedAssociationOverrides, Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST); + removeItemFromList(associationOverride, this.specifiedAssociationOverrides, SPECIFIED_ASSOCIATION_OVERRIDES_LIST); } public void moveSpecifiedAssociationOverride(int targetIndex, int sourceIndex) { CollectionTools.move(this.specifiedAssociationOverrides, targetIndex, sourceIndex); this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex, AssociationOverridesAnnotation.ANNOTATION_NAME); - fireItemMoved(Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST, targetIndex, sourceIndex); + fireItemMoved(SPECIFIED_ASSOCIATION_OVERRIDES_LIST, targetIndex, sourceIndex); } protected JavaAssociationOverride setAssociationOverrideVirtual(boolean virtual, JavaAssociationOverride associationOverride) { @@ -1107,7 +1107,7 @@ for (PersistentAttribute persistentAttribute : CollectionTools.iterable(allOverridableAssociations())) { if (persistentAttribute.getName().equals(associationOverrideName)) { //store the virtualAssociationOverride so we can fire change notification later - virtualAssociationOverride = buildAssociationOverride(new NullAssociationOverride(this.javaResourcePersistentType, associationOverrideName)); + virtualAssociationOverride = buildAssociationOverride(new NullAssociationOverrideAnnotation(this.javaResourcePersistentType, associationOverrideName)); this.virtualAssociationOverrides.add(virtualAssociationOverride); break; } @@ -1115,10 +1115,10 @@ } this.javaResourcePersistentType.removeSupportingAnnotation(index, AssociationOverrideAnnotation.ANNOTATION_NAME, AssociationOverridesAnnotation.ANNOTATION_NAME); - fireItemRemoved(Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST, index, associationOverride); + fireItemRemoved(SPECIFIED_ASSOCIATION_OVERRIDES_LIST, index, associationOverride); if (virtualAssociationOverride != null) { - fireItemAdded(Entity.VIRTUAL_ASSOCIATION_OVERRIDES_LIST, virtualAssociationOverridesSize() - 1, virtualAssociationOverride); + fireItemAdded(VIRTUAL_ASSOCIATION_OVERRIDES_LIST, virtualAssociationOverridesSize() - 1, virtualAssociationOverride); } return virtualAssociationOverride; } @@ -1136,18 +1136,18 @@ newAssociationOverride.setName(oldAssociationOverride.getName()); - this.fireItemRemoved(Entity.VIRTUAL_ASSOCIATION_OVERRIDES_LIST, virtualIndex, oldAssociationOverride); - this.fireItemAdded(Entity.SPECIFIED_ASSOCIATION_OVERRIDES_LIST, index, newAssociationOverride); + this.fireItemRemoved(VIRTUAL_ASSOCIATION_OVERRIDES_LIST, virtualIndex, oldAssociationOverride); + this.fireItemAdded(SPECIFIED_ASSOCIATION_OVERRIDES_LIST, index, newAssociationOverride); return newAssociationOverride; } protected void addVirtualAssociationOverride(JavaAssociationOverride associationOverride) { - addItemToList(associationOverride, this.virtualAssociationOverrides, Entity.VIRTUAL_ASSOCIATION_OVERRIDES_LIST); + addItemToList(associationOverride, this.virtualAssociationOverrides, VIRTUAL_ASSOCIATION_OVERRIDES_LIST); } protected void removeVirtualAssociationOverride(JavaAssociationOverride associationOverride) { - removeItemFromList(associationOverride, this.virtualAssociationOverrides, Entity.VIRTUAL_ASSOCIATION_OVERRIDES_LIST); + removeItemFromList(associationOverride, this.virtualAssociationOverrides, VIRTUAL_ASSOCIATION_OVERRIDES_LIST); } public ListIterator namedQueries() { @@ -1604,7 +1604,7 @@ } protected String getResourceName() { - return this.getResourceMapping().getName(); + return this.getResourceMappingAnnotation().getName(); } protected String getResourceDefaultName() { @@ -1637,14 +1637,14 @@ } protected Entity calculateRootEntity() { - Entity rootEntity = this; + Entity root = this; for (Iterator stream = getPersistentType().inheritanceHierarchy(); stream.hasNext();) { PersistentType persistentType = stream.next(); if (persistentType.getMapping() instanceof Entity) { - rootEntity = (Entity) persistentType.getMapping(); + root = (Entity) persistentType.getMapping(); } } - return rootEntity; + return root; } public void addSubEntity(Entity subEntity) { @@ -1830,10 +1830,10 @@ return; } if (getDefaultPrimaryKeyJoinColumn() == null) { - this.setDefaultPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumn(this.javaResourcePersistentType))); + this.setDefaultPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType))); } else { - this.defaultPrimaryKeyJoinColumn.update(new NullPrimaryKeyJoinColumn(this.javaResourcePersistentType)); + this.defaultPrimaryKeyJoinColumn.update(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType)); } } @@ -1863,12 +1863,12 @@ } protected JavaAttributeOverride buildVirtualAttributeOverride(PersistentAttribute attribute) { - return buildAttributeOverride(buildVirtualAttributeOverrideResource(attribute)); + return buildAttributeOverride(buildVirtualAttributeOverrideAnnotation(attribute)); } - protected VirtualAttributeOverride buildVirtualAttributeOverrideResource(PersistentAttribute attribute) { + protected VirtualAttributeOverrideAnnotation buildVirtualAttributeOverrideAnnotation(PersistentAttribute attribute) { ColumnMapping columnMapping = (ColumnMapping) attribute.getMapping(); - return new VirtualAttributeOverride(this.javaResourcePersistentType, attribute.getName(), columnMapping.getColumn()); + return new VirtualAttributeOverrideAnnotation(this.javaResourcePersistentType, attribute.getName(), columnMapping.getColumn()); } protected void updateVirtualAttributeOverrides( ) { @@ -1878,7 +1878,7 @@ addVirtualAttributeOverride(buildVirtualAttributeOverride(persistentAttribute)); } else if (attributeOverride.isVirtual()) { - attributeOverride.update(buildVirtualAttributeOverrideResource(persistentAttribute)); + attributeOverride.update(buildVirtualAttributeOverrideAnnotation(persistentAttribute)); } } @@ -1923,11 +1923,11 @@ String associationName = i.next(); JavaAssociationOverride associationOverride = getAssociationOverrideNamed(associationName); if (associationOverride == null) { - associationOverride = buildAssociationOverride(new NullAssociationOverride(this.javaResourcePersistentType, associationName)); + associationOverride = buildAssociationOverride(new NullAssociationOverrideAnnotation(this.javaResourcePersistentType, associationName)); addVirtualAssociationOverride(associationOverride); } else if (associationOverride.isVirtual()) { - associationOverride.update(new NullAssociationOverride(this.javaResourcePersistentType, associationName)); + associationOverride.update(new NullAssociationOverrideAnnotation(this.javaResourcePersistentType, associationName)); } } Index: src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java,v retrieving revision 1.4 diff -u -r1.4 AbstractJavaBasicMapping.java --- src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java 12 Mar 2009 05:07:38 -0000 1.4 +++ src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java 6 Apr 2009 20:59:12 -0000 @@ -119,7 +119,7 @@ public void setSpecifiedFetch(FetchType newSpecifiedFetch) { FetchType oldFetch = this.specifiedFetch; this.specifiedFetch = newSpecifiedFetch; - this.resourceMapping.setFetch(FetchType.toJavaResourceModel(newSpecifiedFetch)); + this.mappingAnnotation.setFetch(FetchType.toJavaResourceModel(newSpecifiedFetch)); firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch); } @@ -150,7 +150,7 @@ public void setSpecifiedOptional(Boolean newSpecifiedOptional) { Boolean oldOptional = this.specifiedOptional; this.specifiedOptional = newSpecifiedOptional; - this.resourceMapping.setOptional(newSpecifiedOptional); + this.mappingAnnotation.setOptional(newSpecifiedOptional); firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, oldOptional, newSpecifiedOptional); } @@ -218,11 +218,11 @@ } protected FetchType getResourceFetch() { - return FetchType.fromJavaResourceModel(this.resourceMapping.getFetch()); + return FetchType.fromJavaResourceModel(this.mappingAnnotation.getFetch()); } protected Boolean getResourceOptional() { - return this.resourceMapping.getOptional(); + return this.mappingAnnotation.getOptional(); } protected JavaConverter buildSpecifiedConverter(String converterType) { Index: src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java,v retrieving revision 1.18 diff -u -r1.18 AbstractJavaBaseEmbeddedMapping.java --- src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java 2 Apr 2009 17:28:48 -0000 1.18 +++ src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java 6 Apr 2009 20:59:12 -0000 @@ -26,10 +26,11 @@ import org.eclipse.jpt.core.context.java.JavaBaseEmbeddedMapping; import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; import org.eclipse.jpt.core.internal.context.MappingTools; +import org.eclipse.jpt.core.internal.resource.java.NullColumnAnnotation; +import org.eclipse.jpt.core.resource.java.Annotation; 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.NestableAnnotation; import org.eclipse.jpt.utility.Filter; import org.eclipse.jpt.utility.internal.CollectionTools; @@ -43,7 +44,7 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter; -public abstract class AbstractJavaBaseEmbeddedMapping +public abstract class AbstractJavaBaseEmbeddedMapping extends AbstractJavaAttributeMapping implements JavaBaseEmbeddedMapping { @@ -288,12 +289,12 @@ } protected JavaAttributeOverride buildVirtualAttributeOverride(String attributeName) { - return buildAttributeOverride(buildVirtualAttributeOverrideResource(attributeName)); + return buildAttributeOverride(buildVirtualAttributeOverrideAnnotation(attributeName)); } - protected VirtualAttributeOverride buildVirtualAttributeOverrideResource(String attributeName) { + protected VirtualAttributeOverrideAnnotation buildVirtualAttributeOverrideAnnotation(String attributeName) { ColumnMapping columnMapping = (ColumnMapping) this.getEmbeddable().getPersistentType().getAttributeNamed(attributeName).getMapping(); - return new VirtualAttributeOverride(this.resourcePersistentAttribute, attributeName, columnMapping.getColumn()); + return new VirtualAttributeOverrideAnnotation(this.resourcePersistentAttribute, attributeName, columnMapping.getColumn()); } protected void updateVirtualAttributeOverrides() { @@ -304,7 +305,7 @@ addVirtualAttributeOverride(buildVirtualAttributeOverride(attributeName)); } else if (attributeOverride.isVirtual()) { - attributeOverride.update(buildVirtualAttributeOverrideResource(attributeName)); + attributeOverride.update(buildVirtualAttributeOverrideAnnotation(attributeName)); } } Index: src/org/eclipse/jpt/core/internal/context/java/GenericJavaSecondaryTable.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaSecondaryTable.java,v retrieving revision 1.17 diff -u -r1.17 GenericJavaSecondaryTable.java --- src/org/eclipse/jpt/core/internal/context/java/GenericJavaSecondaryTable.java 26 Feb 2009 21:43:07 -0000 1.17 +++ src/org/eclipse/jpt/core/internal/context/java/GenericJavaSecondaryTable.java 6 Apr 2009 20:59:15 -0000 @@ -23,7 +23,7 @@ import org.eclipse.jpt.core.context.java.JavaEntity; import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn; import org.eclipse.jpt.core.context.java.JavaSecondaryTable; -import org.eclipse.jpt.core.internal.resource.java.NullPrimaryKeyJoinColumn; +import org.eclipse.jpt.core.internal.resource.java.NullPrimaryKeyJoinColumnAnnotation; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; @@ -176,7 +176,7 @@ //create the defaultJoinColumn now or this will happen during project update //after removing the join column from the resource model. That causes problems //in the UI because the change notifications end up in the wrong order. - this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumn(this.resourceSecondaryTable)); + this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.resourceSecondaryTable)); } this.resourceSecondaryTable.removePkJoinColumn(index); fireItemRemoved(SecondaryTable.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, removedPrimaryKeyJoinColumn); @@ -226,7 +226,7 @@ if (!shouldBuildDefaultPrimaryKeyJoinColumn()) { return; } - this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumn(secondaryTable)); + this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(secondaryTable)); } @@ -262,10 +262,10 @@ return; } if (getDefaultPrimaryKeyJoinColumn() == null) { - this.setDefaultPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumn(sta))); + this.setDefaultPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(sta))); } else { - this.defaultPrimaryKeyJoinColumn.update(new NullPrimaryKeyJoinColumn(sta)); + this.defaultPrimaryKeyJoinColumn.update(new NullPrimaryKeyJoinColumnAnnotation(sta)); } } Index: src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneMapping.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneMapping.java,v retrieving revision 1.16 diff -u -r1.16 GenericJavaManyToOneMapping.java --- src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneMapping.java 12 Mar 2009 05:07:38 -0000 1.16 +++ src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneMapping.java 6 Apr 2009 20:59:15 -0000 @@ -61,12 +61,12 @@ @Override protected Boolean getResourceOptional() { - return this.resourceMapping.getOptional(); + return this.mappingAnnotation.getOptional(); } @Override protected void setOptionalOnResourceModel(Boolean newOptional) { - this.resourceMapping.setOptional(newOptional); + this.mappingAnnotation.setOptional(newOptional); } @Override Index: src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumn.java diff -N src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumn.java --- src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumn.java 5 Sep 2008 15:27:19 -0000 1.6 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,146 +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.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.context.Column; -import org.eclipse.jpt.core.internal.resource.java.NullBaseColumn; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - - -public class VirtualAttributeOverrideColumn extends NullBaseColumn implements ColumnAnnotation, Annotation -{ - private Column column; - - public VirtualAttributeOverrideColumn(AttributeOverrideAnnotation parent, Column column) { - super(parent); - this.column = column; - } - - @Override - public AttributeOverrideAnnotation getParent() { - return (AttributeOverrideAnnotation) super.getParent(); - } - - public String getAnnotationName() { - return ColumnAnnotation.ANNOTATION_NAME; - } - - @Override - protected ColumnAnnotation createResourceColumn() { - return getParent().addColumn(); - } - - @Override - public String getName() { - if (this.column.getSpecifiedName() != null) { - return this.column.getSpecifiedName(); - } - return null; - } - - @Override - public String getTable() { - if (this.column.getSpecifiedTable() != null) { - return this.column.getSpecifiedTable(); - } - return null; - } - - @Override - public Boolean getInsertable() { - if (this.column.getSpecifiedInsertable() != null) { - return this.column.getSpecifiedInsertable(); - } - return null; - } - - @Override - public Boolean getUpdatable() { - if (this.column.getSpecifiedUpdatable() != null) { - return this.column.getSpecifiedUpdatable(); - } - return null; - } - @Override - public Boolean getNullable() { - if (this.column.getSpecifiedNullable() != null) { - return this.column.getSpecifiedNullable(); - } - return null; - } - - @Override - public Boolean getUnique() { - if (this.column.getSpecifiedUnique() != null) { - return this.column.getSpecifiedUnique(); - } - return null; - } - - @Override - public String getColumnDefinition() { - return this.column.getColumnDefinition(); - } - - public Integer getLength() { - if (this.column.getSpecifiedLength() != null) { - return this.column.getSpecifiedLength(); - } - return null; - } - - public void setLength(Integer length) { - if (length != null) { - createResourceColumn().setLength(length); - } - } - - public Integer getScale() { - if (this.column.getSpecifiedScale() != null) { - return this.column.getSpecifiedScale(); - } - return null; - } - - public void setScale(Integer scale) { - if (scale != null) { - createResourceColumn().setScale(scale); - } - } - - public Integer getPrecision() { - if (this.column.getSpecifiedPrecision() != null) { - return this.column.getSpecifiedPrecision(); - } - return null; - } - - public void setPrecision(Integer precision) { - if (precision != null) { - createResourceColumn().setPrecision(precision); - } - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - return null; - } -} Index: src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverride.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverride.java diff -N src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverride.java --- src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverride.java 20 Oct 2008 20:52:49 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,112 +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.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.context.Column; -import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - - -public class VirtualAttributeOverride extends AbstractJavaResourceNode implements AttributeOverrideAnnotation, Annotation -{ - private final VirtualAttributeOverrideColumn column; - - private String name; - - public VirtualAttributeOverride(JavaResourceNode parent, String name, Column column) { - super(parent); - this.name = name; - this.column = new VirtualAttributeOverrideColumn(this, column); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return AttributeOverrideAnnotation.ANNOTATION_NAME; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - if (name != null) { - createAttributeOverrideResource().setName(name); - } - } - - public ColumnAnnotation getNonNullColumn() { - return getColumn(); - } - - public ColumnAnnotation getColumn() { - return this.column; - } - - public ColumnAnnotation addColumn() { - throw new UnsupportedOperationException(); - } - - public void removeColumn() { - throw new UnsupportedOperationException(); - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - protected AttributeOverrideAnnotation createAttributeOverrideResource() { - return (AttributeOverrideAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return false; - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideImpl.java 23 Oct 2008 19:04:08 -0000 1.13 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAttributeOverride; -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; - -public class AttributeOverrideImpl - extends OverrideImpl - implements NestableAttributeOverride -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final MemberAnnotationAdapter columnAdapter; - - private ColumnImpl column; - - - protected AttributeOverrideImpl(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.columnAdapter = new MemberAnnotationAdapter(getMember(), ColumnImpl.buildAttributeOverrideAnnotationAdapter(getDeclarationAnnotationAdapter())); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - if (this.columnAdapter.getAnnotation(astRoot) != null) { - this.column = ColumnImpl.createAttributeOverrideColumn(this, getMember(), getDeclarationAnnotationAdapter()); - this.column.initialize(astRoot); - } - } - - public String getAnnotationName() { - return AttributeOverrideAnnotation.ANNOTATION_NAME; - } - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - AttributeOverrideAnnotation oldAttributeOverride = (AttributeOverrideAnnotation) oldAnnotation; - if (oldAttributeOverride.getColumn() != null) { - ColumnAnnotation column = addColumn(); - ((NestableAnnotation) column).initializeFrom((NestableAnnotation) oldAttributeOverride.getColumn()); - } - } - - //************ AttributeOverride implementation **************** - - public ColumnAnnotation getNonNullColumn() { - return (getColumn() != null) ? getColumn() : new NullAttributeOverrideColumn(this); - } - - public ColumnAnnotation getColumn() { - return this.column; - } - - public ColumnAnnotation addColumn() { - ColumnImpl column = ColumnImpl.createAttributeOverrideColumn(this, getMember(), getDeclarationAnnotationAdapter()); - column.newAnnotation(); - setColumn(column); - return column; - } - - public void removeColumn() { - this.column.removeAnnotation(); - setColumn(null); - } - - protected void setColumn(ColumnImpl newColumn) { - ColumnImpl oldColumn = this.column; - this.column = newColumn; - firePropertyChanged(AttributeOverrideAnnotation.COLUMN_PROPERTY, oldColumn, newColumn); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - if (this.columnAdapter.getAnnotation(astRoot) == null) { - this.setColumn(null); - } - else { - if (getColumn() != null) { - getColumn().update(astRoot); - } - else { - ColumnImpl column = ColumnImpl.createAttributeOverrideColumn(this, getMember(), getDeclarationAnnotationAdapter()); - column.initialize(astRoot); - this.setColumn(column); - } - } - } - - // ********** static methods ********** - static AttributeOverrideImpl createAttributeOverride(JavaResourceNode parent, Member member) { - return new AttributeOverrideImpl(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); - } - - static AttributeOverrideImpl createNestedAttributeOverride(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa); - return new AttributeOverrideImpl(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(attributeOverridesAdapter, index, JPA.ATTRIBUTE_OVERRIDE); - } - - public static class AttributeOverrideAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final AttributeOverrideAnnotationDefinition 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 AttributeOverrideImpl.createAttributeOverride(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return AttributeOverrideAnnotation.ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueImpl.java 23 Oct 2008 19:04:08 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.resource.java.JavaResourcePersistentMember; -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; -import org.eclipse.jpt.core.utility.jdt.Type; - -public class DiscriminatorValueImpl extends AbstractResourceAnnotation implements DiscriminatorValueAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - - private final AnnotationElementAdapter valueAdapter; - - private String value; - - protected DiscriminatorValueImpl(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(type, VALUE_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public String getValue() { - return this.value; - } - - public void setValue(String newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - String oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(newValue); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected String value(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_VALUE__VALUE); - } - - - public static class DiscriminatorValueAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final DiscriminatorValueAnnotationDefinition 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 DiscriminatorValueImpl(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullDiscriminatorValue(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/IdClassImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/IdClassImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/IdClassImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/IdClassImpl.java 23 Oct 2008 19:04:07 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,139 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.resource.java.JavaResourcePersistentMember; -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; -import org.eclipse.jpt.core.utility.jdt.Type; - -public class IdClassImpl extends AbstractResourceAnnotation implements IdClassAnnotation -{ - private final AnnotationElementAdapter valueAdapter; - - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - private String value; - - private String fullyQualifiedValue; - - public IdClassImpl(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(type, VALUE_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - this.fullyQualifiedValue = fullyQualifiedClass(astRoot); - } - - public String getAnnotationName() { - return IdClassAnnotation.ANNOTATION_NAME; - } - - public String getValue() { - return this.value; - } - - public void setValue(String newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - String oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(newValue); - firePropertyChanged(IdClassAnnotation.VALUE_PROPERTY, oldValue, newValue); - } - - public String getFullyQualifiedClass() { - return this.fullyQualifiedValue; - } - - private void setFullyQualifiedClass(String newQualifiedClass) { - String oldQualifiedClass = this.fullyQualifiedValue; - this.fullyQualifiedValue = newQualifiedClass; - firePropertyChanged(IdClassAnnotation.FULLY_QUALIFIED_CLASS_PROPERTY, oldQualifiedClass, newQualifiedClass); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - this.setFullyQualifiedClass(this.fullyQualifiedClass(astRoot)); - } - - protected String value(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - private String fullyQualifiedClass(CompilationUnit astRoot) { - if (getValue() == null) { - return null; - } - return JDTTools.resolveFullyQualifiedName(this.valueAdapter.getExpression(astRoot)); - } - - // ********** static methods ********** - protected static DeclarationAnnotationElementAdapter buildValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ID_CLASS__VALUE, SimpleTypeStringExpressionConverter.instance()); - } - - - public static class IdClassAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final IdClassAnnotationDefinition 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 IdClassImpl(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValue.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValue.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValue.java --- src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValue.java 20 Oct 2008 20:52:50 -0000 1.12 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullDiscriminatorValue extends AbstractJavaResourceNode implements DiscriminatorValueAnnotation, Annotation -{ - protected NullDiscriminatorValue(JavaResourcePersistentMember parent) { - super(parent); - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return DiscriminatorValueAnnotation.ANNOTATION_NAME; - } - - public String getValue() { - return null; - } - - public void setValue(String value) { - if (value != null) { - createDiscriminatorValueResource().setValue(value); - } - } - - protected DiscriminatorValueAnnotation createDiscriminatorValueResource() { - return (DiscriminatorValueAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsImpl.java 23 Oct 2008 19:04:08 -0000 1.13 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumn; -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; - -public class JoinColumnsImpl extends AbstractResourceAnnotation implements JoinColumnsAnnotation -{ - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private List joinColumns; - - protected JoinColumnsImpl(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.joinColumns = new ArrayList(); - } - - public void initialize(CompilationUnit astRoot) { - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public String getNestableAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(this.joinColumns); - } - - public int nestedAnnotationsSize() { - return this.joinColumns.size(); - } - - public NestableJoinColumn addInternal(int index) { - JoinColumnImpl joinColumn = createJoinColumn(index); - this.joinColumns.add(index, joinColumn); - return joinColumn; - } - - public NestableJoinColumn add(int index) { - JoinColumnImpl joinColumn = createJoinColumn(index); - add(index, joinColumn); - return joinColumn; - } - - protected void add(int index, NestableJoinColumn joinColumn) { - addItemToList(index, joinColumn, this.joinColumns, JOIN_COLUMNS_LIST); - } - - public void remove(NestableJoinColumn joinColumn) { - removeItemFromList(joinColumn, this.joinColumns, JOIN_COLUMNS_LIST); - } - - public void remove(int index) { - removeItemFromList(index, this.joinColumns, JOIN_COLUMNS_LIST); - } - - public int indexOf(NestableJoinColumn joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public NestableJoinColumn nestedAnnotationAt(int index) { - return this.joinColumns.get(index); - } - - public NestableJoinColumn nestedAnnotationFor(Annotation jdtAnnotation) { - for (NestableJoinColumn joinColumn : this.joinColumns) { - if (jdtAnnotation == joinColumn.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return joinColumn; - } - } - return null; - } - - public void move(int targetIndex, int sourceIndex) { - moveItemInList(targetIndex, sourceIndex, this.joinColumns, JOIN_COLUMNS_LIST); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.joinColumns, targetIndex, sourceIndex); - } - - public String getElementName() { - return JPA.JOIN_COLUMNS__VALUE; - } - - public void update(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this); - } - - private JoinColumnImpl createJoinColumn(int index) { - return JoinColumnImpl.createNestedJoinColumn(this, getMember(), index, getDeclarationAnnotationAdapter()); - } - - - public static class JoinColumnsAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final JoinColumnsAnnotationDefinition 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 JoinColumnsImpl(parent, member); - } - - public JoinColumnsAnnotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/TableImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/TableImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/TableImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/TableImpl.java 23 Oct 2008 19:04:08 -0000 1.12 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraint; -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; - -public class TableImpl extends AbstractResourceTable -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__NAME); - - private static final DeclarationAnnotationElementAdapter SCHEMA_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__SCHEMA); - - private static final DeclarationAnnotationElementAdapter CATALOG_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__CATALOG); - - protected TableImpl(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); - } - - public String getAnnotationName() { - return TableAnnotation.ANNOTATION_NAME; - } - - @Override - protected DeclarationAnnotationElementAdapter getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @Table is never nested - return NAME_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @Table is never nested - return SCHEMA_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @Table is never nested - return CATALOG_ADAPTER; - } - - @Override - protected String getUniqueConstraintsElementName() { - return JPA.TABLE__UNIQUE_CONSTRAINTS; - } - - @Override - protected NestableUniqueConstraint createUniqueConstraint(int index) { - return UniqueConstraintImpl.createTableUniqueConstraint(this, this.getMember(), index); - } - - public static class TableAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final TableAnnotationDefinition 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 TableImpl(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullTable(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassImpl.java 23 Oct 2008 19:04:07 -0000 1.9 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - - -public class MappedSuperclassImpl extends AbstractResourceAnnotation implements MappedSuperclassAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected MappedSuperclassImpl(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void update(CompilationUnit astRoot) { - //no annotation members - } - - public static class MappedSuperclassAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final MappedSuperclassAnnotationDefinition INSTANCE = new MappedSuperclassAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static MappedSuperclassAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MappedSuperclassAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new MappedSuperclassImpl((JavaResourcePersistentType) parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorImpl.java 23 Oct 2008 19:04:08 -0000 1.21 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,525 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraint; -import org.eclipse.jpt.core.resource.java.TableAnnotation; -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.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * - */ -public class TableGeneratorImpl - extends GeneratorImpl - implements TableGeneratorAnnotation -{ - private final AnnotationElementAdapter tableAdapter; - - private final AnnotationElementAdapter catalogAdapter; - - private final AnnotationElementAdapter schemaAdapter; - - private final AnnotationElementAdapter pkColumnNameAdapter; - - private final AnnotationElementAdapter valueColumnNameAdapter; - - private final AnnotationElementAdapter pkColumnValueAdapter; - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__NAME); - - private static final DeclarationAnnotationElementAdapter INITIAL_VALUE_ADAPTER = buildIntegerAdapter(JPA.TABLE_GENERATOR__INITIAL_VALUE); - - private static final DeclarationAnnotationElementAdapter ALLOCATION_SIZE_ADAPTER = buildIntegerAdapter(JPA.TABLE_GENERATOR__ALLOCATION_SIZE); - - private static final DeclarationAnnotationElementAdapter TABLE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__TABLE); - - private static final DeclarationAnnotationElementAdapter CATALOG_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__CATALOG); - - private static final DeclarationAnnotationElementAdapter SCHEMA_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__SCHEMA); - - private static final DeclarationAnnotationElementAdapter PK_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_NAME); - - private static final DeclarationAnnotationElementAdapter VALUE_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__VALUE_COLUMN_NAME); - - private static final DeclarationAnnotationElementAdapter PK_COLUMN_VALUE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_VALUE); - - private String table; - - private String catalog; - - private String schema; - - private String pkColumnName; - - private String valueColumnName; - - private String pkColumnValue; - - final List uniqueConstraints; - - private final UniqueConstraintsContainerAnnotation uniqueConstraintsContainerAnnotation; - - - protected TableGeneratorImpl(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); - this.uniqueConstraints = new ArrayList(); - this.uniqueConstraintsContainerAnnotation = new UniqueConstraintsContainerAnnotation(); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.table = this.table(astRoot); - this.catalog = this.catalog(astRoot); - this.schema = this.schema(astRoot); - this.pkColumnName = this.pkColumnName(astRoot); - this.valueColumnName = this.valueColumnName(astRoot); - this.pkColumnValue = this.pkColumnValue(astRoot); - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this.uniqueConstraintsContainerAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - //************ GeneratorImpl implementation ************** - - @Override - protected DeclarationAnnotationElementAdapter getAllocationSizeAdapter() { - return ALLOCATION_SIZE_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getInitialValueAdapter() { - return INITIAL_VALUE_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getNameAdapter() { - return NAME_ADAPTER; - } - - public String getTable() { - return this.table; - } - - public void setTable(String newTable) { - if (attributeValueHasNotChanged(this.table, newTable)) { - return; - } - String oldTable = this.table; - this.table = newTable; - this.tableAdapter.setValue(newTable); - firePropertyChanged(TABLE_PROPERTY, oldTable, newTable); - } - - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String newCatalog) { - if (attributeValueHasNotChanged(this.catalog, newCatalog)) { - return; - } - String oldCatalog = this.catalog; - this.catalog = newCatalog; - this.catalogAdapter.setValue(newCatalog); - firePropertyChanged(CATALOG_PROPERTY, oldCatalog, newCatalog); - } - - public String getSchema() { - return this.schema; - } - - public void setSchema(String newSchema) { - if (attributeValueHasNotChanged(this.schema, newSchema)) { - return; - } - String oldSchema = this.schema; - this.schema = newSchema; - this.schemaAdapter.setValue(newSchema); - firePropertyChanged(SCHEMA_PROPERTY, oldSchema, newSchema); - } - - public String getPkColumnName() { - return this.pkColumnName; - } - - public void setPkColumnName(String newPkColumnName) { - if (attributeValueHasNotChanged(this.pkColumnName, newPkColumnName)) { - return; - } - String oldPkColumnName = this.pkColumnName; - this.pkColumnName = newPkColumnName; - this.pkColumnNameAdapter.setValue(newPkColumnName); - firePropertyChanged(PK_COLUMN_NAME_PROPERTY, oldPkColumnName, newPkColumnName); - } - - public String getValueColumnName() { - return this.valueColumnName; - } - - public void setValueColumnName(String newValueColumnName) { - if (attributeValueHasNotChanged(this.valueColumnName, newValueColumnName)) { - return; - } - String oldValueColumnName = this.valueColumnName; - this.valueColumnName = newValueColumnName; - this.valueColumnNameAdapter.setValue(newValueColumnName); - firePropertyChanged(VALUE_COLUMN_NAME_PROPERTY, oldValueColumnName, newValueColumnName); - } - - public String getPkColumnValue() { - return this.pkColumnValue; - } - - public void setPkColumnValue(String newPkColumnValue) { - if (attributeValueHasNotChanged(this.pkColumnValue, newPkColumnValue)) { - return; - } - String oldPkColumnValue = this.pkColumnValue; - this.pkColumnValue = newPkColumnValue; - this.pkColumnValueAdapter.setValue(newPkColumnValue); - firePropertyChanged(PK_COLUMN_VALUE_PROPERTY, oldPkColumnValue, newPkColumnValue); - } - - public ListIterator uniqueConstraints() { - return new CloneListIterator(this.uniqueConstraints); - } - - public int uniqueConstraintsSize() { - return this.uniqueConstraints.size(); - } - - public NestableUniqueConstraint uniqueConstraintAt(int index) { - return this.uniqueConstraints.get(index); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - return this.uniqueConstraints.indexOf(uniqueConstraint); - } - - public NestableUniqueConstraint addUniqueConstraint(int index) { - NestableUniqueConstraint uniqueConstraint = (NestableUniqueConstraint) ContainerAnnotationTools.addNestedAnnotation(index, this.uniqueConstraintsContainerAnnotation); - fireItemAdded(TableGeneratorAnnotation.UNIQUE_CONSTRAINTS_LIST, index, uniqueConstraint); - return uniqueConstraint; - } - - protected void addUniqueConstraint(int index, NestableUniqueConstraint uniqueConstraint) { - addItemToList(index, uniqueConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST); - } - - public void removeUniqueConstraint(int index) { - NestableUniqueConstraint uniqueConstraint = this.uniqueConstraints.get(index); - removeUniqueConstraint(uniqueConstraint); - uniqueConstraint.removeAnnotation(); - synchUniqueConstraintAnnotationsAfterRemove(index); - } - - protected void removeUniqueConstraint(NestableUniqueConstraint uniqueConstraint) { - removeItemFromList(uniqueConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - moveUniqueConstraintInternal(targetIndex, sourceIndex); - ContainerAnnotationTools.synchAnnotationsAfterMove(targetIndex, sourceIndex, this.uniqueConstraintsContainerAnnotation); - fireItemMoved(TableAnnotation.UNIQUE_CONSTRAINTS_LIST, targetIndex, sourceIndex); - } - - protected void moveUniqueConstraintInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.uniqueConstraints, targetIndex, sourceIndex); - } - - /** - * synchronize the annotations with the model join columns, - * starting at the specified index to prevent overlap - */ - private void synchUniqueConstraintAnnotationsAfterRemove(int index) { - ContainerAnnotationTools.synchAnnotationsAfterRemove(index, this.uniqueConstraintsContainerAnnotation); - } - - protected NestableUniqueConstraint createUniqueConstraint(int index) { - return UniqueConstraintImpl.createTableGeneratorUniqueConstraint(this, this.getMember(), index); - } - - - // ********** text ranges ********** - - 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); - } - - 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); - } - - 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); - } - - 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); - } - - 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); - } - - 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); - } - - // ********** java annotations -> persistence model ********** - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setTable(this.table(astRoot)); - this.setCatalog(this.catalog(astRoot)); - this.setSchema(this.schema(astRoot)); - this.setPkColumnName(this.pkColumnName(astRoot)); - this.setValueColumnName(this.valueColumnName(astRoot)); - this.setPkColumnValue(this.pkColumnValue(astRoot)); - this.updateUniqueConstraintsFromJava(astRoot); - } - - protected String table(CompilationUnit astRoot) { - return this.tableAdapter.getValue(astRoot); - } - protected String catalog(CompilationUnit astRoot) { - return this.catalogAdapter.getValue(astRoot); - } - protected String schema(CompilationUnit astRoot) { - return this.schemaAdapter.getValue(astRoot); - } - protected String pkColumnName(CompilationUnit astRoot) { - return this.pkColumnNameAdapter.getValue(astRoot); - } - protected String valueColumnName(CompilationUnit astRoot) { - return this.valueColumnNameAdapter.getValue(astRoot); - } - protected String pkColumnValue(CompilationUnit astRoot) { - return this.pkColumnValueAdapter.getValue(astRoot); - } - - /** - * here we just worry about getting the unique constraints lists the same size; - * then we delegate to the unique constraints to synch themselves up - */ - private void updateUniqueConstraintsFromJava(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this.uniqueConstraintsContainerAnnotation); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildAdapter(String elementName) { - return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - private static DeclarationAnnotationElementAdapter buildIntegerAdapter(String elementName) { - return buildIntegerAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - - // ********** unique constraints container annotation ********** - - private class UniqueConstraintsContainerAnnotation - extends AbstractJavaResourceNode - implements ContainerAnnotation - { - public UniqueConstraintsContainerAnnotation() { - super(TableGeneratorImpl.this); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public NestableUniqueConstraint addInternal(int index) { - NestableUniqueConstraint uniqueConstraint = TableGeneratorImpl.this.createUniqueConstraint(index); - TableGeneratorImpl.this.uniqueConstraints.add(index, uniqueConstraint); - return uniqueConstraint; - } - - public NestableUniqueConstraint add(int index) { - NestableUniqueConstraint uniqueConstraint = TableGeneratorImpl.this.createUniqueConstraint(index); - TableGeneratorImpl.this.addUniqueConstraint(index, uniqueConstraint); - return uniqueConstraint; - } - - public String getAnnotationName() { - return TableGeneratorImpl.this.getAnnotationName(); - } - - public String getNestableAnnotationName() { - return JPA.UNIQUE_CONSTRAINT; - } - - public int indexOf(NestableUniqueConstraint uniqueConstraint) { - return TableGeneratorImpl.this.indexOfUniqueConstraint(uniqueConstraint); - } - - public void move(int targetIndex, int sourceIndex) { - TableGeneratorImpl.this.moveUniqueConstraint(targetIndex, sourceIndex); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - TableGeneratorImpl.this.moveUniqueConstraintInternal(targetIndex, sourceIndex); - } - - public NestableUniqueConstraint nestedAnnotationAt(int index) { - return TableGeneratorImpl.this.uniqueConstraintAt(index); - } - - public NestableUniqueConstraint nestedAnnotationFor(org.eclipse.jdt.core.dom.Annotation jdtAnnotation) { - for (NestableUniqueConstraint uniqueConstraint : CollectionTools.iterable(nestedAnnotations())) { - if (jdtAnnotation == uniqueConstraint.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return uniqueConstraint; - } - } - return null; - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(TableGeneratorImpl.this.uniqueConstraints); - } - - public int nestedAnnotationsSize() { - return TableGeneratorImpl.this.uniqueConstraints.size(); - } - - public void remove(NestableUniqueConstraint uniqueConstraint) { - TableGeneratorImpl.this.removeUniqueConstraint(uniqueConstraint); - } - - public void remove(int index) { - this.remove(nestedAnnotationAt(index)); - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return TableGeneratorImpl.this.getJdtAnnotation(astRoot); - } - - public void newAnnotation() { - TableGeneratorImpl.this.newAnnotation(); - } - - public void removeAnnotation() { - TableGeneratorImpl.this.removeAnnotation(); - } - - public void update(CompilationUnit astRoot) { - TableGeneratorImpl.this.update(astRoot); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return TableGeneratorImpl.this.getTextRange(astRoot); - } - - public String getElementName() { - return JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getAnnotationName()); - } - - } - - - // ********** annotation definition ********** - - public static class TableGeneratorAnnotationDefinition - implements AnnotationDefinition - { - // singleton - private static final TableGeneratorAnnotationDefinition 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 TableGeneratorImpl(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullAccessAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/NullAccessAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 NullAccessAnnotation.java --- src/org/eclipse/jpt/core/internal/resource/java/NullAccessAnnotation.java 25 Mar 2009 21:34:28 -0000 1.2 +++ src/org/eclipse/jpt/core/internal/resource/java/NullAccessAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -12,66 +12,43 @@ import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.resource.java.AccessAnnotation; import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.utility.TextRange; -public class NullAccessAnnotation extends AbstractJavaResourceNode implements AccessAnnotation, Annotation +/** + * javax.persistence.Access + */ +public class NullAccessAnnotation + extends NullAnnotation + implements AccessAnnotation { + protected NullAccessAnnotation(JavaResourcePersistentMember parent) { super(parent); } - @Override - public JavaResourcePersistentType getParent() { - return (JavaResourcePersistentType) super.getParent(); - } - public String getAnnotationName() { - return AccessAnnotation.ANNOTATION_NAME; + return ANNOTATION_NAME; } - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - protected AccessAnnotation createAccessAnnotation() { - return (AccessAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); + @Override + protected AccessAnnotation buildSupportingAnnotation() { + return (AccessAnnotation) super.buildSupportingAnnotation(); } + // ***** value public AccessType getValue() { return null; } public void setValue(AccessType value) { if (value != null) { - createAccessAnnotation().setValue(value); + this.buildSupportingAnnotation().setValue(value); } } - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - public TextRange getValueTextRange(CompilationUnit astRoot) { return null; } - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - } Index: src/org/eclipse/jpt/core/internal/resource/java/TransientImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/TransientImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/TransientImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/TransientImpl.java 23 Oct 2008 19:04:07 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -public class TransientImpl extends AbstractResourceAnnotation implements TransientAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected TransientImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void update(CompilationUnit astRoot) { - //no annotation members - } - - public static class TransientAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final TransientAnnotationDefinition INSTANCE = new TransientAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static TransientAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private TransientAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new TransientImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/VersionImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/VersionImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/VersionImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/VersionImpl.java 23 Oct 2008 19:04:08 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -public class VersionImpl extends AbstractResourceAnnotation implements VersionAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - public VersionImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void update(CompilationUnit astRoot) { - //no annotation members - } - - public static class VersionAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final VersionAnnotationDefinition INSTANCE = new VersionAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static VersionAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private VersionAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new VersionImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesImpl.java 23 Oct 2008 19:04:08 -0000 1.13 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NamedNativeQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedNativeQuery; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -public class NamedNativeQueriesImpl extends AbstractResourceAnnotation implements NamedNativeQueriesAnnotation -{ - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private List namedNativeQueries; - - protected NamedNativeQueriesImpl(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.namedNativeQueries = new ArrayList(); - } - - public void initialize(CompilationUnit astRoot) { - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this); - } - - public String getAnnotationName() { - return NamedNativeQueriesAnnotation.ANNOTATION_NAME; - } - - public String getNestableAnnotationName() { - return NamedNativeQueryAnnotation.ANNOTATION_NAME; - } - - public String getElementName() { - return JPA.NAMED_NATIVE_QUERIES__VALUE; - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(this.namedNativeQueries); - } - - public int nestedAnnotationsSize() { - return this.namedNativeQueries.size(); - } - - public NestableNamedNativeQuery addInternal(int index) { - NestableNamedNativeQuery namedNativeQuery = createNamedNativeQuery(index); - this.namedNativeQueries.add(index, namedNativeQuery); - return namedNativeQuery; - } - - public NestableNamedNativeQuery add(int index) { - NestableNamedNativeQuery namedNativeQuery = createNamedNativeQuery(index); - add(index, namedNativeQuery); - return namedNativeQuery; - } - - protected void add(int index, NestableNamedNativeQuery query) { - addItemToList(index, query, this.namedNativeQueries, NamedNativeQueriesAnnotation.NAMED_NATIVE_QUERIES_LIST); - } - - public void remove(NestableNamedNativeQuery query) { - removeItemFromList(query, this.namedNativeQueries, NamedNativeQueriesAnnotation.NAMED_NATIVE_QUERIES_LIST); - } - - public void remove(int index) { - removeItemFromList(index, this.namedNativeQueries, NamedNativeQueriesAnnotation.NAMED_NATIVE_QUERIES_LIST); - } - - public int indexOf(NestableNamedNativeQuery query) { - return this.namedNativeQueries.indexOf(query); - } - - public NestableNamedNativeQuery nestedAnnotationAt(int index) { - return this.namedNativeQueries.get(index); - } - - public NestableNamedNativeQuery nestedAnnotationFor(org.eclipse.jdt.core.dom.Annotation jdtAnnotation) { - for (NestableNamedNativeQuery namedQuery : this.namedNativeQueries) { - if (jdtAnnotation == namedQuery.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return namedQuery; - } - } - return null; - } - - public void move(int targetIndex, int sourceIndex) { - moveItemInList(targetIndex, sourceIndex, this.namedNativeQueries, NAMED_NATIVE_QUERIES_LIST); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.namedNativeQueries, targetIndex, sourceIndex); - } - - public void update(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this); - } - - private NamedNativeQueryImpl createNamedNativeQuery(int index) { - return NamedNativeQueryImpl.createNestedNamedNativeQuery(this, getMember(), index, getDeclarationAnnotationAdapter()); - } - - - public static class NamedNativeQueriesAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final NamedNativeQueriesAnnotationDefinition 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 NamedNativeQueriesImpl(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentTypeImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentTypeImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentTypeImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentTypeImpl.java 10 Mar 2009 04:12:10 -0000 1.21 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,626 +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.Collection; -import java.util.HashMap; -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.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.Counter; -import org.eclipse.jpt.utility.internal.iterators.CloneIterator; -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 - */ -public class JavaResourcePersistentTypeImpl - extends AbstractJavaResourcePersistentMember - implements JavaResourcePersistentType -{ - private String name; - - private String qualifiedName; - - private String superClassQualifiedName; - - private boolean abstract_; // 'abstract' is a reserved word - - private final Vector types; - - private final Vector fields; - - private final Vector methods; - - private AccessType access; - - - // ********** construction/initialization ********** - - /** - * build top-level persistent type - */ - public static JavaResourcePersistentType newInstance( - JavaResourceCompilationUnit javaResourceCompilationUnit, - TypeDeclaration typeDeclaration, - CompilationUnit astRoot) { - Type type = new JDTType( - typeDeclaration, - javaResourceCompilationUnit.getCompilationUnit(), - javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(), - javaResourceCompilationUnit.getAnnotationEditFormatter()); - JavaResourcePersistentType jrpt = new JavaResourcePersistentTypeImpl(javaResourceCompilationUnit, type); - jrpt.initialize(astRoot); - return jrpt; - } - - /** - * build nested persistent type - */ - protected 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 JavaResourcePersistentTypeImpl(javaResourceCompilationUnit, type); - jrpt.initialize(astRoot); - return jrpt; - } - - protected JavaResourcePersistentTypeImpl(JavaResourceCompilationUnit javaResourceCompilationUnit, Type type) { - super(javaResourceCompilationUnit, type); - this.types = new Vector(); - this.fields = new Vector(); - this.methods = new Vector(); - } - - @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(); - } - - protected void initializeTypes(CompilationUnit astRoot) { - TypeDeclaration[] typeDeclarations = this.getMember().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)); - } - } - - protected void initializeFields(CompilationUnit astRoot) { - FieldDeclaration[] fieldDeclarations = this.getMember().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)); - } - } - } - - protected void initializeMethods(CompilationUnit astRoot) { - MethodDeclaration[] methodDeclarations = this.getMember().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 - protected Annotation buildMappingAnnotation(String mappingAnnotationName) { - return this.getAnnotationProvider().buildTypeMappingAnnotation(this, this.getMember(), mappingAnnotationName); - } - - @Override - protected Annotation buildNullMappingAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullTypeMappingAnnotation(this, this.getMember(), annotationName); - } - - @Override - protected Annotation buildSupportingAnnotation(String annotationName) { - return this.getAnnotationProvider().buildTypeSupportingAnnotation(this, this.getMember(), annotationName); - } - - @Override - protected Annotation buildNullSupportingAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullTypeSupportingAnnotation(this, this.getMember(), annotationName); - } - - @Override - protected ListIterator validMappingAnnotationNames() { - return this.getAnnotationProvider().typeMappingAnnotationNames(); - } - - @Override - protected ListIterator validSupportingAnnotationNames() { - return this.getAnnotationProvider().typeSupportingAnnotationNames(); - } - - @Override - public void resolveTypes(CompilationUnit astRoot) { - super.resolveTypes(astRoot); - - this.setSuperClassQualifiedName(this.buildSuperClassQualifiedName(astRoot)); - - for (Iterator stream = this.fields(); stream.hasNext(); ) { - stream.next().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 (Iterator stream = this.methods(); stream.hasNext(); ) { - stream.next().resolveTypes(astRoot); - } - synchronized (this.types) { - for (JavaResourcePersistentType type : this.types) { - type.resolveTypes(astRoot); - } - } - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ******** JavaResourcePersistentType implementation ******** - - // ***** name - public String getName() { - return this.name; - } - - protected void setName(String name) { - String old = this.name; - this.name = name; - this.firePropertyChanged(NAME_PROPERTY, old, name); - } - - protected String buildName(CompilationUnit astRoot) { - ITypeBinding binding = this.getMember().getBinding(astRoot); - return (binding == null) ? null : binding.getName(); - } - - // ***** qualified name - public String getQualifiedName() { - return this.qualifiedName; - } - - protected void setQualifiedName(String qualifiedName) { - String old = this.qualifiedName; - this.qualifiedName = qualifiedName; - this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, qualifiedName); - } - - protected String buildQualifiedName(CompilationUnit astRoot) { - ITypeBinding binding = this.getMember().getBinding(astRoot); - return (binding == null) ? null : binding.getQualifiedName(); - } - - // ***** superclass qualified name - public String getSuperClassQualifiedName() { - return this.superClassQualifiedName; - } - - protected void setSuperClassQualifiedName(String superClassQualifiedName) { - String old = this.superClassQualifiedName; - this.superClassQualifiedName = superClassQualifiedName; - this.firePropertyChanged(SUPER_CLASS_QUALIFIED_NAME_PROPERTY, old, superClassQualifiedName); - } - - protected String buildSuperClassQualifiedName(CompilationUnit astRoot) { - ITypeBinding binding = this.getMember().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_; - } - - protected void setAbstract(boolean abstract_) { - boolean old = this.abstract_; - this.abstract_ = abstract_; - this.firePropertyChanged(ABSTRACT_PROPERTY, old, abstract_); - } - - protected boolean buildAbstract(CompilationUnit astRoot) { - ITypeBinding binding = this.getMember().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 - protected void setAccess(AccessType access) { - AccessType old = this.access; - this.access = access; - this.firePropertyChanged(ACCESS_PROPERTY, old, access); - } - - protected AccessType buildAccess() { - return JPTTools.buildAccess(this); - } - - /** - * check only persistable attributes - */ - public boolean hasAnyAttributePersistenceAnnotations() { - for (Iterator stream = this.persistableAttributes(); stream.hasNext(); ) { - if (stream.next().hasAnyPersistenceAnnotations()) { - return true; - } - } - return false; - } - - - // ********** types ********** - - public Iterator types() { - return new CloneIterator(this.types); // read-only - } - - public Iterator allTypes() { - return new TreeIterator(this) { - @Override - protected Iterator children(JavaResourcePersistentType type) { - return type.types(); - } - }; - } - - public Iterator persistableTypes() { - return this.persistableMembers(this.types()); - } - - public Iterator allPersistableTypes() { - return this.persistableMembers(this.allTypes()); - } - - protected JavaResourcePersistentType getType(String typeName, int occurrence) { - synchronized (this.types) { - for (JavaResourcePersistentType type : this.types) { - if (type.isFor(typeName, occurrence)) { - return type; - } - } - } - return null; - } - - protected void addType(JavaResourcePersistentType type) { - this.addItemToCollection(type, this.types, TYPES_COLLECTION); - } - - protected void removeTypes(Collection remove) { - this.removeItemsFromCollection(remove, this.types, TYPES_COLLECTION); - } - - - // ********** fields ********** - - public Iterator fields() { - return new CloneIterator(this.fields); - } - - public Iterator persistableFields() { - return this.persistableMembers(this.fields()); - } - - public Iterator persistableFieldsWithSpecifiedFieldAccess() { - return new FilteringIterator(this.persistableFields()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.FIELD; - } - }; - } - - protected void addField(JavaResourcePersistentAttribute field) { - this.addItemToCollection(field, this.fields, FIELDS_COLLECTION); - } - - protected JavaResourcePersistentAttribute getField(String fieldName, int occurrence) { - synchronized (this.fields) { - for (JavaResourcePersistentAttribute field : this.fields) { - if (field.isFor(fieldName, occurrence)) { - return field; - } - } - } - return null; - } - - protected void removeFields(Collection remove) { - this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION); - } - - - // ********** methods ********** - - public Iterator methods() { - return new CloneIterator(this.methods); - } - - public Iterator persistableProperties() { - return this.persistableMembers(this.methods()); - } - - public Iterator persistablePropertiesWithSpecifiedPropertyAccess() { - return new FilteringIterator(this.persistableProperties()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.PROPERTY; - } - }; - } - - protected JavaResourcePersistentAttribute getMethod(MethodSignature signature, int occurrence) { - synchronized (this.methods) { - for (JavaResourcePersistentAttribute method : this.methods) { - if (method.isFor(signature, occurrence)) { - return method; - } - } - } - return null; - } - - protected void addMethod(JavaResourcePersistentAttribute method) { - this.addItemToCollection(method, this.methods, METHODS_COLLECTION); - } - - protected void removeMethods(Collection remove) { - this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION); - } - - - // ********** attributes ********** - - @SuppressWarnings("unchecked") - public Iterator persistableAttributes() { - return new CompositeIterator( - this.persistableFields(), - this.persistableProperties() - ); - } - - public Iterator 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") - public Iterator persistableAttributesForFieldAccessType() { - return new CompositeIterator( - this.persistableFields(), - this.persistablePropertiesWithSpecifiedPropertyAccess() - ); - } - - @SuppressWarnings("unchecked") - public Iterator persistableAttributesForPropertyAccessType() { - return new CompositeIterator( - 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()); - } - - protected void updateTypes(CompilationUnit astRoot) { - synchronized (this.types) { - this.updateTypes_(astRoot); - } - } - - protected void updateTypes_(CompilationUnit astRoot) { - TypeDeclaration[] typeDeclarations = this.getMember().getTypes(astRoot); - CounterMap counters = new CounterMap(typeDeclarations.length); - HashSet typesToRemove = new HashSet(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); - } - - protected JavaResourcePersistentType buildType(TypeDeclaration nestedTypeDeclaration, int occurrence, CompilationUnit astRoot) { - return newInstance(this.getJavaResourceCompilationUnit(), this.getMember(), nestedTypeDeclaration, occurrence, astRoot); - } - - protected void updateFields(CompilationUnit astRoot) { - synchronized (this.fields) { - this.updateFields_(astRoot); - } - } - - protected void updateFields_(CompilationUnit astRoot) { - FieldDeclaration[] fieldDeclarations = this.getMember().getFields(astRoot); - CounterMap counters = new CounterMap(fieldDeclarations.length); - HashSet fieldsToRemove = new HashSet(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); - } - - protected JavaResourcePersistentAttribute buildField(String fieldName, int occurrence, CompilationUnit astRoot) { - return JavaResourcePersistentAttributeImpl.newInstance(this, this.getMember(), fieldName, occurrence, this.getJavaResourceCompilationUnit(), astRoot); - } - - protected void updateMethods(CompilationUnit astRoot) { - synchronized (this.methods) { - this.updateMethods_(astRoot); - } - } - - protected void updateMethods_(CompilationUnit astRoot) { - MethodDeclaration[] methodDeclarations = this.getMember().getMethods(astRoot); - CounterMap counters = new CounterMap(methodDeclarations.length); - HashSet methodsToRemove = new HashSet(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); - } - - protected JavaResourcePersistentAttribute buildMethod(MethodSignature signature, int occurrence, CompilationUnit astRoot) { - return JavaResourcePersistentAttributeImpl.newInstance(this, this.getMember(), signature, occurrence, this.getJavaResourceCompilationUnit(), astRoot); - } - - - // ********** static methods ********** - - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - protected static List fragments(FieldDeclaration fd) { - return fd.fragments(); - } - - - // ********** CounterMap ********** - - protected static class CounterMap { - private final HashMap counters; - - protected CounterMap(int initialCapacity) { - super(); - this.counters = new HashMap(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(); - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/EnumeratedImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/EnumeratedImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/EnumeratedImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/EnumeratedImpl.java 23 Oct 2008 19:04:08 -0000 1.18 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.resource.java.JavaResourcePersistentMember; -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.Member; - -public class EnumeratedImpl extends AbstractResourceAnnotation implements EnumeratedAnnotation -{ - - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - private final AnnotationElementAdapter valueAdapter; - - private EnumType value; - - protected EnumeratedImpl(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(attribute, VALUE_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public EnumType getValue() { - return this.value; - } - - public void setValue(EnumType newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - EnumType oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(EnumType.toJavaAnnotationValue(newValue)); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected EnumType value(CompilationUnit astRoot) { - return EnumType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ENUMERATED__VALUE, false); - } - - public static class EnumeratedAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final EnumeratedAnnotationDefinition 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 EnumeratedImpl(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullEnumerated(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/EntityImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/EntityImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/EntityImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/EntityImpl.java 10 Mar 2009 04:12:10 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -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; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.EntityAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * @Entity - */ -public class EntityImpl - extends AbstractResourceAnnotation - implements EntityAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter nameAdapter; - - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildNameAdapter(); - - private String name; - - protected EntityImpl(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter(getMember(), NAME_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - } - - //*********** Annotation implementation **************** - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*********** Entity implementation **************** - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(EntityAnnotation.NAME_PROPERTY, oldName, newName); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(NAME_ADAPTER, astRoot); - } - - //*********** JavaResource implementation **************** - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - //*********** static methods **************** - private static DeclarationAnnotationElementAdapter buildNameAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ENTITY__NAME, false); // false = do not remove annotation when empty - } - - - public static class EntityAnnotationDefinition - implements AnnotationDefinition - { - // singleton - private static final EntityAnnotationDefinition INSTANCE = new EntityAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static EntityAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EntityAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new EntityImpl((JavaResourcePersistentType) parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/EmbeddableImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/EmbeddableImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/EmbeddableImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/EmbeddableImpl.java 23 Oct 2008 19:04:08 -0000 1.9 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - - -public class EmbeddableImpl extends AbstractResourceAnnotation implements EmbeddableAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected EmbeddableImpl(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void update(CompilationUnit astRoot) { - //no annotation members - } - - - public static class EmbeddableAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final EmbeddableAnnotationDefinition INSTANCE = new EmbeddableAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static EmbeddableAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EmbeddableAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new EmbeddableImpl((JavaResourcePersistentType) parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumn.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumn.java --- src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumn.java 5 Sep 2008 15:27:20 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - - - -public class NullPrimaryKeyJoinColumn extends NullNamedColumn implements PrimaryKeyJoinColumnAnnotation, Annotation -{ - public NullPrimaryKeyJoinColumn(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME; - } - - @Override - protected PrimaryKeyJoinColumnAnnotation createResourceColumn() { - throw new UnsupportedOperationException(); - } - - 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; - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullBasic.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullBasic.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullBasic.java --- src/org/eclipse/jpt/core/internal/resource/java/NullBasic.java 4 Aug 2008 19:53:53 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.BasicAnnotation; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullBasic extends AbstractJavaResourceNode implements BasicAnnotation, Annotation -{ - protected NullBasic(JavaResourcePersistentMember parent) { - super(parent); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return BasicAnnotation.ANNOTATION_NAME; - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - protected BasicAnnotation createBasicResource() { - getParent().setMappingAnnotation(getAnnotationName()); - return (BasicAnnotation) getParent().getMappingAnnotation(); - } - - public FetchType getFetch() { - return null; - } - - public void setFetch(FetchType fetch) { - if (fetch != null) { - createBasicResource().setFetch(fetch); - } - } - - public Boolean getOptional() { - return null; - } - - public void setOptional(Boolean optional) { - if (optional != null) { - createBasicResource().setOptional(optional); - } - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return null; - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullOneToMany.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullOneToMany.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullOneToMany.java --- src/org/eclipse/jpt/core/internal/resource/java/NullOneToMany.java 21 Nov 2008 15:33:09 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,163 +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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.OneToManyAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullOneToMany extends AbstractJavaResourceNode implements OneToManyAnnotation, Annotation -{ - protected NullOneToMany(JavaResourcePersistentMember parent) { - super(parent); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return OneToManyAnnotation.ANNOTATION_NAME; - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - protected OneToManyAnnotation createOneToManyResource() { - getParent().setMappingAnnotation(getAnnotationName()); - return (OneToManyAnnotation) getParent().getMappingAnnotation(); - } - - public FetchType getFetch() { - return null; - } - - public void setFetch(FetchType fetch) { - if (fetch != null) { - createOneToManyResource().setFetch(fetch); - } - } - - public String getMappedBy() { - return null; - } - - public void setMappedBy(String mappedBy) { - if (mappedBy != null) { - createOneToManyResource().setMappedBy(mappedBy); - } - } - - public String getFullyQualifiedTargetEntity() { - return null; - } - - public String getTargetEntity() { - return null; - } - - public void setTargetEntity(String targetEntity) { - if (targetEntity != null) { - createOneToManyResource().setTargetEntity(targetEntity); - } - } - - public boolean isCascadeAll() { - return false; - } - - public void setCascadeAll(boolean all) { - createOneToManyResource().setCascadeAll(all); - } - - public boolean isCascadeMerge() { - return false; - } - - public void setCascadeMerge(boolean merge) { - createOneToManyResource().setCascadeMerge(merge); - } - - public boolean isCascadePersist() { - return false; - } - - public void setCascadePersist(boolean persist) { - createOneToManyResource().setCascadePersist(persist); - } - - public boolean isCascadeRefresh() { - return false; - } - - public void setCascadeRefresh(boolean refresh) { - createOneToManyResource().setCascadeRefresh(refresh); - } - - public boolean isCascadeRemove() { - return false; - } - - public void setCascadeRemove(boolean remove) { - createOneToManyResource().setCascadeRemove(remove); - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getCascadeTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getTargetEntityTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return false; - } - - -} Index: src/org/eclipse/jpt/core/internal/resource/java/AbstractResourceTable.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AbstractResourceTable.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AbstractResourceTable.java --- src/org/eclipse/jpt/core/internal/resource/java/AbstractResourceTable.java 17 Oct 2008 19:05:01 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,353 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraint; -import org.eclipse.jpt.core.resource.java.TableAnnotation; -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.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -public abstract class AbstractResourceTable extends AbstractResourceAnnotation implements TableAnnotation -{ - // hold this so we can get the 'name' text range - private final DeclarationAnnotationElementAdapter nameDeclarationAdapter; - - // hold this so we can get the 'schema' text range - private final DeclarationAnnotationElementAdapter schemaDeclarationAdapter; - - // hold this so we can get the 'catalog' text range - private final DeclarationAnnotationElementAdapter catalogDeclarationAdapter; - - private final AnnotationElementAdapter nameAdapter; - - private final AnnotationElementAdapter schemaAdapter; - - private final AnnotationElementAdapter catalogAdapter; - - private String name; - - private String catalog; - - private String schema; - - final List uniqueConstraints; - - private final UniqueConstraintsContainerAnnotation uniqueConstraintsContainerAnnotation; - - protected AbstractResourceTable(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 = buildAnnotationElementAdapter(this.nameDeclarationAdapter); - this.schemaAdapter = buildAnnotationElementAdapter(this.schemaDeclarationAdapter); - this.catalogAdapter = buildAnnotationElementAdapter(this.catalogDeclarationAdapter); - this.uniqueConstraints = new ArrayList(); - this.uniqueConstraintsContainerAnnotation = new UniqueConstraintsContainerAnnotation(); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - this.catalog = this.catalog(astRoot); - this.schema = this.schema(astRoot); - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this.uniqueConstraintsContainerAnnotation); - } - - protected AnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(this.getMember(), daea); - } - - /** - * Build and return a declaration element adapter for the table's 'name' element - */ - protected abstract DeclarationAnnotationElementAdapter getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter); - - /** - * Build and return a declaration element adapter for the table's 'schema' element - */ - protected abstract DeclarationAnnotationElementAdapter getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter); - - /** - * Build and return a declaration element adapter for the table's 'catalog' element - */ - protected abstract DeclarationAnnotationElementAdapter getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter); - - /** - * Return the uniqueConstraints element name - */ - protected abstract String getUniqueConstraintsElementName(); - - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String newCatalog) { - if (attributeValueHasNotChanged(this.catalog, newCatalog)) { - return; - } - String oldCatalog = this.catalog; - this.catalog = newCatalog; - this.catalogAdapter.setValue(newCatalog); - firePropertyChanged(CATALOG_PROPERTY, oldCatalog, newCatalog); - } - - public String getSchema() { - return this.schema; - } - - public void setSchema(String newSchema) { - if (attributeValueHasNotChanged(this.schema, newSchema)) { - return; - } - String oldSchema = this.schema; - this.schema = newSchema; - this.schemaAdapter.setValue(newSchema); - firePropertyChanged(SCHEMA_PROPERTY, oldSchema, newSchema); - } - - public ListIterator uniqueConstraints() { - return new CloneListIterator(this.uniqueConstraints); - } - - public int uniqueConstraintsSize() { - return this.uniqueConstraints.size(); - } - - public NestableUniqueConstraint uniqueConstraintAt(int index) { - return this.uniqueConstraints.get(index); - } - - public int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint) { - return this.uniqueConstraints.indexOf(uniqueConstraint); - } - - public NestableUniqueConstraint addUniqueConstraint(int index) { - NestableUniqueConstraint uniqueConstraint = (NestableUniqueConstraint) ContainerAnnotationTools.addNestedAnnotation(index, this.uniqueConstraintsContainerAnnotation); - fireItemAdded(TableAnnotation.UNIQUE_CONSTRAINTS_LIST, index, uniqueConstraint); - return uniqueConstraint; - } - - protected void addUniqueConstraint(int index, NestableUniqueConstraint uniqueConstraint) { - addItemToList(index, uniqueConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST); - } - - public void removeUniqueConstraint(int index) { - NestableUniqueConstraint uniqueConstraint = this.uniqueConstraintAt(index); - removeUniqueConstraint(uniqueConstraint); - uniqueConstraint.removeAnnotation(); - ContainerAnnotationTools.synchAnnotationsAfterRemove(index, this.uniqueConstraintsContainerAnnotation); - } - - protected void removeUniqueConstraint(NestableUniqueConstraint uniqueConstraint) { - removeItemFromList(uniqueConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST); - } - - public void moveUniqueConstraint(int targetIndex, int sourceIndex) { - moveUniqueConstraintInternal(targetIndex, sourceIndex); - ContainerAnnotationTools.synchAnnotationsAfterMove(targetIndex, sourceIndex, this.uniqueConstraintsContainerAnnotation); - fireItemMoved(TableAnnotation.UNIQUE_CONSTRAINTS_LIST, targetIndex, sourceIndex); - } - - protected void moveUniqueConstraintInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.uniqueConstraints, targetIndex, sourceIndex); - } - - protected abstract NestableUniqueConstraint createUniqueConstraint(int index); - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - return getElementTextRange(this.schemaDeclarationAdapter, astRoot); - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - return getElementTextRange(this.catalogDeclarationAdapter, astRoot); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.catalogDeclarationAdapter, pos, astRoot); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.schemaDeclarationAdapter, pos, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - this.setSchema(this.schema(astRoot)); - this.setCatalog(this.catalog(astRoot)); - this.updateUniqueConstraintsFromJava(astRoot); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - protected String schema(CompilationUnit astRoot) { - return this.schemaAdapter.getValue(astRoot); - } - - protected String catalog(CompilationUnit astRoot) { - return this.catalogAdapter.getValue(astRoot); - } - - /** - * here we just worry about getting the unique constraints lists the same size; - * then we delegate to the unique constraints to synch themselves up - */ - private void updateUniqueConstraintsFromJava(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this.uniqueConstraintsContainerAnnotation); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - private class UniqueConstraintsContainerAnnotation extends AbstractJavaResourceNode - implements ContainerAnnotation - { - public UniqueConstraintsContainerAnnotation() { - super(AbstractResourceTable.this); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public NestableUniqueConstraint addInternal(int index) { - NestableUniqueConstraint uniqueConstraint = AbstractResourceTable.this.createUniqueConstraint(index); - AbstractResourceTable.this.uniqueConstraints.add(index, uniqueConstraint); - return uniqueConstraint; - } - - public NestableUniqueConstraint add(int index) { - NestableUniqueConstraint uniqueConstraint = AbstractResourceTable.this.createUniqueConstraint(index); - AbstractResourceTable.this.addUniqueConstraint(index, uniqueConstraint); - return uniqueConstraint; - } - - public String getAnnotationName() { - return AbstractResourceTable.this.getAnnotationName(); - } - - public String getNestableAnnotationName() { - return JPA.UNIQUE_CONSTRAINT; - } - - public int indexOf(NestableUniqueConstraint uniqueConstraint) { - return AbstractResourceTable.this.indexOfUniqueConstraint(uniqueConstraint); - } - - public void move(int targetIndex, int sourceIndex) { - AbstractResourceTable.this.moveUniqueConstraint(targetIndex, sourceIndex); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - AbstractResourceTable.this.moveUniqueConstraintInternal(targetIndex, sourceIndex); - } - - public NestableUniqueConstraint nestedAnnotationAt(int index) { - return AbstractResourceTable.this.uniqueConstraintAt(index); - } - - public NestableUniqueConstraint nestedAnnotationFor(Annotation jdtAnnotation) { - for (NestableUniqueConstraint uniqueConstraint : CollectionTools.iterable(nestedAnnotations())) { - if (jdtAnnotation == uniqueConstraint.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return uniqueConstraint; - } - } - return null; - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(AbstractResourceTable.this.uniqueConstraints); - } - - public int nestedAnnotationsSize() { - return AbstractResourceTable.this.uniqueConstraintsSize(); - } - - public void remove(NestableUniqueConstraint uniqueConstraint) { - AbstractResourceTable.this.removeUniqueConstraint(uniqueConstraint); - } - - public void remove(int index) { - this.remove(nestedAnnotationAt(index)); - } - - public Annotation getJdtAnnotation(CompilationUnit astRoot) { - return AbstractResourceTable.this.getJdtAnnotation(astRoot); - } - - public void newAnnotation() { - AbstractResourceTable.this.newAnnotation(); - } - - public void removeAnnotation() { - AbstractResourceTable.this.removeAnnotation(); - } - - public void update(CompilationUnit astRoot) { - AbstractResourceTable.this.update(astRoot); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return AbstractResourceTable.this.getTextRange(astRoot); - } - - public String getElementName() { - return AbstractResourceTable.this.getUniqueConstraintsElementName(); - } - - @Override - public void toString(StringBuilder sb) { - AbstractResourceTable.this.toString(sb); - } - - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullAssociationOverride.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullAssociationOverride.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullAssociationOverride.java --- src/org/eclipse/jpt/core/internal/resource/java/NullAssociationOverride.java 20 Oct 2008 20:52:50 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,121 +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.java; - -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - - -public class NullAssociationOverride extends AbstractJavaResourceNode implements AssociationOverrideAnnotation, Annotation -{ - private String name; - - public NullAssociationOverride(JavaResourceNode parent, String name) { - super(parent); - this.name = name; - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return AssociationOverrideAnnotation.ANNOTATION_NAME; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - if (name != null) { - createAssociationOverrideResource().setName(name); - } - } - - public ListIterator joinColumns() { - return EmptyListIterator.instance(); - } - - public JoinColumnAnnotation joinColumnAt(int index) { - return null; - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - throw new UnsupportedOperationException(); - } - - public int joinColumnsSize() { - return 0; - } - - public JoinColumnAnnotation addJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void removeJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - protected AssociationOverrideAnnotation createAssociationOverrideResource() { - return (AssociationOverrideAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return false; - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getName()); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumn.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumn.java --- src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumn.java 5 Sep 2008 15:27:19 -0000 1.9 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - - -public abstract class NullNamedColumn extends AbstractJavaResourceNode implements NamedColumnAnnotation, Annotation -{ - protected NullNamedColumn(JavaResourceNode parent) { - super(parent); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - protected abstract NamedColumnAnnotation createResourceColumn(); - - public String getName() { - return null; - } - - public void setName(String name) { - if (name != null) { - createResourceColumn().setName(name); - } - } - - public String getColumnDefinition() { - return null; - } - - public void setColumnDefinition(String columnDefinition) { - if (columnDefinition != null) { - createResourceColumn().setColumnDefinition(columnDefinition); - } - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getColumnDefinitionTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return false; - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/QueryHintImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/QueryHintImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/QueryHintImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/QueryHintImpl.java 17 Oct 2008 19:09:27 -0000 1.15 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.NestableQueryHint; -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; - -public class QueryHintImpl extends AbstractResourceAnnotation - implements NestableQueryHint -{ - - // hold this so we can get the 'name' text range - private final DeclarationAnnotationElementAdapter nameDeclarationAdapter; - - // hold this so we can get the 'value' text range - private final DeclarationAnnotationElementAdapter valueDeclarationAdapter; - - private final AnnotationElementAdapter nameAdapter; - - private final AnnotationElementAdapter valueAdapter; - - private String name; - - private String value; - - public QueryHintImpl(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 void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - this.value = this.value(astRoot); - } - - // ********** initialization ********** - protected AnnotationElementAdapter buildAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(getMember(), daea); - } - - protected DeclarationAnnotationElementAdapter buildNameAdapter(DeclarationAnnotationAdapter daa) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.QUERY_HINT__NAME); - } - - protected DeclarationAnnotationElementAdapter buildValueAdapter(DeclarationAnnotationAdapter daa) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.QUERY_HINT__VALUE); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public IndexedAnnotationAdapter getAnnotationAdapter() { - return (IndexedAnnotationAdapter) super.getAnnotationAdapter(); - } - - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public String getValue() { - return this.value; - } - - public void setValue(String newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - String oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(newValue); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.valueDeclarationAdapter, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - this.setValue(this.value(astRoot)); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - protected String value(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - // ********** persistence model -> java annotations ********** - public void moveAnnotation(int newIndex) { - getAnnotationAdapter().moveAnnotation(newIndex); - } - - public void initializeFrom(NestableAnnotation oldAnnotation) { - QueryHintAnnotation oldQueryHint = (QueryHintAnnotation) oldAnnotation; - setName(oldQueryHint.getName()); - setValue(oldQueryHint.getValue()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - // ********** static methods ********** - static QueryHintImpl createNamedQueryQueryHint(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter namedQueryAdapter, int index) { - return new QueryHintImpl(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 QueryHintImpl createNamedNativeQueryQueryHint(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter namedNativeQueryAdapter, int index) { - return new QueryHintImpl(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); - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideImpl.java 23 Oct 2008 19:04:08 -0000 1.16 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,290 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverride; -import org.eclipse.jpt.core.resource.java.NestableJoinColumn; -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.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; - -public class AssociationOverrideImpl - extends OverrideImpl - implements NestableAssociationOverride -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected final List joinColumns; - - private final JoinColumnsContainerAnnotation joinColumnsContainerAnnotation; - - protected AssociationOverrideImpl(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.joinColumns = new ArrayList(); - this.joinColumnsContainerAnnotation = new JoinColumnsContainerAnnotation(); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this.joinColumnsContainerAnnotation); - } - - public String getAnnotationName() { - return AssociationOverrideAnnotation.ANNOTATION_NAME; - } - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - AssociationOverrideAnnotation oldAssociationOverride = (AssociationOverrideAnnotation) oldAnnotation; - for (JoinColumnAnnotation joinColumn : CollectionTools.iterable(oldAssociationOverride.joinColumns())) { - NestableJoinColumn newJoinColumn = addJoinColumn(oldAssociationOverride.indexOfJoinColumn(joinColumn)); - newJoinColumn.initializeFrom((NestableAnnotation) joinColumn); - } - } - - - // ************* Association implementation ******************* - - public ListIterator joinColumns() { - return new CloneListIterator(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public NestableJoinColumn joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public NestableJoinColumn addJoinColumn(int index) { - NestableJoinColumn joinColumn = (NestableJoinColumn) ContainerAnnotationTools.addNestedAnnotation(index, this.joinColumnsContainerAnnotation); - fireItemAdded(AssociationOverrideAnnotation.JOIN_COLUMNS_LIST, index, joinColumn); - return joinColumn; - } - - protected void addJoinColumn(int index, NestableJoinColumn joinColumn) { - addItemToList(index, joinColumn, this.joinColumns, AssociationOverrideAnnotation.JOIN_COLUMNS_LIST); - } - - public void removeJoinColumn(int index) { - NestableJoinColumn joinColumn = this.joinColumns.get(index); - removeJoinColumn(joinColumn); - joinColumn.removeAnnotation(); - ContainerAnnotationTools.synchAnnotationsAfterRemove(index, this.joinColumnsContainerAnnotation); - } - - protected void removeJoinColumn(NestableJoinColumn joinColumn) { - removeItemFromList(joinColumn, this.joinColumns, AssociationOverrideAnnotation.JOIN_COLUMNS_LIST); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - moveJoinColumnInternal(targetIndex, sourceIndex); - ContainerAnnotationTools.synchAnnotationsAfterMove(targetIndex, sourceIndex, this.joinColumnsContainerAnnotation); - fireItemMoved(AssociationOverrideAnnotation.JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - protected void moveJoinColumnInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.joinColumns, targetIndex, sourceIndex); - } - - protected NestableJoinColumn createJoinColumn(int index) { - return JoinColumnImpl.createAssociationOverrideJoinColumn(getDeclarationAnnotationAdapter(), this, getMember(), index); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.updateJoinColumnsFromJava(astRoot); - } - - private void updateJoinColumnsFromJava(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this.joinColumnsContainerAnnotation); - } - - - // ********** static methods ********** - static AssociationOverrideImpl createAssociationOverride(JavaResourceNode parent, Member member) { - return new AssociationOverrideImpl(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); - } - - static AssociationOverrideImpl createNestedAssociationOverride(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa); - return new AssociationOverrideImpl(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(attributeOverridesAdapter, index, JPA.ASSOCIATION_OVERRIDE); - } - - private class JoinColumnsContainerAnnotation extends AbstractJavaResourceNode - implements ContainerAnnotation - { - public JoinColumnsContainerAnnotation() { - super(AssociationOverrideImpl.this); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public NestableJoinColumn addInternal(int index) { - NestableJoinColumn joinColumn = AssociationOverrideImpl.this.createJoinColumn(index); - AssociationOverrideImpl.this.joinColumns.add(index, joinColumn); - return joinColumn; - } - - public NestableJoinColumn add(int index) { - NestableJoinColumn joinColumn = AssociationOverrideImpl.this.createJoinColumn(index); - AssociationOverrideImpl.this.addJoinColumn(index, joinColumn); - return joinColumn; - } - - public int indexOf(NestableJoinColumn pkJoinColumn) { - return AssociationOverrideImpl.this.indexOfJoinColumn(pkJoinColumn); - } - - public void move(int targetIndex, int sourceIndex) { - AssociationOverrideImpl.this.moveJoinColumn(targetIndex, sourceIndex); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - AssociationOverrideImpl.this.moveJoinColumnInternal(targetIndex, sourceIndex); - } - - public NestableJoinColumn nestedAnnotationAt(int index) { - return AssociationOverrideImpl.this.joinColumnAt(index); - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(AssociationOverrideImpl.this.joinColumns); - } - - public int nestedAnnotationsSize() { - return joinColumnsSize(); - } - - public void remove(int index) { - this.remove(nestedAnnotationAt(index)); - } - - public void remove(NestableJoinColumn joinColumn) { - AssociationOverrideImpl.this.removeJoinColumn(joinColumn); - } - - public String getAnnotationName() { - return AssociationOverrideImpl.this.getAnnotationName(); - } - - public String getNestableAnnotationName() { - return JPA.JOIN_COLUMN; - } - - public NestableJoinColumn nestedAnnotationFor(org.eclipse.jdt.core.dom.Annotation jdtAnnotation) { - for (NestableJoinColumn pkJoinColumn : CollectionTools.iterable(nestedAnnotations())) { - if (jdtAnnotation == pkJoinColumn.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return pkJoinColumn; - } - } - return null; - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return AssociationOverrideImpl.this.getJdtAnnotation(astRoot); - } - - public void newAnnotation() { - AssociationOverrideImpl.this.newAnnotation(); - } - - public void removeAnnotation() { - AssociationOverrideImpl.this.removeAnnotation(); - } - - public void update(CompilationUnit astRoot) { - AssociationOverrideImpl.this.update(astRoot); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return AssociationOverrideImpl.this.getTextRange(astRoot); - } - - public String getElementName() { - return JPA.ASSOCIATION_OVERRIDE__JOIN_COLUMNS; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getAnnotationName()); - } - - } - - public static class AssociationOverrideAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final AssociationOverrideAnnotationDefinition 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 AssociationOverrideImpl.createAssociationOverride(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return AssociationOverrideAnnotation.ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableImpl.java 23 Oct 2008 19:04:08 -0000 1.19 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,333 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -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.resource.java.NestablePrimaryKeyJoinColumn; -import org.eclipse.jpt.core.resource.java.NestableSecondaryTable; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraint; -import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation; -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.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.iterators.CloneListIterator; - -public class SecondaryTableImpl extends AbstractResourceTable implements NestableSecondaryTable -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(SecondaryTableAnnotation.ANNOTATION_NAME); - - protected final List pkJoinColumns; - - private final PkJoinColumnsContainerAnnotation pkJoinColumnsContainerAnnotation; - - - protected SecondaryTableImpl(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.pkJoinColumns = new ArrayList(); - this.pkJoinColumnsContainerAnnotation = new PkJoinColumnsContainerAnnotation(); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this.pkJoinColumnsContainerAnnotation); - } - - @Override - protected DeclarationAnnotationElementAdapter getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__CATALOG); - } - - @Override - protected DeclarationAnnotationElementAdapter getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__NAME); - } - - @Override - protected DeclarationAnnotationElementAdapter getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__SCHEMA); - } - - public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) super.getAnnotationAdapter(); - } - - public String getAnnotationName() { - return SecondaryTableAnnotation.ANNOTATION_NAME; - } - - public void moveAnnotation(int newIndex) { - getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - public void initializeFrom(NestableAnnotation oldAnnotation) { - SecondaryTableAnnotation oldSecondaryTable = (SecondaryTableAnnotation) oldAnnotation; - setName(oldSecondaryTable.getName()); - setCatalog(oldSecondaryTable.getCatalog()); - setSchema(oldSecondaryTable.getSchema()); - for (UniqueConstraintAnnotation uniqueConstraint : CollectionTools.iterable(oldSecondaryTable.uniqueConstraints())) { - NestableUniqueConstraint newUniqueConstraint = addUniqueConstraint(oldSecondaryTable.indexOfUniqueConstraint(uniqueConstraint)); - newUniqueConstraint.initializeFrom((NestableAnnotation) uniqueConstraint); - } - for (PrimaryKeyJoinColumnAnnotation pkJoinColumn : CollectionTools.iterable(oldSecondaryTable.pkJoinColumns())) { - NestablePrimaryKeyJoinColumn newPkJoinColumn = addPkJoinColumn(oldSecondaryTable.indexOfPkJoinColumn(pkJoinColumn)); - newPkJoinColumn.initializeFrom((NestableAnnotation) pkJoinColumn); - } - } - - @Override - protected String getUniqueConstraintsElementName() { - return JPA.SECONDARY_TABLE__UNIQUE_CONSTRAINTS; - } - - @Override - protected NestableUniqueConstraint createUniqueConstraint(int index) { - return UniqueConstraintImpl.createSecondaryTableUniqueConstraint(this, this.getMember(), this.getDeclarationAnnotationAdapter(), index); - } - - // ************* SecondaryTable implementation ******************* - - - public ListIterator pkJoinColumns() { - return new CloneListIterator(this.pkJoinColumns); - } - - public int pkJoinColumnsSize() { - return this.pkJoinColumns.size(); - } - - public NestablePrimaryKeyJoinColumn pkJoinColumnAt(int index) { - return this.pkJoinColumns.get(index); - } - - public int indexOfPkJoinColumn(PrimaryKeyJoinColumnAnnotation joinColumn) { - return this.pkJoinColumns.indexOf(joinColumn); - } - - public NestablePrimaryKeyJoinColumn addPkJoinColumn(int index) { - NestablePrimaryKeyJoinColumn pkJoinColumn = (NestablePrimaryKeyJoinColumn) ContainerAnnotationTools.addNestedAnnotation(index, this.pkJoinColumnsContainerAnnotation); - fireItemAdded(SecondaryTableAnnotation.PK_JOIN_COLUMNS_LIST, index, pkJoinColumn); - return pkJoinColumn; - } - - protected void addPkJoinColumn(int index, NestablePrimaryKeyJoinColumn pkJoinColumn) { - addItemToList(index, pkJoinColumn, this.pkJoinColumns, PK_JOIN_COLUMNS_LIST); - } - - public void removePkJoinColumn(int index) { - NestablePrimaryKeyJoinColumn pkJoinColumn = this.pkJoinColumns.get(index); - removePkJoinColumn(pkJoinColumn); - pkJoinColumn.removeAnnotation(); - ContainerAnnotationTools.synchAnnotationsAfterRemove(index, this.pkJoinColumnsContainerAnnotation); - } - - protected void removePkJoinColumn(NestablePrimaryKeyJoinColumn pkJoinColumn) { - removeItemFromList(pkJoinColumn, this.pkJoinColumns, SecondaryTableAnnotation.PK_JOIN_COLUMNS_LIST); - } - - public void movePkJoinColumn(int targetIndex, int sourceIndex) { - movePkJoinColumnInternal(targetIndex, sourceIndex); - ContainerAnnotationTools.synchAnnotationsAfterMove(targetIndex, sourceIndex, this.pkJoinColumnsContainerAnnotation); - fireItemMoved(SecondaryTableAnnotation.PK_JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - protected void movePkJoinColumnInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.pkJoinColumns, targetIndex, sourceIndex); - } - - - protected NestablePrimaryKeyJoinColumn createPrimaryKeyJoinColumn(int index) { - return PrimaryKeyJoinColumnImpl.createSecondaryTablePrimaryKeyJoinColumn(getDeclarationAnnotationAdapter(), this, getMember(), index); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.updatePkJoinColumnsFromJava(astRoot); - } - - private void updatePkJoinColumnsFromJava(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this.pkJoinColumnsContainerAnnotation); - } - - // ********** static methods ********** - static SecondaryTableImpl createSecondaryTable(JavaResourceNode parent, Member member) { - return new SecondaryTableImpl(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); - } - - static SecondaryTableImpl createNestedSecondaryTable(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter secondaryTablesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, secondaryTablesAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa); - return new SecondaryTableImpl(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter secondaryTablesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(secondaryTablesAdapter, index, JPA.SECONDARY_TABLE); - } - - - private class PkJoinColumnsContainerAnnotation extends AbstractJavaResourceNode - implements ContainerAnnotation - { - public PkJoinColumnsContainerAnnotation() { - super(SecondaryTableImpl.this); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public NestablePrimaryKeyJoinColumn addInternal(int index) { - NestablePrimaryKeyJoinColumn pKJoinColumn = SecondaryTableImpl.this.createPrimaryKeyJoinColumn(index); - SecondaryTableImpl.this.pkJoinColumns.add(index, pKJoinColumn); - return pKJoinColumn; - } - - public NestablePrimaryKeyJoinColumn add(int index) { - NestablePrimaryKeyJoinColumn pKJoinColumn = SecondaryTableImpl.this.createPrimaryKeyJoinColumn(index); - SecondaryTableImpl.this.addPkJoinColumn(index, pKJoinColumn); - return pKJoinColumn; - } - - public int indexOf(NestablePrimaryKeyJoinColumn pkJoinColumn) { - return SecondaryTableImpl.this.indexOfPkJoinColumn(pkJoinColumn); - } - - public void move(int targetIndex, int sourceIndex) { - SecondaryTableImpl.this.movePkJoinColumn(targetIndex, sourceIndex); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - SecondaryTableImpl.this.movePkJoinColumnInternal(targetIndex, sourceIndex); - } - - public NestablePrimaryKeyJoinColumn nestedAnnotationAt(int index) { - return SecondaryTableImpl.this.pkJoinColumnAt(index); - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(SecondaryTableImpl.this.pkJoinColumns); - } - - public int nestedAnnotationsSize() { - return pkJoinColumnsSize(); - } - - public String getAnnotationName() { - return SecondaryTableImpl.this.getAnnotationName(); - } - - public String getNestableAnnotationName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN; - } - - public NestablePrimaryKeyJoinColumn nestedAnnotationFor(org.eclipse.jdt.core.dom.Annotation jdtAnnotation) { - for (NestablePrimaryKeyJoinColumn pkJoinColumn : CollectionTools.iterable(nestedAnnotations())) { - if (jdtAnnotation == pkJoinColumn.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return pkJoinColumn; - } - } - return null; - } - - public void remove(int index) { - this.remove(nestedAnnotationAt(index)); - } - - public void remove(NestablePrimaryKeyJoinColumn pkJoinColumn) { - SecondaryTableImpl.this.removePkJoinColumn(pkJoinColumn); - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return SecondaryTableImpl.this.getJdtAnnotation(astRoot); - } - - public void newAnnotation() { - SecondaryTableImpl.this.newAnnotation(); - } - - public void removeAnnotation() { - SecondaryTableImpl.this.removeAnnotation(); - } - - public void update(CompilationUnit astRoot) { - SecondaryTableImpl.this.update(astRoot); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return SecondaryTableImpl.this.getTextRange(astRoot); - } - - public String getElementName() { - return JPA.SECONDARY_TABLE__PK_JOIN_COLUMNS; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getAnnotationName()); - } - - } - - public static class SecondaryTableAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final SecondaryTableAnnotationDefinition 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 SecondaryTableImpl.createSecondaryTable(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return SecondaryTableAnnotation.ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumn.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumn.java --- src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumn.java 5 Sep 2008 15:27:20 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullAttributeOverrideColumn extends NullBaseColumn implements ColumnAnnotation, Annotation -{ - public NullAttributeOverrideColumn(AttributeOverrideAnnotation parent) { - super(parent); - } - - @Override - public AttributeOverrideAnnotation getParent() { - return (AttributeOverrideAnnotation) super.getParent(); - } - - public String getAnnotationName() { - return ColumnAnnotation.ANNOTATION_NAME; - } - - @Override - protected ColumnAnnotation createResourceColumn() { - return getParent().addColumn(); - } - - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - if (length != null) { - createResourceColumn().setLength(length); - } - } - - public Integer getScale() { - return null; - } - - public void setScale(Integer scale) { - if (scale != null) { - createResourceColumn().setScale(scale); - } - } - - public Integer getPrecision() { - return null; - } - - public void setPrecision(Integer precision) { - if (precision != null) { - createResourceColumn().setPrecision(precision); - } - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - return null; - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/JavaResourceCompilationUnitImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/JavaResourceCompilationUnitImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/JavaResourceCompilationUnitImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/JavaResourceCompilationUnitImpl.java 25 Mar 2009 21:34:28 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,261 +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.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.JavaResourceCompilationUnit; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -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 class JavaResourceCompilationUnitImpl - extends AbstractJavaResourceNode - 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 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 JavaResourceCompilationUnitImpl( - 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.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; - } - - - // ********** JpaCompilationUnit implementation ********** - - public ICompilationUnit getCompilationUnit() { - return this.compilationUnit; - } - - public Iterator persistableTypes() { - return (this.persistentType == null) ? - EmptyIterator.instance() : - this.persistentType.allPersistableTypes(); - } - - public void resourceModelChanged() { - for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelChanged(); - } - } - - 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 JavaResourcePersistentTypeImpl.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 resolveBinding() on the TypeDeclaration returns null - * 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 ? (TypeDeclaration) atd : null; - } - } - return null; - } - - // minimize scope of suppressed warnings - @SuppressWarnings("unchecked") - protected static List 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.persistentType.getName()); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueImpl.java 17 Dec 2008 06:19:38 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.resource.java.JavaResourcePersistentMember; -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; - -public class GeneratedValueImpl extends AbstractResourceAnnotation implements GeneratedValueAnnotation -{ - private final AnnotationElementAdapter strategyAdapter; - - private final AnnotationElementAdapter generatorAdapter; - - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter STRATEGY_ADAPTER = buildStrategyAdapter(); - - private static final DeclarationAnnotationElementAdapter GENERATOR_ADAPTER = buildGeneratorAdapter(); - - private GenerationType strategy; - - private String generator; - - - protected GeneratedValueImpl(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.strategyAdapter = new ShortCircuitAnnotationElementAdapter(member, STRATEGY_ADAPTER); - this.generatorAdapter = new ShortCircuitAnnotationElementAdapter(member, GENERATOR_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.strategy = this.strategy(astRoot); - this.generator = this.generator(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public GenerationType getStrategy() { - return this.strategy; - } - - public void setStrategy(GenerationType newStrategy) { - if (attributeValueHasNotChanged(this.strategy, newStrategy)) { - return; - } - GenerationType oldStrategy = this.strategy; - this.strategy = newStrategy; - this.strategyAdapter.setValue(GenerationType.toJavaAnnotationValue(newStrategy)); - firePropertyChanged(STRATEGY_PROPERTY, oldStrategy, newStrategy); - } - - public String getGenerator() { - return this.generator; - } - - public void setGenerator(String newGenerator) { - if (attributeValueHasNotChanged(this.generator, newGenerator)) { - return; - } - String oldGenerator = this.generator; - this.generator = newGenerator; - this.generatorAdapter.setValue(newGenerator); - firePropertyChanged(GENERATOR_PROPERTY, oldGenerator, newGenerator); - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(STRATEGY_ADAPTER, 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); - } - - // ********** java annotations -> persistence model ********** - public void update(CompilationUnit astRoot) { - this.setStrategy(this.strategy(astRoot)); - this.setGenerator(this.generator(astRoot)); - } - - protected GenerationType strategy(CompilationUnit astRoot) { - return GenerationType.fromJavaAnnotationValue(this.strategyAdapter.getValue(astRoot)); - } - - protected String generator(CompilationUnit astRoot) { - return this.generatorAdapter.getValue(astRoot); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildStrategyAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__STRATEGY, false); - } - - private static DeclarationAnnotationElementAdapter buildGeneratorAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__GENERATOR, false); - } - - public static class GeneratedValueAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final GeneratedValueAnnotationDefinition 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 GeneratedValueImpl(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NamedQueryImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NamedQueryImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NamedQueryImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/NamedQueryImpl.java 23 Oct 2008 19:04:08 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,112 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestableNamedQuery; -import org.eclipse.jpt.core.resource.java.NestableQueryHint; -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; -import org.eclipse.jpt.core.utility.jdt.Type; - -public class NamedQueryImpl extends AbstractNamedQuery - implements NestableNamedQuery -{ - - public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected NamedQueryImpl(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, type, daa, annotationAdapter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //************* AbstractNamedQuery implementation ************* - @Override - protected String getNameElementName() { - return JPA.NAMED_QUERY__NAME; - } - - @Override - protected String getQueryElementName() { - return JPA.NAMED_QUERY__QUERY; - } - - @Override - protected String getHintsElementName() { - return JPA.NAMED_QUERY__HINTS; - } - - @Override - protected NestableQueryHint createQueryHint(int index) { - return QueryHintImpl.createNamedQueryQueryHint(this, getMember(), this.getDeclarationAnnotationAdapter(), index); - } - - // ********** static methods ********** - static NamedQueryImpl createNamedQuery(JavaResourceNode parent, Type type) { - return new NamedQueryImpl(parent, type, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER)); - } - - static NamedQueryImpl createNestedNamedQuery(JavaResourceNode parent, Type type, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(type, idaa); - return new NamedQueryImpl(parent, type, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter namedQueriesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(namedQueriesAdapter, index, JPA.NAMED_QUERY); - } - - public static class NamedQueryAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final NamedQueryAnnotationDefinition 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 NamedQueryImpl.createNamedQuery(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/ContainerAnnotationTools.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/ContainerAnnotationTools.java diff -N src/org/eclipse/jpt/core/internal/resource/java/ContainerAnnotationTools.java --- src/org/eclipse/jpt/core/internal/resource/java/ContainerAnnotationTools.java 20 Oct 2008 20:52:50 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,214 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.List; - -import org.eclipse.jdt.core.dom.ASTVisitor; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.MarkerAnnotation; -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.internal.utility.jdt.JDTTools; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.utility.internal.CollectionTools; - -public class ContainerAnnotationTools -{ - - public static NestableAnnotation addNestedAnnotation(int index, ContainerAnnotation containerAnnotation) { - int size = containerAnnotation.nestedAnnotationsSize(); - NestableAnnotation nestedAnnotation = containerAnnotation.addInternal(size); - nestedAnnotation.newAnnotation(); - containerAnnotation.moveInternal(index, size); - synchAnnotationsAfterMove(index, size, containerAnnotation); - return nestedAnnotation; - } - - /** - * synchronize the source annotations with the model nestableAnnotations, - * starting at the end of the list to prevent overlap - */ - public static void synchAnnotationsAfterAdd(int index, ContainerAnnotation containerAnnotation) { - List nestableAnnotations = CollectionTools.list(containerAnnotation.nestedAnnotations()); - for (int i = nestableAnnotations.size(); i-- > index;) { - synch(nestableAnnotations.get(i), i); - } - } - - /** - * synchronize the source annotations with the model nestableAnnotations, - * starting at the specified index to prevent overlap - */ - public static void synchAnnotationsAfterRemove(int index, ContainerAnnotation pluralAnnotation) { - List nestableAnnotations = CollectionTools.list(pluralAnnotation.nestedAnnotations()); - for (int i = index; i < nestableAnnotations.size(); i++) { - synch(nestableAnnotations.get(i), i); - } - } - - private static void synch(NestableAnnotation nestableAnnotation, int index) { - nestableAnnotation.moveAnnotation(index); - } - - /** - * synchronize the annotations with the model nestableAnnotations - */ - public static void synchAnnotationsAfterMove(int targetIndex, int sourceIndex, ContainerAnnotation containerAnnotation) { - NestableAnnotation nestableAnnotation = containerAnnotation.nestedAnnotationAt(targetIndex); - - synch(nestableAnnotation, containerAnnotation.nestedAnnotationsSize()); - - List nestableAnnotations = CollectionTools.list(containerAnnotation.nestedAnnotations()); - if (sourceIndex < targetIndex) { - for (int i = sourceIndex; i < targetIndex; i++) { - synch(nestableAnnotations.get(i), i); - } - } - else { - for (int i = sourceIndex; i > targetIndex; i-- ) { - synch(nestableAnnotations.get(i), i); - } - } - synch(nestableAnnotation, targetIndex); - } - - - public static void initializeNestedAnnotations(CompilationUnit astRoot, ContainerAnnotation containerAnnotation) { - addAnnotationsFromSource(astRoot, containerAnnotation); - } - - private static void addAnnotationsFromSource(CompilationUnit astRoot, ContainerAnnotation containerAnnotation) { - containerAnnotation.getJdtAnnotation(astRoot).accept(buildInitialAnnotationVisitor(astRoot, containerAnnotation)); - } - - private static ASTVisitor buildInitialAnnotationVisitor(CompilationUnit astRoot, ContainerAnnotation containerAnnotation) { - return new InitialAnnotationVisitor(astRoot, containerAnnotation); - } - - public static void updateNestedAnnotationsFromJava(CompilationUnit astRoot, ContainerAnnotation containerAnnotation) { - addOrUpdateAnnotationInSource(astRoot, containerAnnotation); - //TODO not sure how to handle generics here and get rid of this warning - removeAnnotationsNotInSource(astRoot, (ContainerAnnotation) containerAnnotation); - } - - private static void addOrUpdateAnnotationInSource(CompilationUnit astRoot, ContainerAnnotation containerAnnotation) { - containerAnnotation.getJdtAnnotation(astRoot).accept(buildUpdateAnnotationVisitor(astRoot, containerAnnotation)); - } - - private static void removeAnnotationsNotInSource(CompilationUnit astRoot, ContainerAnnotation containerAnnotation) { - for (NestableAnnotation annotation : CollectionTools.iterable(containerAnnotation.nestedAnnotations())) { - if (annotation.getJdtAnnotation(astRoot) == null) { - containerAnnotation.remove(annotation); - } - } - } - - private static ASTVisitor buildUpdateAnnotationVisitor(CompilationUnit astRoot, ContainerAnnotation containerAnnotation) { - return new UpdateAnnotationVisitor(astRoot, containerAnnotation); - } - - private ContainerAnnotationTools() { - super(); - throw new UnsupportedOperationException(); - } - - - // ********** annotation visitor ********** - - /** - * Only visit the member value pair for the container annotation's element name. - */ - private abstract static class AnnotationVisitor extends ASTVisitor { - protected final CompilationUnit astRoot; - protected final ContainerAnnotation containerAnnotation; - - AnnotationVisitor(CompilationUnit astRoot, ContainerAnnotation containerAnnotation) { - this.astRoot = astRoot; - this.containerAnnotation = containerAnnotation; - } - - @Override - public boolean visit(MemberValuePair node) { - return node.getName().getFullyQualifiedName().equals(this.containerAnnotation.getElementName()); - } - - @Override - public boolean visit(SingleMemberAnnotation node) { - return this.visit_(node); - } - - @Override - public boolean visit(NormalAnnotation node) { - return this.visit_(node); - } - - @Override - public boolean visit(MarkerAnnotation node) { - return this.visit_(node); - } - - protected boolean visit_(org.eclipse.jdt.core.dom.Annotation node) { - String jdtAnnotationName = JDTTools.resolveAnnotation(node); - if (this.containerAnnotation.getAnnotationName().equals(jdtAnnotationName)) { - return true; - } - if (this.containerAnnotation.getNestableAnnotationName().equals(jdtAnnotationName)) { - this.visitNestedAnnotation(node); - } - return false; - } - - protected abstract void visitNestedAnnotation(org.eclipse.jdt.core.dom.Annotation node); - - } - - - // ********** initial annotation visitor ********** - - private static class InitialAnnotationVisitor extends AnnotationVisitor { - - InitialAnnotationVisitor(CompilationUnit astRoot, ContainerAnnotation containerAnnotation) { - super(astRoot, containerAnnotation); - } - - @Override - protected void visitNestedAnnotation(org.eclipse.jdt.core.dom.Annotation node) { - NestableAnnotation nestedAnnotation = this.containerAnnotation.addInternal(this.containerAnnotation.nestedAnnotationsSize()); - nestedAnnotation.initialize(this.astRoot); - } - - } - - - // ********** update annotation visitor ********** - - private static class UpdateAnnotationVisitor extends AnnotationVisitor { - - UpdateAnnotationVisitor(CompilationUnit astRoot, ContainerAnnotation containerAnnotation) { - super(astRoot, containerAnnotation); - } - - @Override - protected void visitNestedAnnotation(org.eclipse.jdt.core.dom.Annotation node) { - NestableAnnotation nestedAnnotation = this.containerAnnotation.nestedAnnotationFor(node); - if (nestedAnnotation == null) { - nestedAnnotation = this.containerAnnotation.add(this.containerAnnotation.nestedAnnotationsSize()); - nestedAnnotation.initialize(this.astRoot); - } else { - nestedAnnotation.update(this.astRoot); - } - } - - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesImpl.java 23 Oct 2008 19:04:08 -0000 1.13 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedQuery; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -public class NamedQueriesImpl extends AbstractResourceAnnotation implements NamedQueriesAnnotation -{ - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(NamedQueriesAnnotation.ANNOTATION_NAME); - - private List namedQueries; - - protected NamedQueriesImpl(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.namedQueries = new ArrayList(); - } - - public void initialize(CompilationUnit astRoot) { - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this); - } - - public String getAnnotationName() { - return NamedQueriesAnnotation.ANNOTATION_NAME; - } - - public String getNestableAnnotationName() { - return NamedQueryAnnotation.ANNOTATION_NAME; - } - - public String getElementName() { - return JPA.NAMED_QUERIES__VALUE; - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(this.namedQueries); - } - - public int nestedAnnotationsSize() { - return this.namedQueries.size(); - } - - public NestableNamedQuery addInternal(int index) { - NestableNamedQuery namedQuery = createNamedQuery(index); - this.namedQueries.add(index, namedQuery); - return namedQuery; - } - - public NestableNamedQuery add(int index) { - NestableNamedQuery namedQuery = createNamedQuery(index); - add(index, namedQuery); - return namedQuery; - } - - protected void add(int index, NestableNamedQuery namedQuery) { - addItemToList(index, namedQuery, this.namedQueries, NamedQueriesAnnotation.NAMED_QUERIES_LIST); - } - - public void remove(NestableNamedQuery namedQuery) { - removeItemFromList(namedQuery, this.namedQueries, NamedQueriesAnnotation.NAMED_QUERIES_LIST); - } - - public void remove(int index) { - removeItemFromList(index, this.namedQueries, NamedQueriesAnnotation.NAMED_QUERIES_LIST); - } - - public int indexOf(NestableNamedQuery attributeOverride) { - return this.namedQueries.indexOf(attributeOverride); - } - - public NestableNamedQuery nestedAnnotationAt(int index) { - return this.namedQueries.get(index); - } - - public NestableNamedQuery nestedAnnotationFor(org.eclipse.jdt.core.dom.Annotation jdtAnnotation) { - for (NestableNamedQuery namedQuery : this.namedQueries) { - if (jdtAnnotation == namedQuery.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return namedQuery; - } - } - return null; - } - - public void move(int targetIndex, int sourceIndex) { - moveItemInList(targetIndex, sourceIndex, this.namedQueries, NamedQueriesAnnotation.NAMED_QUERIES_LIST); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.namedQueries, targetIndex, sourceIndex); - } - - public void update(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this); - } - - private NamedQueryImpl createNamedQuery(int index) { - return NamedQueryImpl.createNestedNamedQuery(this, getMember(), index, getDeclarationAnnotationAdapter()); - } - - public static class NamedQueriesAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final NamedQueriesAnnotationDefinition 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 NamedQueriesImpl(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/EmbeddedImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/EmbeddedImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/EmbeddedImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/EmbeddedImpl.java 23 Oct 2008 19:04:08 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - - -public class EmbeddedImpl extends AbstractResourceAnnotation implements EmbeddedAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected EmbeddedImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void update(CompilationUnit astRoot) { - //no annotation members - } - - public static class EmbeddedAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final EmbeddedAnnotationDefinition INSTANCE = new EmbeddedAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static EmbeddedAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EmbeddedAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new EmbeddedImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullEmbedded(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsImpl.java 23 Oct 2008 19:04:08 -0000 1.13 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestablePrimaryKeyJoinColumn; -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; - -public class PrimaryKeyJoinColumnsImpl extends AbstractResourceAnnotation implements PrimaryKeyJoinColumnsAnnotation -{ - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private List pkJoinColumns; - - protected PrimaryKeyJoinColumnsImpl(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.pkJoinColumns = new ArrayList(); - } - - public void initialize(CompilationUnit astRoot) { - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public String getNestableAnnotationName() { - return PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME; - } - - public String getElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMNS__VALUE; - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(this.pkJoinColumns); - } - - public int nestedAnnotationsSize() { - return this.pkJoinColumns.size(); - } - - public NestablePrimaryKeyJoinColumn addInternal(int index) { - NestablePrimaryKeyJoinColumn pkJoinColumn = createPrimaryKeyJoinColumn(index); - this.pkJoinColumns.add(index, pkJoinColumn); - return pkJoinColumn; - } - - public NestablePrimaryKeyJoinColumn add(int index) { - NestablePrimaryKeyJoinColumn pkJoinColumn = createPrimaryKeyJoinColumn(index); - add(index, pkJoinColumn); - return pkJoinColumn; - } - - protected void add(int index, NestablePrimaryKeyJoinColumn pkJoinColumn) { - addItemToList(index, pkJoinColumn, this.pkJoinColumns, PK_JOIN_COLUMNS_LIST); - } - - public void remove(NestablePrimaryKeyJoinColumn pkJoinColumn) { - removeItemFromList(pkJoinColumn, this.pkJoinColumns, PK_JOIN_COLUMNS_LIST); - } - - public void remove(int index) { - removeItemFromList(index, this.pkJoinColumns, PK_JOIN_COLUMNS_LIST); - } - - public int indexOf(NestablePrimaryKeyJoinColumn pkJoinColumn) { - return this.pkJoinColumns.indexOf(pkJoinColumn); - } - - public NestablePrimaryKeyJoinColumn nestedAnnotationAt(int index) { - return this.pkJoinColumns.get(index); - } - - public NestablePrimaryKeyJoinColumn nestedAnnotationFor(Annotation jdtAnnotation) { - for (NestablePrimaryKeyJoinColumn pkJoinColumn : this.pkJoinColumns) { - if (jdtAnnotation == pkJoinColumn.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return pkJoinColumn; - } - } - return null; - } - - public void move(int targetIndex, int sourceIndex) { - moveItemInList(targetIndex, sourceIndex, this.pkJoinColumns, PK_JOIN_COLUMNS_LIST); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.pkJoinColumns, targetIndex, sourceIndex); - } - - public void update(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this); - } - - private PrimaryKeyJoinColumnImpl createPrimaryKeyJoinColumn(int index) { - return PrimaryKeyJoinColumnImpl.createNestedPrimaryKeyJoinColumn(this, getMember(), index, getDeclarationAnnotationAdapter()); - } - - - public static class PrimaryKeyJoinColumnsAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final PrimaryKeyJoinColumnsAnnotationDefinition 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 PrimaryKeyJoinColumnsImpl(parent, member); - } - - public PrimaryKeyJoinColumnsAnnotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/AbstractNamedColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AbstractNamedColumn.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AbstractNamedColumn.java --- src/org/eclipse/jpt/core/internal/resource/java/AbstractNamedColumn.java 17 Oct 2008 19:04:13 -0000 1.15 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.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; - -public abstract class AbstractNamedColumn extends AbstractResourceAnnotation implements NamedColumnAnnotation -{ - // hold this so we can get the 'name' text range - private final DeclarationAnnotationElementAdapter nameDeclarationAdapter; - - // hold this so we can get the 'columnDefinition' text range - private final DeclarationAnnotationElementAdapter columnDefinitionDeclarationAdapter; - - private final AnnotationElementAdapter nameAdapter; - - private final AnnotationElementAdapter columnDefinitionAdapter; - - private String name; - private String columnDefinition; - - public AbstractNamedColumn(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); - } - - protected DeclarationAnnotationElementAdapter buildStringElementAdapter(String elementName) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(getDeclarationAnnotationAdapter(), elementName); - } - - protected DeclarationAnnotationElementAdapter buildBooleanElementAdapter(String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(getDeclarationAnnotationAdapter(), elementName, BooleanExpressionConverter.instance()); - } - - protected DeclarationAnnotationElementAdapter buildIntegerElementAdapter(String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(getDeclarationAnnotationAdapter(), elementName, NumberIntegerExpressionConverter.instance()); - } - - protected AnnotationElementAdapter buildShortCircuitElementAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(getMember(), daea); - } - - protected AnnotationElementAdapter buildShortCircuitBooleanElementAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(getMember(), daea); - } - - protected AnnotationElementAdapter buildShortCircuitIntegerElementAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(getMember(), daea); - } - - protected AnnotationElementAdapter buildShortCircuitStringElementAdapter(String elementName) { - return this.buildShortCircuitElementAdapter(this.buildStringElementAdapter(elementName)); - } - - protected abstract String getNameElementName(); - - protected abstract String getColumnDefinitionElementName(); - - public void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - this.columnDefinition = this.columnDefinition(astRoot); - } - - public void initializeFrom(NestableAnnotation oldAnnotation) { - NamedColumnAnnotation oldColumn = (NamedColumnAnnotation) oldAnnotation; - setName(oldColumn.getName()); - setColumnDefinition(oldColumn.getColumnDefinition()); - } - - //************* NamedColumn implementation ************** - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public String getColumnDefinition() { - return this.columnDefinition; - } - - public void setColumnDefinition(String newColumnDefinition) { - if (attributeValueHasNotChanged(this.columnDefinition, newColumnDefinition)) { - return; - } - String oldColumnDefinition = this.columnDefinition; - this.columnDefinition = newColumnDefinition; - this.columnDefinitionAdapter.setValue(newColumnDefinition); - firePropertyChanged(COLUMN_DEFINITION_PROPERTY, oldColumnDefinition, newColumnDefinition); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public TextRange getColumnDefinitionTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.columnDefinitionDeclarationAdapter, astRoot); - } - - public boolean nameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - this.setColumnDefinition(this.columnDefinition(astRoot)); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - protected String columnDefinition(CompilationUnit astRoot) { - return this.columnDefinitionAdapter.getValue(astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/AccessImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AccessImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AccessImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/AccessImpl.java 12 Jan 2009 19:19:45 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,118 +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.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.AccessAnnotation; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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; - - -public class AccessImpl extends AbstractResourceAnnotation implements AccessAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter valueAdapter; - - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - - private AccessType value; - - protected AccessImpl(JavaResourcePersistentMember parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(member, VALUE_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** AccessAnnotation implementation **************** - public AccessType getValue() { - return this.value; - } - - public void setValue(AccessType newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - AccessType oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(AccessType.toJavaAnnotationValue(newValue)); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected AccessType value(CompilationUnit astRoot) { - return AccessType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ACCESS__VALUE); - } - - public static class AccessAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final AccessAnnotationDefinition INSTANCE = new AccessAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AccessAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AccessAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new AccessImpl(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullAccessAnnotation(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/BaseColumnImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/BaseColumnImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/BaseColumnImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/BaseColumnImpl.java 5 Sep 2008 15:27:20 -0000 1.6 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,233 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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; - -public abstract class BaseColumnImpl extends AbstractNamedColumn implements BaseColumnAnnotation -{ - // hold this so we can get the 'table' text range - private final DeclarationAnnotationElementAdapter tableDeclarationAdapter; - - // hold this so we can get the 'unique' text range - private final DeclarationAnnotationElementAdapter uniqueDeclarationAdapter; - - // hold this so we can get the 'nullable' text range - private final DeclarationAnnotationElementAdapter nullableDeclarationAdapter; - - // hold this so we can get the 'insertable' text range - private final DeclarationAnnotationElementAdapter insertableDeclarationAdapter; - - // hold this so we can get the 'updatable' text range - private final DeclarationAnnotationElementAdapter updatableDeclarationAdapter; - - private final AnnotationElementAdapter tableAdapter; - - private final AnnotationElementAdapter uniqueAdapter; - - private final AnnotationElementAdapter nullableAdapter; - - private final AnnotationElementAdapter insertableAdapter; - - private final AnnotationElementAdapter updatableAdapter; - - private String table; - private Boolean unique; - private Boolean nullable; - private Boolean insertable; - private Boolean updatable; - - - public BaseColumnImpl(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - } - - public BaseColumnImpl(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.table(astRoot); - this.unique = this.unique(astRoot); - this.nullable = this.nullable(astRoot); - this.insertable = this.insertable(astRoot); - this.updatable = this.updatable(astRoot); - } - - protected abstract String getTableElementName(); - - protected abstract String getUniqueElementName(); - - protected abstract String getNullableElementName(); - - protected abstract String getInsertableElementName(); - - protected abstract String getUpdatableElementName(); - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - BaseColumnAnnotation oldColumn = (BaseColumnAnnotation) oldAnnotation; - setTable(oldColumn.getTable()); - setUnique(oldColumn.getUnique()); - setNullable(oldColumn.getNullable()); - setInsertable(oldColumn.getInsertable()); - setUpdatable(oldColumn.getUpdatable()); - } - - //************* AbstractColumn implementation ************* - public String getTable() { - return this.table; - } - - public void setTable(String newTable) { - if (attributeValueHasNotChanged(this.table, newTable)) { - return; - } - String oldTable = this.table; - this.table = newTable; - this.tableAdapter.setValue(newTable); - firePropertyChanged(TABLE_PROPERTY, oldTable, newTable); - } - - public Boolean getUnique() { - return this.unique; - } - - public void setUnique(Boolean newUnique) { - if (attributeValueHasNotChanged(this.unique, newUnique)) { - return; - } - Boolean oldUnique = this.unique; - this.unique = newUnique; - this.uniqueAdapter.setValue(newUnique); - firePropertyChanged(UNIQUE_PROPERTY, oldUnique, newUnique); - } - - public Boolean getNullable() { - return this.nullable; - } - - public void setNullable(Boolean newNullable) { - if (attributeValueHasNotChanged(this.nullable, newNullable)) { - return; - } - Boolean oldNullable = this.nullable; - this.nullable = newNullable; - this.nullableAdapter.setValue(newNullable); - firePropertyChanged(NULLABLE_PROPERTY, oldNullable, newNullable); - } - - public Boolean getInsertable() { - return this.insertable; - } - - public void setInsertable(Boolean newInsertable) { - if (attributeValueHasNotChanged(this.insertable, newInsertable)) { - return; - } - Boolean oldInsertable = this.insertable; - this.insertable = newInsertable; - this.insertableAdapter.setValue(newInsertable); - firePropertyChanged(INSERTABLE_PROPERTY, oldInsertable, newInsertable); - } - - public Boolean getUpdatable() { - return this.updatable; - } - - public void setUpdatable(Boolean newUpdatable) { - if (attributeValueHasNotChanged(this.updatable, newUpdatable)) { - return; - } - Boolean oldUpdatable = this.updatable; - this.updatable = newUpdatable; - this.updatableAdapter.setValue(newUpdatable); - firePropertyChanged(UPDATABLE_PROPERTY, oldUpdatable, newUpdatable); - } - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nullableDeclarationAdapter, astRoot); - } - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.insertableDeclarationAdapter, astRoot); - } - - public TextRange getUniqueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.uniqueDeclarationAdapter, astRoot); - } - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.updatableDeclarationAdapter, 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); - } - - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setTable(this.table(astRoot)); - this.setUnique(this.unique(astRoot)); - this.setNullable(this.nullable(astRoot)); - this.setInsertable(this.insertable(astRoot)); - this.setUpdatable(this.updatable(astRoot)); - } - - protected String table(CompilationUnit astRoot) { - return this.tableAdapter.getValue(astRoot); - } - - protected Boolean unique(CompilationUnit astRoot) { - return this.uniqueAdapter.getValue(astRoot); - } - - protected Boolean nullable(CompilationUnit astRoot) { - return this.nullableAdapter.getValue(astRoot); - } - - protected Boolean insertable(CompilationUnit astRoot) { - return this.insertableAdapter.getValue(astRoot); - } - - protected Boolean updatable(CompilationUnit astRoot) { - return this.updatableAdapter.getValue(astRoot); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnImpl.java 23 Oct 2008 19:04:07 -0000 1.16 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,184 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -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.resource.java.NestablePrimaryKeyJoinColumn; -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; - -public class PrimaryKeyJoinColumnImpl extends AbstractNamedColumn implements NestablePrimaryKeyJoinColumn -{ - - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - // hold this so we can get the 'referenced column name' text range - private final DeclarationAnnotationElementAdapter referencedColumnNameDeclarationAdapter; - - private final AnnotationElementAdapter referencedColumnNameAdapter; - - private String referencedColumnName; - - protected PrimaryKeyJoinColumnImpl(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); - } - - protected PrimaryKeyJoinColumnImpl(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - } - - protected PrimaryKeyJoinColumnImpl(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { - this(parent, member, idaa, new MemberIndexedAnnotationAdapter(member, idaa)); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.referencedColumnName = this.referencedColumnName(astRoot); - } - - @Override - protected String getNameElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.PRIMARY_KEY_JOIN_COLUMN__COLUMN_DEFINITION; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - private IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) super.getAnnotationAdapter(); - } - - public void moveAnnotation(int newIndex) { - getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - PrimaryKeyJoinColumnAnnotation oldColumn = (PrimaryKeyJoinColumnAnnotation) oldAnnotation; - setReferencedColumnName(oldColumn.getReferencedColumnName()); - } - - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - public void setReferencedColumnName(String newReferencedColumnName) { - if (attributeValueHasNotChanged(this.referencedColumnName, newReferencedColumnName)) { - return; - } - String oldReferencedColumnName = this.referencedColumnName; - this.referencedColumnName = newReferencedColumnName; - this.referencedColumnNameAdapter.setValue(newReferencedColumnName); - firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, oldReferencedColumnName, newReferencedColumnName); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setReferencedColumnName(this.referencedColumnName(astRoot)); - } - - protected String referencedColumnName(CompilationUnit astRoot) { - return this.referencedColumnNameAdapter.getValue(astRoot); - } - - public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.referencedColumnNameDeclarationAdapter, pos, astRoot); - } - - public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.referencedColumnNameDeclarationAdapter, astRoot); - } - - // ********** static methods ********** - - static PrimaryKeyJoinColumnImpl createPrimaryKeyJoinColumn(JavaResourceNode parent, Member member) { - return new PrimaryKeyJoinColumnImpl(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - static PrimaryKeyJoinColumnImpl createNestedPrimaryKeyJoinColumn(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter pkJoinColumnsAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, pkJoinColumnsAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa); - return new PrimaryKeyJoinColumnImpl(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter pkJoinColumnsAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(pkJoinColumnsAdapter, index, JPA.PRIMARY_KEY_JOIN_COLUMN); - } - - - static NestablePrimaryKeyJoinColumn createSecondaryTablePrimaryKeyJoinColumn(DeclarationAnnotationAdapter secondaryTableAdapter, JavaResourceNode parent, Member member, int index) { - return new PrimaryKeyJoinColumnImpl(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); - } - - public static class PrimaryKeyJoinColumnAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final PrimaryKeyJoinColumnAnnotationDefinition 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 PrimaryKeyJoinColumnImpl.createPrimaryKeyJoinColumn(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullEmbedded.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullEmbedded.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullEmbedded.java --- src/org/eclipse/jpt/core/internal/resource/java/NullEmbedded.java 4 Aug 2008 19:53:53 -0000 1.9 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,60 +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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullEmbedded extends AbstractJavaResourceNode implements EmbeddedAnnotation, Annotation -{ - protected NullEmbedded(JavaResourcePersistentMember parent) { - super(parent); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return EmbeddedAnnotation.ANNOTATION_NAME; - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - -} Index: src/org/eclipse/jpt/core/internal/resource/java/JoinColumnImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/JoinColumnImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/JoinColumnImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/JoinColumnImpl.java 23 Oct 2008 19:04:07 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumn; -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; - -public class JoinColumnImpl extends BaseColumnImpl implements NestableJoinColumn -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - // hold this so we can get the 'referenced column name' text range - private final DeclarationAnnotationElementAdapter referencedColumnNameDeclarationAdapter; - - private final AnnotationElementAdapter referencedColumnNameAdapter; - - private String referencedColumnName; - - public JoinColumnImpl(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 JoinColumnImpl(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - } - - public JoinColumnImpl(JavaResourceNode parent, Member member, IndexedDeclarationAnnotationAdapter idaa) { - this(parent, member, idaa, new MemberIndexedAnnotationAdapter(member, idaa)); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.referencedColumnName = this.referencedColumnName(astRoot); - } - - @Override - protected String getNameElementName() { - return JPA.JOIN_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.JOIN_COLUMN__COLUMN_DEFINITION; - } - - @Override - protected String getTableElementName() { - return JPA.JOIN_COLUMN__TABLE; - } - - @Override - protected String getUniqueElementName() { - return JPA.JOIN_COLUMN__UNIQUE; - } - - @Override - protected String getNullableElementName() { - return JPA.JOIN_COLUMN__NULLABLE; - } - - @Override - protected String getInsertableElementName() { - return JPA.JOIN_COLUMN__INSERTABLE; - } - - @Override - protected String getUpdatableElementName() { - return JPA.JOIN_COLUMN__UPDATABLE; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - private IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) super.getAnnotationAdapter(); - } - - public void moveAnnotation(int newIndex) { - getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - JoinColumnAnnotation oldColumn = (JoinColumnAnnotation) oldAnnotation; - setReferencedColumnName(oldColumn.getReferencedColumnName()); - } - - //************ JoinColumn implementation *************** - public String getReferencedColumnName() { - return this.referencedColumnName; - } - - public void setReferencedColumnName(String newReferencedColumnName) { - if (attributeValueHasNotChanged(this.referencedColumnName, newReferencedColumnName)) { - return; - } - String oldReferencedColumnName = this.referencedColumnName; - this.referencedColumnName = newReferencedColumnName; - this.referencedColumnNameAdapter.setValue(newReferencedColumnName); - firePropertyChanged(REFERENCED_COLUMN_NAME_PROPERTY, oldReferencedColumnName, newReferencedColumnName); - } - - 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); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setReferencedColumnName(this.referencedColumnName(astRoot)); - } - - protected String referencedColumnName(CompilationUnit astRoot) { - return this.referencedColumnNameAdapter.getValue(astRoot); - } - - // ********** static methods ********** - - static JoinColumnImpl createJoinColumn(JavaResourceNode parent, Member member) { - return new JoinColumnImpl(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - static JoinColumnImpl createNestedJoinColumn(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter joinColumnsAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, joinColumnsAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa); - return new JoinColumnImpl(parent, member, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter joinColumnsAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(joinColumnsAdapter, index, JPA.JOIN_COLUMN); - } - static NestableJoinColumn createJoinTableJoinColumn(JavaResourceNode parent, Member member, int index) { - return new JoinColumnImpl(parent, member, buildJoinTableAnnotationAdapter(index)); - } - - private static IndexedDeclarationAnnotationAdapter buildJoinTableAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(JoinTableImpl.DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__JOIN_COLUMNS, index, JPA.JOIN_COLUMN); - } - - static NestableJoinColumn createJoinTableInverseJoinColumn(JavaResourceNode parent, Member member, int index) { - return new JoinColumnImpl(parent, member, buildJoinTableInverseAnnotationAdapter(index)); - } - - private static IndexedDeclarationAnnotationAdapter buildJoinTableInverseAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(JoinTableImpl.DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__INVERSE_JOIN_COLUMNS, index, JPA.JOIN_COLUMN); - } - - - static NestableJoinColumn createAssociationOverrideJoinColumn(DeclarationAnnotationAdapter associationOverrideAdapter, JavaResourceNode parent, Member member, int index) { - return new JoinColumnImpl(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); - } - - - public static class JoinColumnAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final JoinColumnAnnotationDefinition 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 JoinColumnImpl.createJoinColumn(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourceNode.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourceNode.java,v retrieving revision 1.15 diff -u -r1.15 AbstractJavaResourceNode.java --- src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourceNode.java 25 Mar 2009 21:34:28 -0000 1.15 +++ src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourceNode.java 6 Apr 2009 20:59:18 -0000 @@ -11,7 +11,6 @@ import org.eclipse.core.resources.IFile; import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; import org.eclipse.jpt.core.resource.java.JavaResourceNode; import org.eclipse.jpt.utility.internal.model.AbstractModel; import org.eclipse.jpt.utility.internal.model.CallbackChangeSupport; @@ -24,10 +23,10 @@ extends AbstractModel implements JavaResourceNode { - private final JavaResourceNode parent; + protected final JavaResourceNode parent; - // ********** construction ********** + // ********** constructor ********** protected AbstractJavaResourceNode(JavaResourceNode parent) { super(); @@ -35,6 +34,9 @@ this.parent = parent; } + + // ********** parent ********** + protected void checkParent(JavaResourceNode p) { if (p == null) { if (this.requiresParent()) { @@ -55,12 +57,15 @@ return ! this.requiresParent(); // assume 'parent' is not optional } + + // ********** change support callback hook ********** + @Override - protected ChangeSupport buildChangeSupport() { + protected final ChangeSupport buildChangeSupport() { return new CallbackChangeSupport(this, this.buildChangeSupportListener()); } - protected CallbackChangeSupport.Listener buildChangeSupportListener() { + private CallbackChangeSupport.Listener buildChangeSupportListener() { return new CallbackChangeSupport.Listener() { public void aspectChanged(String aspectName) { AbstractJavaResourceNode.this.aspectChanged(aspectName); @@ -68,6 +73,13 @@ }; } + /** + * ignore the aspect name, we notify listeners of *every* change + */ + void aspectChanged(@SuppressWarnings("unused") String aspectName) { + this.getRoot().resourceModelChanged(); + } + // ********** JavaResourceNode implementation ********** @@ -78,31 +90,12 @@ public IFile getFile() { return this.getRoot().getFile(); } - - - // ********** change support callback ********** - - /** - * ignore the aspect name, we notify listeners of *every* change - */ - protected void aspectChanged(@SuppressWarnings("unused") String aspectName) { - this.getRoot().resourceModelChanged(); - } // ********** convenience methods ********** - - protected JavaResourceNode getParent() { - return this.parent; - } protected JpaAnnotationProvider getAnnotationProvider() { return this.getRoot().getAnnotationProvider(); } - // TODO move... ======================== - public JavaResourceCompilationUnit getJavaResourceCompilationUnit() { - return (JavaResourceCompilationUnit) this.getRoot(); - } - } Index: src/org/eclipse/jpt/core/internal/resource/java/NullOneToOne.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullOneToOne.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullOneToOne.java --- src/org/eclipse/jpt/core/internal/resource/java/NullOneToOne.java 21 Nov 2008 15:33:09 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,173 +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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.OneToOneAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullOneToOne extends AbstractJavaResourceNode implements OneToOneAnnotation, Annotation -{ - protected NullOneToOne(JavaResourcePersistentMember parent) { - super(parent); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return OneToOneAnnotation.ANNOTATION_NAME; - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - protected OneToOneAnnotation createOneToOneResource() { - getParent().setMappingAnnotation(getAnnotationName()); - return (OneToOneAnnotation) getParent().getMappingAnnotation(); - } - - public FetchType getFetch() { - return null; - } - - public void setFetch(FetchType fetch) { - if (fetch != null) { - createOneToOneResource().setFetch(fetch); - } - } - - public Boolean getOptional() { - return null; - } - - public void setOptional(Boolean optional) { - if (optional != null) { - createOneToOneResource().setOptional(optional); - } - } - - public String getMappedBy() { - return null; - } - - public void setMappedBy(String mappedBy) { - if (mappedBy != null) { - createOneToOneResource().setMappedBy(mappedBy); - } - } - - public String getFullyQualifiedTargetEntity() { - return null; - } - - public String getTargetEntity() { - return null; - } - - public void setTargetEntity(String targetEntity) { - if (targetEntity != null) { - createOneToOneResource().setTargetEntity(targetEntity); - } - } - - public boolean isCascadeAll() { - return false; - } - - public void setCascadeAll(boolean all) { - createOneToOneResource().setCascadeAll(all); - } - - public boolean isCascadeMerge() { - return false; - } - - public void setCascadeMerge(boolean merge) { - createOneToOneResource().setCascadeMerge(merge); - } - - public boolean isCascadePersist() { - return false; - } - - public void setCascadePersist(boolean persist) { - createOneToOneResource().setCascadePersist(persist); - } - - public boolean isCascadeRefresh() { - return false; - } - - public void setCascadeRefresh(boolean refresh) { - createOneToOneResource().setCascadeRefresh(refresh); - } - - public boolean isCascadeRemove() { - return false; - } - - public void setCascadeRemove(boolean remove) { - createOneToOneResource().setCascadeRemove(remove); - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getCascadeTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getTargetEntityTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return false; - } - - -} Index: src/org/eclipse/jpt/core/internal/resource/java/JoinTableImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/JoinTableImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/JoinTableImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/JoinTableImpl.java 23 Oct 2008 19:04:08 -0000 1.18 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,400 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -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.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.ContainerAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumn; -import org.eclipse.jpt.core.resource.java.NestableUniqueConstraint; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -public class JoinTableImpl extends AbstractResourceTable implements JoinTableAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JoinTableAnnotation.ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__NAME); - - private static final DeclarationAnnotationElementAdapter SCHEMA_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__SCHEMA); - - private static final DeclarationAnnotationElementAdapter CATALOG_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__CATALOG); - - protected final List joinColumns; - - protected final List inverseJoinColumns; - - private final JoinColumnsContainerAnnotation joinColumnsContainerAnnotation; - - private final InverseJoinColumnsContainerAnnotation inverseJoinColumnsContainerAnnotation; - - protected JoinTableImpl(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); - this.joinColumns = new ArrayList(); - this.inverseJoinColumns = new ArrayList(); - this.joinColumnsContainerAnnotation = new JoinColumnsContainerAnnotation(); - this.inverseJoinColumnsContainerAnnotation = new InverseJoinColumnsContainerAnnotation(); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this.joinColumnsContainerAnnotation); - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this.inverseJoinColumnsContainerAnnotation); - } - - public String getAnnotationName() { - return JoinTableAnnotation.ANNOTATION_NAME; - } - - @Override - protected DeclarationAnnotationElementAdapter getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @JoinTable is never nested - return NAME_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @JoinTable is never nested - return SCHEMA_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @JoinTable is never nested - return CATALOG_ADAPTER; - } - - @Override - protected String getUniqueConstraintsElementName() { - return JPA.JOIN_TABLE__UNIQUE_CONSTRAINTS; - } - - @Override - protected NestableUniqueConstraint createUniqueConstraint(int index) { - return UniqueConstraintImpl.createJoinTableUniqueConstraint(this, this.getMember(), index); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.updateJoinColumnsFromJava(astRoot); - this.updateInverseJoinColumnsFromJava(astRoot); - } - - private void updateJoinColumnsFromJava(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this.joinColumnsContainerAnnotation); - } - - private void updateInverseJoinColumnsFromJava(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this.inverseJoinColumnsContainerAnnotation); - } - - public ListIterator joinColumns() { - return new CloneListIterator(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public NestableJoinColumn joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public JoinColumnAnnotation addJoinColumn(int index) { - NestableJoinColumn joinColumn = (NestableJoinColumn) ContainerAnnotationTools.addNestedAnnotation(index, this.joinColumnsContainerAnnotation); - fireItemAdded(JoinTableAnnotation.JOIN_COLUMNS_LIST, index, joinColumn); - return joinColumn; - } - - protected void addJoinColumn(int index, NestableJoinColumn joinColumn) { - addItemToList(index, joinColumn, this.joinColumns, JOIN_COLUMNS_LIST); - } - - public void removeJoinColumn(int index) { - NestableJoinColumn joinColumn = this.joinColumns.get(index); - removeJoinColumn(joinColumn); - joinColumn.removeAnnotation(); - ContainerAnnotationTools.synchAnnotationsAfterRemove(index, this.joinColumnsContainerAnnotation); - } - - protected void removeJoinColumn(NestableJoinColumn joinColumn) { - removeItemFromList(joinColumn, this.joinColumns, JOIN_COLUMNS_LIST); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - moveJoinColumnInternal(targetIndex, sourceIndex); - ContainerAnnotationTools.synchAnnotationsAfterMove(targetIndex, sourceIndex, this.joinColumnsContainerAnnotation); - fireItemMoved(JoinTableAnnotation.JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - protected void moveJoinColumnInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.joinColumns, targetIndex, sourceIndex); - } - - public ListIterator inverseJoinColumns() { - return new CloneListIterator(this.inverseJoinColumns); - } - - public int inverseJoinColumnsSize() { - return this.inverseJoinColumns.size(); - } - - public NestableJoinColumn inverseJoinColumnAt(int index) { - return this.inverseJoinColumns.get(index); - } - - public int indexOfInverseJoinColumn(JoinColumnAnnotation joinColumn) { - return this.inverseJoinColumns.indexOf(joinColumn); - } - - public JoinColumnAnnotation addInverseJoinColumn(int index) { - NestableJoinColumn inverseJoinColumn = (NestableJoinColumn) ContainerAnnotationTools.addNestedAnnotation(index, this.inverseJoinColumnsContainerAnnotation); - fireItemAdded(JoinTableAnnotation.INVERSE_JOIN_COLUMNS_LIST, index, inverseJoinColumn); - return inverseJoinColumn; - } - - protected void addInverseJoinColumn(int index, NestableJoinColumn joinColumn) { - addItemToList(index, joinColumn, this.inverseJoinColumns, INVERSE_JOIN_COLUMNS_LIST); - } - - public void removeInverseJoinColumn(int index) { - NestableJoinColumn joinColumn = this.inverseJoinColumns.get(index); - this.removeInverseJoinColumn(joinColumn); - joinColumn.removeAnnotation(); - ContainerAnnotationTools.synchAnnotationsAfterRemove(index, this.inverseJoinColumnsContainerAnnotation); - } - - protected void removeInverseJoinColumn(NestableJoinColumn joinColumn) { - removeItemFromList(joinColumn, this.inverseJoinColumns, INVERSE_JOIN_COLUMNS_LIST); - } - - public void moveInverseJoinColumn(int targetIndex, int sourceIndex) { - moveInverseJoinColumnInternal(targetIndex, sourceIndex); - ContainerAnnotationTools.synchAnnotationsAfterMove(targetIndex, sourceIndex, this.inverseJoinColumnsContainerAnnotation); - fireItemMoved(JoinTableAnnotation.INVERSE_JOIN_COLUMNS_LIST, targetIndex, sourceIndex); - } - - protected void moveInverseJoinColumnInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.inverseJoinColumns, targetIndex, sourceIndex); - } - - protected NestableJoinColumn createJoinColumn(int index) { - return JoinColumnImpl.createJoinTableJoinColumn(this, getMember(), index); - } - - protected NestableJoinColumn createInverseJoinColumn(int index) { - return JoinColumnImpl.createJoinTableInverseJoinColumn(this, getMember(), index); - } - - protected class JoinColumnsContainerAnnotation extends AbstractContainerAnnotation { - - public NestableJoinColumn addInternal(int index) { - NestableJoinColumn joinColumn = JoinTableImpl.this.createJoinColumn(index); - JoinTableImpl.this.joinColumns.add(index, joinColumn); - return joinColumn; - } - - public NestableJoinColumn add(int index) { - NestableJoinColumn joinColumn = JoinTableImpl.this.createJoinColumn(index); - JoinTableImpl.this.addJoinColumn(index, joinColumn); - return joinColumn; - } - - public int indexOf(NestableJoinColumn joinColumn) { - return JoinTableImpl.this.indexOfJoinColumn(joinColumn); - } - - public void move(int targetIndex, int sourceIndex) { - JoinTableImpl.this.moveJoinColumn(targetIndex, sourceIndex); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - JoinTableImpl.this.moveJoinColumnInternal(targetIndex, sourceIndex); - } - - public NestableJoinColumn nestedAnnotationAt(int index) { - return JoinTableImpl.this.joinColumnAt(index); - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(JoinTableImpl.this.joinColumns); - } - - public int nestedAnnotationsSize() { - return joinColumnsSize(); - } - - public void remove(NestableJoinColumn nestedAnnotation) { - JoinTableImpl.this.removeJoinColumn(nestedAnnotation); - } - public String getElementName() { - return JPA.JOIN_TABLE__JOIN_COLUMNS; - } - } - - protected class InverseJoinColumnsContainerAnnotation extends AbstractContainerAnnotation { - - public NestableJoinColumn addInternal(int index) { - NestableJoinColumn joinColumn = JoinTableImpl.this.createInverseJoinColumn(index); - JoinTableImpl.this.inverseJoinColumns.add(index, joinColumn); - return joinColumn; - } - - public NestableJoinColumn add(int index) { - NestableJoinColumn joinColumn = JoinTableImpl.this.createInverseJoinColumn(index); - JoinTableImpl.this.addInverseJoinColumn(index, joinColumn); - return joinColumn; - } - - public int indexOf(NestableJoinColumn joinColumn) { - return JoinTableImpl.this.indexOfInverseJoinColumn(joinColumn); - } - - public void move(int targetIndex, int sourceIndex) { - JoinTableImpl.this.moveInverseJoinColumn(targetIndex, sourceIndex); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - JoinTableImpl.this.moveInverseJoinColumnInternal(targetIndex, sourceIndex); - } - - public NestableJoinColumn nestedAnnotationAt(int index) { - return JoinTableImpl.this.inverseJoinColumnAt(index); - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(JoinTableImpl.this.inverseJoinColumns); - } - - public int nestedAnnotationsSize() { - return inverseJoinColumnsSize(); - } - - public void remove(NestableJoinColumn nestedAnnotation) { - JoinTableImpl.this.removeInverseJoinColumn(nestedAnnotation); - } - - public String getElementName() { - return JPA.JOIN_TABLE__INVERSE_JOIN_COLUMNS; - } - } - - private abstract class AbstractContainerAnnotation extends AbstractJavaResourceNode implements ContainerAnnotation { - - public AbstractContainerAnnotation() { - super(JoinTableImpl.this); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public String getAnnotationName() { - return JoinTableImpl.this.getAnnotationName(); - } - - public String getNestableAnnotationName() { - return JPA.JOIN_COLUMN; - } - - public void remove(int index) { - this.remove(nestedAnnotationAt(index)); - } - - public NestableJoinColumn nestedAnnotationFor(org.eclipse.jdt.core.dom.Annotation jdtAnnotation) { - for (NestableJoinColumn joinColumn : CollectionTools.iterable(nestedAnnotations())) { - if (jdtAnnotation == joinColumn.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return joinColumn; - } - } - return null; - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return JoinTableImpl.this.getJdtAnnotation(astRoot); - } - - public void newAnnotation() { - JoinTableImpl.this.newAnnotation(); - } - - public void removeAnnotation() { - JoinTableImpl.this.removeAnnotation(); - } - - public void update(CompilationUnit astRoot) { - JoinTableImpl.this.update(astRoot); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return JoinTableImpl.this.getTextRange(astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getAnnotationName()); - } - - } - public static class JoinTableAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final JoinTableAnnotationDefinition 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 JoinTableImpl(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullJoinTable(parent); - } - - public String getAnnotationName() { - return JoinTableAnnotation.ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourcePersistentMember.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourcePersistentMember.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourcePersistentMember.java --- src/org/eclipse/jpt/core/internal/resource/java/AbstractJavaResourcePersistentMember.java 10 Mar 2009 04:12:10 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,649 +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.HashSet; -import java.util.Iterator; -import java.util.ListIterator; -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.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneIterator; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator; - -/** - * Java source persistent member (annotations, "persistable") - */ -public abstract class AbstractJavaResourcePersistentMember - extends AbstractJavaResourceNode - implements JavaResourcePersistentMember -{ - private final E member; - - /** - * mapping annotations; no duplicates (java compiler has an error for - * duplicates) - */ - private final Vector mappingAnnotations; - - /** - * supporting annotations; no duplicates (java compiler has an error for - * duplicates) - */ - private final Vector supportingAnnotations; - - private boolean persistable; - - - // ********** construction/initialization ********** - - protected AbstractJavaResourcePersistentMember(JavaResourceNode parent, E member) { - super(parent); - this.member = member; - this.mappingAnnotations = new Vector(); - this.supportingAnnotations = new Vector(); - } - - public void initialize(CompilationUnit astRoot) { - this.getMember().getBodyDeclaration(astRoot).accept(this.buildInitialAnnotationVisitor(astRoot)); - this.persistable = this.buildPersistable(astRoot); - } - - protected ASTVisitor buildInitialAnnotationVisitor(CompilationUnit astRoot) { - return new InitialAnnotationVisitor(astRoot, this.getMember().getBodyDeclaration(astRoot)); - } - - /** - * called from InitialAnnotationVisitor - */ - protected void addInitialAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot) { - String jdtAnnotationName = JDTTools.resolveAnnotation(node); - if (jdtAnnotationName == null) { - return; - } - if (this.annotationIsValidSupportingAnnotation(jdtAnnotationName)) { - if (this.getSupportingAnnotation(jdtAnnotationName) == null) { // ignore duplicates - Annotation annotation = this.buildSupportingAnnotation(jdtAnnotationName); - annotation.initialize(astRoot); - this.supportingAnnotations.add(annotation); - } - } else if (this.annotationIsValidMappingAnnotation(jdtAnnotationName)) { - if (this.getMappingAnnotation_(jdtAnnotationName) == null) { // ignore duplicates - Annotation annotation = this.buildMappingAnnotation(jdtAnnotationName); - annotation.initialize(astRoot); - this.mappingAnnotations.add(annotation); - } - } - } - - - // ********** mapping annotations ********** - - public Iterator mappingAnnotations() { - return new CloneIterator(this.mappingAnnotations); - } - - public int mappingAnnotationsSize() { - return this.mappingAnnotations.size(); - } - - // TODO need property change notification on this mappingAnnotation changing - // from the context model we don't really care if their are multiple mapping - // annotations, just which one we need to use - public Annotation getMappingAnnotation() { - synchronized (this.mappingAnnotations) { - return this.getMappingAnnotation_(); - } - } - - protected Annotation getMappingAnnotation_() { - for (ListIterator stream = this.validMappingAnnotationNames(); stream.hasNext();) { - Annotation annotation = this.getMappingAnnotation_(stream.next()); - if (annotation != null) { - return annotation; - } - } - return null; - } - - public Annotation getMappingAnnotation(String annotationName) { - return getAnnotation(this.mappingAnnotations(), annotationName); - } - - /** - * use this method when 'mappingAnnotations' is synchronized - */ - protected Annotation getMappingAnnotation_(String annotationName) { - return getAnnotation(this.mappingAnnotations, annotationName); - } - - /** - * Remove all other *mapping* annotations that exist; not just the one - * returned by #getMappingAnnotation(). #getMappingAnnotation() returns the - * first mapping annotation found in the source. If there were multiple - * mapping annotations (which is a validation error) then calling this - * method would not work because the new mapping annotation would be added - * to the end of the list of annotations. - */ - public void setMappingAnnotation(String annotationName) { - synchronized (this.mappingAnnotations) { - this.setMappingAnnotation_(annotationName); - } - // hold change notification until the end so a project update does not - // occur before we are finished removing the old mapping(s) and adding - // the new mapping; just fire "collection changed" since one or more - // removes and/or one add occurred - this.fireCollectionChanged(MAPPING_ANNOTATIONS_COLLECTION); - } - - protected void setMappingAnnotation_(String annotationName) { - if (annotationName == null) { - this.removeMappingAnnotations_(); - return; - } - - if (this.getMappingAnnotation_(annotationName) != null) { - throw new IllegalStateException("duplicate mapping annotation: " + annotationName); //$NON-NLS-1$ - } - - this.removeMappingAnnotations_(); - Annotation newMapping = this.buildMappingAnnotation(annotationName); - this.mappingAnnotations.add(newMapping); - newMapping.newAnnotation(); - } - - /** - * Remove all mapping annotations that already exist. No change notification - * is fired. - */ - protected void removeMappingAnnotations() { - synchronized (this.mappingAnnotations) { - this.removeMappingAnnotations_(); - } - } - - protected void removeMappingAnnotations_() { - for (ListIterator stream = this.validMappingAnnotationNames(); stream.hasNext();) { - Annotation mappingAnnotation = this.getMappingAnnotation_(stream.next()); - if (mappingAnnotation != null) { - this.mappingAnnotations.remove(mappingAnnotation); - mappingAnnotation.removeAnnotation(); - } - } - } - - public JavaResourceNode getNullMappingAnnotation(String annotationName) { - return (annotationName == null) ? null : this.buildNullMappingAnnotation(annotationName); - } - - protected abstract Annotation buildNullMappingAnnotation(String annotationName); - - protected boolean annotationIsValidMappingAnnotation(String annotationName) { - return CollectionTools.contains(this.validMappingAnnotationNames(), annotationName); - } - - protected abstract ListIterator validMappingAnnotationNames(); - - protected abstract Annotation buildMappingAnnotation(String mappingAnnotationName); - - protected void addMappingAnnotation(Annotation annotation) { - this.addItemToCollection(annotation, this.mappingAnnotations, MAPPING_ANNOTATIONS_COLLECTION); - } - - protected void removeMappingAnnotation(Annotation annotation) { - this.removeMappingAnnotation_(annotation); - annotation.removeAnnotation(); - } - - protected void removeMappingAnnotation_(Annotation annotation) { - this.removeItemFromCollection(annotation, this.mappingAnnotations, MAPPING_ANNOTATIONS_COLLECTION); - } - - - // ********** supporting annotations ********** - - public Iterator supportingAnnotations() { - return new CloneIterator(this.supportingAnnotations); - } - - public int supportingAnnotationsSize() { - return this.supportingAnnotations.size(); - } - - public ListIterator supportingAnnotations(String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - return containerAnnotation.nestedAnnotations(); - } - NestableAnnotation nestableAnnotation = this.getSupportingNestableAnnotation(nestableAnnotationName); - return (nestableAnnotation == null) ? EmptyListIterator.instance() : new SingleElementListIterator(nestableAnnotation); - } - - protected NestableAnnotation getSupportingNestableAnnotation(String annotationName) { - return (NestableAnnotation) this.getSupportingAnnotation(annotationName); - } - - public Annotation getSupportingAnnotation(String annotationName) { - return getAnnotation(this.supportingAnnotations(), annotationName); - } - - public JavaResourceNode getNonNullSupportingAnnotation(String annotationName) { - Annotation annotation = this.getSupportingAnnotation(annotationName); - return (annotation != null) ? annotation : this.buildNullSupportingAnnotation(annotationName); - } - - protected abstract Annotation buildNullSupportingAnnotation(String annotationName); - - public Annotation addSupportingAnnotation(String annotationName) { - Annotation annotation = this.buildSupportingAnnotation(annotationName); - this.supportingAnnotations.add(annotation); - annotation.newAnnotation(); - this.fireItemAdded(SUPPORTING_ANNOTATIONS_COLLECTION, annotation); - return annotation; - } - - protected abstract Annotation buildSupportingAnnotation(String annotationName); - - protected void addSupportingAnnotation(Annotation annotation) { - this.addItemToCollection(annotation, this.supportingAnnotations, SUPPORTING_ANNOTATIONS_COLLECTION); - } - - public void removeSupportingAnnotation(String annotationName) { - synchronized (this.supportingAnnotations) { - this.removeSupportingAnnotation_(annotationName); - } - } - - protected void removeSupportingAnnotation_(String annotationName) { - Annotation annotation = this.getSupportingAnnotation(annotationName); - if (annotation != null) { - this.removeSupportingAnnotation(annotation); - } - } - - protected void removeSupportingAnnotation(Annotation annotation) { - this.removeSupportingAnnotation_(annotation); - // TODO looks odd that we remove the annotation here, but in - // addAnnotation(Annotation) we don't do the same - annotation.removeAnnotation(); - } - - protected void removeSupportingAnnotation_(Annotation annotation) { - this.removeItemFromCollection(annotation, this.supportingAnnotations, SUPPORTING_ANNOTATIONS_COLLECTION); - } - - public NestableAnnotation addSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - synchronized (this.supportingAnnotations) { - return this.addSupportingAnnotation_(index, nestableAnnotationName, containerAnnotationName); - } - } - - // TODO it seems we should be firing one change notification here, that a - // new nestable annotation was added. - protected NestableAnnotation addSupportingAnnotation_(int index, String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - // ignore any nestable annotation and just add to the container - // annotation - NestableAnnotation newNestedAnnotation = ContainerAnnotationTools.addNestedAnnotation(index, containerAnnotation); - // TODO any event notification being fired for the add??? - return newNestedAnnotation; - } - - NestableAnnotation nestedAnnotation = this.getSupportingNestableAnnotation(nestableAnnotationName); - if (nestedAnnotation == null) { - // add the nestable annotation since neither the nestable nor the - // container exist - return this.addSupportingNestableAnnotation(nestableAnnotationName); - } - - // move the existing nestable annotation to a new container annotation - // and add a new one - ContainerAnnotation newContainerAnnotation = this.addSupportingContainerAnnotationTwoNestableAnnotations(containerAnnotationName); - if (index == 0) { - newContainerAnnotation.nestedAnnotationAt(1).initializeFrom(nestedAnnotation); - } else { - newContainerAnnotation.nestedAnnotationAt(0).initializeFrom(nestedAnnotation); - } - this.removeSupportingAnnotation(nestedAnnotation); - return newContainerAnnotation.nestedAnnotationAt(index); - } - - @SuppressWarnings("unchecked") - protected ContainerAnnotation getSupportingContainerAnnotation(String annotationName) { - return (ContainerAnnotation) this.getSupportingAnnotation(annotationName); - } - - protected NestableAnnotation addSupportingNestableAnnotation(String annotationName) { - return (NestableAnnotation) this.addSupportingAnnotation(annotationName); - } - - protected ContainerAnnotation addSupportingContainerAnnotationTwoNestableAnnotations(String annotationName) { - ContainerAnnotation containerAnnotation = this.buildContainerAnnotation(annotationName); - this.supportingAnnotations.add(containerAnnotation); - containerAnnotation.newAnnotation(); - containerAnnotation.addInternal(0).newAnnotation(); - containerAnnotation.addInternal(1).newAnnotation(); - return containerAnnotation; - } - - @SuppressWarnings("unchecked") - protected ContainerAnnotation buildContainerAnnotation(String annotationName) { - return (ContainerAnnotation) this.buildSupportingAnnotation(annotationName); - } - - protected boolean annotationIsValidSupportingAnnotation(String annotationName) { - return CollectionTools.contains(this.validSupportingAnnotationNames(), annotationName); - } - - protected abstract ListIterator validSupportingAnnotationNames(); - - public void removeSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - synchronized (this.supportingAnnotations) { - this.removeSupportingAnnotation_(index, nestableAnnotationName, containerAnnotationName); - } - } - - protected void removeSupportingAnnotation_(int index, String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName); - if (containerAnnotation == null) { - Annotation annotation = this.getSupportingAnnotation(nestableAnnotationName); - this.removeSupportingAnnotation(annotation); - } else { - this.removeSupportingAnnotation(index, containerAnnotation); - } - } - - protected void removeSupportingAnnotation(int index, ContainerAnnotation containerAnnotation) { - NestableAnnotation nestableAnnotation = containerAnnotation.nestedAnnotationAt(index); - containerAnnotation.remove(index); - // TODO move these 2 lines to the ContainerAnnotation implementation, i think - nestableAnnotation.removeAnnotation(); - ContainerAnnotationTools.synchAnnotationsAfterRemove(index, containerAnnotation); - - if (containerAnnotation.nestedAnnotationsSize() == 0) { - this.removeSupportingAnnotation(containerAnnotation); - } else if (containerAnnotation.nestedAnnotationsSize() == 1) { - NestableAnnotation nestedAnnotation = containerAnnotation.nestedAnnotationAt(0); - - this.supportingAnnotations.remove(containerAnnotation); - containerAnnotation.removeAnnotation(); - - NestableAnnotation newAnnotation = (NestableAnnotation) this.buildSupportingAnnotation(containerAnnotation.getNestableAnnotationName()); - this.supportingAnnotations.add(newAnnotation); - newAnnotation.newAnnotation(); - - newAnnotation.initializeFrom(nestedAnnotation); - - this.fireItemAdded(SUPPORTING_ANNOTATIONS_COLLECTION, newAnnotation); - this.fireItemRemoved(SUPPORTING_ANNOTATIONS_COLLECTION, containerAnnotation); - } - } - - public void moveSupportingAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) { - this.moveAnnotation(targetIndex, sourceIndex, this.getSupportingContainerAnnotation(containerAnnotationName)); - } - - protected void moveAnnotation(int targetIndex, int sourceIndex, ContainerAnnotation containerAnnotation) { - containerAnnotation.move(targetIndex, sourceIndex); - ContainerAnnotationTools.synchAnnotationsAfterMove(targetIndex, sourceIndex, containerAnnotation); - } - - - // ********** simple state ********** - - public boolean isPersistable() { - return this.persistable; - } - - protected void setPersistable(boolean persistable) { - boolean old = this.persistable; - this.persistable = persistable; - this.firePropertyChanged(PERSISTABLE_PROPERTY, old, persistable); - } - - protected boolean buildPersistable(CompilationUnit astRoot) { - return this.getMember().isPersistable(astRoot); - } - - public boolean isPersisted() { - return this.getMappingAnnotation() != null; - } - - public boolean isFor(String memberName, int occurrence) { - return this.member.matches(memberName, occurrence); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return this.fullTextRange(astRoot); - } - - protected TextRange fullTextRange(CompilationUnit astRoot) { - return this.buildTextRange(this.getMember().getBodyDeclaration(astRoot)); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getMember().getNameTextRange(astRoot); - } - - - // ********** update ********** - - public void update(CompilationUnit astRoot) { - this.updateAnnotations(astRoot); - this.setPersistable(this.buildPersistable(astRoot)); - } - - protected void updateAnnotations(CompilationUnit astRoot) { - synchronized (this.mappingAnnotations) { - synchronized (this.supportingAnnotations) { - this.updateAnnotations_(astRoot); - } - } - } - - protected void updateAnnotations_(CompilationUnit astRoot) { - HashSet mappingAnnotationsToRemove = new HashSet(this.mappingAnnotations); - HashSet supportingAnnotationsToRemove = new HashSet(this.supportingAnnotations); - - this.getMember().getBodyDeclaration(astRoot).accept(this.buildUpdateAnnotationVisitor(astRoot, mappingAnnotationsToRemove, supportingAnnotationsToRemove)); - - for (Annotation annotation : mappingAnnotationsToRemove) { - this.removeMappingAnnotation_(annotation); - } - for (Annotation annotation : supportingAnnotationsToRemove) { - this.removeSupportingAnnotation_(annotation); - } - } - - protected ASTVisitor buildUpdateAnnotationVisitor(CompilationUnit astRoot, Set mappingAnnotationsToRemove, Set supportingAnnotationsToRemove) { - return new UpdateAnnotationVisitor(astRoot, this.getMember().getBodyDeclaration(astRoot), mappingAnnotationsToRemove, supportingAnnotationsToRemove); - } - - protected void addOrUpdateAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot, Set mappingAnnotationsToRemove, Set supportingAnnotationsToRemove) { - String jdtAnnotationName = JDTTools.resolveAnnotation(node); - if (jdtAnnotationName == null) { - return; - } - if (this.annotationIsValidSupportingAnnotation(jdtAnnotationName)) { - this.addOrUpdateSupportingAnnotation(jdtAnnotationName, astRoot, supportingAnnotationsToRemove); - return; - } - if (this.annotationIsValidMappingAnnotation(jdtAnnotationName)) { - this.addOrUpdateMappingAnnotation(jdtAnnotationName, astRoot, mappingAnnotationsToRemove); - return; - } - } - - protected void addOrUpdateSupportingAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set supportingAnnotationsToRemove) { - Annotation annotation = this.getAnnotation(supportingAnnotationsToRemove, jdtAnnotationName); - if (annotation != null) { - annotation.update(astRoot); - supportingAnnotationsToRemove.remove(annotation); - } else { - annotation = this.buildSupportingAnnotation(jdtAnnotationName); - annotation.initialize(astRoot); - this.addSupportingAnnotation(annotation); - } - } - - protected void addOrUpdateMappingAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set mappingAnnotationsToRemove) { - Annotation annotation = this.getAnnotation(mappingAnnotationsToRemove, jdtAnnotationName); - if (annotation != null) { - annotation.update(astRoot); - mappingAnnotationsToRemove.remove(annotation); - } else { - annotation = this.buildMappingAnnotation(jdtAnnotationName); - annotation.initialize(astRoot); - this.addMappingAnnotation(annotation); - } - } - - - // ********** miscellaneous ********** - - public void resolveTypes(CompilationUnit astRoot) { - this.setPersistable(this.buildPersistable(astRoot)); - } - - protected E getMember() { - return this.member; - } - - protected Annotation getAnnotation(Iterable annotations, String annotationName) { - return this.getAnnotation(annotations.iterator(), annotationName); - } - - protected Annotation getAnnotation(Iterator annotations, String annotationName) { - while (annotations.hasNext()) { - Annotation annotation = annotations.next(); - if (annotation.getAnnotationName().equals(annotationName)) { - return annotation; - } - } - return null; - } - - protected TextRange buildTextRange(ASTNode astNode) { - return (astNode == null) ? null : new ASTNodeTextRange(astNode); - } - - protected Iterator persistableMembers(Iterator members) { - return new FilteringIterator(members) { - @Override - protected boolean accept(T m) { - return m.isPersistable(); - } - }; - } - - - // ********** AST visitors ********** - - /** - * annotation visitor - */ - protected static abstract class AnnotationVisitor extends ASTVisitor { - private final CompilationUnit astRoot; - private 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 CompilationUnit getASTRoot() { - return this.astRoot; - } - - 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) { - AbstractJavaResourcePersistentMember.this.addInitialAnnotation(node, this.getASTRoot()); - } - - } - - /** - * update annotation visitor - */ - protected class UpdateAnnotationVisitor extends AnnotationVisitor { - protected final Set mappingAnnotationsToRemove; - protected final Set supportingAnnotationsToRemove; - - protected UpdateAnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration, Set mappingAnnotationsToRemove, Set supportingAnnotationsToRemove) { - super(astRoot, bodyDeclaration); - this.mappingAnnotationsToRemove = mappingAnnotationsToRemove; - this.supportingAnnotationsToRemove = supportingAnnotationsToRemove; - } - - @Override - protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) { - AbstractJavaResourcePersistentMember.this.addOrUpdateAnnotation(node, this.getASTRoot(), this.mappingAnnotationsToRemove, this.supportingAnnotationsToRemove); - } - - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryImpl.java 23 Oct 2008 19:04:08 -0000 1.16 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,238 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NamedNativeQueryAnnotation; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableNamedNativeQuery; -import org.eclipse.jpt.core.resource.java.NestableQueryHint; -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; -import org.eclipse.jpt.core.utility.jdt.Type; - -public class NamedNativeQueryImpl extends AbstractNamedQuery - implements NestableNamedNativeQuery -{ - - public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - // hold this so we can get the 'resultClass' text range - private final DeclarationAnnotationElementAdapter resultClassDeclarationAdapter; - - // hold this so we can get the 'resultSetMapping' text range - private final DeclarationAnnotationElementAdapter resultSetMappingDeclarationAdapter; - - - private final AnnotationElementAdapter resultClassAdapter; - - private final AnnotationElementAdapter resultSetMappingAdapter; - - private String resultClass; - - private String fullyQualifiedResultClass; - - private String resultSetMapping; - - protected NamedNativeQueryImpl(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, type, daa, annotationAdapter); - this.resultClassDeclarationAdapter = resultClassAdapter(daa); - this.resultClassAdapter = this.buildAdapter(this.resultClassDeclarationAdapter); - this.resultSetMappingDeclarationAdapter = resultSetMappingAdapter(daa); - this.resultSetMappingAdapter = this.buildAdapter(this.resultSetMappingDeclarationAdapter); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.resultClass = this.resultClass(astRoot); - this.fullyQualifiedResultClass = this.fullyQualifiedResultClass(astRoot); - this.resultSetMapping = this.resultSetMapping(astRoot); - } - - - // ********** initialization ********** - protected DeclarationAnnotationElementAdapter resultClassAdapter(DeclarationAnnotationAdapter daa) { - return new ConversionDeclarationAnnotationElementAdapter(daa, JPA.NAMED_NATIVE_QUERY__RESULT_CLASS, SimpleTypeStringExpressionConverter.instance()); - } - - protected DeclarationAnnotationElementAdapter resultSetMappingAdapter(DeclarationAnnotationAdapter daa) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //************* AbstractNamedQuery implementation ************* - - @Override - protected String getNameElementName() { - return JPA.NAMED_NATIVE_QUERY__NAME; - } - - @Override - protected String getQueryElementName() { - return JPA.NAMED_NATIVE_QUERY__QUERY; - } - - @Override - protected String getHintsElementName() { - return JPA.NAMED_NATIVE_QUERY__HINTS; - } - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - NamedNativeQueryAnnotation oldNamedQuery = (NamedNativeQueryAnnotation) oldAnnotation; - setResultClass(oldNamedQuery.getResultClass()); - setResultSetMapping(oldNamedQuery.getResultSetMapping()); - } - - public String getResultClass() { - return this.resultClass; - } - - public void setResultClass(String newResultClass) { - if (attributeValueHasNotChanged(this.resultClass, newResultClass)) { - return; - } - String oldResultClass = this.resultClass; - this.resultClass = newResultClass; - this.resultClassAdapter.setValue(newResultClass); - firePropertyChanged(RESULT_CLASS_PROPERTY, oldResultClass, newResultClass); - } - - public String getFullyQualifiedResultClass() { - return this.fullyQualifiedResultClass; - } - - protected void setFullyQualifiedResultClass(String newQualifiedResultClass) { - String oldFullyQualifiedResultClass = this.fullyQualifiedResultClass; - this.fullyQualifiedResultClass = newQualifiedResultClass; - firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_PROPERTY, oldFullyQualifiedResultClass, newQualifiedResultClass); - } - - public String getResultSetMapping() { - return this.resultSetMapping; - } - - public void setResultSetMapping(String newResultSetMapping) { - if (attributeValueHasNotChanged(this.resultSetMapping, newResultSetMapping)) { - return; - } - String oldResultSetMapping = this.resultSetMapping; - this.resultSetMapping = newResultSetMapping; - this.resultSetMappingAdapter.setValue(newResultSetMapping); - firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, oldResultSetMapping, newResultSetMapping); - } - - public TextRange getResultClassTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.resultClassDeclarationAdapter, astRoot); - } - - public TextRange getResultSetMappingTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.resultSetMappingDeclarationAdapter, astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setResultClass(this.resultClass(astRoot)); - this.setFullyQualifiedResultClass(this.fullyQualifiedResultClass(astRoot)); - this.setResultSetMapping(this.resultSetMapping(astRoot)); - } - - protected String resultClass(CompilationUnit astRoot) { - return this.resultClassAdapter.getValue(astRoot); - } - - protected String resultSetMapping(CompilationUnit astRoot) { - return this.resultSetMappingAdapter.getValue(astRoot); - } - - protected String fullyQualifiedResultClass(CompilationUnit astRoot) { - if (getResultClass() == null) { - return null; - } - return JDTTools.resolveFullyQualifiedName(this.resultClassAdapter.getExpression(astRoot)); - } - - @Override - protected NestableQueryHint createQueryHint(int index) { - return QueryHintImpl.createNamedNativeQueryQueryHint(this, this.getMember(), this.getDeclarationAnnotationAdapter(), index); - } - - // ********** static methods ********** - static NamedNativeQueryImpl createNamedNativeQuery(JavaResourceNode parent, Type type) { - return new NamedNativeQueryImpl(parent, type, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER)); - } - - static NamedNativeQueryImpl createNestedNamedNativeQuery(JavaResourceNode parent, Type type, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(type, idaa); - return new NamedNativeQueryImpl(parent, type, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter namedQueriesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(namedQueriesAdapter, index, JPA.NAMED_NATIVE_QUERY); - } - - public static class NamedNativeQueryAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final NamedNativeQueryAnnotationDefinition 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 NamedNativeQueryImpl.createNamedNativeQuery(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesImpl.java 23 Oct 2008 19:04:08 -0000 1.13 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestableAttributeOverride; -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; - -public class AttributeOverridesImpl extends AbstractResourceAnnotation implements AttributeOverridesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final List attributesOverrides; - - protected AttributeOverridesImpl(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.attributesOverrides = new ArrayList(); - } - - public void initialize(CompilationUnit astRoot) { - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public String getNestableAnnotationName() { - return AttributeOverrideAnnotation.ANNOTATION_NAME; - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(this.attributesOverrides); - } - - public int nestedAnnotationsSize() { - return this.attributesOverrides.size(); - } - - public NestableAttributeOverride addInternal(int index) { - NestableAttributeOverride attributeOverride = createAttributeOverride(index); - this.attributesOverrides.add(index, attributeOverride); - return attributeOverride; - } - - public NestableAttributeOverride add(int index) { - NestableAttributeOverride attributeOverride = createAttributeOverride(index); - add(index, attributeOverride); - return attributeOverride; - } - - private void add(int index, NestableAttributeOverride attributeOverride) { - addItemToList(index, attributeOverride, this.attributesOverrides, ATTRIBUTE_OVERRIDES_LIST); - } - - public void remove(NestableAttributeOverride attributeOverride) { - removeItemFromList(attributeOverride, this.attributesOverrides, ATTRIBUTE_OVERRIDES_LIST); - } - - public void remove(int index) { - removeItemFromList(index, this.attributesOverrides, ATTRIBUTE_OVERRIDES_LIST); - } - - public int indexOf(NestableAttributeOverride attributeOverride) { - return this.attributesOverrides.indexOf(attributeOverride); - } - - public NestableAttributeOverride nestedAnnotationAt(int index) { - return this.attributesOverrides.get(index); - } - - public NestableAttributeOverride nestedAnnotationFor(Annotation jdtAnnotation) { - for (NestableAttributeOverride attributeOverride : this.attributesOverrides) { - if (jdtAnnotation == attributeOverride.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return attributeOverride; - } - } - return null; - } - - public void move(int targetIndex, int sourceIndex) { - moveItemInList(targetIndex, sourceIndex, this.attributesOverrides, ATTRIBUTE_OVERRIDES_LIST); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.attributesOverrides, targetIndex, sourceIndex); - } - - public String getElementName() { - return JPA.ATTRIBUTE_OVERRIDES__VALUE; - } - - public void update(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this); - } - - private AttributeOverrideImpl createAttributeOverride(int index) { - return AttributeOverrideImpl.createNestedAttributeOverride(this, getMember(), index, getDeclarationAnnotationAdapter()); - } - - - public static class AttributeOverridesAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final AttributeOverridesAnnotationDefinition 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 AttributeOverridesImpl(parent, member); - } - - public AttributeOverridesAnnotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentAttributeImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentAttributeImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentAttributeImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/JavaResourcePersistentAttributeImpl.java 10 Mar 2009 04:12:10 -0000 1.19 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,407 +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.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.resource.java.AccessAnnotation; -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) - */ -public class JavaResourcePersistentAttributeImpl - extends AbstractJavaResourcePersistentMember - implements JavaResourcePersistentAttribute -{ - private int modifiers; - - private String typeName; - - private boolean typeIsInterface; - - private boolean typeIsEnum; - - private final Vector typeSuperclassNames = new Vector(); - - private final Vector typeInterfaceNames = new Vector(); - - private final Vector typeTypeArgumentNames = new Vector(); - - - /** - * construct field attribute - */ - public 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 JavaResourcePersistentAttributeImpl(parent, attribute); - jrpa.initialize(astRoot); - return jrpa; - } - - /** - * construct property attribute - */ - public 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 JavaResourcePersistentAttributeImpl(parent, attribute); - jrpa.initialize(astRoot); - return jrpa; - } - - public JavaResourcePersistentAttributeImpl(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 - protected Annotation buildMappingAnnotation(String mappingAnnotationName) { - return this.getAnnotationProvider().buildAttributeMappingAnnotation(this, this.getMember(), mappingAnnotationName); - } - - @Override - protected Annotation buildSupportingAnnotation(String annotationName) { - return this.getAnnotationProvider().buildAttributeSupportingAnnotation(this, this.getMember(), annotationName); - } - - @Override - protected Annotation buildNullSupportingAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullAttributeSupportingAnnotation(this, this.getMember(), annotationName); - } - - @Override - protected Annotation buildNullMappingAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullAttributeMappingAnnotation(this, this.getMember(), annotationName); - } - - @Override - protected ListIterator validMappingAnnotationNames() { - return this.getAnnotationProvider().attributeMappingAnnotationNames(); - } - - @Override - protected ListIterator validSupportingAnnotationNames() { - return this.getAnnotationProvider().attributeSupportingAnnotationNames(); - } - - public boolean isFor(MethodSignature signature, int occurrence) { - return ((MethodAttribute) this.getMember()).matches(signature, occurrence); - } - - - // ******** JavaResourcePersistentAttribute implementation ******** - - public String getName() { - return this.getMember().getAttributeName(); - } - - public boolean isField() { - return this.getMember().isField(); - } - - public boolean isProperty() { - return ! this.isField(); - } - - public boolean hasAnyPersistenceAnnotations() { - return (this.mappingAnnotationsSize() > 0) - || (this.supportingAnnotationsSize() > 0); - } - - public AccessType getSpecifiedAccess() { - AccessAnnotation accessAnnotation = (AccessAnnotation) this.getSupportingAnnotation(AccessAnnotation.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); - } - - protected ITypeBinding getTypeBinding(CompilationUnit astRoot) { - return this.getMember().getTypeBinding(astRoot); - } - - // ***** modifiers - public int getModifiers() { - return this.modifiers; - } - - protected void setModifiers(int modifiers) { - int old = this.modifiers; - this.modifiers = modifiers; - this.firePropertyChanged(MODIFIERS_PROPERTY, old, modifiers); - } - - /** - * zero seems like a reasonable default... - */ - protected int buildModifiers(CompilationUnit astRoot) { - IBinding binding = this.getMember().getBinding(astRoot); - return (binding == null) ? 0 : binding.getModifiers(); - } - - // ***** type name - public String getTypeName() { - return this.typeName; - } - - protected 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 - */ - protected 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; - } - - protected void setTypeIsInterface(boolean typeIsInterface) { - boolean old = this.typeIsInterface; - this.typeIsInterface = typeIsInterface; - this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, typeIsInterface); - } - - protected 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; - } - - protected void setTypeIsEnum(boolean typeIsEnum) { - boolean old = this.typeIsEnum; - this.typeIsEnum = typeIsEnum; - this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, typeIsEnum); - } - - protected boolean buildTypeIsEnum(CompilationUnit astRoot) { - ITypeBinding typeBinding = this.getTypeBinding(astRoot); - return (typeBinding != null) && ( ! typeBinding.isArray()) && typeBinding.isEnum(); - } - - // ***** type superclass hierarchy - public ListIterator typeSuperclassNames() { - return new CloneListIterator(this.typeSuperclassNames); - } - - protected void setTypeSuperclassNames(List typeSuperclassNames) { - synchronized (this.typeSuperclassNames) { - this.synchronizeList(typeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_COLLECTION); - } - } - - protected List buildTypeSuperclassNames(CompilationUnit astRoot) { - ITypeBinding typeBinding = this.getTypeBinding(astRoot); - if (typeBinding == null) { - return Collections.emptyList(); - } - ArrayList names = new ArrayList(); - typeBinding = typeBinding.getSuperclass(); - while (typeBinding != null) { - names.add(typeBinding.getQualifiedName()); - typeBinding = typeBinding.getSuperclass(); - } - return names; - } - - // ***** type interface hierarchy - public Iterator typeInterfaceNames() { - return new CloneIterator(this.typeInterfaceNames); - } - - protected boolean typeInterfaceNamesContains(String interfaceName) { - return this.typeInterfaceNames.contains(interfaceName); - } - - protected void setTypeInterfaceNames(Collection typeInterfaceNames) { - synchronized (this.typeInterfaceNames) { - this.synchronizeCollection(typeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION); - } - } - - protected Collection buildTypeInterfaceNames(CompilationUnit astRoot) { - ITypeBinding typeBinding = this.getTypeBinding(astRoot); - if (typeBinding == null) { - return Collections.emptySet(); - } - HashSet names = new HashSet(); - while (typeBinding != null) { - this.addInterfaceNamesTo(typeBinding, names); - typeBinding = typeBinding.getSuperclass(); - } - return names; - } - - protected void addInterfaceNamesTo(ITypeBinding typeBinding, HashSet names) { - for (ITypeBinding interfaceBinding : typeBinding.getInterfaces()) { - names.add(interfaceBinding.getQualifiedName()); - this.addInterfaceNamesTo(interfaceBinding, names); // recurse - } - } - - // ***** type type argument names - public ListIterator typeTypeArgumentNames() { - return new CloneListIterator(this.typeTypeArgumentNames); - } - - public int typeTypeArgumentNamesSize() { - return this.typeTypeArgumentNames.size(); - } - - public String getTypeTypeArgumentName(int index) { - return this.typeTypeArgumentNames.get(index); - } - - protected void setTypeTypeArgumentNames(List typeTypeArgumentNames) { - synchronized (this.typeTypeArgumentNames) { - this.synchronizeList(typeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_COLLECTION); - } - } - - /** - * 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") - */ - protected List 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 names = new ArrayList(typeArguments.length); - for (ITypeBinding typeArgument : typeArguments) { - if (typeArgument == null) { - names.add(null); - } else { - names.add(typeArgument.getTypeDeclaration().getQualifiedName()); - } - } - return names; - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/OrderByImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/OrderByImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/OrderByImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/OrderByImpl.java 23 Oct 2008 19:04:08 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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; -import org.eclipse.jpt.core.utility.jdt.Member; - -public class OrderByImpl extends AbstractResourceAnnotation implements OrderByAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - - private final AnnotationElementAdapter valueAdapter; - - private String value; - - protected OrderByImpl(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(attribute, VALUE_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public String getValue() { - return this.value; - } - - public void setValue(String newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - String oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(newValue); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected String value(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ORDER_BY__VALUE, false); - } - - - public static class OrderByAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final OrderByAnnotationDefinition 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 OrderByImpl(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullBaseTable.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullBaseTable.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullBaseTable.java --- src/org/eclipse/jpt/core/internal/resource/java/NullBaseTable.java 20 Oct 2008 20:52:50 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.TableAnnotation; -import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - -public abstract class NullBaseTable extends AbstractJavaResourceNode implements Annotation -{ - protected NullBaseTable(JavaResourcePersistentMember parent) { - super(parent); - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - protected TableAnnotation createTableResource() { - return (TableAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); - } - - public String getName() { - return null; - } - - public void setName(String name) { - if (name != null) { - createTableResource().setName(name); - } - } - - public String getCatalog() { - return null; - } - - public void setCatalog(String catalog) { - if (catalog != null) { - createTableResource().setCatalog(catalog); - } - } - - public String getSchema() { - return null; - } - - public void setSchema(String schema) { - if (schema != null) { - createTableResource().setSchema(schema); - } - } - - public UniqueConstraintAnnotation addUniqueConstraint(int index) { - return createTableResource().addUniqueConstraint(index); - } - - public void removeUniqueConstraint(@SuppressWarnings("unused") int index) { - throw new UnsupportedOperationException(); - } - - public int indexOfUniqueConstraint(@SuppressWarnings("unused") UniqueConstraintAnnotation uniqueConstraint) { - throw new UnsupportedOperationException(); - } - - public void moveUniqueConstraint(@SuppressWarnings("unused") int targetIndex, @SuppressWarnings("unused") int sourceIndex) { - throw new UnsupportedOperationException(); - } - public UniqueConstraintAnnotation uniqueConstraintAt(@SuppressWarnings("unused") int index) { - throw new UnsupportedOperationException(); - } - - public ListIterator uniqueConstraints() { - return EmptyListIterator.instance(); - } - - public int uniqueConstraintsSize() { - return 0; - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getNameTextRange(@SuppressWarnings("unused") CompilationUnit astRoot) { - return null; - } - - public TextRange getCatalogTextRange(@SuppressWarnings("unused") CompilationUnit astRoot) { - return null; - } - - public TextRange getSchemaTextRange(@SuppressWarnings("unused") CompilationUnit astRoot) { - return null; - } - - public boolean nameTouches(@SuppressWarnings("unused") int pos, @SuppressWarnings("unused") CompilationUnit astRoot) { - return false; - } - - public boolean catalogTouches(@SuppressWarnings("unused") int pos, @SuppressWarnings("unused") CompilationUnit astRoot) { - return false; - } - - public boolean schemaTouches(@SuppressWarnings("unused") int pos, @SuppressWarnings("unused") CompilationUnit astRoot) { - return false; - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getName()); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/OneToManyImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/OneToManyImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/OneToManyImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/OneToManyImpl.java 23 Oct 2008 19:04:07 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -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.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.Member; - -public class OneToManyImpl extends AbstractRelationshipMappingAnnotation implements OneToManyAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter MAPPED_BY_ADAPTER = buildMappedByAdapter(); - - private final AnnotationElementAdapter mappedByAdapter; - - private String mappedBy; - - protected OneToManyImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.mappedByAdapter = buildAnnotationElementAdapter(MAPPED_BY_ADAPTER); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.mappedBy = this.mappedBy(astRoot); - } - - //**************** AbstractRelationshipMappingAnnotation implementation ************** - - @Override - protected DeclarationAnnotationElementAdapter getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getFetchAdapter() { - return FETCH_ADAPTER; - } - - //**************** Annotation implementation ************** - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String newMappedBy) { - if (attributeValueHasNotChanged(this.mappedBy, newMappedBy)) { - return; - } - String oldMappedBy = this.mappedBy; - this.mappedBy = newMappedBy; - this.mappedByAdapter.setValue(newMappedBy); - firePropertyChanged(MAPPED_BY_PROPERTY, oldMappedBy, newMappedBy); - } - - 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); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setMappedBy(this.mappedBy(astRoot)); - } - - protected String mappedBy(CompilationUnit astRoot) { - return this.mappedByAdapter.getValue(astRoot); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__CASCADE); - } - - private static DeclarationAnnotationElementAdapter buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__FETCH); - } - - private static DeclarationAnnotationElementAdapter buildMappedByAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__MAPPED_BY, false); // false = do not remove annotation when empty - } - - public static class OneToManyAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final OneToManyAnnotationDefinition INSTANCE = new OneToManyAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static OneToManyAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private OneToManyAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new OneToManyImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullOneToMany(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/InheritanceImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/InheritanceImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/InheritanceImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/InheritanceImpl.java 23 Oct 2008 19:04:08 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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; -import org.eclipse.jpt.core.utility.jdt.Type; - -public class InheritanceImpl extends AbstractResourceAnnotation implements InheritanceAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - private static final DeclarationAnnotationElementAdapter STRATEGY_ADAPTER = buildStrategyAdapter(); - - private final AnnotationElementAdapter strategyAdapter; - - private InheritanceType strategy; - - protected InheritanceImpl(JavaResourceNode parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.strategyAdapter = new ShortCircuitAnnotationElementAdapter(type, STRATEGY_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.strategy = this.strategy(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public InheritanceType getStrategy() { - return this.strategy; - } - - public void setStrategy(InheritanceType newStrategy) { - if (attributeValueHasNotChanged(this.strategy, newStrategy)) { - return; - } - InheritanceType oldStrategy = this.strategy; - this.strategy = newStrategy; - this.strategyAdapter.setValue(InheritanceType.toJavaAnnotationValue(newStrategy)); - firePropertyChanged(STRATEGY_PROPERTY, oldStrategy, newStrategy); - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(STRATEGY_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setStrategy(this.strategy(astRoot)); - } - - protected InheritanceType strategy(CompilationUnit astRoot) { - return InheritanceType.fromJavaAnnotationValue(this.strategyAdapter.getValue(astRoot)); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildStrategyAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.INHERITANCE__STRATEGY); - } - - public static class InheritanceAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final InheritanceAnnotationDefinition 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 InheritanceImpl(parent, (Type) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullInheritance(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/TemporalImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/TemporalImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/TemporalImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/TemporalImpl.java 23 Oct 2008 19:04:08 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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; -import org.eclipse.jpt.core.utility.jdt.Member; - -public class TemporalImpl extends AbstractResourceAnnotation implements TemporalAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); - - private final AnnotationElementAdapter valueAdapter; - - private TemporalType value; - - protected TemporalImpl(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(attribute, VALUE_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.value(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public TemporalType getValue() { - return this.value; - } - - public void setValue(TemporalType newValue) { - if (attributeValueHasNotChanged(this.value, newValue)) { - return; - } - TemporalType oldValue = this.value; - this.value = newValue; - this.valueAdapter.setValue(TemporalType.toJavaAnnotationValue(newValue)); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setValue(this.value(astRoot)); - } - - protected TemporalType value(CompilationUnit astRoot) { - return TemporalType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildValueAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.TEMPORAL__VALUE); - } - - public static class TemporalAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final TemporalAnnotationDefinition 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 TemporalImpl(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullTemporal(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullEnumerated.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullEnumerated.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullEnumerated.java --- src/org/eclipse/jpt/core/internal/resource/java/NullEnumerated.java 20 Oct 2008 20:52:50 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.EnumType; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullEnumerated extends AbstractJavaResourceNode implements EnumeratedAnnotation, Annotation -{ - protected NullEnumerated(JavaResourcePersistentMember parent) { - super(parent); - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return EnumeratedAnnotation.ANNOTATION_NAME; - } - - protected EnumeratedAnnotation createEnumeratedResource() { - return (EnumeratedAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); - } - - - public EnumType getValue() { - return null; - } - - public void setValue(EnumType value) { - if (value != null) { - createEnumeratedResource().setValue(value); - } - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorImpl.java 23 Oct 2008 19:04:08 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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; - -public class SequenceGeneratorImpl - extends GeneratorImpl - implements SequenceGeneratorAnnotation -{ - private final AnnotationElementAdapter sequenceNameAdapter; - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__NAME); - - private static final DeclarationAnnotationElementAdapter INITIAL_VALUE_ADAPTER = buildIntegerAdapter(JPA.SEQUENCE_GENERATOR__INITIAL_VALUE); - - private static final DeclarationAnnotationElementAdapter ALLOCATION_SIZE_ADAPTER = buildIntegerAdapter(JPA.SEQUENCE_GENERATOR__ALLOCATION_SIZE); - - private static final DeclarationAnnotationElementAdapter SEQUENCE_NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__SEQUENCE_NAME); - - private String sequenceName; - - protected SequenceGeneratorImpl(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.sequenceNameAdapter = this.buildAdapter(SEQUENCE_NAME_ADAPTER); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.sequenceName = this.sequenceName(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //************ GeneratorImpl implementation ************** - - @Override - protected DeclarationAnnotationElementAdapter getAllocationSizeAdapter() { - return ALLOCATION_SIZE_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getInitialValueAdapter() { - return INITIAL_VALUE_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getNameAdapter() { - return NAME_ADAPTER; - } - - - public String getSequenceName() { - return this.sequenceName; - } - - public void setSequenceName(String newSequenceName) { - if (attributeValueHasNotChanged(this.sequenceName, newSequenceName)) { - return; - } - String oldSequenceName = this.sequenceName; - this.sequenceName = newSequenceName; - this.sequenceNameAdapter.setValue(newSequenceName); - firePropertyChanged(SEQUENCE_NAME_PROPERTY, oldSequenceName, newSequenceName); - } - - 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); - } - - // ********** java annotations -> persistence model ********** - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setSequenceName(this.sequenceName(astRoot)); - } - - protected String sequenceName(CompilationUnit astRoot) { - return this.sequenceNameAdapter.getValue(astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildAdapter(String elementName) { - return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - private static DeclarationAnnotationElementAdapter buildIntegerAdapter(String elementName) { - return buildIntegerAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - - // ********** annotation definition ********** - - public static class SequenceGeneratorAnnotationDefinition - implements AnnotationDefinition - { - // singleton - private static final SequenceGeneratorAnnotationDefinition INSTANCE = new SequenceGeneratorAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private SequenceGeneratorAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new SequenceGeneratorImpl(parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/AbstractRelationshipMappingAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AbstractRelationshipMappingAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AbstractRelationshipMappingAnnotation.java --- src/org/eclipse/jpt/core/internal/resource/java/AbstractRelationshipMappingAnnotation.java 10 Feb 2009 22:55:39 -0000 1.16 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,313 +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.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.CollectionTools; - -/** - * - */ -public abstract class AbstractRelationshipMappingAnnotation - extends AbstractResourceAnnotation - implements RelationshipMappingAnnotation -{ - // hold this so we can get the 'targetEntity' text range - private final DeclarationAnnotationElementAdapter targetEntityDeclarationAdapter; - - // hold this so we can get the 'fetch' text range - private final DeclarationAnnotationElementAdapter fetchDeclarationAdapter; - - // hold this so we can get the 'cascade' text range - private final DeclarationAnnotationElementAdapter cascadeDeclarationAdapter; - - private final AnnotationElementAdapter targetEntityAdapter; - - private final AnnotationElementAdapter fetchAdapter; - - private final AnnotationElementAdapter cascadeAdapter; - - private String targetEntity; - - private String fullyQualifiedTargetEntity; - - private FetchType fetch; - - protected boolean cascadeAll; - - protected boolean cascadePersist; - - protected boolean cascadeMerge; - - protected boolean cascadeRemove; - - protected boolean cascadeRefresh; - - - public AbstractRelationshipMappingAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute, DeclarationAnnotationAdapter daa) { - super(parent, attribute, daa); - this.targetEntityDeclarationAdapter = getTargetEntityAdapter(); - this.targetEntityAdapter = buildAnnotationElementAdapter(this.targetEntityDeclarationAdapter); - this.fetchDeclarationAdapter = getFetchAdapter(); - this.fetchAdapter = buildAnnotationElementAdapter(this.fetchDeclarationAdapter); - this.cascadeDeclarationAdapter = getCascadeAdapter(); - this.cascadeAdapter = new ShortCircuitArrayAnnotationElementAdapter(attribute, this.cascadeDeclarationAdapter); - } - - protected AnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(this.getMember(), daea); - } - - protected AnnotationElementAdapter buildBooleanAnnotationElementAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(this.getMember(), daea); - } - - /** - * return the Java adapter's 'targetEntity' element adapter config - */ - protected abstract DeclarationAnnotationElementAdapter getTargetEntityAdapter(); - - /** - * return the Java adapter's 'cascade' element adapter config - */ - protected abstract DeclarationAnnotationElementAdapter getCascadeAdapter(); - - /** - * return the Java adapter's 'fetch' element adapter config - */ - protected abstract DeclarationAnnotationElementAdapter getFetchAdapter(); - - public void initialize(CompilationUnit astRoot) { - this.targetEntity = this.targetEntity(astRoot); - this.fullyQualifiedTargetEntity = this.fullyQualifiedTargetEntity(astRoot); - this.fetch = this.fetch(astRoot); - this.initializeCascadeTypes(astRoot); - } - - protected void initializeCascadeTypes(CompilationUnit astRoot) { - String[] javaValue = this.cascadeAdapter.getValue(astRoot); - CascadeType[] cascadeTypes = CascadeType.fromJavaAnnotationValue(javaValue); - - this.cascadeAll = CollectionTools.contains(cascadeTypes, CascadeType.ALL); - this.cascadeMerge = CollectionTools.contains(cascadeTypes, CascadeType.MERGE); - this.cascadePersist = CollectionTools.contains(cascadeTypes, CascadeType.PERSIST); - this.cascadeRefresh = CollectionTools.contains(cascadeTypes, CascadeType.REFRESH); - this.cascadeRemove = CollectionTools.contains(cascadeTypes, CascadeType.REMOVE); - } - - public String getTargetEntity() { - return this.targetEntity; - } - - public void setTargetEntity(String newTargetEntity) { - if (attributeValueHasNotChanged(this.targetEntity, newTargetEntity)) { - return; - } - String oldTargetEntity = this.targetEntity; - this.targetEntity = newTargetEntity; - this.targetEntityAdapter.setValue(newTargetEntity); - firePropertyChanged(TARGET_ENTITY_PROPERTY, oldTargetEntity, newTargetEntity); - } - - public String getFullyQualifiedTargetEntity() { - return this.fullyQualifiedTargetEntity; - } - - protected void setFullyQualifiedTargetEntity(String newTargetEntity) { - String oldTargetEntity = this.fullyQualifiedTargetEntity; - this.fullyQualifiedTargetEntity = newTargetEntity; - firePropertyChanged(FULLY_QUALFIEID_TARGET_ENTITY_PROPERTY, oldTargetEntity, newTargetEntity); - } - - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType newFetch) { - if (attributeValueHasNotChanged(this.fetch, newFetch)) { - return; - } - FetchType oldFetch = this.fetch; - this.fetch = newFetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(newFetch)); - firePropertyChanged(FETCH_PROPERTY, oldFetch, newFetch); - } - - 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); - } - - 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); - } - - 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); - } - - 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); - } - - 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); - } - - private void setCascadeTypes(CascadeType[] cascadeTypes) { - this.cascadeAdapter.setValue(CascadeType.toJavaAnnotationValue(cascadeTypes)); - } - - private void setCascade(CascadeType cascadeType, boolean set) { - String[] javaValues = this.cascadeAdapter.getValue(); - CascadeType[] cascadeTypes = CascadeType.fromJavaAnnotationValue(javaValues); - - boolean present = CollectionTools.contains(cascadeTypes, cascadeType); - if (set) { - if ( ! present) { - this.setCascadeTypes(CollectionTools.add(cascadeTypes, cascadeType)); - } - } else { - if (present) { - this.setCascadeTypes(CollectionTools.remove(cascadeTypes, cascadeType)); - } - } - } - - public TextRange getTargetEntityTextRange(CompilationUnit astRoot) { - return getElementTextRange(this.targetEntityDeclarationAdapter, astRoot); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return getElementTextRange(this.fetchDeclarationAdapter, astRoot); - } - - public TextRange getCascadeTextRange(CompilationUnit astRoot) { - return getElementTextRange(this.cascadeDeclarationAdapter, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setFetch(this.fetch(astRoot)); - this.setTargetEntity(this.targetEntity(astRoot)); - this.setFullyQualifiedTargetEntity(this.fullyQualifiedTargetEntity(astRoot)); - this.updateCascadeFromJava(astRoot); - } - - protected FetchType fetch(CompilationUnit astRoot) { - return FetchType.fromJavaAnnotationValue(this.fetchAdapter.getValue(astRoot)); - } - - protected String targetEntity(CompilationUnit astRoot) { - return this.targetEntityAdapter.getValue(astRoot); - } - - private void updateCascadeFromJava(CompilationUnit astRoot) { - String[] javaValue = this.cascadeAdapter.getValue(astRoot); - CascadeType[] cascadeTypes = CascadeType.fromJavaAnnotationValue(javaValue); - setCascadeAll(CollectionTools.contains(cascadeTypes, CascadeType.ALL)); - setCascadeMerge(CollectionTools.contains(cascadeTypes, CascadeType.MERGE)); - setCascadePersist(CollectionTools.contains(cascadeTypes, CascadeType.PERSIST)); - setCascadeRefresh(CollectionTools.contains(cascadeTypes, CascadeType.REFRESH)); - setCascadeRemove(CollectionTools.contains(cascadeTypes, CascadeType.REMOVE)); - } - - private String fullyQualifiedTargetEntity(CompilationUnit astRoot) { - if (getTargetEntity() == null) { - return null; - } - return JDTTools.resolveFullyQualifiedName(this.targetEntityAdapter.getExpression(astRoot)); - } - - // ********** static methods ********** - - protected static DeclarationAnnotationElementAdapter buildTargetEntityAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - // TODO what about QualifiedType? - return buildAnnotationElementAdapter(annotationAdapter, elementName, SimpleTypeStringExpressionConverter.instance()); - } - - protected static DeclarationAnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); - } - - protected static DeclarationAnnotationElementAdapter buildFetchAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new EnumDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false); - } - - protected static DeclarationAnnotationElementAdapter buildEnumArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new EnumArrayDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/OverrideImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/OverrideImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/OverrideImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/OverrideImpl.java 17 Oct 2008 19:09:12 -0000 1.14 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.JPA; -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; - -public abstract class OverrideImpl - extends AbstractResourceAnnotation - implements OverrideAnnotation -{ - // hold this so we can get the 'name' text range - private final DeclarationAnnotationElementAdapter nameDeclarationAdapter; - - private final AnnotationElementAdapter nameAdapter; - - private String name; - - - protected OverrideImpl(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.nameDeclarationAdapter = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.ATTRIBUTE_OVERRIDE__NAME, false); // false = do not remove annotation when empty - this.nameAdapter = new ShortCircuitAnnotationElementAdapter(getMember(),this.nameDeclarationAdapter); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - } - - public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) super.getAnnotationAdapter(); - } - - public void moveAnnotation(int newIndex) { - getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - public void initializeFrom(NestableAnnotation oldAnnotation) { - OverrideAnnotation oldOverride = (OverrideAnnotation) oldAnnotation; - setName(oldOverride.getName()); - } - - //************ AttriubteOverride implementation **************** - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(OverrideAnnotation.NAME_PROPERTY, oldName, newName); - } - - 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); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumn.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumn.java --- src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumn.java 20 Oct 2008 20:52:50 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation; -import org.eclipse.jpt.core.resource.java.DiscriminatorType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; - - - -public class NullDiscriminatorColumn extends NullNamedColumn implements DiscriminatorColumnAnnotation, Annotation -{ - public NullDiscriminatorColumn(JavaResourcePersistentMember parent) { - super(parent); - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - public String getAnnotationName() { - return DiscriminatorColumnAnnotation.ANNOTATION_NAME; - } - - @Override - protected DiscriminatorColumnAnnotation createResourceColumn() { - return (DiscriminatorColumnAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); - } - - public DiscriminatorType getDiscriminatorType() { - return null; - } - - public void setDiscriminatorType(DiscriminatorType discriminatorType) { - if (discriminatorType != null) { - createResourceColumn().setDiscriminatorType(discriminatorType); - } - } - - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - if (length != null) { - createResourceColumn().setLength(length); - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/ManyToManyImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/ManyToManyImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/ManyToManyImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/ManyToManyImpl.java 23 Oct 2008 19:04:08 -0000 1.16 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -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.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.Member; - - -public class ManyToManyImpl extends AbstractRelationshipMappingAnnotation implements ManyToManyAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter MAPPED_BY_ADAPTER = buildMappedByAdapter(); - - private final AnnotationElementAdapter mappedByAdapter; - - private String mappedBy; - - protected ManyToManyImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.mappedByAdapter = buildAnnotationElementAdapter(MAPPED_BY_ADAPTER); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.mappedBy = this.mappedBy(astRoot); - } - - //**************** AbstractRelationshipMappingAnnotation implementation ************** - - @Override - protected DeclarationAnnotationElementAdapter getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getFetchAdapter() { - return FETCH_ADAPTER; - } - - - //**************** Annotation implementation ************** - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String newMappedBy) { - if (attributeValueHasNotChanged(this.mappedBy, newMappedBy)) { - return; - } - String oldMappedBy = this.mappedBy; - this.mappedBy = newMappedBy; - this.mappedByAdapter.setValue(newMappedBy); - firePropertyChanged(MAPPED_BY_PROPERTY, oldMappedBy, newMappedBy); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setMappedBy(this.mappedBy(astRoot)); - } - - protected String mappedBy(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 buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__CASCADE); - } - - private static DeclarationAnnotationElementAdapter buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__FETCH); - } - - - private static DeclarationAnnotationElementAdapter buildMappedByAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__MAPPED_BY, false); // false = do not remove annotation when empty - } - - - public static class ManyToManyAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final ManyToManyAnnotationDefinition INSTANCE = new ManyToManyAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static ManyToManyAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ManyToManyAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new ManyToManyImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdImpl.java 23 Oct 2008 19:04:08 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -public class EmbeddedIdImpl extends AbstractResourceAnnotation implements EmbeddedIdAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected EmbeddedIdImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void update(CompilationUnit astRoot) { - //no annotation members - } - - - public static class EmbeddedIdAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final EmbeddedIdAnnotationDefinition INSTANCE = new EmbeddedIdAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static EmbeddedIdAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private EmbeddedIdAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new EmbeddedIdImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/ColumnImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/ColumnImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/ColumnImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/ColumnImpl.java 23 Oct 2008 19:04:08 -0000 1.18 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,242 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -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; - -public class ColumnImpl extends BaseColumnImpl implements ColumnAnnotation, NestableAnnotation -{ - // 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); - - // hold this so we can get the 'length' text range - private final DeclarationAnnotationElementAdapter lengthDeclarationAdapter; - - // hold this so we can get the 'precision' text range - private final DeclarationAnnotationElementAdapter precisionDeclarationAdapter; - - // hold this so we can get the 'scale' text range - private final DeclarationAnnotationElementAdapter scaleDeclarationAdapter; - - private final AnnotationElementAdapter lengthAdapter; - - private final AnnotationElementAdapter precisionAdapter; - - private final AnnotationElementAdapter scaleAdapter; - - private Integer length; - - private Integer precision; - - private Integer scale; - - public ColumnImpl(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); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.length = this.length(astRoot); - this.precision = this.precision(astRoot); - this.scale = this.scale(astRoot); - } - - @Override - protected String getNameElementName() { - return JPA.COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.COLUMN__COLUMN_DEFINITION; - } - - @Override - protected String getTableElementName() { - return JPA.COLUMN__TABLE; - } - - @Override - protected String getUniqueElementName() { - return JPA.COLUMN__UNIQUE; - } - - @Override - protected String getNullableElementName() { - return JPA.COLUMN__NULLABLE; - } - - @Override - protected String getInsertableElementName() { - return JPA.COLUMN__INSERTABLE; - } - - @Override - protected String getUpdatableElementName() { - return JPA.COLUMN__UPDATABLE; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void moveAnnotation(int newIndex) { - //TODO move makes no sense for Column. maybe NestableAnnotation - //needs to be split up and we could have IndexableAnnotation - } - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - ColumnAnnotation oldColumn = (ColumnAnnotation) oldAnnotation; - setLength(oldColumn.getLength()); - setPrecision(oldColumn.getPrecision()); - setScale(oldColumn.getScale()); - } - - //************** Column implementation ************** - public Integer getLength() { - return this.length; - } - - public void setLength(Integer newLength) { - if (attributeValueHasNotChanged(this.length, newLength)) { - return; - } - Integer oldLength = this.length; - this.length = newLength; - this.lengthAdapter.setValue(newLength); - firePropertyChanged(LENGTH_PROPERTY, oldLength, newLength); - } - - public Integer getPrecision() { - return this.precision; - } - - public void setPrecision(Integer newPrecision) { - if (attributeValueHasNotChanged(this.precision, newPrecision)) { - return; - } - Integer oldPrecision = this.precision; - this.precision = newPrecision; - this.precisionAdapter.setValue(newPrecision); - firePropertyChanged(PRECISION_PROPERTY, oldPrecision, newPrecision); - } - - public Integer getScale() { - return this.scale; - } - - public void setScale(Integer newScale) { - if (attributeValueHasNotChanged(this.scale, newScale)) { - return; - } - Integer oldScale = this.scale; - this.scale = newScale; - this.scaleAdapter.setValue(newScale); - firePropertyChanged(SCALE_PROPERTY, oldScale, newScale); - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.lengthDeclarationAdapter, astRoot); - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.precisionDeclarationAdapter, astRoot); - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.scaleDeclarationAdapter, astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setLength(this.length(astRoot)); - this.setPrecision(this.precision(astRoot)); - this.setScale(this.scale(astRoot)); - } - - protected Integer length(CompilationUnit astRoot) { - return this.lengthAdapter.getValue(astRoot); - } - - protected Integer precision(CompilationUnit astRoot) { - return this.precisionAdapter.getValue(astRoot); - } - - protected Integer scale(CompilationUnit astRoot) { - return this.scaleAdapter.getValue(astRoot); - } - - // ********** static methods ********** - - static ColumnImpl createAttributeOverrideColumn(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter attributeOverrideAnnotationAdapter) { - return new ColumnImpl(parent, member, buildAttributeOverrideAnnotationAdapter(attributeOverrideAnnotationAdapter)); - } - - static DeclarationAnnotationAdapter buildAttributeOverrideAnnotationAdapter(DeclarationAnnotationAdapter attributeOverrideAnnotationAdapter) { - return new NestedDeclarationAnnotationAdapter(attributeOverrideAnnotationAdapter, JPA.ATTRIBUTE_OVERRIDE__COLUMN, JPA.COLUMN); - } - - public static class ColumnAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final ColumnAnnotationDefinition 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 ColumnImpl(parent, member, ColumnImpl.MAPPING_DECLARATION_ANNOTATION_ADAPTER); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullColumn(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/LobImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/LobImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/LobImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/LobImpl.java 23 Oct 2008 19:04:08 -0000 1.12 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -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.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -public class LobImpl extends AbstractResourceAnnotation implements LobAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected LobImpl(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public void update(CompilationUnit astRoot) { - //nothing to update - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - public static class LobAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final LobAnnotationDefinition 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 LobImpl(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/UniqueConstraintImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/UniqueConstraintImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/UniqueConstraintImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/UniqueConstraintImpl.java 12 Sep 2008 05:20:07 -0000 1.13 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,188 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -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.NestedIndexedDeclarationAnnotationAdapter; -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.NestableUniqueConstraint; -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; - -public class UniqueConstraintImpl extends AbstractResourceAnnotation implements NestableUniqueConstraint -{ - - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.UNIQUE_CONSTRAINT); - - private final DeclarationAnnotationElementAdapter columnNamesDeclarationAdapter; - - private final AnnotationElementAdapter columnNamesAdapter; - - private final List columnNames; - - - public UniqueConstraintImpl(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); - this.columnNames = new ArrayList(); - } - - public void initialize(CompilationUnit astRoot) { - String[] javaColumnNames = this.columnNamesAdapter.getValue(astRoot); - for (int i = 0; i < javaColumnNames.length; i++) { - this.columnNames.add(javaColumnNames[i]); - } - } - - protected AnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitArrayAnnotationElementAdapter(getMember(), daea); - } - - protected static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, AnnotationStringArrayExpressionConverter.forStrings()); - } - - protected static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public IndexedAnnotationAdapter getAnnotationAdapter() { - return (IndexedAnnotationAdapter) super.getAnnotationAdapter(); - } - - public void initializeFrom(NestableAnnotation oldAnnotation) { - UniqueConstraintAnnotation oldUniqueConstraint = (UniqueConstraintAnnotation) oldAnnotation; - for (String columnName : CollectionTools.iterable(oldUniqueConstraint.columnNames())) { - addColumnName(columnName); - } - } - - public ListIterator columnNames() { - return new CloneListIterator(this.columnNames); - } - - public int columnNamesSize() { - return this.columnNames.size(); - } - - public void addColumnName(String columnName) { - addColumnName(columnNamesSize(), columnName); - } - - public void addColumnName(int index, String columnName) { - addColumnName_(index, columnName); - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); - } - - protected void addColumnName_(String columnName) { - this.addColumnName_(this.columnNames.size(), columnName); - } - - protected void addColumnName_(int index, String columnName) { - addItemToList(index, columnName, this.columnNames, COLUMN_NAMES_LIST); - } - - public void removeColumnName(String columnName) { - removeItemFromList(columnName, this.columnNames, COLUMN_NAMES_LIST); - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); - } - - public void removeColumnName(int index) { - removeItemFromList(index, this.columnNames, COLUMN_NAMES_LIST); - this.columnNamesAdapter.setValue(this.columnNames.toArray(new String[this.columnNames.size()])); - } - - public void moveColumnName(int targetIndex, int sourceIndex) { - 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 update(CompilationUnit astRoot) { - this.updateColumnNamesFromJava(astRoot); - } - - protected void updateColumnNamesFromJava(CompilationUnit astRoot) { - String[] javaColumnNames = this.columnNamesAdapter.getValue(astRoot); - //TODO hmm, seems we need change notification for this - CollectionTools.retainAll(this.columnNames, javaColumnNames); - for (int i = 0; i < javaColumnNames.length; i++) { - String columnName = javaColumnNames[i]; - if (!this.columnNames.contains(columnName)) { - addColumnName_(columnName); - } - } - } - - // ********** persistence model -> java annotations ********** - public void moveAnnotation(int newIndex) { - getAnnotationAdapter().moveAnnotation(newIndex); - } - - // ********** static methods ********** - static NestableUniqueConstraint createSecondaryTableUniqueConstraint(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter declarationAnnotationAdapter, int index) { - return new UniqueConstraintImpl(parent, member, buildSecondaryTableUniqueConstraintAnnotationAdapter(declarationAnnotationAdapter, index)); - } - - private static IndexedDeclarationAnnotationAdapter buildSecondaryTableUniqueConstraintAnnotationAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter, int index) { - return new NestedIndexedDeclarationAnnotationAdapter(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); - } - - static NestableUniqueConstraint createJoinTableUniqueConstraint(JavaResourceNode parent, Member member, int index) { - return new UniqueConstraintImpl(parent, member, buildJoinTableUniqueConstraintAnnotationAdapter(index)); - } - - private static IndexedDeclarationAnnotationAdapter buildJoinTableUniqueConstraintAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(JoinTableImpl.DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); - } - - static NestableUniqueConstraint createTableUniqueConstraint(JavaResourceNode parent, Member member, int index) { - return new UniqueConstraintImpl(parent, member, buildTableUniqueConstraintAnnotationAdapter(index)); - } - - private static IndexedDeclarationAnnotationAdapter buildTableUniqueConstraintAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(TableImpl.DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); - } - - static NestableUniqueConstraint createTableGeneratorUniqueConstraint(JavaResourceNode parent, Member member, int index) { - return new UniqueConstraintImpl(parent, member, buildTableGeneratorUniqueConstraintAnnotationAdapter(index)); - } - - private static IndexedDeclarationAnnotationAdapter buildTableGeneratorUniqueConstraintAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(TableGeneratorImpl.DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnImpl.java 23 Oct 2008 19:04:07 -0000 1.14 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter; -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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; - -public class DiscriminatorColumnImpl extends AbstractNamedColumn implements DiscriminatorColumnAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter DISCRIMINATOR_TYPE_ADAPTER = buildDiscriminatorTypeAdapter(); - - // hold this so we can get the 'length' text range - private final DeclarationAnnotationElementAdapter lengthDeclarationAdapter; - - private final AnnotationElementAdapter discriminatorTypeAdapter; - - private final AnnotationElementAdapter lengthAdapter; - - private DiscriminatorType discriminatorType; - - private Integer length; - - protected DiscriminatorColumnImpl(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa) { - super(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - this.discriminatorTypeAdapter = new ShortCircuitAnnotationElementAdapter(member, DISCRIMINATOR_TYPE_ADAPTER); - this.lengthDeclarationAdapter = this.buildIntegerElementAdapter(JPA.DISCRIMINATOR_COLUMN__LENGTH); - this.lengthAdapter = this.buildShortCircuitIntegerElementAdapter(this.lengthDeclarationAdapter); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.discriminatorType = this.discriminatorType(astRoot); - this.length = this.length(astRoot); - } - - @Override - protected String getNameElementName() { - return JPA.DISCRIMINATOR_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA.DISCRIMINATOR_COLUMN__COLUMN_DEFINITION; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void moveAnnotation(int newIndex) { - //TODO move makes no sense for DiscriminatorColumn. maybe NestableAnnotation - //needs to be split up and we could have IndexableAnnotation - } - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - DiscriminatorColumnAnnotation oldColumn = (DiscriminatorColumnAnnotation) oldAnnotation; - setLength(oldColumn.getLength()); - setDiscriminatorType(oldColumn.getDiscriminatorType()); - } - - public DiscriminatorType getDiscriminatorType() { - return this.discriminatorType; - } - - public void setDiscriminatorType(DiscriminatorType newDiscriminatorType) { - if (attributeValueHasNotChanged(this.discriminatorType, newDiscriminatorType)) { - return; - } - DiscriminatorType oldDiscriminatorType = this.discriminatorType; - this.discriminatorType = newDiscriminatorType; - this.discriminatorTypeAdapter.setValue(DiscriminatorType.toJavaAnnotationValue(newDiscriminatorType)); - firePropertyChanged(DISCRIMINATOR_TYPE_PROPERTY, oldDiscriminatorType, newDiscriminatorType); - } - - public Integer getLength() { - return this.length; - } - - public void setLength(Integer newLength) { - if (attributeValueHasNotChanged(this.length, newLength)) { - return; - } - Integer oldLength = this.length; - this.length = newLength; - this.lengthAdapter.setValue(newLength); - firePropertyChanged(LENGTH_PROPERTY, oldLength, newLength); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setLength(this.length(astRoot)); - this.setDiscriminatorType(this.discriminatorType(astRoot)); - } - - protected Integer length(CompilationUnit astRoot) { - return this.lengthAdapter.getValue(astRoot); - } - - protected DiscriminatorType discriminatorType(CompilationUnit astRoot) { - return DiscriminatorType.fromJavaAnnotationValue(this.discriminatorTypeAdapter.getValue(astRoot)); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildDiscriminatorTypeAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE); - } - - public static class DiscriminatorColumnAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final DiscriminatorColumnAnnotationDefinition 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 DiscriminatorColumnImpl(parent, member, DiscriminatorColumnImpl.DECLARATION_ANNOTATION_ADAPTER); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullDiscriminatorColumn(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullColumn.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullColumn.java --- src/org/eclipse/jpt/core/internal/resource/java/NullColumn.java 20 Oct 2008 20:52:50 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullColumn extends NullBaseColumn implements ColumnAnnotation, Annotation -{ - public NullColumn(JavaResourcePersistentMember parent) { - super(parent); - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - public String getAnnotationName() { - return ColumnAnnotation.ANNOTATION_NAME; - } - - @Override - protected ColumnAnnotation createResourceColumn() { - return (ColumnAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); - } - - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - if (length != null) { - createResourceColumn().setLength(length); - } - } - - public Integer getScale() { - return null; - } - - public void setScale(Integer scale) { - if (scale != null) { - createResourceColumn().setScale(scale); - } - } - - public Integer getPrecision() { - return null; - } - - public void setPrecision(Integer precision) { - if (precision != null) { - createResourceColumn().setPrecision(precision); - } - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - return null; - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumn.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumn.java --- src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumn.java 2 Oct 2008 21:25:55 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.BaseColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - - -public abstract class NullBaseColumn extends NullNamedColumn implements BaseColumnAnnotation, Annotation -{ - protected NullBaseColumn(JavaResourceNode parent) { - super(parent); - } - - @Override - protected abstract BaseColumnAnnotation createResourceColumn(); - - public String getTable() { - return null; - } - - public void setTable(String table) { - if (table != null) { - createResourceColumn().setTable(table); - } - } - - public Boolean getUnique() { - return null; - } - - public void setUnique(Boolean unique) { - if (unique != null) { - createResourceColumn().setUnique(unique); - } - } - - public Boolean getUpdatable() { - return null; - } - - public void setUpdatable(Boolean updatable) { - if (updatable != null) { - createResourceColumn().setUpdatable(updatable); - } - } - - public Boolean getInsertable() { - return null; - } - - public void setInsertable(Boolean insertable) { - if (insertable != null) { - createResourceColumn().setInsertable(insertable); - } - } - - public Boolean getNullable() { - return null; - } - - public void setNullable(Boolean nullable) { - if (nullable != null) { - createResourceColumn().setNullable(nullable); - } - } - - public TextRange getTableTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getUniqueTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean tableTouches(int pos, CompilationUnit astRoot) { - return false; - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/AbstractResourceAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AbstractResourceAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AbstractResourceAnnotation.java --- src/org/eclipse/jpt/core/internal/resource/java/AbstractResourceAnnotation.java 10 Mar 2009 04:12:10 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,140 +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.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; - -/** - * most of the behavior for a Java resource annotation - */ -public abstract class AbstractResourceAnnotation - extends AbstractJavaResourceNode - implements Annotation -{ - private final E member; - - private final DeclarationAnnotationAdapter daa; - - private final AnnotationAdapter annotationAdapter; - - protected AbstractResourceAnnotation(JavaResourceNode parent, E member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent); - this.member = member; - this.daa = daa; - this.annotationAdapter = annotationAdapter; - } - - protected AbstractResourceAnnotation(JavaResourceNode parent, E member, DeclarationAnnotationAdapter daa) { - this(parent, member, daa, new MemberAnnotationAdapter(member, daa)); - } - - protected E getMember() { - return this.member; - } - - protected AnnotationAdapter getAnnotationAdapter() { - return this.annotationAdapter; - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return this.annotationAdapter.getAnnotation(astRoot); - } - - protected DeclarationAnnotationAdapter getDeclarationAnnotationAdapter() { - return this.daa; - } - - public void removeAnnotation() { - this.annotationAdapter.removeAnnotation(); - } - - public void newAnnotation() { - this.annotationAdapter.newMarkerAnnotation(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return getAnnotationTextRange(astRoot); - } - - protected TextRange getTextRange(ASTNode astNode) { - return (astNode == null) ? null : new ASTNodeTextRange(astNode); - } - - /** - * Return the text range corresponding to the specified annotation. - * If the annotation is missing, return null. - */ - protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { - return this.getTextRange(getAnnotation(astRoot)); - } - - protected org.eclipse.jdt.core.dom.Annotation getAnnotation(CompilationUnit astRoot) { - return this.daa.getAnnotation(this.member.getModifiedDeclaration(astRoot)); - - } - - protected Expression getAnnotationElementExpression(DeclarationAnnotationElementAdapter adapter, CompilationUnit astRoot) { - return adapter.getExpression(this.member.getModifiedDeclaration(astRoot)); - } - - protected TextRange getAnnotationElementTextRange(DeclarationAnnotationElementAdapter adapter, CompilationUnit astRoot) { - return this.getTextRange(getAnnotationElementExpression(adapter, astRoot)); - - } - - /** - * Convenience method. If the specified element is missing - * return the member's text range instead. - */ - protected TextRange getElementTextRange(DeclarationAnnotationElementAdapter elementAdapter, CompilationUnit astRoot) { - return this.getElementTextRange(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.getTextRange(astRoot); - } - - /** - * Convenience method. Return whether the specified position touches the element. - * Returns false if the element does not exist - */ - protected boolean elementTouches(DeclarationAnnotationElementAdapter elementAdapter, int pos, CompilationUnit astRoot) { - return this.elementTouches(getAnnotationElementTextRange(elementAdapter, astRoot), pos); - } - - /** - * Convenience method. Return whether element's text range is not - * null (meaning the element exists) and the specified position touches it. - */ - protected boolean elementTouches(TextRange elementTextRange, int pos) { - return (elementTextRange != null) && elementTextRange.touches(pos); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getAnnotationName()); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/ManyToOneImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/ManyToOneImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/ManyToOneImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/ManyToOneImpl.java 23 Oct 2008 19:04:08 -0000 1.16 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -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.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.Member; - - -public class ManyToOneImpl extends AbstractRelationshipMappingAnnotation implements ManyToOneAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter OPTIONAL_ADAPTER = buildOptionalAdapter(); - - private final AnnotationElementAdapter optionalAdapter; - - private Boolean optional; - - protected ManyToOneImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.optionalAdapter = this.buildBooleanAnnotationElementAdapter(OPTIONAL_ADAPTER); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.optional = this.optional(astRoot); - } - - //**************** AbstractRelationshipMappingAnnotation implementation ************** - - @Override - protected DeclarationAnnotationElementAdapter getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getFetchAdapter() { - return FETCH_ADAPTER; - } - - //**************** Annotation implementation ************** - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean newOptional) { - if (attributeValueHasNotChanged(this.optional, newOptional)) { - return; - } - Boolean oldOptional = this.optional; - this.optional = newOptional; - this.optionalAdapter.setValue(newOptional); - firePropertyChanged(OPTIONAL_PROPERTY, oldOptional, newOptional); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return getElementTextRange(OPTIONAL_ADAPTER, astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setOptional(this.optional(astRoot)); - } - - protected Boolean optional(CompilationUnit astRoot) { - return this.optionalAdapter.getValue(astRoot); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__CASCADE); - } - - private static DeclarationAnnotationElementAdapter buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__FETCH); - } - - private static DeclarationAnnotationElementAdapter buildOptionalAdapter() { - return buildOptionalAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__OPTIONAL); - } - - private static DeclarationAnnotationElementAdapter buildOptionalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, BooleanExpressionConverter.instance()); - } - - - public static class ManyToOneAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final ManyToOneAnnotationDefinition INSTANCE = new ManyToOneAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static ManyToOneAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ManyToOneAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new ManyToOneImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullTable.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullTable.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullTable.java --- src/org/eclipse/jpt/core/internal/resource/java/NullTable.java 26 Mar 2008 03:12:20 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.TableAnnotation; - - -public class NullTable extends NullBaseTable implements TableAnnotation -{ - protected NullTable(JavaResourcePersistentMember parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullJoinTable.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullJoinTable.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullJoinTable.java --- src/org/eclipse/jpt/core/internal/resource/java/NullJoinTable.java 26 Mar 2008 03:12:20 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ListIterator; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - - -public class NullJoinTable extends NullBaseTable implements JoinTableAnnotation -{ - protected NullJoinTable(JavaResourcePersistentMember parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public JoinColumnAnnotation addInverseJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation addJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public int indexOfInverseJoinColumn(JoinColumnAnnotation joinColumn) { - throw new UnsupportedOperationException(); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation inverseJoinColumnAt(int index) { - return null; - } - - public ListIterator inverseJoinColumns() { - return EmptyListIterator.instance(); - } - - public int inverseJoinColumnsSize() { - return 0; - } - - public JoinColumnAnnotation joinColumnAt(int index) { - return null; - } - - public ListIterator joinColumns() { - return EmptyListIterator.instance(); - } - - public int joinColumnsSize() { - return 0; - } - - public void moveInverseJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeInverseJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void removeJoinColumn(int index) { - throw new UnsupportedOperationException(); - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullTemporal.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullTemporal.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullTemporal.java --- src/org/eclipse/jpt/core/internal/resource/java/NullTemporal.java 20 Oct 2008 20:52:50 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; -import org.eclipse.jpt.core.resource.java.TemporalType; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullTemporal extends AbstractJavaResourceNode implements TemporalAnnotation, Annotation -{ - protected NullTemporal(JavaResourcePersistentMember parent) { - super(parent); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return TemporalAnnotation.ANNOTATION_NAME; - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - protected TemporalAnnotation createTemporalResource() { - return (TemporalAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); - } - - - public TemporalType getValue() { - return null; - } - - public void setValue(TemporalType value) { - if (value != null) { - createTemporalResource().setValue(value); - } - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/MapKeyImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/MapKeyImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/MapKeyImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/MapKeyImpl.java 23 Oct 2008 19:04:08 -0000 1.18 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,125 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -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; -import org.eclipse.jpt.core.utility.jdt.Member; - -public class MapKeyImpl extends AbstractResourceAnnotation implements MapKeyAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildNameAdapter(); - - - private final AnnotationElementAdapter nameAdapter; - - private String name; - - protected MapKeyImpl(JavaResourceNode parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter(attribute, NAME_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.name = name(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - 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); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildNameAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.MAP_KEY__NAME, false); - } - - - public static class MapKeyAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final MapKeyAnnotationDefinition 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 MapKeyImpl(parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/GeneratorImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/GeneratorImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/GeneratorImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/GeneratorImpl.java 17 Oct 2008 19:06:05 -0000 1.16 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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; - -public abstract class GeneratorImpl - extends AbstractResourceAnnotation - implements GeneratorAnnotation -{ - // hold this so we can get the 'name' text range - private final DeclarationAnnotationElementAdapter nameDeclarationAdapter; - - // hold this so we can get the 'initialValue' text range - private final DeclarationAnnotationElementAdapter initialValueDeclarationAdapter; - - // hold this so we can get the 'allocationSize' text range - private final DeclarationAnnotationElementAdapter allocationSizeDeclarationAdapter; - - private final AnnotationElementAdapter nameAdapter; - - private final AnnotationElementAdapter initialValueAdapter; - - private final AnnotationElementAdapter allocationSizeAdapter; - - private String name; - - private Integer initialValue; - - private Integer allocationSize; - - public GeneratorImpl(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); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - this.initialValue = this.initialValue(astRoot); - this.allocationSize = this.allocationSize(astRoot); - } - - // ********** initialization ********** - protected AnnotationElementAdapter buildAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(getMember(), daea); - } - - protected AnnotationElementAdapter buildIntegerAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(getMember(), daea); - } - - protected abstract DeclarationAnnotationElementAdapter getNameAdapter(); - - protected abstract DeclarationAnnotationElementAdapter getInitialValueAdapter(); - - protected abstract DeclarationAnnotationElementAdapter getAllocationSizeAdapter(); - - - - public Integer getAllocationSize() { - return this.allocationSize; - } - - public void setAllocationSize(Integer newAllocationSize) { - if (attributeValueHasNotChanged(this.allocationSize, newAllocationSize)) { - return; - } - Integer oldAllocationSize = this.allocationSize; - this.allocationSize = newAllocationSize; - this.allocationSizeAdapter.setValue(newAllocationSize); - firePropertyChanged(ALLOCATION_SIZE_PROPERTY, oldAllocationSize, newAllocationSize); - } - - public Integer getInitialValue() { - return this.initialValue; - } - - public void setInitialValue(Integer newInitialValue) { - if (attributeValueHasNotChanged(this.initialValue, newInitialValue)) { - return; - } - Integer oldInitialValue = this.initialValue; - this.initialValue = newInitialValue; - this.initialValueAdapter.setValue(newInitialValue); - firePropertyChanged(INITIAL_VALUE_PROPERTY, oldInitialValue, newInitialValue); - } - - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public TextRange getInitialValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.initialValueDeclarationAdapter, astRoot); - } - - public TextRange getAllocationSizeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.allocationSizeDeclarationAdapter, astRoot); - } - - // ********** java annotations -> persistence model ********** - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - this.setAllocationSize(this.allocationSize(astRoot)); - this.setInitialValue(this.initialValue(astRoot)); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - protected Integer allocationSize(CompilationUnit astRoot) { - return this.allocationSizeAdapter.getValue(astRoot); - } - - protected Integer initialValue(CompilationUnit astRoot) { - return this.initialValueAdapter.getValue(astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - // ********** static methods ********** - protected static DeclarationAnnotationElementAdapter buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(annotationAdapter, elementName); - } - - protected static DeclarationAnnotationElementAdapter buildIntegerAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, NumberIntegerExpressionConverter.instance()); - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/OneToOneImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/OneToOneImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/OneToOneImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/OneToOneImpl.java 23 Oct 2008 19:04:08 -0000 1.18 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -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.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.Member; - -public class OneToOneImpl extends AbstractRelationshipMappingAnnotation implements OneToOneAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - static final DeclarationAnnotationElementAdapter TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); - - private static final DeclarationAnnotationElementAdapter CASCADE_ADAPTER = buildCascadeAdapter(); - - private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); - - private static final DeclarationAnnotationElementAdapter OPTIONAL_ADAPTER = buildOptionalAdapter(); - - private static final DeclarationAnnotationElementAdapter MAPPED_BY_ADAPTER = buildMappedByAdapter(); - - private final AnnotationElementAdapter optionalAdapter; - - private final AnnotationElementAdapter mappedByAdapter; - - - private Boolean optional; - - private String mappedBy; - - public OneToOneImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.mappedByAdapter = buildAnnotationElementAdapter(MAPPED_BY_ADAPTER); - this.optionalAdapter = this.buildBooleanAnnotationElementAdapter(OPTIONAL_ADAPTER); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.mappedBy = this.mappedBy(astRoot); - this.optional = this.optional(astRoot); - } - - //**************** AbstractRelationshipMappingAnnotation implementation ************** - - @Override - protected DeclarationAnnotationElementAdapter getTargetEntityAdapter() { - return TARGET_ENTITY_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getCascadeAdapter() { - return CASCADE_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter getFetchAdapter() { - return FETCH_ADAPTER; - } - - //**************** Annotation implementation ************** - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean newOptional) { - if (attributeValueHasNotChanged(this.optional, newOptional)) { - return; - } - Boolean oldOptional = this.optional; - this.optional = newOptional; - this.optionalAdapter.setValue(newOptional); - firePropertyChanged(OPTIONAL_PROPERTY, oldOptional, newOptional); - } - - public String getMappedBy() { - return this.mappedBy; - } - - public void setMappedBy(String newMappedBy) { - if (attributeValueHasNotChanged(this.mappedBy, newMappedBy)) { - return; - } - String oldMappedBy = this.mappedBy; - this.mappedBy = newMappedBy; - this.mappedByAdapter.setValue(newMappedBy); - firePropertyChanged(MAPPED_BY_PROPERTY, oldMappedBy, newMappedBy); - } - - public TextRange getMappedByTextRange(CompilationUnit astRoot) { - return getElementTextRange(MAPPED_BY_ADAPTER, astRoot); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return getElementTextRange(OPTIONAL_ADAPTER, astRoot); - } - - public boolean mappedByTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(MAPPED_BY_ADAPTER, pos, astRoot); - } - - @Override - public void update(CompilationUnit astRoot) { - super.update(astRoot); - this.setOptional(this.optional(astRoot)); - this.setMappedBy(this.mappedByAdapter.getValue(astRoot)); - } - - protected String mappedBy(CompilationUnit astRoot) { - return this.mappedByAdapter.getValue(astRoot); - } - - protected Boolean optional(CompilationUnit astRoot) { - return this.optionalAdapter.getValue(astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter buildTargetEntityAdapter() { - return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__TARGET_ENTITY); - } - - private static DeclarationAnnotationElementAdapter buildCascadeAdapter() { - return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__CASCADE); - } - - private static DeclarationAnnotationElementAdapter buildFetchAdapter() { - return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__FETCH); - } - - private static DeclarationAnnotationElementAdapter buildOptionalAdapter() { - return buildOptionalAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__OPTIONAL); - } - - private static DeclarationAnnotationElementAdapter buildOptionalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildMappedByAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__MAPPED_BY, false); // false = do not remove annotation when empty - } - - public static class OneToOneAnnotationDefinition implements AnnotationDefinition - { - - // singleton - private static final OneToOneAnnotationDefinition INSTANCE = new OneToOneAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static OneToOneAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private OneToOneAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new OneToOneImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullOneToOne(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - - -} Index: src/org/eclipse/jpt/core/internal/resource/java/BasicImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/BasicImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/BasicImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/BasicImpl.java 23 Oct 2008 19:04:08 -0000 1.16 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -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.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.resource.java.JavaResourcePersistentMember; -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.Member; - - -public class BasicImpl extends AbstractResourceAnnotation implements BasicAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final AnnotationElementAdapter optionalAdapter; - - private final AnnotationElementAdapter fetchAdapter; - - private static final DeclarationAnnotationElementAdapter OPTIONAL_ADAPTER = buildOptionalAdapter(); - - private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); - - private Boolean optional; - - private FetchType fetch; - - protected BasicImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.optionalAdapter = new ShortCircuitAnnotationElementAdapter(attribute, OPTIONAL_ADAPTER); - this.fetchAdapter = new ShortCircuitAnnotationElementAdapter(attribute, FETCH_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - this.optional = this.optional(astRoot); - this.fetch = this.fetch(astRoot); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - //*************** Basic implementation **************** - public Boolean getOptional() { - return this.optional; - } - - public void setOptional(Boolean newOptional) { - if (attributeValueHasNotChanged(this.optional, newOptional)) { - return; - } - Boolean oldOptional = this.optional; - this.optional = newOptional; - this.optionalAdapter.setValue(newOptional); - firePropertyChanged(OPTIONAL_PROPERTY, oldOptional, newOptional); - } - - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType newFetch) { - if (attributeValueHasNotChanged(this.fetch, newFetch)) { - return; - } - FetchType oldFetch = this.fetch; - this.fetch = newFetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(newFetch)); - firePropertyChanged(FETCH_PROPERTY, oldFetch, newFetch); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(FETCH_ADAPTER, astRoot); - } - - public TextRange getOptionalTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(OPTIONAL_ADAPTER, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setOptional(this.optional(astRoot)); - this.setFetch(this.fetch(astRoot)); - } - - protected FetchType fetch(CompilationUnit astRoot) { - return FetchType.fromJavaAnnotationValue(this.fetchAdapter.getValue(astRoot)); - } - - protected Boolean optional(CompilationUnit astRoot) { - return this.optionalAdapter.getValue(astRoot); - } - - // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildOptionalAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__OPTIONAL, false, BooleanExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter buildFetchAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__FETCH, false); - } - - public static class BasicAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final BasicAnnotationDefinition INSTANCE = new BasicAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static BasicAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private BasicAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new BasicImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return new NullBasic(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumn.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumn.java --- src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumn.java 5 Sep 2008 15:27:19 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - - - -public class NullJoinColumn extends NullBaseColumn implements JoinColumnAnnotation, Annotation -{ - public NullJoinColumn(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - - @Override - protected JoinColumnAnnotation createResourceColumn() { - throw new UnsupportedOperationException(); - } - - 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; - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/IdImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/IdImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/IdImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/IdImpl.java 10 Mar 2009 04:12:10 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,79 +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.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -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.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - - -public class IdImpl - extends AbstractResourceAnnotation - implements IdAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected IdImpl(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public void initialize(CompilationUnit astRoot) { - //nothing to initialize - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void update(CompilationUnit astRoot) { - //no annotation members - } - - public static class IdAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final IdAnnotationDefinition INSTANCE = new IdAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static IdAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private IdAnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { - return new IdImpl((JavaResourcePersistentAttribute) parent, (Attribute) member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesImpl.java 23 Oct 2008 19:04:08 -0000 1.13 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,153 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -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.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverride; -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; - -public class AssociationOverridesImpl extends AbstractResourceAnnotation implements AssociationOverridesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - protected final List associationOverrides; - - protected AssociationOverridesImpl(JavaResourceNode parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.associationOverrides = new ArrayList(); - } - - public void initialize(CompilationUnit astRoot) { - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public String getNestableAnnotationName() { - return AssociationOverrideAnnotation.ANNOTATION_NAME; - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(this.associationOverrides); - } - - public int nestedAnnotationsSize() { - return this.associationOverrides.size(); - } - - public NestableAssociationOverride addInternal(int index) { - NestableAssociationOverride associationOverride = createAssociationOverride(index); - this.associationOverrides.add(index, associationOverride); - return associationOverride; - } - - public NestableAssociationOverride add(int index) { - NestableAssociationOverride associationOverride = createAssociationOverride(index); - add(index, associationOverride); - return associationOverride; - } - - private void add(int index, NestableAssociationOverride associationOverride) { - addItemToList(index, associationOverride, this.associationOverrides, ASSOCIATION_OVERRIDES_LIST); - } - - public void remove(NestableAssociationOverride associationOverride) { - removeItemFromList(associationOverride, this.associationOverrides, ASSOCIATION_OVERRIDES_LIST); - } - - public void remove(int index) { - removeItemFromList(index, this.associationOverrides, ASSOCIATION_OVERRIDES_LIST); - } - - public int indexOf(NestableAssociationOverride associationOverride) { - return this.associationOverrides.indexOf(associationOverride); - } - - public NestableAssociationOverride nestedAnnotationAt(int index) { - return this.associationOverrides.get(index); - } - - public NestableAssociationOverride nestedAnnotationFor(Annotation jdtAnnotation) { - for (NestableAssociationOverride associationOverride : this.associationOverrides) { - if (jdtAnnotation == associationOverride.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return associationOverride; - } - } - return null; - } - - public void move(int targetIndex, int sourceIndex) { - moveItemInList(targetIndex, sourceIndex, this.associationOverrides, ASSOCIATION_OVERRIDES_LIST); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.associationOverrides, targetIndex, sourceIndex); - } - - public String getElementName() { - return JPA.ASSOCIATION_OVERRIDES__VALUE; - } - - public void update(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this); - } - - private AssociationOverrideImpl createAssociationOverride(int index) { - return AssociationOverrideImpl.createNestedAssociationOverride(this, getMember(), index, getDeclarationAnnotationAdapter()); - } - - public static class AssociationOverridesAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final AssociationOverridesAnnotationDefinition 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 AssociationOverridesImpl(parent, member); - } - - public AssociationOverridesAnnotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/NullInheritance.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullInheritance.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullInheritance.java --- src/org/eclipse/jpt/core/internal/resource/java/NullInheritance.java 20 Oct 2008 20:52:50 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.InheritanceAnnotation; -import org.eclipse.jpt.core.resource.java.InheritanceType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullInheritance extends AbstractJavaResourceNode implements InheritanceAnnotation, Annotation -{ - protected NullInheritance(JavaResourcePersistentMember parent) { - super(parent); - } - - @Override - public JavaResourcePersistentMember getParent() { - return (JavaResourcePersistentMember) super.getParent(); - } - - public void initialize(CompilationUnit astRoot) { - //null, nothing to initialize - } - - public org.eclipse.jdt.core.dom.Annotation getJdtAnnotation(CompilationUnit astRoot) { - return null; - } - - public void newAnnotation() { - throw new UnsupportedOperationException(); - } - - public void removeAnnotation() { - throw new UnsupportedOperationException(); - } - - public String getAnnotationName() { - return InheritanceAnnotation.ANNOTATION_NAME; - } - - public InheritanceType getStrategy() { - return null; - } - - public void setStrategy(InheritanceType strategy) { - if (strategy != null) { - createInheritanceResource().setStrategy(strategy); - } - - } - - protected InheritanceAnnotation createInheritanceResource() { - return (InheritanceAnnotation) getParent().addSupportingAnnotation(getAnnotationName()); - } - - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - - } - - public TextRange getStrategyTextRange(CompilationUnit astRoot) { - return null; - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return null; - } - -} Index: src/org/eclipse/jpt/core/internal/resource/java/AbstractNamedQuery.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AbstractNamedQuery.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AbstractNamedQuery.java --- src/org/eclipse/jpt/core/internal/resource/java/AbstractNamedQuery.java 17 Oct 2008 19:04:37 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,324 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -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.ContainerAnnotation; -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.NestableQueryHint; -import org.eclipse.jpt.core.resource.java.QueryAnnotation; -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.iterators.CloneListIterator; - -public abstract class AbstractNamedQuery extends AbstractResourceAnnotation - implements QueryAnnotation -{ - // hold this so we can get the 'name' text range - private final DeclarationAnnotationElementAdapter nameDeclarationAdapter; - - // hold this so we can get the 'query' text range - private final DeclarationAnnotationElementAdapter queryDeclarationAdapter; - - private final AnnotationElementAdapter nameAdapter; - - private final AnnotationElementAdapter queryAdapter; - - private String name; - - private String query; - - protected final List hints; - private final HintsContainerAnnotation hintsContainerAnnotation; - - protected AbstractNamedQuery(JavaResourceNode parent, Type type,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, type, daa, annotationAdapter); - this.nameDeclarationAdapter = nameAdapter(daa); - this.queryDeclarationAdapter = queryAdapter(daa); - this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter); - this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter); - this.hints = new ArrayList(); - this.hintsContainerAnnotation = new HintsContainerAnnotation(); - } - - public void initialize(CompilationUnit astRoot) { - this.name = this.name(astRoot); - this.query = this.query(astRoot); - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this.hintsContainerAnnotation); - } - - - // ********** initialization ********** - protected AnnotationElementAdapter buildAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(getMember(), daea); - } - - protected DeclarationAnnotationElementAdapter nameAdapter(DeclarationAnnotationAdapter daa) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, getNameElementName()); - } - - protected DeclarationAnnotationElementAdapter queryAdapter(DeclarationAnnotationAdapter daa) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, getQueryElementName()); - } - - protected abstract String getNameElementName(); - - protected abstract String getQueryElementName(); - - /** - * Return the uniqueConstraints element name - */ - protected abstract String getHintsElementName(); - - public String getName() { - return this.name; - } - - public void setName(String newName) { - if (attributeValueHasNotChanged(this.name, newName)) { - return; - } - String oldName = this.name; - this.name = newName; - this.nameAdapter.setValue(newName); - firePropertyChanged(NAME_PROPERTY, oldName, newName); - } - - public String getQuery() { - return this.query; - } - - public void setQuery(String newQuery) { - if (attributeValueHasNotChanged(this.query, newQuery)) { - return; - } - String oldQuery = this.query; - this.query = newQuery; - this.queryAdapter.setValue(newQuery); - firePropertyChanged(QUERY_PROPERTY, oldQuery, newQuery); - } - - public ListIterator hints() { - return new CloneListIterator(this.hints); - } - - public int hintsSize() { - return this.hints.size(); - } - - public NestableQueryHint hintAt(int index) { - return this.hints.get(index); - } - - public int indexOfHint(QueryHintAnnotation queryHint) { - return this.hints.indexOf(queryHint); - } - - public NestableQueryHint addHint(int index) { - NestableQueryHint queryHint = (NestableQueryHint) ContainerAnnotationTools.addNestedAnnotation(index, this.hintsContainerAnnotation); - fireItemAdded(QueryAnnotation.HINTS_LIST, index, queryHint); - return queryHint; - } - - protected void addHint(int index, NestableQueryHint queryHint) { - addItemToList(index, queryHint, this.hints, HINTS_LIST); - } - - public void removeHint(int index) { - NestableQueryHint queryHint = hintAt(index); - removeHint(queryHint); - queryHint.removeAnnotation(); - ContainerAnnotationTools.synchAnnotationsAfterRemove(index, this.hintsContainerAnnotation); - } - - protected void removeHint(NestableQueryHint queryHint) { - removeItemFromList(queryHint, this.hints, HINTS_LIST); - } - - public void moveHint(int targetIndex, int sourceIndex) { - moveHintInternal(targetIndex, sourceIndex); - ContainerAnnotationTools.synchAnnotationsAfterMove(targetIndex, sourceIndex, this.hintsContainerAnnotation); - fireItemMoved(QueryAnnotation.HINTS_LIST, targetIndex, sourceIndex); - } - - protected void moveHintInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.hints, targetIndex, sourceIndex); - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nameDeclarationAdapter, astRoot); - } - - public TextRange getQueryTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.queryDeclarationAdapter, astRoot); - } - - public void update(CompilationUnit astRoot) { - this.setName(this.name(astRoot)); - this.setQuery(this.query(astRoot)); - this.updateQueryHintsFromJava(astRoot); - } - - protected String name(CompilationUnit astRoot) { - return this.nameAdapter.getValue(astRoot); - } - - protected String query(CompilationUnit astRoot) { - return this.queryAdapter.getValue(astRoot); - } - - private void updateQueryHintsFromJava(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this.hintsContainerAnnotation); - } - - protected abstract NestableQueryHint createQueryHint(int index); - - // ********** persistence model -> java annotations ********** - public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) super.getAnnotationAdapter(); - } - - public void moveAnnotation(int newIndex) { - getIndexedAnnotationAdapter().moveAnnotation(newIndex); - } - - public void initializeFrom(NestableAnnotation oldAnnotation) { - AbstractNamedQuery oldNamedQuery = (AbstractNamedQuery) oldAnnotation; - setName(oldNamedQuery.getName()); - setQuery(oldNamedQuery.getQuery()); - for (QueryHintAnnotation queryHint : CollectionTools.iterable(oldNamedQuery.hints())) { - NestableQueryHint newQueryHint = addHint(oldNamedQuery.indexOfHint(queryHint)); - newQueryHint.initializeFrom((NestableQueryHint) queryHint); - } - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - private class HintsContainerAnnotation extends AbstractJavaResourceNode implements ContainerAnnotation { - - public HintsContainerAnnotation() { - super(AbstractNamedQuery.this); - } - - public void initialize(CompilationUnit astRoot) { - // nothing to initialize - } - - public NestableQueryHint add(int index) { - NestableQueryHint queryHint = AbstractNamedQuery.this.createQueryHint(index); - AbstractNamedQuery.this.addHint(index, queryHint); - return queryHint; - } - - public NestableQueryHint addInternal(int index) { - NestableQueryHint queryHint = AbstractNamedQuery.this.createQueryHint(index); - AbstractNamedQuery.this.hints.add(index, queryHint); - return queryHint; - } - - public String getAnnotationName() { - return AbstractNamedQuery.this.getAnnotationName(); - } - - public String getNestableAnnotationName() { - return JPA.QUERY_HINT; - } - - public int indexOf(NestableQueryHint hint) { - return AbstractNamedQuery.this.indexOfHint(hint); - } - - public void move(int targetIndex, int sourceIndex) { - AbstractNamedQuery.this.moveHint(targetIndex, sourceIndex); - } - - public void moveInternal(int targetIndex, int sourceIndex) { - AbstractNamedQuery.this.moveHintInternal(targetIndex, sourceIndex); - } - - public NestableQueryHint nestedAnnotationAt(int index) { - return AbstractNamedQuery.this.hintAt(index); - } - - public NestableQueryHint nestedAnnotationFor(Annotation jdtAnnotation) { - for (NestableQueryHint uniqueConstraint : CollectionTools.iterable(nestedAnnotations())) { - if (jdtAnnotation == uniqueConstraint.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return uniqueConstraint; - } - } - return null; - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(AbstractNamedQuery.this.hints); - } - - public int nestedAnnotationsSize() { - return AbstractNamedQuery.this.hintsSize(); - } - - public void remove(NestableQueryHint queryHint) { - AbstractNamedQuery.this.removeHint(queryHint); - } - - public void remove(int index) { - AbstractNamedQuery.this.removeHint(nestedAnnotationAt(index)); - } - - public Annotation getJdtAnnotation(CompilationUnit astRoot) { - return AbstractNamedQuery.this.getJdtAnnotation(astRoot); - } - - public void newAnnotation() { - AbstractNamedQuery.this.newAnnotation(); - } - - public void removeAnnotation() { - AbstractNamedQuery.this.removeAnnotation(); - } - - public void update(CompilationUnit astRoot) { - AbstractNamedQuery.this.update(astRoot); - } - - public TextRange getTextRange(CompilationUnit astRoot) { - return AbstractNamedQuery.this.getTextRange(astRoot); - } - - public String getElementName() { - return "hints"; - } - - @Override - public void toString(StringBuilder sb) { - AbstractNamedQuery.this.toString(sb); - } - - } -} Index: src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesImpl.java --- src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesImpl.java 23 Oct 2008 19:04:08 -0000 1.13 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.java; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.resource.java.NestableSecondaryTable; -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; - -public class SecondaryTablesImpl extends AbstractResourceAnnotation implements SecondaryTablesAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final List secondaryTables; - - protected SecondaryTablesImpl(JavaResourcePersistentType parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.secondaryTables = new ArrayList(); - } - - public void initialize(CompilationUnit astRoot) { - ContainerAnnotationTools.initializeNestedAnnotations(astRoot, this); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public String getNestableAnnotationName() { - return SecondaryTableAnnotation.ANNOTATION_NAME; - } - - public String getElementName() { - return JPA.SECONDARY_TABLES__VALUE; - } - - public ListIterator nestedAnnotations() { - return new CloneListIterator(this.secondaryTables); - } - - public int nestedAnnotationsSize() { - return this.secondaryTables.size(); - } - - public NestableSecondaryTable addInternal(int index) { - NestableSecondaryTable secondaryTable = createSecondaryTable(index); - this.secondaryTables.add(index, secondaryTable); - return secondaryTable; - } - - public NestableSecondaryTable add(int index) { - NestableSecondaryTable secondaryTable = createSecondaryTable(index); - this.add(index, secondaryTable); - return secondaryTable; - } - - protected void add(int index, NestableSecondaryTable secondaryTable) { - addItemToList(index, secondaryTable, this.secondaryTables, SECONDARY_TABLES_LIST); - } - - public void remove(NestableSecondaryTable secondaryTable) { - removeItemFromList(secondaryTable, this.secondaryTables, SECONDARY_TABLES_LIST); - } - - public void remove(int index) { - removeItemFromList(index, this.secondaryTables, SECONDARY_TABLES_LIST); - } - - public int indexOf(NestableSecondaryTable secondaryTable) { - return this.secondaryTables.indexOf(secondaryTable); - } - - public NestableSecondaryTable nestedAnnotationAt(int index) { - return this.secondaryTables.get(index); - } - - public NestableSecondaryTable nestedAnnotationFor(org.eclipse.jdt.core.dom.Annotation jdtAnnotation) { - for (NestableSecondaryTable secondaryTable : this.secondaryTables) { - if (jdtAnnotation == secondaryTable.getJdtAnnotation((CompilationUnit) jdtAnnotation.getRoot())) { - return secondaryTable; - } - } - return null; - } - - public void move(int targetIndex, int sourceIndex) { - moveItemInList(targetIndex, sourceIndex, this.secondaryTables, SECONDARY_TABLES_LIST); - } - //TODO this move is different than how we handle SecondarTable.pkJoinColumns -// public void movePkJoinColumn(int oldIndex, int newIndex) { -// movePkJoinColumnInternal(oldIndex, newIndex); -// ContainerAnnotationTools.synchAnnotationsAfterMove(newIndex, oldIndex, this.pkJoinColumnsContainerAnnotation); -// fireItemMoved(SecondaryTable.PK_JOIN_COLUMNS_LIST, newIndex, oldIndex); -// } - - public void moveInternal(int targetIndex, int sourceIndex) { - CollectionTools.move(this.secondaryTables, targetIndex, sourceIndex); - } - - public void update(CompilationUnit astRoot) { - ContainerAnnotationTools.updateNestedAnnotationsFromJava(astRoot, this); - } - - private SecondaryTableImpl createSecondaryTable(int index) { - return SecondaryTableImpl.createNestedSecondaryTable(this, getMember(), index, getDeclarationAnnotationAdapter()); - } - - public static class SecondaryTablesAnnotationDefinition implements AnnotationDefinition - { - // singleton - private static final SecondaryTablesAnnotationDefinition 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 SecondaryTablesImpl((JavaResourcePersistentType) parent, member); - } - - public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) { - return null; - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - } - - -} Index: src/org/eclipse/jpt/core/resource/java/CascadeType.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/CascadeType.java,v retrieving revision 1.4 diff -u -r1.4 CascadeType.java --- src/org/eclipse/jpt/core/resource/java/CascadeType.java 10 Mar 2009 04:12:10 -0000 1.4 +++ src/org/eclipse/jpt/core/resource/java/CascadeType.java 6 Apr 2009 20:59:18 -0000 @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA enum + * javax.persistence.CascadeType * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -19,63 +20,79 @@ * will almost certainly be broken (repeatedly) as the API evolves. */ public enum CascadeType { - + ALL(JPA.CASCADE_TYPE__ALL), PERSIST(JPA.CASCADE_TYPE__PERSIST), MERGE(JPA.CASCADE_TYPE__MERGE), REMOVE(JPA.CASCADE_TYPE__REMOVE), REFRESH(JPA.CASCADE_TYPE__REFRESH); - + + private String javaAnnotationValue; - + CascadeType(String javaAnnotationValue) { + if (javaAnnotationValue == null) { + throw new NullPointerException(); + } this.javaAnnotationValue = javaAnnotationValue; } - + public String getJavaAnnotationValue() { return this.javaAnnotationValue; } - - public static CascadeType[] fromJavaAnnotationValue(String[] javaAnnotationValues) { + + + // ********** static methods ********** + + public static CascadeType[] fromJavaAnnotationValues(String[] javaAnnotationValues) { if (javaAnnotationValues == null) { return EMPTY_CASCADE_TYPE_ARRAY; } - CascadeType[] cascadeTypes = new CascadeType[javaAnnotationValues.length]; - for (int i = 0; i < javaAnnotationValues.length; i++) { - String javaAnnotationValue = javaAnnotationValues[i]; - if (javaAnnotationValue != null) { - cascadeTypes[i] = cascadeType(javaAnnotationValue); - } + int len = javaAnnotationValues.length; + if (len == 0) { + return EMPTY_CASCADE_TYPE_ARRAY; + } + + CascadeType[] cascadeTypes = new CascadeType[len]; + for (int i = 0; i < len; i++) { + cascadeTypes[i] = fromJavaAnnotationValue(javaAnnotationValues[i]); } return cascadeTypes; } private static final CascadeType[] EMPTY_CASCADE_TYPE_ARRAY = new CascadeType[0]; - private static CascadeType cascadeType(String javaAnnotationValue) { - if (javaAnnotationValue.equals(ALL.getJavaAnnotationValue())) { - return ALL; - } - if (javaAnnotationValue.equals(PERSIST.getJavaAnnotationValue())) { - return PERSIST; - } - if (javaAnnotationValue.equals(MERGE.getJavaAnnotationValue())) { - return MERGE; - } - if (javaAnnotationValue.equals(REMOVE.getJavaAnnotationValue())) { - return REMOVE; - } - if (javaAnnotationValue.equals(REFRESH.getJavaAnnotationValue())) { - return REFRESH; + public static CascadeType fromJavaAnnotationValue(Object javaAnnotationValue) { + return (javaAnnotationValue == null) ? null : fromJavaAnnotationValue_(javaAnnotationValue); + } + + private static CascadeType fromJavaAnnotationValue_(Object javaAnnotationValue) { + for (CascadeType cascadeType : CascadeType.values()) { + if (cascadeType.getJavaAnnotationValue().equals(javaAnnotationValue)) { + return cascadeType; + } } - throw new IllegalArgumentException("Unknown cascade type: " + javaAnnotationValue); //$NON-NLS-1$ + return null; } - - public static String[] toJavaAnnotationValue(CascadeType[] cascadeTypes) { - String[] javaAnnotationValues = new String[cascadeTypes.length]; - for (int i = 0; i < cascadeTypes.length; i++) { - javaAnnotationValues[i] = cascadeTypes[i].javaAnnotationValue; + + public static String[] toJavaAnnotationValues(CascadeType[] cascadeTypes) { + if (cascadeTypes == null) { + return EMPTY_STRING_ARRAY; + } + int len = cascadeTypes.length; + if (len == 0) { + return EMPTY_STRING_ARRAY; + } + + String[] javaAnnotationValues = new String[len]; + for (int i = 0; i < len; i++) { + javaAnnotationValues[i] = toJavaAnnotationValue(cascadeTypes[i]); } return javaAnnotationValues; } + private static final String[] EMPTY_STRING_ARRAY = new String[0]; + + public static String toJavaAnnotationValue(CascadeType cascadeType) { + return (cascadeType == null) ? null : cascadeType.getJavaAnnotationValue(); + } } Index: src/org/eclipse/jpt/core/resource/java/NamedQueryAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NamedQueryAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 NamedQueryAnnotation.java --- src/org/eclipse/jpt/core/resource/java/NamedQueryAnnotation.java 28 Feb 2008 20:32:02 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/NamedQueryAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * Corresponds to the javax.persistence.NamedQuery annotation + * Corresponds to the JPA annotation + * javax.persistence.NamedQuery * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,8 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface NamedQueryAnnotation extends QueryAnnotation +public interface NamedQueryAnnotation + extends BaseNamedQueryAnnotation { String ANNOTATION_NAME = JPA.NAMED_QUERY; - } Index: src/org/eclipse/jpt/core/resource/java/AttributeOverridesAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AttributeOverridesAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 AttributeOverridesAnnotation.java --- src/org/eclipse/jpt/core/resource/java/AttributeOverridesAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/AttributeOverridesAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.AttributeOverrides * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,7 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface AttributeOverridesAnnotation extends ContainerAnnotation +public interface AttributeOverridesAnnotation + extends ContainerAnnotation { String ANNOTATION_NAME = JPA.ATTRIBUTE_OVERRIDES; Index: src/org/eclipse/jpt/core/resource/java/UniqueConstraintAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/UniqueConstraintAnnotation.java,v retrieving revision 1.3 diff -u -r1.3 UniqueConstraintAnnotation.java --- src/org/eclipse/jpt/core/resource/java/UniqueConstraintAnnotation.java 9 Sep 2008 17:56:46 -0000 1.3 +++ src/org/eclipse/jpt/core/resource/java/UniqueConstraintAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jdt.core.dom.CompilationUnit; /** - * Corresponds to the javax.persistence.UniqueConstraint annotation + * Corresponds to the JPA annotation + * javax.persistence.UniqueConstraint * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,28 +22,51 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface UniqueConstraintAnnotation extends JavaResourceNode +public interface UniqueConstraintAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.UNIQUE_CONSTRAINT; + /** + * Corresponds to the 'columnNames' element of the UniqueConstraint annotation. + * Return null if the element does not exist in the annotation. + */ ListIterator columnNames(); + String COLUMN_NAMES_LIST = "columnNames"; //$NON-NLS-1$ + /** + * Corresponds to the 'columnNames' element of the UniqueConstraint annotation. + */ int columnNamesSize(); + /** + * Corresponds to the 'columnNames' element of the UniqueConstraint annotation. + */ void addColumnName(String columnName); + /** + * Corresponds to the 'columnNames' element of the UniqueConstraint annotation. + */ void addColumnName(int index, String columnName); + /** + * Corresponds to the 'columnNames' element of the UniqueConstraint annotation. + */ + void moveColumnName(int targetIndex, int sourceIndex); + + /** + * Corresponds to the 'columnNames' element of the UniqueConstraint annotation. + */ void removeColumnName(String columnName); + /** + * Corresponds to the 'columnNames' element of the UniqueConstraint annotation. + */ void removeColumnName(int index); - void moveColumnName(int targetIndex, int sourceIndex); - String COLUMN_NAMES_LIST = "columnNames"; //$NON-NLS-1$ - /** - * Return whether the specified postition touches the columnNames element. - * Return false if the columnNames element does not exist. + * Return whether the specified position touches the 'columnNames' element. + * Return false if the element does not exist. */ boolean columnNamesTouches(int pos, CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/TableAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/TableAnnotation.java,v retrieving revision 1.6 diff -u -r1.6 TableAnnotation.java --- src/org/eclipse/jpt/core/resource/java/TableAnnotation.java 12 Sep 2008 05:20:07 -0000 1.6 +++ src/org/eclipse/jpt/core/resource/java/TableAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -9,12 +9,9 @@ ******************************************************************************/ package org.eclipse.jpt.core.resource.java; -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.utility.TextRange; - /** - * + * Corresponds to the JPA annotation + * javax.persistence.Table * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -23,71 +20,7 @@ * will almost certainly be broken (repeatedly) as the API evolves. */ public interface TableAnnotation - extends JavaResourceNode + extends BaseTableAnnotation { String ANNOTATION_NAME = JPA.TABLE; - - String getName(); - void setName(String name); - String NAME_PROPERTY = "name"; //$NON-NLS-1$ - - String getCatalog(); - void setCatalog(String catalog); - String CATALOG_PROPERTY = "catalog"; //$NON-NLS-1$ - - String getSchema(); - void setSchema(String schema); - String SCHEMA_PROPERTY = "schema"; //$NON-NLS-1$ - - ListIterator uniqueConstraints(); - - UniqueConstraintAnnotation uniqueConstraintAt(int index); - - int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint); - - int uniqueConstraintsSize(); - - UniqueConstraintAnnotation addUniqueConstraint(int index); - - void removeUniqueConstraint(int index); - - void moveUniqueConstraint(int targetIndex, int sourceIndex); - String UNIQUE_CONSTRAINTS_LIST = "uniqueConstraints"; //$NON-NLS-1$ - - /** - * Return the {@link TextRange} for the name element. If the name element - * does not exist return the {@link TextRange} for the *Table annotation. - */ - TextRange getNameTextRange(CompilationUnit astRoot); - - /** - * Return the {@link TextRange} for the catalog element. If the catalog element - * does not exist return the {@link TextRange} for the *Table annotation. - */ - TextRange getCatalogTextRange(CompilationUnit astRoot); - - /** - * Return the {@link TextRange} for the schema element. If the schema element - * does not exist return the {@link TextRange} for the *Table annotation. - */ - TextRange getSchemaTextRange(CompilationUnit astRoot); - - /** - * Return whether the specified postition touches the name element. - * Return false if the name element does not exist. - */ - boolean nameTouches(int pos, CompilationUnit astRoot); - - /** - * Return whether the specified postition touches the schema element. - * Return false if the name element does not exist. - */ - boolean schemaTouches(int pos, CompilationUnit astRoot); - - /** - * Return whether the specified postition touches the catalog element. - * Return false if the name element does not exist. - */ - boolean catalogTouches(int pos, CompilationUnit astRoot); - } Index: src/org/eclipse/jpt/core/resource/java/IdAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/IdAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 IdAnnotation.java --- src/org/eclipse/jpt/core/resource/java/IdAnnotation.java 27 Mar 2008 00:17:09 -0000 1.1 +++ src/org/eclipse/jpt/core/resource/java/IdAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.Id * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,8 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface IdAnnotation extends JavaResourceNode +public interface IdAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.ID; - } Index: src/org/eclipse/jpt/core/resource/java/MappedSuperclassAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/MappedSuperclassAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 MappedSuperclassAnnotation.java --- src/org/eclipse/jpt/core/resource/java/MappedSuperclassAnnotation.java 28 Feb 2008 20:32:02 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/MappedSuperclassAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.MappedSuperclass * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,8 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface MappedSuperclassAnnotation extends JavaResourceNode +public interface MappedSuperclassAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.MAPPED_SUPERCLASS; - } Index: src/org/eclipse/jpt/core/resource/java/NestableJoinColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableJoinColumn.java diff -N src/org/eclipse/jpt/core/resource/java/NestableJoinColumn.java --- src/org/eclipse/jpt/core/resource/java/NestableJoinColumn.java 28 Feb 2008 20:32:02 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.resource.java; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface NestableJoinColumn extends JoinColumnAnnotation, NestableAnnotation -{ - // nothing yet -} Index: src/org/eclipse/jpt/core/resource/java/EmbeddedIdAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/EmbeddedIdAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 EmbeddedIdAnnotation.java --- src/org/eclipse/jpt/core/resource/java/EmbeddedIdAnnotation.java 27 Mar 2008 00:17:08 -0000 1.1 +++ src/org/eclipse/jpt/core/resource/java/EmbeddedIdAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.EmbeddedId * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,8 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface EmbeddedIdAnnotation extends JavaResourceNode +public interface EmbeddedIdAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.EMBEDDED_ID; - } Index: src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentMember.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentMember.java,v retrieving revision 1.14 diff -u -r1.14 JavaResourcePersistentMember.java --- src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentMember.java 10 Mar 2009 04:12:10 -0000 1.14 +++ src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentMember.java 6 Apr 2009 20:59:18 -0000 @@ -16,7 +16,7 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Java source code persistent member + * Java source code or binary persistent member. * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -32,7 +32,7 @@ /** * Return the member's mapping annotations. - * Do not return duplicate annotations as this error is handled by the java + * Do not return duplicate annotations as this error is handled by the Java * compiler. * @see #supportingAnnotations() */ @@ -47,35 +47,26 @@ /** * Return the member's mapping annotation. */ - JavaResourceNode getMappingAnnotation(); + Annotation getMappingAnnotation(); /** * Return the mapping annotation with the specified name. * Return the first if there are duplicates in the source code. */ - JavaResourceNode getMappingAnnotation(String annotationName); + Annotation getMappingAnnotation(String annotationName); /** - * Change the mapping annotation. Remove any existing mapping annotations. - * Do not remove any non-mapping annotations. + * Change the mapping annotation. Remove any other existing mapping + * annotations. Do not remove any supporting (non-mapping) annotations. */ - void setMappingAnnotation(String annotationName); - - /** - * Return a null mapping annotation with the specified name. If annotationName is - * null then return null instead of throwing an exception - * The corresponding AnnotationDefinition must implement #buildNullAnnotation() - * {@link AnnotationDefinition#buildNullAnnotation(JavaResourcePersistentMember, - * org.eclipse.jpt.core.utility.jdt.Member)} - */ - JavaResourceNode getNullMappingAnnotation(String annotationName); + Annotation setMappingAnnotation(String annotationName); // ********** supporting annotations ********** /** * Return the member's supporting annotations. - * Do not return duplicate annotations as this error is handled by the java + * Do not return duplicate annotations as this error is handled by the Java * compiler. Do not return any mapping annotations. * @see #mappingAnnotations() */ @@ -101,7 +92,7 @@ * Return the specified supporting annotation. * Return the first if there are duplicates in the source code. */ - JavaResourceNode getSupportingAnnotation(String annotationName); + Annotation getSupportingAnnotation(String annotationName); /** * Return the specified supporting annotation. @@ -109,12 +100,12 @@ * Do not return null, but a Null Object instead if no annotation * with the specified name exists in the source code. */ - JavaResourceNode getNonNullSupportingAnnotation(String annotationName); + Annotation getNonNullSupportingAnnotation(String annotationName); /** * Add a supporting annotation with the specified name. */ - JavaResourceNode addSupportingAnnotation(String annotationName); + Annotation addSupportingAnnotation(String annotationName); /** * Remove the specified supporting annotation. @@ -133,19 +124,19 @@ * the new one. If neither annotation exists, then create a new nestable * annotation. */ - JavaResourceNode addSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName); + Annotation addSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName); /** - * Remove the specified supporting nestable annotation. - */ - void removeSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName); - - /** * Move the supporting nestable annotation found in the specified container * annotation at the specified source index to the specified target index. */ void moveSupportingAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName); + /** + * Remove the specified supporting nestable annotation. + */ + void removeSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName); + // ********** queries ********** Index: src/org/eclipse/jpt/core/resource/java/EntityAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/EntityAnnotation.java,v retrieving revision 1.5 diff -u -r1.5 EntityAnnotation.java --- src/org/eclipse/jpt/core/resource/java/EntityAnnotation.java 22 Dec 2008 16:12:57 -0000 1.5 +++ src/org/eclipse/jpt/core/resource/java/EntityAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the javax.persistence.Entity annotation + * Corresponds to the JPA annotation + * javax.persistence.Entity * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,26 +22,26 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface EntityAnnotation extends JavaResourceNode +public interface EntityAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.ENTITY; /** - * Corresponds to the name element of the Entity annotation. - * Returns null if the name element does not exist in java. + * Corresponds to the 'name' element of the Entity annotation. + * Return null if the element does not exist in Java. */ String getName(); - + String NAME_PROPERTY = "name"; //$NON-NLS-1$ + /** - * Corresponds to the name element of the Entity annotation. - * Set to null to remove the name element. + * Corresponds to the 'name' element of the Entity annotation. + * Set to null to remove the element. */ void setName(String name); - - String NAME_PROPERTY = "name"; //$NON-NLS-1$ - + /** - * Return the {@link TextRange} for the name element. If the name element + * Return the {@link TextRange} for the 'name' element. If the element * does not exist return the {@link TextRange} for the Entity annotation. */ TextRange getNameTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/NestableNamedQuery.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableNamedQuery.java diff -N src/org/eclipse/jpt/core/resource/java/NestableNamedQuery.java --- src/org/eclipse/jpt/core/resource/java/NestableNamedQuery.java 28 Feb 2008 20:32:02 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.resource.java; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface NestableNamedQuery - extends NamedQueryAnnotation, NestableAnnotation -{ - // nothing yet -} Index: src/org/eclipse/jpt/core/resource/java/JoinTableAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JoinTableAnnotation.java,v retrieving revision 1.3 diff -u -r1.3 JoinTableAnnotation.java --- src/org/eclipse/jpt/core/resource/java/JoinTableAnnotation.java 22 Dec 2008 16:12:57 -0000 1.3 +++ src/org/eclipse/jpt/core/resource/java/JoinTableAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -12,7 +12,8 @@ import java.util.ListIterator; /** - * + * Corresponds to the JPA annotation + * javax.persistence.JoinTable * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,38 +21,84 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface JoinTableAnnotation extends TableAnnotation +public interface JoinTableAnnotation + extends BaseTableAnnotation { String ANNOTATION_NAME = JPA.JOIN_TABLE; + /** + * Corresponds to the 'joinColumns' element of the JoinTable annotation. + * Return an empty iterator if the element does not exist in Java. + */ ListIterator joinColumns(); - + String JOIN_COLUMNS_LIST = "joinColumns"; //$NON-NLS-1$ + + /** + * Corresponds to the 'joinColumns' element of the JoinTable annotation. + */ + int joinColumnsSize(); + + /** + * Corresponds to the 'joinColumns' element of the JoinTable annotation. + */ JoinColumnAnnotation joinColumnAt(int index); - + + /** + * Corresponds to the 'joinColumns' element of the JoinTable annotation. + */ int indexOfJoinColumn(JoinColumnAnnotation joinColumn); - - int joinColumnsSize(); + /** + * Corresponds to the 'joinColumns' element of the JoinTable annotation. + */ JoinColumnAnnotation addJoinColumn(int index); - - void removeJoinColumn(int index); - + + /** + * Corresponds to the 'joinColumns' element of the JoinTable annotation. + */ void moveJoinColumn(int targetIndex, int sourceIndex); - String JOIN_COLUMNS_LIST = "joinColumns"; //$NON-NLS-1$ - + + /** + * Corresponds to the 'joinColumns' element of the JoinTable annotation. + */ + void removeJoinColumn(int index); + + + /** + * Corresponds to the 'inverseJoinColumns' element of the JoinTable annotation. + * Return an empty iterator if the element does not exist in Java. + */ ListIterator inverseJoinColumns(); - + String INVERSE_JOIN_COLUMNS_LIST = "inverseJoinColumns"; //$NON-NLS-1$ + + /** + * Corresponds to the 'inverseJoinColumns' element of the JoinTable annotation. + */ + int inverseJoinColumnsSize(); + + /** + * Corresponds to the 'inverseJoinColumns' element of the JoinTable annotation. + */ JoinColumnAnnotation inverseJoinColumnAt(int index); - + + /** + * Corresponds to the 'inverseJoinColumns' element of the JoinTable annotation. + */ int indexOfInverseJoinColumn(JoinColumnAnnotation joinColumn); - - int inverseJoinColumnsSize(); + /** + * Corresponds to the 'inverseJoinColumns' element of the JoinTable annotation. + */ JoinColumnAnnotation addInverseJoinColumn(int index); - - void removeInverseJoinColumn(int index); - + + /** + * Corresponds to the 'inverseJoinColumns' element of the JoinTable annotation. + */ void moveInverseJoinColumn(int targetIndex, int sourceIndex); - String INVERSE_JOIN_COLUMNS_LIST = "inverseJoinColumns"; //$NON-NLS-1$ + + /** + * Corresponds to the 'inverseJoinColumns' element of the JoinTable annotation. + */ + void removeInverseJoinColumn(int index); } Index: src/org/eclipse/jpt/core/resource/java/RelationshipMappingAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/RelationshipMappingAnnotation.java,v retrieving revision 1.5 diff -u -r1.5 RelationshipMappingAnnotation.java --- src/org/eclipse/jpt/core/resource/java/RelationshipMappingAnnotation.java 22 Dec 2008 16:12:57 -0000 1.5 +++ src/org/eclipse/jpt/core/resource/java/RelationshipMappingAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,11 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * + * Common protocol among + * javax.persistence.ManyToOne + * javax.persistence.ManyToMany + * javax.persistence.OneToMany + * javax.persistence.OneToOne * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,90 +25,125 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface RelationshipMappingAnnotation extends JavaResourceNode +public interface RelationshipMappingAnnotation + extends Annotation { /** - * Corresponds to the targetEntity element of the relationship - * annotations (ManyToMany, OneToMany, ManyToOne, OneToOne). - * Returns null if the targetEntity element does not exist in java. - * Returns the portion of the targetEntity preceding the .class. - *

+ * Corresponds to the 'targetEntity' element of the relationship mapping + * annotations. + * Return null if the element does not exist in Java. + * Return the portion of the value preceding ".class". + *

 	 *     @ManyToMany(targetEntity=Employee.class)
-	 * 

+ *
* will return "Employee" - **/ + */ String getTargetEntity(); + String TARGET_ENTITY_PROPERTY = "targetEntity"; //$NON-NLS-1$ /** - * Corresponds to the targetEntity of the relationship - * annotations (ManyToMany, OneToMany, ManyToOne, OneToOne). - * Set to null to remove the targetEntity element. + * Corresponds to the 'targetEntity' element of the relationship mapping + * annotations. + * Set to null to remove the element. */ void setTargetEntity(String targetEntity); - String TARGET_ENTITY_PROPERTY = "targetEntity"; //$NON-NLS-1$ /** - * Returns the qualified targetEntity name as it is resolved in the AST - *

+ * Return the {@link TextRange} for the 'targetEntity' element. If the element + * does not exist return the {@link TextRange} for the relationship mapping annotation. + */ + TextRange getTargetEntityTextRange(CompilationUnit astRoot); + + /** + * Return the fully-qualified target entity class name as resolved by the AST's bindings. + *

 	 *     @ManyToMany(targetEntity=Employee.class)
-	 * 

- * will return "model.Employee" if there is an import for model.Employee + *
+ * will return "model.Employee" if there is an import for model.Employee. * @return */ - String getFullyQualifiedTargetEntity(); - String FULLY_QUALFIEID_TARGET_ENTITY_PROPERTY = "fullyQualifiedTargetEntity"; //$NON-NLS-1$ - + String getFullyQualifiedTargetEntityClassName(); + String FULLY_QUALIFIED_TARGET_ENTITY_CLASS_NAME_PROPERTY = "fullyQualifiedTargetEntityClassName"; //$NON-NLS-1$ + + /** - * Corresponds to the fetch element of the relationship - * annotations (ManyToMany, OneToMany, ManyToOne, OneToOne). - * Returns null if the fetch element does not exist in java. + * Corresponds to the 'fetch' element of the relationship mapping annotations. + * Return null if the element does not exist in Java. */ FetchType getFetch(); + String FETCH_PROPERTY = "fetch"; //$NON-NLS-1$ /** - * Corresponds to the fetch element of the relationship - * annotations (ManyToMany, OneToMany, ManyToOne, OneToOne). - * Set to null to remove the fetch element. + * Corresponds to the 'fetch' element of the relationship annotations. + * Set to null to remove the element. */ void setFetch(FetchType fetch); - String FETCH_PROPERTY = "fetch"; //$NON-NLS-1$ + /** + * Return the {@link TextRange} for the 'fetch' element. If the element + * does not exist return the {@link TextRange} for the relationship mapping annotation. + */ + TextRange getFetchTextRange(CompilationUnit astRoot); + + + /** + * Corresponds to the 'cascade' element of the relationship annotations. + */ boolean isCascadeAll(); - void setCascadeAll(boolean all); String CASCADE_ALL_PROPERTY = "cascadeAll"; //$NON-NLS-1$ + + /** + * Corresponds to the 'cascade' element of the relationship annotations. + */ + void setCascadeAll(boolean all); + /** + * Corresponds to the 'cascade' element of the relationship annotations. + */ boolean isCascadeMerge(); + String CASCADE_MERGE_PROPERTY = "cascadeMerge"; //$NON-NLS-1$ + + /** + * Corresponds to the 'cascade' element of the relationship annotations. + */ void setCascadeMerge(boolean merge); - String CASCADE_MERGE_PROPERTY = "cascadeMerge"; //$NON-NLS-1$ + /** + * Corresponds to the 'cascade' element of the relationship annotations. + */ boolean isCascadePersist(); - void setCascadePersist(boolean persist); String CASCADE_PERSIST_PROPERTY = "cascadePersist"; //$NON-NLS-1$ + /** + * Corresponds to the 'cascade' element of the relationship annotations. + */ + void setCascadePersist(boolean persist); + + /** + * Corresponds to the 'cascade' element of the relationship annotations. + */ boolean isCascadeRefresh(); - void setCascadeRefresh(boolean refresh); String CASCADE_REFRESH_PROPERTY = "cascadeRefresh"; //$NON-NLS-1$ - boolean isCascadeRemove(); - void setCascadeRemove(boolean remove); - String CASCADE_REMOVE_PROPERTY = "cascadeRemove"; //$NON-NLS-1$ + /** + * Corresponds to the 'cascade' element of the relationship annotations. + */ + void setCascadeRefresh(boolean refresh); - /** - * Return the {@link TextRange} for the targetEntity element. If the targetEntity element - * does not exist return the {@link TextRange} for the mapping annotation. + * Corresponds to the 'cascade' element of the relationship annotations. */ - TextRange getTargetEntityTextRange(CompilationUnit astRoot); + boolean isCascadeRemove(); + String CASCADE_REMOVE_PROPERTY = "cascadeRemove"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the fetch element. If the fetch element - * does not exist return the {@link TextRange} for the mapping annotation. + * Corresponds to the 'cascade' element of the relationship annotations. */ - TextRange getFetchTextRange(CompilationUnit astRoot); + void setCascadeRemove(boolean remove); /** - * Return the {@link TextRange} for the cascade element. If the cascade element - * does not exist return the {@link TextRange} for the mapping annotation. + * Return the {@link TextRange} for the 'cascade' element. If the element + * does not exist return the {@link TextRange} for the relationship mapping annotation. */ TextRange getCascadeTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/TransientAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/TransientAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 TransientAnnotation.java --- src/org/eclipse/jpt/core/resource/java/TransientAnnotation.java 27 Mar 2008 00:17:08 -0000 1.1 +++ src/org/eclipse/jpt/core/resource/java/TransientAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * Corresponds to the javax.persistence.Transient annotation + * Corresponds to the JPA annotation + * javax.persistence.Transient * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,8 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface TransientAnnotation extends JavaResourceNode +public interface TransientAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.TRANSIENT; - } Index: src/org/eclipse/jpt/core/resource/java/IdClassAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/IdClassAnnotation.java,v retrieving revision 1.4 diff -u -r1.4 IdClassAnnotation.java --- src/org/eclipse/jpt/core/resource/java/IdClassAnnotation.java 22 Dec 2008 16:12:57 -0000 1.4 +++ src/org/eclipse/jpt/core/resource/java/IdClassAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * This interface corresponds to the javax.persistence.IdClass annotation + * This interface corresponds to the JPA annotation + * javax.persistence.IdClass * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,44 +22,44 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface IdClassAnnotation extends JavaResourceNode +public interface IdClassAnnotation + extends Annotation { final String ANNOTATION_NAME = JPA.ID_CLASS; /** - * Corresponds to the value element of the IdClass annotation. - * Returns null if the value element does not exist in java. - * Returns the portion of the value preceding the .class. - *

+ * Corresponds to the 'value' element of the IdClass annotation. + * Return null if the element does not exist in Java. + * Return the portion of the value preceding ".class". + *

 	 *     @IdClass(value=Employee.class)
-	 * 

+ *
* will return "Employee" - **/ - String getValue(); - - /** - * Corresponds to the value element of the IdClass annotation. - * Set to null to remove the value element. This will also remove the IdClass - * annotation itself. */ - void setValue(String value); + String getValue(); String VALUE_PROPERTY = "value"; //$NON-NLS-1$ - + /** - * Returns the qualified value name as it is resolved in the AST - *

- * @IdClass(Employee.class) - *

- * will return "model.Employee" if there is an import for model.Employee - * @return + * Corresponds to the 'value' element of the IdClass annotation. + * Set to null to remove the element. + * This will also remove the IdClass annotation itself. */ - String getFullyQualifiedClass(); - String FULLY_QUALIFIED_CLASS_PROPERTY = "fullyQualifiedClass"; //$NON-NLS-1$ + void setValue(String value); /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the IdClass annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); + /** + * Return the fully-qualified IdClass name as resolved by the AST's bindings. + *
+	 *     @IdClass(Employee.class)
+	 * 
+ * will return "model.Employee" if there is an import for model.Employee. + */ + String getFullyQualifiedClassName(); + String FULLY_QUALIFIED_CLASS_NAME_PROPERTY = "fullyQualifiedClassName"; //$NON-NLS-1$ + } Index: src/org/eclipse/jpt/core/resource/java/TemporalAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/TemporalAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 TemporalAnnotation.java --- src/org/eclipse/jpt/core/resource/java/TemporalAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/TemporalAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the javax.persistence.Temporal annotation + * Corresponds to the JPA annotation + * javax.persistence.Temporal * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,25 +22,26 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface TemporalAnnotation extends JavaResourceNode +public interface TemporalAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.TEMPORAL; /** - * Corresponds to the value element of the Temporal annotation. - * Returns null if the value element does not exist in java. + * Corresponds to the 'value' element of the Temporal annotation. + * Return null if the element does not exist in Java. */ TemporalType getValue(); + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Corresponds to the value element of the Temporal annotation. - * Set to null to remove the value element. + * Corresponds to the 'value' element of the Temporal annotation. + * Set to null to remove the element. */ void setValue(TemporalType value); - String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the Temporal annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/NestableAttributeOverride.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableAttributeOverride.java diff -N src/org/eclipse/jpt/core/resource/java/NestableAttributeOverride.java --- src/org/eclipse/jpt/core/resource/java/NestableAttributeOverride.java 28 Feb 2008 20:32:02 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.resource.java; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface NestableAttributeOverride - extends AttributeOverrideAnnotation, NestableAnnotation -{ - // nothing yet -} Index: src/org/eclipse/jpt/core/resource/java/NestableNamedNativeQuery.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableNamedNativeQuery.java diff -N src/org/eclipse/jpt/core/resource/java/NestableNamedNativeQuery.java --- src/org/eclipse/jpt/core/resource/java/NestableNamedNativeQuery.java 28 Feb 2008 20:32:02 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.resource.java; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface NestableNamedNativeQuery - extends NamedNativeQueryAnnotation, NestableAnnotation -{ - // nothing yet -} Index: src/org/eclipse/jpt/core/resource/java/EmbeddedAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/EmbeddedAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 EmbeddedAnnotation.java --- src/org/eclipse/jpt/core/resource/java/EmbeddedAnnotation.java 27 Mar 2008 00:17:09 -0000 1.1 +++ src/org/eclipse/jpt/core/resource/java/EmbeddedAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.Embedded * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,8 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface EmbeddedAnnotation extends JavaResourceNode +public interface EmbeddedAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.EMBEDDED; - } Index: src/org/eclipse/jpt/core/resource/java/DiscriminatorValueAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/DiscriminatorValueAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 DiscriminatorValueAnnotation.java --- src/org/eclipse/jpt/core/resource/java/DiscriminatorValueAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/DiscriminatorValueAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the javax.persistence.OrderBy annotation + * Corresponds to the JPA annotation + * javax.persistence.DiscriminatorValue * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,26 +22,26 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface DiscriminatorValueAnnotation extends JavaResourceNode +public interface DiscriminatorValueAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.DISCRIMINATOR_VALUE; /** - * Corresponds to the value element of the javax.persistence.OrderBy annotation. - * Returns null if the value valuePair does not exist in the annotation + * Corresponds to the 'value' element of the DiscriminatorValue annotation. + * Return null if the element does not exist in the annotation. */ String getValue(); + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Corresponds to the value element of the javax.persistence.OrderBy annotation. - * Setting the value to null will not remove the OrderBy annotation + * Corresponds to the 'value' element of the DiscriminatorValue annotation. */ void setValue(String value); - String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the value element. If value element - * does not exist return the {@link TextRange} for the DisriminatorValue annotation. + * Return the {@link TextRange} for the 'value' element. If the element + * does not exist return the {@link TextRange} for the DiscriminatorValue annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/NestablePrimaryKeyJoinColumn.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestablePrimaryKeyJoinColumn.java diff -N src/org/eclipse/jpt/core/resource/java/NestablePrimaryKeyJoinColumn.java --- src/org/eclipse/jpt/core/resource/java/NestablePrimaryKeyJoinColumn.java 28 Feb 2008 20:32:02 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.resource.java; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface NestablePrimaryKeyJoinColumn - extends PrimaryKeyJoinColumnAnnotation, NestableAnnotation -{ - // nothing yet -} Index: src/org/eclipse/jpt/core/resource/java/NestableSecondaryTable.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableSecondaryTable.java diff -N src/org/eclipse/jpt/core/resource/java/NestableSecondaryTable.java --- src/org/eclipse/jpt/core/resource/java/NestableSecondaryTable.java 28 Feb 2008 20:32:02 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.resource.java; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface NestableSecondaryTable - extends SecondaryTableAnnotation, NestableAnnotation -{ - // nothing yet -} Index: src/org/eclipse/jpt/core/resource/java/AccessAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AccessAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 AccessAnnotation.java --- src/org/eclipse/jpt/core/resource/java/AccessAnnotation.java 9 Jan 2009 20:52:54 -0000 1.1 +++ src/org/eclipse/jpt/core/resource/java/AccessAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the JPA 2.0 javax.persistence.Access annotation + * Corresponds to the JPA 2.0 annotation + * javax.persistence.Access * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -24,26 +25,27 @@ * @version 2.2 * @since 2.2 */ -public interface AccessAnnotation extends JavaResourceNode +public interface AccessAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.ACCESS; /** - * Corresponds to the value element of the Access annotation. - * Returns null if the value element does not exist in java. + * Corresponds to the 'value' element of the Access annotation. + * Returns null if the element does not exist in Java. */ AccessType getValue(); + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Corresponds to the value element of the Access annotation. - * Set to null to remove the value element. + * Corresponds to the 'value' element of the Access annotation. + * Set to null to remove the element. */ void setValue(AccessType access); - String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the Access annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/QueryHintAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/QueryHintAnnotation.java,v retrieving revision 1.5 diff -u -r1.5 QueryHintAnnotation.java --- src/org/eclipse/jpt/core/resource/java/QueryHintAnnotation.java 22 Dec 2008 16:12:57 -0000 1.5 +++ src/org/eclipse/jpt/core/resource/java/QueryHintAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the javax.persistence.QueryHint annotation + * Corresponds to the JPA annotation + * javax.persistence.QueryHint * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,44 +22,46 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface QueryHintAnnotation extends JavaResourceNode +public interface QueryHintAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.QUERY_HINT; /** - * Corresponds to the name element of the QueryHint annotation. - * Returns null if the name valuePair does not exist in the annotation + * Corresponds to the 'name' element of the QueryHint annotation. + * Return null if the element does not exist in the annotation */ String getName(); + String NAME_PROPERTY = "name"; //$NON-NLS-1$ /** - * Corresponds to the name element of the QueryHint annotation. - * Setting to null will remove the name valuePair + * Corresponds to the 'name' element of the QueryHint annotation. + * Setting to null will remove the element. */ void setName(String name); - String NAME_PROPERTY = "name"; //$NON-NLS-1$ /** - * Corresponds to the value element of the QueryHint annotation. - * Returns null if the value valuePair does not exist in the annotation + * Return the {@link TextRange} for the 'name' element. If the element + * does not exist return the {@link TextRange} for the QueryHint annotation. */ - String getValue(); - + TextRange getNameTextRange(CompilationUnit astRoot); + + /** - * Corresponds to the value element of the QueryHint annotation. - * Setting to null will remove the value valuePair + * Corresponds to the 'value' element of the QueryHint annotation. + * Return null if the element does not exist in the annotation */ - void setValue(String value); + String getValue(); String VALUE_PROPERTY = "value"; //$NON-NLS-1$ - + /** - * Return the {@link TextRange} for the name element. If the name element - * does not exist return the {@link TextRange} for the QueryHint annotation. + * Corresponds to the 'value' element of the QueryHint annotation. + * Setting to null will remove the element. */ - TextRange getNameTextRange(CompilationUnit astRoot); + void setValue(String value); /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the QueryHint annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/EnumeratedAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/EnumeratedAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 EnumeratedAnnotation.java --- src/org/eclipse/jpt/core/resource/java/EnumeratedAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/EnumeratedAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the javax.persistence.Enumerated annotation + * Corresponds to the JPA annotation + * javax.persistence.Enumerated * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,25 +22,26 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface EnumeratedAnnotation extends JavaResourceNode +public interface EnumeratedAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.ENUMERATED; /** - * Corresponds to the value element of the Enumerated annotation. - * Returns null if the value element does not exist in java. + * Corresponds to the 'value' element of the Enumerated annotation. + * Return null if the element does not exist in Java. */ EnumType getValue(); + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Corresponds to the value element of the Enumerated annotation. - * Set to null to remove the value element. + * Corresponds to the 'value' element of the Enumerated annotation. + * Set to null to remove the element. */ void setValue(EnumType value); - String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the Enumerated annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/NestableQueryHint.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableQueryHint.java diff -N src/org/eclipse/jpt/core/resource/java/NestableQueryHint.java --- src/org/eclipse/jpt/core/resource/java/NestableQueryHint.java 28 Feb 2008 20:32:02 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.resource.java; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface NestableQueryHint - extends QueryHintAnnotation, NestableAnnotation -{ - // nothing yet -} Index: src/org/eclipse/jpt/core/resource/java/PrimaryKeyJoinColumnsAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/PrimaryKeyJoinColumnsAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 PrimaryKeyJoinColumnsAnnotation.java --- src/org/eclipse/jpt/core/resource/java/PrimaryKeyJoinColumnsAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/PrimaryKeyJoinColumnsAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.PrimaryKeyJoinColumns * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,7 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface PrimaryKeyJoinColumnsAnnotation extends ContainerAnnotation +public interface PrimaryKeyJoinColumnsAnnotation + extends ContainerAnnotation { String ANNOTATION_NAME = JPA.PRIMARY_KEY_JOIN_COLUMNS; Index: src/org/eclipse/jpt/core/resource/java/GeneratedValueAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/GeneratedValueAnnotation.java,v retrieving revision 1.5 diff -u -r1.5 GeneratedValueAnnotation.java --- src/org/eclipse/jpt/core/resource/java/GeneratedValueAnnotation.java 17 Dec 2008 06:19:37 -0000 1.5 +++ src/org/eclipse/jpt/core/resource/java/GeneratedValueAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the javax.persistence.GeneratedValue annotation + * Corresponds to the JPA annotation + * javax.persistence.GeneratedValue * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -22,49 +23,53 @@ * will almost certainly be broken (repeatedly) as the API evolves. */ public interface GeneratedValueAnnotation - extends JavaResourceNode -{ + extends Annotation +{ String ANNOTATION_NAME = JPA.GENERATED_VALUE; /** - * Corresponds to the strategy element of the GeneratedValue annotation. - * Returns null if the strategy element does not exist in java. + * Corresponds to the 'strategy' element of the GeneratedValue annotation. + * Return null if the element does not exist in Java. */ GenerationType getStrategy(); - + String STRATEGY_PROPERTY = "strategy"; //$NON-NLS-1$ + /** - * Corresponds to the strategy element of the GeneratedValue annotation. - * Set to null to remove the strategy element. + * Corresponds to the 'strategy' element of the GeneratedValue annotation. + * Set to null to remove the element. */ void setStrategy(GenerationType strategy); - String STRATEGY_PROPERTY = "strategy"; //$NON-NLS-1$ - + /** - * Corresponds to the generator element of the GeneratedValue annotation. - * Returns null if the generator element does not exist in java. + * Return the {@link TextRange} for the 'strategy' element. If the element + * does not exist return the {@link TextRange} for the GeneratedValue annotation. + */ + TextRange getStrategyTextRange(CompilationUnit astRoot); + + + /** + * Corresponds to the 'generator' element of the GeneratedValue annotation. + * Return null if the element does not exist in Java. */ String getGenerator(); - + String GENERATOR_PROPERTY = "generator"; //$NON-NLS-1$ + /** - * Corresponds to the generator element of the GeneratedValue annotation. - * Set to null to remove the generator element. + * Corresponds to the 'generator' element of the GeneratedValue annotation. + * Set to null to remove the element. */ void setGenerator(String generator); - String GENERATOR_PROPERTY = "generator"; //$NON-NLS-1$ - - + /** - * Return the {@link TextRange} for the generator element. If the generator element + * Return the {@link TextRange} for the 'generator' element. If the element * does not exist return the {@link TextRange} for the GeneratedValue annotation. */ TextRange getGeneratorTextRange(CompilationUnit astRoot); /** - * Return the {@link TextRange} for the strategy element. If the strategy element - * does not exist return the {@link TextRange} for the GeneratedValue annotation. + * Return whether the specified position touches the 'generator' element. + * Return false if the element does not exist. */ - TextRange getStrategyTextRange(CompilationUnit astRoot); - boolean generatorTouches(int pos, CompilationUnit astRoot); } Index: src/org/eclipse/jpt/core/resource/java/GeneratorAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/GeneratorAnnotation.java,v retrieving revision 1.5 diff -u -r1.5 GeneratorAnnotation.java --- src/org/eclipse/jpt/core/resource/java/GeneratorAnnotation.java 12 Sep 2008 05:20:07 -0000 1.5 +++ src/org/eclipse/jpt/core/resource/java/GeneratorAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,9 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * + * Common protocol among + * javax.persistence.SequenceGenerator + * javax.persistence.TableGenerator * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -22,67 +24,66 @@ * will almost certainly be broken (repeatedly) as the API evolves. */ public interface GeneratorAnnotation - extends JavaResourceNode + extends Annotation { /** - * Corresponds to the name element of the TableGenerator or SequenceGenerator annotation. - * Returns null if the name element does not exist in java. If no other memberValuePairs exist - * the *Generator annotation will be removed as well. + * Corresponds to the 'name' element of the *Generator annotation. + * Return null if the element does not exist in Java. */ String getName(); - + String NAME_PROPERTY = "name"; //$NON-NLS-1$ + /** - * Corresponds to the name element of the TableGenerator or SequenceGenerator annotation. - * Set to null to remove the name element. If no other memberValuePairs exist + * Corresponds to the 'name' element of the *Generator annotation. + * Set to null to remove the element. If no other elements exist * the *Generator annotation will be removed as well. */ void setName(String name); - String NAME_PROPERTY = "name"; //$NON-NLS-1$ - + /** - * Corresponds to the initialValue element of the TableGenerator or SequenceGenerator annotation. - * Returns null if the initialValue element does not exist in java. If no other memberValuePairs exist - * the *Generator annotation will be removed as well. + * Return the {@link TextRange} for the 'name' element. If the element + * does not exist return the {@link TextRange} for the *Generator annotation. */ - Integer getInitialValue(); - + TextRange getNameTextRange(CompilationUnit astRoot); + + /** - * Corresponds to the initialValue element of the TableGenerator or SequenceGenerator annotation. - * Set to null to remove the initialValue element. If no other memberValuePairs exist - * the *Generator annotation will be removed as well. + * Corresponds to the 'initialValue' element of the *Generator annotation. + * Return null if the element does not exist in Java. */ - void setInitialValue(Integer initialValue); + Integer getInitialValue(); String INITIAL_VALUE_PROPERTY = "initialValue"; //$NON-NLS-1$ - + /** - * Corresponds to the allocationSize element of the TableGenerator or SequenceGenerator annotation. - * Returns null if the allocationSize element does not exist in java. If no other memberValuePairs exist + * Corresponds to the 'initialValue' element of the *Generator annotation. + * Set to null to remove the element. If no other elements exist * the *Generator annotation will be removed as well. */ - Integer getAllocationSize(); - + void setInitialValue(Integer initialValue); + /** - * Corresponds to the allocationSize element of the TableGenerator or SequenceGenerator annotation. - * Set to null to remove the allocationSize element. If no other memberValuePairs exist - * the *Generator annotation will be removed as well. + * Return the {@link TextRange} for the 'initialValue' element. If the element + * does not exist return the {@link TextRange} for the *Generator annotation. */ - void setAllocationSize(Integer allocationSize); - String ALLOCATION_SIZE_PROPERTY = "allocationSize"; //$NON-NLS-1$ - + TextRange getInitialValueTextRange(CompilationUnit astRoot); + + /** - * Return the {@link TextRange} for the name element. If the name element - * does not exist return the {@link TextRange} for the *Generator annotation. + * Corresponds to the 'allocationSize' element of the *Generator annotation. + * Return null if the element does not exist in Java. */ - TextRange getNameTextRange(CompilationUnit astRoot); + Integer getAllocationSize(); + String ALLOCATION_SIZE_PROPERTY = "allocationSize"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the initialValue element. If the initialValue element - * does not exist return the {@link TextRange} for the *Generator annotation. + * Corresponds to the 'allocationSize' element of the *Generator annotation. + * Set to null to remove the element. If no other elements exist + * the *Generator annotation will be removed as well. */ - TextRange getInitialValueTextRange(CompilationUnit astRoot); + void setAllocationSize(Integer allocationSize); /** - * Return the {@link TextRange} for the allocationSize element. If the allocationSize element + * Return the {@link TextRange} for the 'allocationSize' element. If the element * does not exist return the {@link TextRange} for the *Generator annotation. */ TextRange getAllocationSizeTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/NestableUniqueConstraint.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableUniqueConstraint.java diff -N src/org/eclipse/jpt/core/resource/java/NestableUniqueConstraint.java --- src/org/eclipse/jpt/core/resource/java/NestableUniqueConstraint.java 27 Mar 2008 00:17:08 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.resource.java; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface NestableUniqueConstraint - extends UniqueConstraintAnnotation, NestableAnnotation -{ - // nothing yet -} Index: src/org/eclipse/jpt/core/resource/java/BasicAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/BasicAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 BasicAnnotation.java --- src/org/eclipse/jpt/core/resource/java/BasicAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/BasicAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * + * Corresponds to the JPA annotation + * javax.persistence.Basic * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,45 +22,46 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface BasicAnnotation extends JavaResourceNode +public interface BasicAnnotation + extends Annotation { - String ANNOTATION_NAME = JPA.BASIC; - + /** - * Corresponds to the fetch element of the Basic annotation. - * Returns null if the fetch element does not exist in java. + * Corresponds to the 'fetch' element of the Basic annotation. + * Return null if the element does not exist in Java. */ FetchType getFetch(); - + String FETCH_PROPERTY = "fetch"; //$NON-NLS-1$ + /** - * Corresponds to the fetch element of the Basic annotation. - * Set to null to remove the fetch element. + * Corresponds to the 'fetch' element of the Basic annotation. + * Set to null to remove the element. */ void setFetch(FetchType fetch); - String FETCH_PROPERTY = "fetch"; //$NON-NLS-1$ - + /** - * Corresponds to the optional element of the Basic annotation. - * Returns null if the optional element does not exist in java. + * Return the {@link TextRange} for the 'fetch' element. If the element + * does not exist return the {@link TextRange} for the Basic annotation. */ - Boolean getOptional(); - + TextRange getFetchTextRange(CompilationUnit astRoot); + + /** - * Corresponds to the optional element of the Basic annotation. - * Set to null to remove the optional element. + * Corresponds to the 'optional' element of the Basic annotation. + * Return null if the element does not exist in Java. */ - void setOptional(Boolean optional); + Boolean getOptional(); String OPTIONAL_PROPERTY = "optional"; //$NON-NLS-1$ - + /** - * Return the {@link TextRange} for the fetch element. If the fetch element - * does not exist return the {@link TextRange} for the Basic annotation. + * Corresponds to the 'optional' element of the Basic annotation. + * Set to null to remove the element. */ - TextRange getFetchTextRange(CompilationUnit astRoot); - + void setOptional(Boolean optional); + /** - * Return the {@link TextRange} for the optional element. If the optional element + * Return the {@link TextRange} for the 'optional' element. If the element * does not exist return the {@link TextRange} for the Basic annotation. */ TextRange getOptionalTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/OrderByAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/OrderByAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 OrderByAnnotation.java --- src/org/eclipse/jpt/core/resource/java/OrderByAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/OrderByAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the javax.persistence.OrderBy annotation + * Corresponds to the JPA annotation + * javax.persistence.OrderBy * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,25 +22,26 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface OrderByAnnotation extends JavaResourceNode +public interface OrderByAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.ORDER_BY; /** - * Corresponds to the value element of the javax.persistence.OrderBy annotation. - * Returns null if the value valuePair does not exist in the annotation + * Corresponds to the 'value' element of the OrderBy annotation. + * Return null if the element does not exist in the annotation. */ String getValue(); + String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Corresponds to the value element of the javax.persistence.OrderBy annotation. - * Setting the value to null will not remove the OrderBy annotation + * Corresponds to the 'value' element of the OrderBy annotation. + * Setting the element to null will not remove the OrderBy annotation. */ void setValue(String value); - String VALUE_PROPERTY = "value"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the value element. If the value element + * Return the {@link TextRange} for the 'value' element. If the element * does not exist return the {@link TextRange} for the OrderBy annotation. */ TextRange getValueTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/AnnotationDefinition.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AnnotationDefinition.java,v retrieving revision 1.9 diff -u -r1.9 AnnotationDefinition.java --- src/org/eclipse/jpt/core/resource/java/AnnotationDefinition.java 25 Mar 2009 21:34:28 -0000 1.9 +++ src/org/eclipse/jpt/core/resource/java/AnnotationDefinition.java 6 Apr 2009 20:59:18 -0000 @@ -9,15 +9,16 @@ ******************************************************************************/ package org.eclipse.jpt.core.resource.java; +import org.eclipse.jdt.core.IAnnotation; import org.eclipse.jpt.core.utility.jdt.Member; /** - * Used for building new Annotations. - * These should be used to define non-mapping annotations. If you - * want to provide new AnnotationDefinitions you will need - * to create a new JpaPlatform by extending GenericJpaPlatform. + * Used to build Annotations discovered in the Java source code. + * To provide new AnnotationDefinitions, create a new JpaPlatform + * by implementing JpaPlatform and/or extending GenericJpaPlatform. * - * @see MappingAnnotation + * @see Annotation + * @see org.eclipse.jpt.core.JpaPlatform * @see org.eclipse.jpt.core.internal.platform.GenericJpaPlatform * * Provisional API: This interface is part of an interim API that is still @@ -38,15 +39,15 @@ */ Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member); -// /** -// * Build and return an annotation for the specified JDT annotation. -// */ -// Annotation buildAnnotation(JarResourcePersistentMember parent, IAnnotation jdtAnnotation); -// + /** + * Build and return an annotation for the specified JDT annotation. + */ + Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation); + /** * Build and return a null annotation for the specified member. */ - Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member); + Annotation buildNullAnnotation(JavaResourcePersistentMember parent); // /** // * Build and return a null annotation. Index: src/org/eclipse/jpt/core/resource/java/QueryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/QueryAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/QueryAnnotation.java --- src/org/eclipse/jpt/core/resource/java/QueryAnnotation.java 22 Dec 2008 16:12:57 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.resource.java; - -import java.util.ListIterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface QueryAnnotation extends JavaResourceNode -{ - String getName(); - void setName(String name); - String NAME_PROPERTY = "name"; //$NON-NLS-1$ - - String getQuery(); - void setQuery(String query); - String QUERY_PROPERTY = "query"; //$NON-NLS-1$ - - ListIterator hints(); - - QueryHintAnnotation hintAt(int index); - - int indexOfHint(QueryHintAnnotation hint); - - int hintsSize(); - - QueryHintAnnotation addHint(int index); - - void removeHint(int index); - - void moveHint(int targetIndex, int sourceIndex); - String HINTS_LIST = "hints"; //$NON-NLS-1$ - - /** - * Return the {@link TextRange} for the name element. If name element - * does not exist return the {@link TextRange} for the *Query annotation. - */ - TextRange getNameTextRange(CompilationUnit astRoot); - - /** - * Return the {@link TextRange} for the query element. If query element - * does not exist return the {@link TextRange} for the *Query annotation. - */ - TextRange getQueryTextRange(CompilationUnit astRoot); - -} Index: src/org/eclipse/jpt/core/resource/java/VersionAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/VersionAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 VersionAnnotation.java --- src/org/eclipse/jpt/core/resource/java/VersionAnnotation.java 27 Mar 2008 00:17:08 -0000 1.1 +++ src/org/eclipse/jpt/core/resource/java/VersionAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * Corresponds to the javax.persistence.Version annotation + * Corresponds to the JPA annotation + * javax.persistence.Version * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,8 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface VersionAnnotation extends JavaResourceNode +public interface VersionAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.VERSION; - } Index: src/org/eclipse/jpt/core/resource/java/ContainerAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/ContainerAnnotation.java,v retrieving revision 1.3 diff -u -r1.3 ContainerAnnotation.java --- src/org/eclipse/jpt/core/resource/java/ContainerAnnotation.java 2 Sep 2008 20:38:09 -0000 1.3 +++ src/org/eclipse/jpt/core/resource/java/ContainerAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -9,10 +9,8 @@ ******************************************************************************/ package org.eclipse.jpt.core.resource.java; -import java.util.ListIterator; - /** - * + * Common behavior for all "container" annotations. * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,45 +18,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface ContainerAnnotation extends Annotation +public interface ContainerAnnotation + extends Annotation, AnnotationContainer { - /** - * Return the fully qualified nestable annotation name. - */ - String getNestableAnnotationName(); - - /** - * Return the element name of the nestable annotation when - * it is nested within the container annotation as a member value pair - */ - String getElementName(); - - ListIterator nestedAnnotations(); - - int nestedAnnotationsSize(); - - T nestedAnnotationAt(int index); - - T nestedAnnotationFor(org.eclipse.jdt.core.dom.Annotation jdtAnnotation); - - int indexOf(T nestedAnnotation); - - T add(int index); - - /** - * Add directly to the List without firing change notification. - */ - T addInternal(int index); - - void remove(T nestedAnnotation); - - void remove(int index); - - /** - * Move in the List without firing change notification. - */ - void moveInternal(int targetIndex, int sourceIndex); - - void move(int targetIndex, int sourceIndex); - + // combine two interfaces } Index: src/org/eclipse/jpt/core/resource/java/NamedNativeQueriesAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NamedNativeQueriesAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 NamedNativeQueriesAnnotation.java --- src/org/eclipse/jpt/core/resource/java/NamedNativeQueriesAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/NamedNativeQueriesAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.NamedNativeQueries * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,7 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface NamedNativeQueriesAnnotation extends ContainerAnnotation +public interface NamedNativeQueriesAnnotation + extends ContainerAnnotation { String ANNOTATION_NAME = JPA.NAMED_NATIVE_QUERIES; Index: src/org/eclipse/jpt/core/resource/java/SecondaryTablesAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/SecondaryTablesAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 SecondaryTablesAnnotation.java --- src/org/eclipse/jpt/core/resource/java/SecondaryTablesAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/SecondaryTablesAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.SecondaryTables * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,7 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface SecondaryTablesAnnotation extends ContainerAnnotation +public interface SecondaryTablesAnnotation + extends ContainerAnnotation { String ANNOTATION_NAME = JPA.SECONDARY_TABLES; Index: src/org/eclipse/jpt/core/resource/java/SecondaryTableAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/SecondaryTableAnnotation.java,v retrieving revision 1.3 diff -u -r1.3 SecondaryTableAnnotation.java --- src/org/eclipse/jpt/core/resource/java/SecondaryTableAnnotation.java 22 Dec 2008 16:12:57 -0000 1.3 +++ src/org/eclipse/jpt/core/resource/java/SecondaryTableAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -12,7 +12,8 @@ import java.util.ListIterator; /** - * + * Corresponds to the JPA annotation + * javax.persistence.SecondaryTable * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -20,23 +21,46 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface SecondaryTableAnnotation extends TableAnnotation +public interface SecondaryTableAnnotation + extends BaseTableAnnotation { String ANNOTATION_NAME = JPA.SECONDARY_TABLE; + /** + * Corresponds to the 'pkJoinColumns' element of the SecondaryTable annotation. + * Return an empty iterator if the element does not exist in Java. + */ ListIterator pkJoinColumns(); - + String PK_JOIN_COLUMNS_LIST = "pkJoinColumns"; //$NON-NLS-1$ + + /** + * Corresponds to the 'pkJoinColumns' element of the SecondaryTable annotation. + */ + int pkJoinColumnsSize(); + + /** + * Corresponds to the 'pkJoinColumns' element of the SecondaryTable annotation. + */ PrimaryKeyJoinColumnAnnotation pkJoinColumnAt(int index); - + + /** + * Corresponds to the 'pkJoinColumns' element of the SecondaryTable annotation. + */ int indexOfPkJoinColumn(PrimaryKeyJoinColumnAnnotation pkJoinColumn); - - int pkJoinColumnsSize(); + /** + * Corresponds to the 'pkJoinColumns' element of the SecondaryTable annotation. + */ PrimaryKeyJoinColumnAnnotation addPkJoinColumn(int index); - + + /** + * Corresponds to the 'pkJoinColumns' element of the SecondaryTable annotation. + */ void removePkJoinColumn(int index); - + + /** + * Corresponds to the 'pkJoinColumns' element of the SecondaryTable annotation. + */ void movePkJoinColumn(int targetIndex, int sourceIndex); - String PK_JOIN_COLUMNS_LIST = "pkJoinColumns"; //$NON-NLS-1$ } Index: src/org/eclipse/jpt/core/resource/java/OverrideAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/OverrideAnnotation.java,v retrieving revision 1.5 diff -u -r1.5 OverrideAnnotation.java --- src/org/eclipse/jpt/core/resource/java/OverrideAnnotation.java 22 Dec 2008 16:12:57 -0000 1.5 +++ src/org/eclipse/jpt/core/resource/java/OverrideAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,9 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the javax.persistence.AttributeOverride annotation + * Common protocol for + * javax.persistence.AttributeOverride + * javax.persistence.AssociationOverride * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,31 +23,32 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface OverrideAnnotation extends JavaResourceNode +public interface OverrideAnnotation + extends Annotation { /** - * Corresponds to the name element of the AttributeOverride annotation. - * Returns null if the name element does not exist in java. + * Corresponds to the 'name' element of the override annotations. + * Return null if the element does not exist in Java. */ String getName(); + String NAME_PROPERTY = "name"; //$NON-NLS-1$ /** - * Corresponds to the name element of the AttributeOverride annotation. - * Set to null to remove the name element. + * Corresponds to the 'name' element of the override annotations. + * Set to null to remove the element. */ void setName(String name); - String NAME_PROPERTY = "name"; //$NON-NLS-1$ /** - * Return the {@link TextRange} for the name element. If name element - * does not exist return the {@link TextRange} for the AttributeOverride annotation. + * Return the {@link TextRange} for the 'name' element. If element + * does not exist return the {@link TextRange} for the override annotation. */ TextRange getNameTextRange(CompilationUnit astRoot); /** - * Return whether the specified postition touches the table element. - * Return false if the table element does not exist. + * Return whether the specified position touches the 'name' element. + * Return false if the element does not exist in Java. */ boolean nameTouches(int pos, CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentAttribute.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentAttribute.java,v retrieving revision 1.10 diff -u -r1.10 JavaResourcePersistentAttribute.java --- src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentAttribute.java 10 Mar 2009 04:12:10 -0000 1.10 +++ src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentAttribute.java 6 Apr 2009 20:59:18 -0000 @@ -15,7 +15,7 @@ import org.eclipse.jpt.utility.MethodSignature; /** - * Java source code persistent attribute (field or property) + * Java source code or binary persistent attribute (field or property) * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -35,6 +35,15 @@ String getName(); /** + * Return a null mapping annotation with the specified name. + * Return null if the specified annotation name is null. + * The corresponding AnnotationDefinition must implement #buildNullAnnotation() + * {@link AnnotationDefinition#buildNullAnnotation(JavaResourcePersistentMember, + * org.eclipse.jpt.core.utility.jdt.Member)} + */ + Annotation getNullMappingAnnotation(String annotationName); + + /** * Whether the Java resource persistent attribute is a field does not change. */ boolean isField(); Index: src/org/eclipse/jpt/core/resource/java/NamedQueriesAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NamedQueriesAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 NamedQueriesAnnotation.java --- src/org/eclipse/jpt/core/resource/java/NamedQueriesAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/NamedQueriesAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.NamedQueries * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,7 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface NamedQueriesAnnotation extends ContainerAnnotation +public interface NamedQueriesAnnotation + extends ContainerAnnotation { String ANNOTATION_NAME = JPA.NAMED_QUERIES; Index: src/org/eclipse/jpt/core/resource/java/NamedNativeQueryAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NamedNativeQueryAnnotation.java,v retrieving revision 1.5 diff -u -r1.5 NamedNativeQueryAnnotation.java --- src/org/eclipse/jpt/core/resource/java/NamedNativeQueryAnnotation.java 22 Dec 2008 16:12:57 -0000 1.5 +++ src/org/eclipse/jpt/core/resource/java/NamedNativeQueryAnnotation.java 6 Apr 2009 20:59:19 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -14,7 +14,8 @@ /** - * Corresponds to the javax.persistence.NamedNativeQuery annotation + * Corresponds to the JPA annotation + * javax.persistence.NamedNativeQuery * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -22,48 +23,49 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface NamedNativeQueryAnnotation extends QueryAnnotation +public interface NamedNativeQueryAnnotation + extends BaseNamedQueryAnnotation { String ANNOTATION_NAME = JPA.NAMED_NATIVE_QUERY; /** - * Corresponds to the resultClass element of the NamedNativeQuery annotation. - * Returns null if the resultClass element does not exist in java. + * Corresponds to the 'resultClass' element of the NamedNativeQuery annotation. + * Return null if the element does not exist in Java. */ String getResultClass(); - + String RESULT_CLASS_PROPERTY = "resultClass"; //$NON-NLS-1$ + /** - * Corresponds to the resultClass element of the NamedNativeQuery annotation. - * Set to null to remove the resultClass element. + * Corresponds to the 'resultClass' element of the NamedNativeQuery annotation. + * Set to null to remove the element. */ void setResultClass(String resultClass); - String RESULT_CLASS_PROPERTY = "resultClass"; //$NON-NLS-1$ - + /** - * Corresponds to the resultSetMapping element of the NamedNativeQuery annotation. - * Returns null if the resultSetMapping element does not exist in java. + * Return the {@link TextRange} for the 'resultClass' element. If element + * does not exist return the {@link TextRange} for the NamedNativeQuery annotation. */ - String getResultSetMapping(); + TextRange getResultClassTextRange(CompilationUnit astRoot); + + String getFullyQualifiedResultClassName(); + String FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY = "fullyQualifiedResultClassName"; //$NON-NLS-1$ + /** - * Corresponds to the resultSetMapping element of the NamedNativeQuery annotation. - * Set to null to remove the resultSetMapping element. + * Corresponds to the 'resultSetMapping' element of the NamedNativeQuery annotation. + * Return null if the element does not exist in Java. */ - void setResultSetMapping(String resultSetMapping); + String getResultSetMapping(); String RESULT_SET_MAPPING_PROPERTY = "resultSetMapping"; //$NON-NLS-1$ - - String getFullyQualifiedResultClass(); - String FULLY_QUALIFIED_RESULT_CLASS_PROPERTY = "fullyQualifiedResultClass"; //$NON-NLS-1$ - + /** - * Return the {@link TextRange} for the resultClass element. If resultClass element - * does not exist return the {@link TextRange} for the NamedNativeQuery annotation. + * Corresponds to the 'resultSetMapping' element of the NamedNativeQuery annotation. + * Set to null to remove the element. */ - TextRange getResultClassTextRange(CompilationUnit astRoot); + void setResultSetMapping(String resultSetMapping); - /** - * Return the {@link TextRange} for the resultSetMapping element. If resultSetMapping element + * Return the {@link TextRange} for the 'resultSetMapping' element. If element * does not exist return the {@link TextRange} for the NamedNativeQuery annotation. */ TextRange getResultSetMappingTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/LobAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/LobAnnotation.java,v retrieving revision 1.1 diff -u -r1.1 LobAnnotation.java --- src/org/eclipse/jpt/core/resource/java/LobAnnotation.java 27 Mar 2008 00:17:09 -0000 1.1 +++ src/org/eclipse/jpt/core/resource/java/LobAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * Corresponds to the javax.persistence.Lob annotation + * Corresponds to the JPA annotation + * javax.persistence.Lob * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,8 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface LobAnnotation extends JavaResourceNode +public interface LobAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.LOB; - } Index: src/org/eclipse/jpt/core/resource/java/NamedColumnAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/NamedColumnAnnotation.java,v retrieving revision 1.5 diff -u -r1.5 NamedColumnAnnotation.java --- src/org/eclipse/jpt/core/resource/java/NamedColumnAnnotation.java 22 Dec 2008 16:12:57 -0000 1.5 +++ src/org/eclipse/jpt/core/resource/java/NamedColumnAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,11 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * + * Common protocol among + * javax.persistence.Column + * javax.persistence.JoinColumn + * javax.persistence.DiscriminatorColumn + * javax.persistence.PrimaryKeyJoinColumn. * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,50 +25,52 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface NamedColumnAnnotation extends JavaResourceNode +public interface NamedColumnAnnotation + extends Annotation { /** - * Corresponds to the name element of the *Column annotation. - * Returns null if the name valuePair does not exist in the annotation + * Corresponds to the 'name' element of the *Column annotation. + * Return null if the element does not exist in Java. */ String getName(); + String NAME_PROPERTY = "name"; //$NON-NLS-1$ /** - * Corresponds to the name element of the *Column annotation. - * Set to null to remove the name valuePair from the annotation + * Corresponds to the 'name' element of the *Column annotation. + * Set to null to remove the element. */ void setName(String name); - String NAME_PROPERTY = "name"; //$NON-NLS-1$ /** - * Corresponds to the columnDefinition element of the *Column annotation. - * Returns null if the columnDefinition valuePair does not exist in the annotation + * Return the {@link TextRange} for the 'name' element. If the element + * does not exist return the {@link TextRange} for the *Column annotation. */ - String getColumnDefinition(); - + TextRange getNameTextRange(CompilationUnit astRoot); + /** - * Corresponds to the columnDefinition element of the *Column annotation. - * Set to null to remove the columnDefinition valuePair from the annotation + * Return whether the specified position touches the 'name' element. + * Return false if the element does not exist. */ - void setColumnDefinition(String columnDefinition); - String COLUMN_DEFINITION_PROPERTY = "columnDefinition"; //$NON-NLS-1$ + boolean nameTouches(int pos, CompilationUnit astRoot); + /** - * Return the {@link TextRange} for the name element. If the name element - * does not exist return the {@link TextRange} for the *Column annotation. + * Corresponds to the 'columnDefinition' element of the *Column annotation. + * Return null if the element does not exist in Java. */ - TextRange getNameTextRange(CompilationUnit astRoot); - + String getColumnDefinition(); + String COLUMN_DEFINITION_PROPERTY = "columnDefinition"; //$NON-NLS-1$ + /** - * Return the {@link TextRange} for the columnDefinition element. If the columnDefinition - * element does not exist return the {@link TextRange} for the *Column annotation. + * Corresponds to the 'columnDefinition' element of the *Column annotation. + * Set to null to remove the element. */ - TextRange getColumnDefinitionTextRange(CompilationUnit astRoot); + void setColumnDefinition(String columnDefinition); /** - * Return whether the specified postition touches the name element. - * Return false if the name element does not exist. + * Return the {@link TextRange} for the 'columnDefinition' element. If the + * element does not exist return the {@link TextRange} for the *Column annotation. */ - boolean nameTouches(int pos, CompilationUnit astRoot); + TextRange getColumnDefinitionTextRange(CompilationUnit astRoot); } Index: src/org/eclipse/jpt/core/resource/java/InheritanceAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/InheritanceAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 InheritanceAnnotation.java --- src/org/eclipse/jpt/core/resource/java/InheritanceAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/InheritanceAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the javax.persistence.Inheritance annotation + * Corresponds to the JPA annotation + * javax.persistence.Inheritance * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,17 +22,26 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface InheritanceAnnotation extends JavaResourceNode +public interface InheritanceAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.INHERITANCE; + /** + * Corresponds to the 'strategy' element of the Inheritance annotation. + * Return null if the element does not exist in Java. + */ InheritanceType getStrategy(); - - void setStrategy(InheritanceType strategy); String STRATEGY_PROPERTY = "strategy"; //$NON-NLS-1$ - + + /** + * Corresponds to the 'strategy' element of the Inheritance annotation. + * Set to null to remove the element. + */ + void setStrategy(InheritanceType strategy); + /** - * Return the {@link TextRange} for the strategy element. If the strategy element + * Return the {@link TextRange} for the 'strategy' element. If the element * does not exist return the {@link TextRange} for the Inheritance annotation. */ TextRange getStrategyTextRange(CompilationUnit astRoot); Index: src/org/eclipse/jpt/core/resource/java/AssociationOverridesAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/AssociationOverridesAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 AssociationOverridesAnnotation.java --- src/org/eclipse/jpt/core/resource/java/AssociationOverridesAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/AssociationOverridesAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.AssociationOverrides * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,7 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface AssociationOverridesAnnotation extends ContainerAnnotation +public interface AssociationOverridesAnnotation + extends ContainerAnnotation { String ANNOTATION_NAME = JPA.ASSOCIATION_OVERRIDES; Index: src/org/eclipse/jpt/core/resource/java/NestableAssociationOverride.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableAssociationOverride.java diff -N src/org/eclipse/jpt/core/resource/java/NestableAssociationOverride.java --- src/org/eclipse/jpt/core/resource/java/NestableAssociationOverride.java 28 Feb 2008 20:32:03 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 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.resource.java; - -/** - * - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface NestableAssociationOverride - extends AssociationOverrideAnnotation, NestableAnnotation -{ - // nothing yet -} Index: src/org/eclipse/jpt/core/resource/java/EmbeddableAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/EmbeddableAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 EmbeddableAnnotation.java --- src/org/eclipse/jpt/core/resource/java/EmbeddableAnnotation.java 28 Feb 2008 20:32:02 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/EmbeddableAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * Corresponds to the javax.persistence.Embeddable annotation + * Corresponds to the JPA annotation + * javax.persistence.Embeddable * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,8 +19,8 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface EmbeddableAnnotation extends JavaResourceNode +public interface EmbeddableAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.EMBEDDABLE; - } Index: src/org/eclipse/jpt/core/resource/java/JoinColumnsAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JoinColumnsAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 JoinColumnsAnnotation.java --- src/org/eclipse/jpt/core/resource/java/JoinColumnsAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/JoinColumnsAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -10,7 +10,8 @@ package org.eclipse.jpt.core.resource.java; /** - * + * Corresponds to the JPA annotation + * javax.persistence.JoinColumns * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -18,10 +19,10 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface JoinColumnsAnnotation extends ContainerAnnotation +public interface JoinColumnsAnnotation + extends ContainerAnnotation { String ANNOTATION_NAME = JPA.JOIN_COLUMNS; - + String JOIN_COLUMNS_LIST = "joinColumns"; //$NON-NLS-1$ - } Index: src/org/eclipse/jpt/core/resource/java/MapKeyAnnotation.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/MapKeyAnnotation.java,v retrieving revision 1.2 diff -u -r1.2 MapKeyAnnotation.java --- src/org/eclipse/jpt/core/resource/java/MapKeyAnnotation.java 22 Dec 2008 16:12:57 -0000 1.2 +++ src/org/eclipse/jpt/core/resource/java/MapKeyAnnotation.java 6 Apr 2009 20:59:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * 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. @@ -13,7 +13,8 @@ import org.eclipse.jpt.core.utility.TextRange; /** - * Corresponds to the javax.persistence.MapKey annotation + * Corresponds to the JPA annotation + * javax.persistence.MapKey * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -21,23 +22,34 @@ * pioneering adopters on the understanding that any code that uses this API * will almost certainly be broken (repeatedly) as the API evolves. */ -public interface MapKeyAnnotation extends JavaResourceNode +public interface MapKeyAnnotation + extends Annotation { String ANNOTATION_NAME = JPA.MAP_KEY; - String getName(); - void setName(String name); + /** + * Corresponds to the 'name' element of the MapKey annotation. + * Returns null if the element does not exist in Java. + */ + String getName(); String NAME_PROPERTY = "name"; //$NON-NLS-1$ - + /** - * Return the {@link TextRange} for the name element. If the name element + * Corresponds to the 'name' element of the MapKey annotation. + * Set to null to remove the element. + */ + void setName(String name); + + /** + * Return the {@link TextRange} for the 'name' element. If the element * does not exist return the {@link TextRange} for the MapKey annotation. */ TextRange getNameTextRange(CompilationUnit astRoot); /** - * Return whether the specified postition touches the name element. - * Return false if the name element does not exist. + * Return whether the specified position touches the 'name' element. + * Return false if the element does not exist. */ - public boolean nameTouches(int pos, CompilationUnit astRoot); + boolean nameTouches(int pos, CompilationUnit astRoot); + } Index: src/org/eclipse/jpt/core/JpaFactory.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaFactory.java,v retrieving revision 1.38 diff -u -r1.38 JpaFactory.java --- src/org/eclipse/jpt/core/JpaFactory.java 1 Apr 2009 14:36:20 -0000 1.38 +++ src/org/eclipse/jpt/core/JpaFactory.java 6 Apr 2009 20:59:10 -0000 @@ -19,7 +19,7 @@ import org.eclipse.jpt.core.context.PersistentType; import org.eclipse.jpt.core.context.UniqueConstraint; import org.eclipse.jpt.core.context.XmlContextNode; -import org.eclipse.jpt.core.context.jar.JarFile; +import org.eclipse.jpt.core.context.java.JarFile; import org.eclipse.jpt.core.context.java.JavaAssociationOverride; import org.eclipse.jpt.core.context.java.JavaAttributeMapping; import org.eclipse.jpt.core.context.java.JavaAttributeOverride; @@ -106,7 +106,7 @@ import org.eclipse.jpt.core.context.persistence.Persistence; import org.eclipse.jpt.core.context.persistence.PersistenceUnit; import org.eclipse.jpt.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; +import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; @@ -414,6 +414,6 @@ // ********** JAR Context Model ********** - JarFile buildJarFile(JarFileRef parent, JarResourcePackageFragmentRoot jarResourcePackageFragmentRoot); + JarFile buildJarFile(JarFileRef parent, JavaResourcePackageFragmentRoot jarResourcePackageFragmentRoot); } Index: src/org/eclipse/jpt/core/JpaAnnotationProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaAnnotationProvider.java,v retrieving revision 1.9 diff -u -r1.9 JpaAnnotationProvider.java --- src/org/eclipse/jpt/core/JpaAnnotationProvider.java 10 Mar 2009 04:12:10 -0000 1.9 +++ src/org/eclipse/jpt/core/JpaAnnotationProvider.java 6 Apr 2009 20:59:10 -0000 @@ -12,8 +12,6 @@ import java.util.ListIterator; import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.resource.jar.JarResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.jar.JarResourcePersistentType; import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; @@ -60,21 +58,7 @@ * Throw an IllegalArgumentException if the specified annotation is unsupported. * @see #typeMappingAnnotationNames() */ - Annotation buildTypeMappingAnnotation(JarResourcePersistentType parent, IAnnotation jdtAnnotation); - - /** - * Build a null type mapping annotation with the specified name. - * Throw an IllegalArgumentException if the specified name is unsupported. - * @see #typeMappingAnnotationNames() - */ - Annotation buildNullTypeMappingAnnotation(JavaResourcePersistentType parent, Type type, String annotationName); - - /** - * Build a null type mapping annotation with the specified name. - * Throw an IllegalArgumentException if the specified name is unsupported. - * @see #typeMappingAnnotationNames() - */ - Annotation buildNullTypeMappingAnnotation(JarResourcePersistentType parent, String annotationName); + Annotation buildTypeMappingAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation); /** * Return the names of the supporting annotations that can modify a type. @@ -93,21 +77,14 @@ * Throw an IllegalArgumentException if the specified annotation is unsupported. * @see #typeSupportingAnnotationNames() */ - Annotation buildTypeSupportingAnnotation(JarResourcePersistentType parent, IAnnotation jdtAnnotation); - - /** - * Build a null type supporting annotation with the specified name. - * Throw an IllegalArgumentException if the specified name is unsupported. - * @see #typeSupportingAnnotationNames() - */ - Annotation buildNullTypeSupportingAnnotation(JavaResourcePersistentType parent, Type type, String annotationName); + Annotation buildTypeSupportingAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation); /** * Build a null type supporting annotation with the specified name. * Throw an IllegalArgumentException if the specified name is unsupported. * @see #typeSupportingAnnotationNames() */ - Annotation buildNullTypeSupportingAnnotation(JarResourcePersistentType parent, String annotationName); + Annotation buildNullTypeSupportingAnnotation(JavaResourcePersistentType parent, String annotationName); // ********** attribute annotations ********** @@ -129,21 +106,16 @@ * Throw an IllegalArgumentException if the specified annotation is unsupported. * @see #attributeMappingAnnotationNames() */ - Annotation buildAttributeMappingAnnotation(JarResourcePersistentAttribute parent, IAnnotation jdtAnnotation); - - /** - * Build a null attribute mapping annotation with the specified name. - * Throw an IllegalArgumentException if the specified name is unsupported. - * @see #attributeMappingAnnotationNames() - */ - Annotation buildNullAttributeMappingAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute, String annotationName); + Annotation buildAttributeMappingAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation); /** * Build a null attribute mapping annotation with the specified name. * Throw an IllegalArgumentException if the specified name is unsupported. + * This is used by an attribute's "default" mapping, since there is no + * annotation present (thus the "default" part...). * @see #attributeMappingAnnotationNames() */ - Annotation buildNullAttributeMappingAnnotation(JarResourcePersistentAttribute parent, String annotationName); + Annotation buildNullAttributeMappingAnnotation(JavaResourcePersistentAttribute parent, String annotationName); /** * Return the names of the supporting annotations that can modify an attribute. @@ -162,20 +134,13 @@ * Throw an IllegalArgumentException if the specified annotation is unsupported. * @see #attributeSupportingAnnotationNames() */ - Annotation buildAttributeSupportingAnnotation(JarResourcePersistentAttribute parent, IAnnotation jdtAnnotation); - - /** - * Build a null attribute supporting annotation with the specified name. - * Throw an IllegalArgumentException if the specified name is unsupported. - * @see #attributeSupportingAnnotationNames() - */ - Annotation buildNullAttributeSupportingAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute, String annotationName); + Annotation buildAttributeSupportingAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation); /** * Build a null attribute supporting annotation with the specified name. * Throw an IllegalArgumentException if the specified name is unsupported. * @see #attributeSupportingAnnotationNames() */ - Annotation buildNullAttributeSupportingAnnotation(JarResourcePersistentAttribute parent, String annotationName); + Annotation buildNullAttributeSupportingAnnotation(JavaResourcePersistentAttribute parent, String annotationName); } Index: src/org/eclipse/jpt/core/JpaProject.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProject.java,v retrieving revision 1.30 diff -u -r1.30 JpaProject.java --- src/org/eclipse/jpt/core/JpaProject.java 10 Mar 2009 04:12:10 -0000 1.30 +++ src/org/eclipse/jpt/core/JpaProject.java 6 Apr 2009 20:59:11 -0000 @@ -20,7 +20,7 @@ import org.eclipse.jdt.core.ElementChangedEvent; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jpt.core.context.JpaRootContextNode; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; +import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.xml.JpaXmlResource; import org.eclipse.jpt.db.Catalog; @@ -151,14 +151,11 @@ */ JavaResourcePersistentType getJavaResourcePersistentType(String typeName); - - // ********** JAR resources ********** - /** - * Return the JAR resource package fragement root for the specified JAR. + * Return the Java resource package fragement root for the specified JAR. * Return null if absent. */ - JarResourcePackageFragmentRoot getJarResourcePackageFragmentRoot(String jarFileName); + JavaResourcePackageFragmentRoot getJavaResourcePackageFragmentRoot(String jarFileName); // ********** model synchronization ********** Index: src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePackageFragmentImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePackageFragmentImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePackageFragmentImpl.java --- src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePackageFragmentImpl.java 10 Mar 2009 04:12:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,206 +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.jar; - -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.internal.utility.jdt.JPTTools; -import org.eclipse.jpt.core.resource.jar.JarResourceClassFile; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragment; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * JAR package fragment - */ -public class JarResourcePackageFragmentImpl - extends AbstractJarResourceNode - implements JarResourcePackageFragment -{ - /** JDT package fragment */ - private final IPackageFragment packageFragment; - - /** class files in the package fragment */ - private final Vector classFiles; - - - // ********** construction/initialization ********** - - public JarResourcePackageFragmentImpl(JarResourcePackageFragmentRoot parent, IPackageFragment packageFragment) { - super(parent); - this.packageFragment = packageFragment; - this.classFiles = this.buildClassFiles(); - } - - protected Vector buildClassFiles() { - Vector result = new Vector(); - for (IJavaElement child : this.getJDTChildren()) { - IClassFile classFile = (IClassFile) child; - IType type = classFile.getType(); - if (JPTTools.typeIsPersistable(new JPTToolsAdapter(type))) { // we only hold persistable types - result.add(new JarResourceClassFileImpl(this, classFile)); - } - } - return result; - } - - protected 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]; - - - // ********** JarResourceNode implementation ********** - - @Override - public void update() { - super.update(); - // TODO - } - - - // ********** JarResourcePackageFragment implementation ********** - - public IPackageFragment getPackageFragment() { - return this.packageFragment; - } - - public ListIterator classFiles() { - return new CloneListIterator(this.classFiles); - } - - public int classFilesSize() { - return this.classFiles.size(); - } - - public Iterator persistableTypes() { - return new TransformationIterator(this.classFiles()) { - @Override - protected JavaResourcePersistentType transform(JarResourceClassFile classFile) { - return classFile.getPersistentType(); // we only hold persistable types - } - }; - } - - - // ********** misc ********** - - @Override - public void toString(StringBuilder sb) { - sb.append(this.packageFragment.getElementName()); - } - - - // ********** JPT tools adapter ********** - - /** - * JPTTools needs an adapter so it can work with either an IType - * or an ITypeBinding etc. - */ - protected 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; // ??? - } - - } - -} Index: src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePersistentTypeImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePersistentTypeImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePersistentTypeImpl.java --- src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePersistentTypeImpl.java 10 Mar 2009 04:12:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,397 +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.jar; - -import java.util.Collection; -import java.util.Iterator; -import java.util.ListIterator; -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.jar.JarResourceClassFile; -import org.eclipse.jpt.core.resource.jar.JarResourcePersistentType; -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.iterators.CloneIterator; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; - -/** - * JAR persistent type - */ -public class JarResourcePersistentTypeImpl - extends AbstractJarResourcePersistentMember - implements JarResourcePersistentType -{ - private String name; - - private String qualifiedName; - - private String superClassQualifiedName; - - private boolean abstract_; // 'abstract' is a reserved word - - private final Vector fields; - - private final Vector methods; - - private AccessType access; - - - // ********** construction/initialization ********** - - public JarResourcePersistentTypeImpl(JarResourceClassFile parent, IType type) { - super(parent, new TypeAdapter(type)); - this.name = type.getElementName(); - this.qualifiedName = type.getFullyQualifiedName(); - this.superClassQualifiedName = this.buildSuperClassQualifiedName(type); - this.abstract_ = this.buildAbstract(type); - this.fields = this.buildFields(type); - this.methods = this.buildMethods(type); - // need to wait until everything is built to calculate 'access' - this.access = this.buildAccess(); - } - - - // ********** AbstractJarResourcePersistentMember implementation ********** - - @Override - protected Annotation buildMappingAnnotation(IAnnotation jdtAnnotation) { - return this.getAnnotationProvider().buildTypeMappingAnnotation(this, jdtAnnotation); - } - - @Override - protected Annotation buildNullMappingAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullTypeMappingAnnotation(this, annotationName); - } - - @Override - protected Annotation buildSupportingAnnotation(IAnnotation jdtAnnotation) { - return this.getAnnotationProvider().buildTypeSupportingAnnotation(this, jdtAnnotation); - } - - @Override - protected Annotation buildNullSupportingAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullTypeSupportingAnnotation(this, annotationName); - } - - @Override - protected ListIterator validMappingAnnotationNames() { - return this.getAnnotationProvider().typeMappingAnnotationNames(); - } - - @Override - protected ListIterator validSupportingAnnotationNames() { - return this.getAnnotationProvider().typeSupportingAnnotationNames(); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.name); - } - - - // ********** JarResourcePersistentType implementation ********** - - public String getName() { - return this.name; - } - - public String getQualifiedName() { - return this.qualifiedName; - } - - // ***** superclass qualified name - public String getSuperClassQualifiedName() { - return this.superClassQualifiedName; - } - - protected void setSuperClassQualifiedName(String superClassQualifiedName) { - String old = this.superClassQualifiedName; - this.superClassQualifiedName = superClassQualifiedName; - this.firePropertyChanged(SUPER_CLASS_QUALIFIED_NAME_PROPERTY, old, superClassQualifiedName); - } - - protected String buildSuperClassQualifiedName(IType type) { - try { - return type.getSuperclassName(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - // ***** abstract - public boolean isAbstract() { - return this.abstract_; - } - - protected void setAbstract(boolean abstract_) { - boolean old = this.abstract_; - this.abstract_ = abstract_; - this.firePropertyChanged(ABSTRACT_PROPERTY, old, abstract_); - } - - protected boolean buildAbstract(IType type) { - try { - return Flags.isAbstract(type.getFlags()); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** access - public AccessType getAccess() { - return this.access; - } - - protected void setAccess(AccessType access) { - AccessType old = this.access; - this.access = access; - this.firePropertyChanged(ACCESS_PROPERTY, old, access); - } - - protected AccessType buildAccess() { - return JPTTools.buildAccess(this); - } - - /** - * check only persistable attributes - */ - public boolean hasAnyAttributePersistenceAnnotations() { - for (Iterator stream = this.persistableAttributes(); stream.hasNext(); ) { - if (stream.next().hasAnyPersistenceAnnotations()) { - return true; - } - } - return false; - } - - @Override - public IType getMember() { - return (IType) super.getMember(); - } - - - // ********** fields ********** - - public Iterator fields() { - return new CloneIterator(this.fields); - } - - public Iterator persistableFields() { - return persistableMembers(this.fields()); - } - - public Iterator persistableFieldsWithSpecifiedFieldAccess() { - return new FilteringIterator(this.persistableFields()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.FIELD; - } - }; - } - - protected void addField(JavaResourcePersistentAttribute field) { - this.addItemToCollection(field, this.fields, FIELDS_COLLECTION); - } - - protected JavaResourcePersistentAttribute getField(String fieldName, int occurrence) { - synchronized (this.fields) { - for (JavaResourcePersistentAttribute field : this.fields) { - if (field.isFor(fieldName, occurrence)) { - return field; - } - } - } - return null; - } - - protected void removeFields(Collection remove) { - this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION); - } - - protected Vector buildFields(IType type) { - IField[] jdtFields = this.getFields(type); - Vector result = new Vector(jdtFields.length); - for (IField jdtField : jdtFields) { - result.add(this.buildField(jdtField)); - } - return result; - } - - protected IField[] getFields(IType type) { - try { - return type.getFields(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_FIELD_ARRAY; - } - } - protected static final IField[] EMPTY_FIELD_ARRAY = new IField[0]; - - protected JavaResourcePersistentAttribute buildField(IField jdtField) { - return new JarResourcePersistentAttributeImpl(this, jdtField); - } - - - // ********** methods ********** - - public Iterator methods() { - return new CloneIterator(this.methods); - } - - public Iterator persistableProperties() { - return persistableMembers(this.methods()); - } - - public Iterator persistablePropertiesWithSpecifiedPropertyAccess() { - return new FilteringIterator(this.persistableProperties()) { - @Override - protected boolean accept(JavaResourcePersistentAttribute resourceAttribute) { - return resourceAttribute.getSpecifiedAccess() == AccessType.PROPERTY; - } - }; - } - - protected JavaResourcePersistentAttribute getMethod(MethodSignature signature, int occurrence) { - synchronized (this.methods) { - for (JavaResourcePersistentAttribute method : this.methods) { - if (method.isFor(signature, occurrence)) { - return method; - } - } - } - return null; - } - - protected void addMethod(JavaResourcePersistentAttribute method) { - this.addItemToCollection(method, this.methods, METHODS_COLLECTION); - } - - protected void removeMethods(Collection remove) { - this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION); - } - - protected Vector buildMethods(IType type) { - IMethod[] jdtMethods = this.getMethods(type); - Vector result = new Vector(jdtMethods.length); - for (IMethod jdtMethod : jdtMethods) { - result.add(this.buildMethod(jdtMethod)); - } - return result; - } - - protected IMethod[] getMethods(IType type) { - try { - return type.getMethods(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_METHOD_ARRAY; - } - } - protected static final IMethod[] EMPTY_METHOD_ARRAY = new IMethod[0]; - - protected JavaResourcePersistentAttribute buildMethod(IMethod jdtMethod) { - return new JarResourcePersistentAttributeImpl(this, jdtMethod); - } - - - // ********** attributes ********** - - @SuppressWarnings("unchecked") - public Iterator persistableAttributes() { - return new CompositeIterator( - this.persistableFields(), - this.persistableProperties() - ); - } - - public Iterator 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") - public Iterator persistableAttributesForFieldAccessType() { - return new CompositeIterator( - this.persistableFields(), - this.persistablePropertiesWithSpecifiedPropertyAccess() - ); - } - - @SuppressWarnings("unchecked") - public Iterator persistableAttributesForPropertyAccessType() { - return new CompositeIterator( - this.persistableProperties(), - this.persistableFieldsWithSpecifiedFieldAccess() - ); - } - - - // ********** updating ********** - - @Override - public void update() { - super.update(); - // TODO - } - - protected static class TypeAdapter implements Adapter { - private final IType type; - - protected 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(); - } - - } - - // ============== TODO remove... ======================== - public Iterator types() { - throw new UnsupportedOperationException(); - } - public Iterator allTypes() { - throw new UnsupportedOperationException(); - } - public Iterator persistableTypes() { - throw new UnsupportedOperationException(); - } - public Iterator allPersistableTypes() { - return null; - } -} Index: src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePackageFragmentRootImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePackageFragmentRootImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePackageFragmentRootImpl.java --- src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePackageFragmentRootImpl.java 10 Mar 2009 04:12:10 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,168 +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.jar; - -import java.util.Iterator; -import java.util.ListIterator; -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.JpaResourceModelListener; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragment; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.internal.ListenerList; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * JAR package fragment root - */ -public class JarResourcePackageFragmentRootImpl - extends AbstractJarResourceNode - implements JarResourcePackageFragmentRoot -{ - /** JDT package fragment root */ - private final IPackageFragmentRoot packageFragmentRoot; - - /** pluggable annotation provider */ - private final JpaAnnotationProvider annotationProvider; - - /** listeners notified whenever the resource model changes */ - private final ListenerList resourceModelListenerList; - - /** package fragments in the JAR */ - private final Vector packageFragments; - - - // ********** construction/initialization ********** - - public JarResourcePackageFragmentRootImpl(IPackageFragmentRoot packageFragmentRoot, JpaAnnotationProvider annotationProvider) { - super(null); // the package fragment root is the root of its sub-tree - this.packageFragmentRoot = packageFragmentRoot; - this.annotationProvider = annotationProvider; - this.resourceModelListenerList = new ListenerList(JpaResourceModelListener.class); - this.packageFragments = this.buildPackageFragments(); - } - - protected Vector buildPackageFragments() { - Vector result = new Vector(); - for (IJavaElement pf : this.getJDTChildren()) { - result.add(new JarResourcePackageFragmentImpl(this, (IPackageFragment) pf)); - } - return result; - } - - protected IJavaElement[] getJDTChildren() { - try { - return this.packageFragmentRoot.getChildren(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_JAVA_ELEMENT_ARRAY; - } - } - protected static final IJavaElement[] EMPTY_JAVA_ELEMENT_ARRAY = new IJavaElement[0]; - - - // ********** AbstractJarResourceNode overrides ********** - - @Override - protected boolean requiresParent() { - return false; - } - - @Override - public JarResourcePackageFragmentRoot getRoot() { - return this; - } - - @Override - public IFile getFile() { - return (IFile) this.packageFragmentRoot.getResource(); - } - - @Override - public JpaAnnotationProvider getAnnotationProvider() { - return this.annotationProvider; - } - - - // ********** JarResourceNode implementation ********** - - @Override - public void update() { - super.update(); - // TODO - } - - - // ********** JavaResourceNode.Root implementation ********** - - public Iterator persistableTypes() { - return new CompositeIterator(this.persistableTypeIterators()); - } - - protected Iterator> persistableTypeIterators() { - return new TransformationIterator>(this.packageFragments()) { - @Override - protected Iterator transform(JarResourcePackageFragment pf) { - return pf.persistableTypes(); - } - }; - } - - 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); - } - - - // ********** JarResourcePackageFragmentRoot implementation ********** - - public IPackageFragmentRoot getPackageFragmentRoot() { - return this.packageFragmentRoot; - } - - public ListIterator packageFragments() { - return new CloneListIterator(this.packageFragments); - } - - public int packageFragmentsSize() { - return this.packageFragments.size(); - } - - - // ********** misc ********** - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getFile().getName()); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePersistentAttributeImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePersistentAttributeImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePersistentAttributeImpl.java --- src/org/eclipse/jpt/core/internal/resource/jar/JarResourcePersistentAttributeImpl.java 10 Mar 2009 04:12:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,628 +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.jar; - -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.resource.jar.JarResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.jar.JarResourcePersistentType; -import org.eclipse.jpt.core.resource.java.AccessAnnotation; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.Annotation; -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; - -/** - * JAR persistent attribute (field or property) - */ -public class JarResourcePersistentAttributeImpl - extends AbstractJarResourcePersistentMember - implements JarResourcePersistentAttribute -{ - private int modifiers; - - private String typeName; - - private boolean typeIsInterface; - - private boolean typeIsEnum; - - private final Vector typeSuperclassNames = new Vector(); - - private final Vector typeInterfaceNames = new Vector(); - - private final Vector typeTypeArgumentNames = new Vector(); - - - protected JarResourcePersistentAttributeImpl(JarResourcePersistentType parent, IField field) { - this(parent, new FieldAdapter(field)); - } - - protected JarResourcePersistentAttributeImpl(JarResourcePersistentType parent, IMethod method) { - this(parent, new MethodAdapter(method)); - } - - protected JarResourcePersistentAttributeImpl(JarResourcePersistentType parent, Adapter adapter) { - super(parent, adapter); - this.modifiers = this.buildModifiers(); - this.typeName = this.buildTypeName(); - this.typeIsInterface = this.buildTypeIsInterface(); - this.typeIsEnum = this.buildTypeIsEnum(); - this.typeSuperclassNames.addAll(this.buildTypeSuperclassNames()); - this.typeInterfaceNames.addAll(this.buildTypeInterfaceNames()); - this.typeTypeArgumentNames.addAll(this.buildTypeTypeArgumentNames()); - } - - - // ******** overrides ******** - - @Override - public void update() { - super.update(); - // TODO - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.getName()); - } - - - // ********** AbstractJarResourcePersistentMember implementation ********** - - @Override - protected Adapter getAdapter() { - return (Adapter) super.getAdapter(); - } - - @Override - protected Annotation buildMappingAnnotation(IAnnotation jdtAnnotation) { - return this.getAnnotationProvider().buildAttributeMappingAnnotation(this, jdtAnnotation); - } - - @Override - protected Annotation buildSupportingAnnotation(IAnnotation jdtAnnotation) { - return this.getAnnotationProvider().buildAttributeSupportingAnnotation(this, jdtAnnotation); - } - - @Override - protected Annotation buildNullSupportingAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullAttributeSupportingAnnotation(this, annotationName); - } - - @Override - protected Annotation buildNullMappingAnnotation(String annotationName) { - return this.getAnnotationProvider().buildNullAttributeMappingAnnotation(this, annotationName); - } - - @Override - protected ListIterator validMappingAnnotationNames() { - return this.getAnnotationProvider().attributeMappingAnnotationNames(); - } - - @Override - protected ListIterator validSupportingAnnotationNames() { - return this.getAnnotationProvider().attributeSupportingAnnotationNames(); - } - - - // ********** JarResourcePersistentAttribute implementation ********** - - public String getName() { - return this.getAdapter().getAttributeName(); - } - - public boolean isField() { - return this.getAdapter().isField(); - } - - public boolean isProperty() { - return ! this.isField(); - } - - public boolean hasAnyPersistenceAnnotations() { - return (this.mappingAnnotationsSize() > 0) - || (this.supportingAnnotationsSize() > 0); - } - - public AccessType getSpecifiedAccess() { - AccessAnnotation accessAnnotation = (AccessAnnotation) this.getSupportingAnnotation(AccessAnnotation.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; - } - - protected void setModifiers(int modifiers) { - int old = this.modifiers; - this.modifiers = modifiers; - this.firePropertyChanged(MODIFIERS_PROPERTY, old, modifiers); - } - - /** - * zero seems like a reasonable default... - */ - protected int buildModifiers() { - try { - return this.getMember().getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - // ***** type name - public String getTypeName() { - return this.typeName; - } - - protected 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 arguments - */ - protected String buildTypeName() { - return convertTypeSignatureToTypeName(this.getTypeSignature()); - } - - // ***** type is interface - public boolean typeIsInterface() { - return this.typeIsInterface; - } - - protected void setTypeIsInterface(boolean typeIsInterface) { - boolean old = this.typeIsInterface; - this.typeIsInterface = typeIsInterface; - this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, typeIsInterface); - } - - protected boolean buildTypeIsInterface() { - IType type = this.getType(); // shouldn't be an array... - try { - return (type != null) && type.isInterface(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** type is enum - public boolean typeIsEnum() { - return this.typeIsEnum; - } - - protected void setTypeIsEnum(boolean typeIsEnum) { - boolean old = this.typeIsEnum; - this.typeIsEnum = typeIsEnum; - this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, typeIsEnum); - } - - protected boolean buildTypeIsEnum() { - IType type = this.getType(); // shouldn't be an array... - try { - return (type != null) && type.isEnum(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - // ***** type superclass hierarchy - public ListIterator typeSuperclassNames() { - return new CloneListIterator(this.typeSuperclassNames); - } - - public boolean typeSuperclassNamesContains(String superclassName) { - return this.typeSuperclassNames.contains(superclassName); - } - - protected void setTypeSuperclassNames(List typeSuperclassNames) { - synchronized (this.typeSuperclassNames) { - this.synchronizeList(typeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_COLLECTION); - } - } - - protected List buildTypeSuperclassNames() { - IType type = this.getType(); - if (type == null) { - return Collections.emptyList(); - } - - ArrayList names = new ArrayList(); - type = this.findSuperclass(type); - while (type != null) { - names.add(type.getFullyQualifiedName()); - type = this.findSuperclass(type); - } - return names; - } - - // ***** type interface hierarchy - public Iterator typeInterfaceNames() { - return new CloneIterator(this.typeInterfaceNames); - } - - public boolean typeInterfaceNamesContains(String interfaceName) { - return this.typeInterfaceNames.contains(interfaceName); - } - - protected void setTypeInterfaceNames(Collection typeInterfaceNames) { - synchronized (this.typeInterfaceNames) { - this.synchronizeCollection(typeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION); - } - } - - protected Collection buildTypeInterfaceNames() { - IType type = this.getType(); - if (type == null) { - return Collections.emptySet(); - } - - HashSet names = new HashSet(); - while (type != null) { - this.addInterfaceNamesTo(type, names); - type = this.findSuperclass(type); - } - return names; - } - - protected void addInterfaceNamesTo(IType type, HashSet 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 typeTypeArgumentNames() { - return new CloneListIterator(this.typeTypeArgumentNames); - } - - public int typeTypeArgumentNamesSize() { - return this.typeTypeArgumentNames.size(); - } - - public String getTypeTypeArgumentName(int index) { - return this.typeTypeArgumentNames.get(index); - } - - protected void setTypeTypeArgumentNames(List typeTypeArgumentNames) { - synchronized (this.typeTypeArgumentNames) { - this.synchronizeList(typeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_COLLECTION); - } - } - - /** - * 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") - */ - protected List buildTypeTypeArgumentNames() { - String typeSignature = this.getTypeSignature(); - if (typeSignature == null) { - return Collections.emptyList(); - } - - String[] typeArgumentSignatures = Signature.getTypeArguments(typeSignature); - if (typeArgumentSignatures.length == 0) { - return Collections.emptyList(); - } - - ArrayList names = new ArrayList(typeArgumentSignatures.length); - for (String typeArgumentSignature : typeArgumentSignatures) { - names.add(convertTypeSignatureToTypeName(typeArgumentSignature)); - } - return names; - } - - - // ********** convenience methods ********** - - protected String getTypeSignature() { - try { - return this.getAdapter().getTypeSignature(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - protected IType findSuperclass(IType type) { - return this.findTypeBySignature(this.getSuperclassSignature(type)); - } - - protected String getSuperclassSignature(IType type) { - try { - return type.getSuperclassTypeSignature(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - protected String[] getSuperInterfaceTypeSignatures(IType type) { - try { - return type.getSuperInterfaceTypeSignatures(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_STRING_ARRAY; - } - } - protected static final String[] EMPTY_STRING_ARRAY = new String[0]; - - /** - * Strip off the type signature's parameters if present. - * Convert to a readable string. - */ - protected static String convertTypeSignatureToTypeName(String typeSignature) { - return (typeSignature == null) ? null : convertTypeSignatureToTypeName_(typeSignature); - } - - /** - * no null check - */ - protected static String convertTypeSignatureToTypeName_(String typeSignature) { - return Signature.toString(Signature.getTypeErasure(typeSignature)); - } - - protected IType findTypeBySignature(String typeSignature) { - return (typeSignature == null) ? null : this.findType(convertTypeSignatureToTypeName_(typeSignature)); - } - - protected IType getType() { - return (this.typeName == null) ? null : this.findType(this.typeName); - } - - protected IType findType(String fullyQualifiedName) { - try { - return this.getJavaProject().findType(fullyQualifiedName); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - protected IJavaProject getJavaProject() { - return this.getMember().getJavaProject(); - } - - - // ********** adapters ********** - - protected interface Adapter extends AbstractJarResourcePersistentMember.Adapter { - String getAttributeName(); - boolean isField(); - String getTypeSignature() throws JavaModelException; - } - - protected static class FieldAdapter implements Adapter { - private final IField field; - - protected FieldAdapter(IField field) { - super(); - this.field = field; - } - - public IField getMember() { - return this.field; - } - - public boolean isPersistable() { - return this.field.exists() && JPTTools.fieldIsPersistable(new JPTToolsAdapter(this.field)); - } - - 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. - */ - protected static class JPTToolsAdapter implements JPTTools.FieldAdapter { - private final IField field; - - protected JPTToolsAdapter(IField field) { - super(); - if (field == null) { - throw new NullPointerException(); - } - this.field = field; - } - - public int getModifiers() { - try { - return this.field.getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - } - - } - - protected static class MethodAdapter implements Adapter { - private final IMethod method; - - protected MethodAdapter(IMethod method) { - super(); - this.method = method; - } - - public IMethod getMember() { - return this.method; - } - - public boolean isPersistable() { - return JPTTools.methodIsPersistablePropertyGetter(new JPTToolsAdapter(this.method)); - } - - 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. - */ - protected static class JPTToolsAdapter implements JPTTools.MethodAdapter { - private final IMethod method; - - protected JPTToolsAdapter(IMethod method) { - super(); - if (method == null) { - throw new NullPointerException(); - } - this.method = method; - } - - public String getName() { - return this.method.getElementName(); - } - - public int getModifiers() { - try { - return this.method.getFlags(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return 0; - } - } - - public String getReturnTypeName() { - try { - return this.method.getReturnType(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return null; - } - } - - public boolean isConstructor() { - try { - return this.method.isConstructor(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return false; - } - } - - public int getParametersLength() { - return this.method.getParameterTypes().length; - } - - public JPTTools.MethodAdapter getSibling(String name) { - for (IMethod sibling : this.getSiblings()) { - if ((sibling.getParameterTypes().length == 0) - && sibling.getElementName().equals(name)) { - return new JPTToolsAdapter(sibling); - } - } - return null; - } - - public JPTTools.MethodAdapter getSibling(String name, String parameterTypeName) { - for (IMethod sibling : this.getSiblings()) { - String[] parmTypes = sibling.getParameterTypes(); - if ((parmTypes.length == 1) - && parmTypes[0].equals(parameterTypeName) - && sibling.getElementName().equals(name)) { - return new JPTToolsAdapter(sibling); - } - } - return null; - } - - protected IMethod[] getSiblings() { - try { - return this.method.getDeclaringType().getMethods(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_METHOD_ARRAY; - } - } - protected static final IMethod[] EMPTY_METHOD_ARRAY = new IMethod[0]; - - } - - } - - // TODO ============== remove ======================== - public boolean isFor(MethodSignature methodSignature, int occurrence) { - throw new UnsupportedOperationException(); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/jar/AbstractJarResourcePersistentMember.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/jar/AbstractJarResourcePersistentMember.java diff -N src/org/eclipse/jpt/core/internal/resource/jar/AbstractJarResourcePersistentMember.java --- src/org/eclipse/jpt/core/internal/resource/jar/AbstractJarResourcePersistentMember.java 10 Mar 2009 04:12:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,298 +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.jar; - -import java.util.Iterator; -import java.util.ListIterator; -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.dom.CompilationUnit; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.resource.jar.JarResourceNode; -import org.eclipse.jpt.core.resource.jar.JarResourcePersistentMember; -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.iterators.CloneIterator; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator; - -/** - * JAR persistent member - */ -public abstract class AbstractJarResourcePersistentMember - extends AbstractJarResourceNode - implements JarResourcePersistentMember -{ - /** JDT member adapter */ - private final Adapter adapter; - - /** mapping annotations */ - private final Vector mappingAnnotations = new Vector(); - - /** supporting annotations */ - private final Vector supportingAnnotations = new Vector(); - - private boolean persistable; - - - // ********** construction/initialization ********** - - public AbstractJarResourcePersistentMember(JarResourceNode parent, Adapter adapter) { - super(parent); - this.adapter = adapter; - this.initializeAnnotations(); - this.persistable = this.buildPersistable(); - } - - protected void initializeAnnotations() { - for (IAnnotation annotation : this.getJdtAnnotations()) { - this.addAnnotation(annotation); - } - } - - protected IAnnotation[] getJdtAnnotations() { - try { - return this.adapter.getAnnotations(); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - return EMPTY_JDT_ANNOTATION_ARRAY; - } - } - protected static final IAnnotation[] EMPTY_JDT_ANNOTATION_ARRAY = new IAnnotation[0]; - - // TODO - protected void addAnnotation(IAnnotation jdtAnnotation) { -// if (this.annotationIsValidSupportingAnnotation(jdtAnnotation)) { -// this.supportingAnnotations.add(this.buildSupportingAnnotation(jdtAnnotation)); -// } else if (this.annotationIsValidMappingAnnotation(jdtAnnotation)) { -// this.mappingAnnotations.add(this.buildMappingAnnotation(jdtAnnotation)); -// } - } - - - // ********** mapping annotations ********** - - public Iterator mappingAnnotations() { - return new CloneIterator(this.mappingAnnotations); - } - - public int mappingAnnotationsSize() { - return this.mappingAnnotations.size(); - } - - public JavaResourceNode getMappingAnnotation() { - synchronized (this.mappingAnnotations) { - return this.getMappingAnnotation_(); - } - } - - protected Annotation getMappingAnnotation_() { - for (ListIterator stream = this.validMappingAnnotationNames(); stream.hasNext();) { - Annotation annotation = this.getMappingAnnotation_(stream.next()); - if (annotation != null) { - return annotation; - } - } - return null; - } - - /** - * use this method when 'mappingAnnotations' is synchronized - */ - protected Annotation getMappingAnnotation_(String annotationName) { - return this.getAnnotation(this.mappingAnnotations, annotationName); - } - - public JavaResourceNode getMappingAnnotation(String annotationName) { - return this.getAnnotation(this.mappingAnnotations(), annotationName); - } - - public JavaResourceNode getNullMappingAnnotation(String annotationName) { - return (annotationName == null) ? null : this.buildNullMappingAnnotation(annotationName); - } - - protected abstract Annotation buildNullMappingAnnotation(String annotationName); - - protected boolean annotationIsValidMappingAnnotation(IAnnotation jdtAnnotation) { - return CollectionTools.contains(this.validMappingAnnotationNames(), jdtAnnotation.getElementName()); - } - - protected abstract ListIterator validMappingAnnotationNames(); - - protected abstract Annotation buildMappingAnnotation(IAnnotation jdtAnnotation); - - - // ********** supporting annotations ********** - - public Iterator supportingAnnotations() { - return new CloneIterator(this.supportingAnnotations); - } - - public int supportingAnnotationsSize() { - return this.supportingAnnotations.size(); - } - - public ListIterator supportingAnnotations(String nestableAnnotationName, String containerAnnotationName) { - ContainerAnnotation containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName); - if (containerAnnotation != null) { - return containerAnnotation.nestedAnnotations(); - } - NestableAnnotation nestableAnnotation = this.getSupportingNestableAnnotation(nestableAnnotationName); - return (nestableAnnotation == null) ? EmptyListIterator.instance() : new SingleElementListIterator(nestableAnnotation); - } - - protected NestableAnnotation getSupportingNestableAnnotation(String annotationName) { - return (NestableAnnotation) this.getSupportingAnnotation(annotationName); - } - - public Annotation getSupportingAnnotation(String annotationName) { - return this.getAnnotation(this.supportingAnnotations(), annotationName); - } - - public JavaResourceNode getNonNullSupportingAnnotation(String annotationName) { - Annotation annotation = this.getSupportingAnnotation(annotationName); - return (annotation != null) ? annotation : this.buildNullSupportingAnnotation(annotationName); - } - - protected abstract Annotation buildNullSupportingAnnotation(String annotationName); - - protected abstract Annotation buildSupportingAnnotation(IAnnotation jdtAnnotation); - - protected boolean annotationIsValidSupportingAnnotation(IAnnotation jdtAnnotation) { - return CollectionTools.contains(this.validSupportingAnnotationNames(), jdtAnnotation.getElementName()); - } - - protected abstract ListIterator validSupportingAnnotationNames(); - - @SuppressWarnings("unchecked") - protected ContainerAnnotation getSupportingContainerAnnotation(String annotationName) { - return (ContainerAnnotation) this.getSupportingAnnotation(annotationName); - } - - - // ********** simple state ********** - - public boolean isPersistable() { - return this.persistable; - } - - protected void setPersistable(boolean persistable) { - boolean old = this.persistable; - this.persistable = persistable; - this.firePropertyChanged(PERSISTABLE_PROPERTY, old, persistable); - } - - protected boolean buildPersistable() { - return this.adapter.isPersistable(); - } - - public boolean isPersisted() { - return this.getMappingAnnotation() != null; - } - - - // ********** miscellaneous ********** - - protected Adapter getAdapter() { - return this.adapter; - } - - public IMember getMember() { - return this.adapter.getMember(); - } - - protected Annotation getAnnotation(Iterable annotations, String annotationName) { - return this.getAnnotation(annotations.iterator(), annotationName); - } - - protected Annotation getAnnotation(Iterator annotations, String annotationName) { - while (annotations.hasNext()) { - Annotation annotation = annotations.next(); - if (annotation.getAnnotationName().equals(annotationName)) { - return annotation; - } - } - return null; - } - - protected Iterator persistableMembers(Iterator members) { - return new FilteringIterator(members) { - @Override - protected boolean accept(T m) { - return m.isPersistable(); - } - }; - } - - - // ********** updating ********** - - @Override - public void update() { - super.update(); - // TODO - } - - - // ********** IMember adapter ********** - - protected interface Adapter { - IMember getMember(); - boolean isPersistable(); - IAnnotation[] getAnnotations() throws JavaModelException; - } - - // ============== TODO remove... ======================== - public void setMappingAnnotation(String annotationName) { - throw new UnsupportedOperationException(); - } - - public JavaResourceNode addSupportingAnnotation(String annotationName) { - throw new UnsupportedOperationException(); - } - - public JavaResourceNode addSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - public void moveSupportingAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) { - throw new UnsupportedOperationException(); - } - - public void removeSupportingAnnotation(String annotationName) { - throw new UnsupportedOperationException(); - } - - public void removeSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { - 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(); - } - -} Index: src/org/eclipse/jpt/core/internal/resource/jar/AbstractJarResourceNode.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/jar/AbstractJarResourceNode.java diff -N src/org/eclipse/jpt/core/internal/resource/jar/AbstractJarResourceNode.java --- src/org/eclipse/jpt/core/internal/resource/jar/AbstractJarResourceNode.java 10 Mar 2009 04:12:10 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,54 +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.jar; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.AbstractJavaResourceNode; -import org.eclipse.jpt.core.resource.jar.JarResourceNode; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * resource containment hierarchy - */ -public abstract class AbstractJarResourceNode - extends AbstractJavaResourceNode - implements JarResourceNode -{ - - // ********** construction ********** - - protected AbstractJarResourceNode(JarResourceNode parent) { - super(parent); - } - - - // ********** JarResourceNode implementation ********** - - @Override - public JarResourcePackageFragmentRoot getRoot() { - return (JarResourcePackageFragmentRoot) super.getRoot(); - } - - public void update() { - // nothing by default - } - - // TODO remove... ====================== - public TextRange getTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - public void update(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - public void initialize(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } -} Index: src/org/eclipse/jpt/core/internal/resource/jar/JarResourceClassFileImpl.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/jar/JarResourceClassFileImpl.java diff -N src/org/eclipse/jpt/core/internal/resource/jar/JarResourceClassFileImpl.java --- src/org/eclipse/jpt/core/internal/resource/jar/JarResourceClassFileImpl.java 10 Mar 2009 04:12:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -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.jar; - -import org.eclipse.jdt.core.IClassFile; -import org.eclipse.jpt.core.resource.jar.JarResourceClassFile; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragment; -import org.eclipse.jpt.core.resource.jar.JarResourcePersistentType; - -/** - * JAR class file - */ -public class JarResourceClassFileImpl - extends AbstractJarResourceNode - implements JarResourceClassFile -{ - /** JDT class file */ - private IClassFile classFile; - - /** class file's persistent type */ - private JarResourcePersistentType persistentType; - - - // ********** construction/initialization ********** - - public JarResourceClassFileImpl(JarResourcePackageFragment parent, IClassFile classFile) { - super(parent); - this.classFile = classFile; - this.persistentType = this.buildPersistentType(); - } - - protected JarResourcePersistentType buildPersistentType() { - return new JarResourcePersistentTypeImpl(this, this.classFile.getType()); - } - - - // ********** JarResourceNode implementation ********** - - @Override - public void update() { - super.update(); - // TODO - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.classFile.getElementName()); - } - - - // ********** JarResourceClassFile implementation ********** - - public IClassFile getClassFile() { - return this.classFile; - } - - public JarResourcePersistentType getPersistentType() { - return this.persistentType; - } - -} Index: src/org/eclipse/jpt/core/internal/context/persistence/GenericJarFileRef.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/GenericJarFileRef.java,v retrieving revision 1.3 diff -u -r1.3 GenericJarFileRef.java --- src/org/eclipse/jpt/core/internal/context/persistence/GenericJarFileRef.java 18 Feb 2009 21:13:57 -0000 1.3 +++ src/org/eclipse/jpt/core/internal/context/persistence/GenericJarFileRef.java 6 Apr 2009 20:59:17 -0000 @@ -14,14 +14,14 @@ import org.eclipse.core.runtime.content.IContentType; import org.eclipse.jpt.core.JpaStructureNode; import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.context.jar.JarFile; +import org.eclipse.jpt.core.context.java.JarFile; import org.eclipse.jpt.core.context.persistence.JarFileRef; import org.eclipse.jpt.core.context.persistence.PersistenceStructureNodes; import org.eclipse.jpt.core.context.persistence.PersistenceUnit; import org.eclipse.jpt.core.internal.context.AbstractXmlContextNode; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; +import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; import org.eclipse.jpt.core.resource.persistence.XmlJarFileRef; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.utility.internal.StringTools; @@ -49,7 +49,7 @@ } protected JarFile buildJarFile() { - JarResourcePackageFragmentRoot jrpfr = this.getJpaProject().getJarResourcePackageFragmentRoot(this.getJarFileName()); + JavaResourcePackageFragmentRoot jrpfr = this.getJpaProject().getJavaResourcePackageFragmentRoot(this.getJarFileName()); return (jrpfr == null) ? null : this.buildJarFile(jrpfr); } @@ -120,7 +120,7 @@ } protected void updateJarFile() { - JarResourcePackageFragmentRoot jrpfr = this.getJpaProject().getJarResourcePackageFragmentRoot(this.getJarFileName()); + JavaResourcePackageFragmentRoot jrpfr = this.getJpaProject().getJavaResourcePackageFragmentRoot(this.getJarFileName()); if (jrpfr == null) { if (this.jarFile != null) { this.jarFile.dispose(); @@ -135,7 +135,7 @@ } } - protected JarFile buildJarFile(JarResourcePackageFragmentRoot jrpfr) { + protected JarFile buildJarFile(JavaResourcePackageFragmentRoot jrpfr) { return this.getJpaFactory().buildJarFile(this, jrpfr); } Index: src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java,v retrieving revision 1.17 diff -u -r1.17 AbstractPersistenceUnit.java --- src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java 12 Mar 2009 05:07:40 -0000 1.17 +++ src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java 6 Apr 2009 20:59:17 -0000 @@ -16,6 +16,7 @@ import java.util.ListIterator; import java.util.Set; import java.util.Vector; + import org.eclipse.core.runtime.content.IContentType; import org.eclipse.jpt.core.JpaStructureNode; import org.eclipse.jpt.core.JptCorePlugin; @@ -47,6 +48,7 @@ import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.utility.internal.CollectionTools; import org.eclipse.jpt.utility.internal.HashBag; +import org.eclipse.jpt.utility.internal.iterables.CloneIterable; import org.eclipse.jpt.utility.internal.iterators.CloneIterator; import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; @@ -608,6 +610,10 @@ return new CloneListIterator(this.properties); } + protected Iterable getProperties() { + return new CloneIterable(this.properties); + } + public int propertiesSize() { return this.properties.size(); } @@ -616,11 +622,9 @@ if (propertyName == null) { throw new NullPointerException(); } - synchronized (this.properties) { - for (Property property : this.properties) { - if (propertyName.equals(property.getName())) { - return property; - } + for (Property property : this.getProperties()) { + if (propertyName.equals(property.getName())) { + return property; } } return null; @@ -708,22 +712,18 @@ } public void removeProperty(Property property) { - synchronized (this.properties) { - this.removeProperty(this.properties.indexOf(property)); - } + this.removeProperty(this.properties.indexOf(property)); } public void removeProperty(String propertyName) { if (propertyName == null) { throw new NullPointerException(); } - synchronized (this.properties) { - for (ListIterator stream = this.properties.listIterator(); stream.hasNext(); ) { - Property property = stream.next(); - if (propertyName.equals(property.getName())) { - this.removeProperty(stream.previousIndex()); - return; - } + for (ListIterator stream = this.properties.listIterator(); stream.hasNext(); ) { + Property property = stream.next(); + if (propertyName.equals(property.getName())) { + this.removeProperty(stream.previousIndex()); + return; } } throw new IllegalArgumentException("invalid property name: " + propertyName); //$NON-NLS-1$ @@ -733,13 +733,11 @@ if ((propertyName == null) || (value == null)) { throw new NullPointerException(); } - synchronized (this.properties) { - for (ListIterator stream = this.properties.listIterator(); stream.hasNext(); ) { - Property property = stream.next(); - if (propertyName.equals(property.getName()) && value.equals(property.getValue())) { - this.removeProperty(stream.previousIndex()); - return; - } + for (ListIterator stream = this.properties.listIterator(); stream.hasNext(); ) { + Property property = stream.next(); + if (propertyName.equals(property.getName()) && value.equals(property.getValue())) { + this.removeProperty(stream.previousIndex()); + return; } } throw new IllegalArgumentException("invalid property name/value pair: " + propertyName + " = " + value); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1103,8 +1101,7 @@ protected void updateProperties() { Iterator xmlProperties = this.xmlProperties(); - for (Iterator contextProperties = this.properties(); contextProperties.hasNext(); ) { - Property contextProperty = contextProperties.next(); + for (Property contextProperty : this.getProperties()) { if (xmlProperties.hasNext()) { contextProperty.update(xmlProperties.next()); } else { Index: src/org/eclipse/jpt/core/resource/jar/JarResourcePackageFragmentRoot.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/jar/JarResourcePackageFragmentRoot.java diff -N src/org/eclipse/jpt/core/resource/jar/JarResourcePackageFragmentRoot.java --- src/org/eclipse/jpt/core/resource/jar/JarResourcePackageFragmentRoot.java 10 Mar 2009 04:12:10 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,43 +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.resource.jar; - -import java.util.ListIterator; - -import org.eclipse.jdt.core.IPackageFragmentRoot; - -/** - * Dali resource for JDT package fragement root JAR. - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JarResourcePackageFragmentRoot - extends JarResourceNode.Root -{ - /** - * Return the corresponding JDT package fragement root. - */ - IPackageFragmentRoot getPackageFragmentRoot(); - - /** - * Return the package fragment root's package fragments. - */ - ListIterator packageFragments(); - - /** - * Return the size of the package fragment root's package fragments. - */ - int packageFragmentsSize(); - -} Index: src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentAttribute.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentAttribute.java diff -N src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentAttribute.java --- src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentAttribute.java 10 Mar 2009 04:12:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,27 +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.resource.jar; - -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * JAR persistent attribute (field or property) - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JarResourcePersistentAttribute - extends JarResourcePersistentMember, JavaResourcePersistentAttribute -{ - // combine 2 interfaces -} Index: src/org/eclipse/jpt/core/resource/jar/JarResourceNode.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/jar/JarResourceNode.java diff -N src/org/eclipse/jpt/core/resource/jar/JarResourceNode.java --- src/org/eclipse/jpt/core/resource/jar/JarResourceNode.java 10 Mar 2009 04:12:10 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,45 +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.resource.jar; - -import org.eclipse.jpt.core.resource.java.JavaResourceNode; - -/** - * Common interface for JAR Java resource nodes. - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JarResourceNode - extends JavaResourceNode -{ - - /** - * covariant override - */ - JarResourcePackageFragmentRoot getRoot(); - - /** - * The JAR has changed, synchronize the model with it. - */ - void update(); - - - /** - * root of containment hierarchy - */ - interface Root extends JarResourceNode, JavaResourceNode.Root { - // pull together 2 interfaces - } - -} Index: src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentType.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentType.java diff -N src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentType.java --- src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentType.java 10 Mar 2009 04:12:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -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.resource.jar; - -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * JAR persistent type - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JarResourcePersistentType - extends JarResourcePersistentMember, JavaResourcePersistentType -{ - /** - * covariant override - */ - IType getMember(); - -} Index: src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentMember.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentMember.java diff -N src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentMember.java --- src/org/eclipse/jpt/core/resource/jar/JarResourcePersistentMember.java 10 Mar 2009 04:12:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,33 +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.resource.jar; - - -import org.eclipse.jdt.core.IMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; - -/** - * JAR persistent member - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JarResourcePersistentMember - extends JarResourceNode, JavaResourcePersistentMember -{ - /** - * Return the corresponding JDT member. - */ - IMember getMember(); - -} Index: src/org/eclipse/jpt/core/resource/jar/JarResourcePackageFragment.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/jar/JarResourcePackageFragment.java diff -N src/org/eclipse/jpt/core/resource/jar/JarResourcePackageFragment.java --- src/org/eclipse/jpt/core/resource/jar/JarResourcePackageFragment.java 10 Mar 2009 04:12:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,52 +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.resource.jar; - -import java.util.Iterator; -import java.util.ListIterator; - -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * JAR package fragment - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JarResourcePackageFragment - extends JarResourceNode -{ - - /** - * Return the corresponding JDT package fragement. - */ - IPackageFragment getPackageFragment(); - - /** - * Return the package fragment's class files that contain "persistable" types. - */ - ListIterator classFiles(); - - /** - * Return the size of the package fragment's class files. - */ - int classFilesSize(); - - /** - * Return the package fragment's "persistable" resource types, as defined - * by the JPA spec. - */ - Iterator persistableTypes(); - -} Index: src/org/eclipse/jpt/core/resource/jar/JarResourceClassFile.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/jar/JarResourceClassFile.java diff -N src/org/eclipse/jpt/core/resource/jar/JarResourceClassFile.java --- src/org/eclipse/jpt/core/resource/jar/JarResourceClassFile.java 10 Mar 2009 04:12:10 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,37 +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.resource.jar; - -import org.eclipse.jdt.core.IClassFile; - -/** - * JAR class file - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JarResourceClassFile - extends JarResourceNode -{ - - /** - * Return the corresponding JDT class file. - */ - IClassFile getClassFile(); - - /** - * Return the class file's persistent type. - */ - JarResourcePersistentType getPersistentType(); - -} Index: src/org/eclipse/jpt/core/context/java/JavaAttributeMapping.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaAttributeMapping.java,v retrieving revision 1.9 diff -u -r1.9 JavaAttributeMapping.java --- src/org/eclipse/jpt/core/context/java/JavaAttributeMapping.java 12 Mar 2009 05:07:38 -0000 1.9 +++ src/org/eclipse/jpt/core/context/java/JavaAttributeMapping.java 6 Apr 2009 20:59:11 -0000 @@ -10,8 +10,9 @@ package org.eclipse.jpt.core.context.java; import java.util.Iterator; + import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.Annotation; /** * Java attribute mapping @@ -29,11 +30,11 @@ * Covariant override. */ JavaPersistentAttribute getPersistentAttribute(); - - JavaResourceNode getMappingAnnotation(); - - void initialize(JavaResourceNode mappingAnnotation); - + + Annotation getMappingAnnotation(); + + void initialize(Annotation mappingAnnotation); + /** * Update the JavaAttributeMapping context model object to match the JavaResourcePersistentAttribute * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} @@ -41,7 +42,7 @@ //TODO want to remove parameter from the update method, but we have to have //it because of GenericJavaPersistentAttribute.setSpecifiedMappingKey(), it is unable //to call initialize and pass the resource object in before the update is called. - void update(JavaResourceNode mappingAnnotation); + void update(Annotation mappingAnnotation); String getAnnotationName(); Index: src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java,v retrieving revision 1.36 diff -u -r1.36 GenericJpaFactory.java --- src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java 1 Apr 2009 14:36:19 -0000 1.36 +++ src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java 6 Apr 2009 20:59:18 -0000 @@ -25,7 +25,7 @@ import org.eclipse.jpt.core.context.PersistentType; import org.eclipse.jpt.core.context.UniqueConstraint; import org.eclipse.jpt.core.context.XmlContextNode; -import org.eclipse.jpt.core.context.jar.JarFile; +import org.eclipse.jpt.core.context.java.JarFile; import org.eclipse.jpt.core.context.java.JavaAssociationOverride; import org.eclipse.jpt.core.context.java.JavaAttributeMapping; import org.eclipse.jpt.core.context.java.JavaAttributeOverride; @@ -116,7 +116,7 @@ import org.eclipse.jpt.core.internal.GenericJpaFile; import org.eclipse.jpt.core.internal.GenericJpaProject; import org.eclipse.jpt.core.internal.context.GenericRootContextNode; -import org.eclipse.jpt.core.internal.context.jar.GenericJarFile; +import org.eclipse.jpt.core.internal.context.java.GenericJarFile; import org.eclipse.jpt.core.internal.context.java.GenericJavaAssociationOverride; import org.eclipse.jpt.core.internal.context.java.GenericJavaAttributeOverride; import org.eclipse.jpt.core.internal.context.java.GenericJavaBasicMapping; @@ -208,7 +208,7 @@ import org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceUnitProperty; import org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceXml; import org.eclipse.jpt.core.internal.context.persistence.ImpliedMappingFileRef; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; +import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; @@ -669,7 +669,7 @@ // ********** JAR Context Model ********** - public JarFile buildJarFile(JarFileRef parent, JarResourcePackageFragmentRoot jarResourcePackageFragmentRoot) { + public JarFile buildJarFile(JarFileRef parent, JavaResourcePackageFragmentRoot jarResourcePackageFragmentRoot) { return new GenericJarFile(parent, jarResourcePackageFragmentRoot); } Index: src/org/eclipse/jpt/core/internal/platform/GenericJpaAnnotationDefinitionProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaAnnotationDefinitionProvider.java,v retrieving revision 1.1 diff -u -r1.1 GenericJpaAnnotationDefinitionProvider.java --- src/org/eclipse/jpt/core/internal/platform/GenericJpaAnnotationDefinitionProvider.java 15 Jan 2009 17:59:30 -0000 1.1 +++ src/org/eclipse/jpt/core/internal/platform/GenericJpaAnnotationDefinitionProvider.java 6 Apr 2009 20:59:18 -0000 @@ -11,48 +11,48 @@ import java.util.List; import org.eclipse.jpt.core.JpaAnnotationDefinitionProvider; -import org.eclipse.jpt.core.internal.resource.java.AssociationOverrideImpl.AssociationOverrideAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.AssociationOverridesImpl.AssociationOverridesAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.AttributeOverrideImpl.AttributeOverrideAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.AttributeOverridesImpl.AttributeOverridesAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.BasicImpl.BasicAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.ColumnImpl.ColumnAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.DiscriminatorColumnImpl.DiscriminatorColumnAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.DiscriminatorValueImpl.DiscriminatorValueAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.EmbeddableImpl.EmbeddableAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.EmbeddedIdImpl.EmbeddedIdAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.EmbeddedImpl.EmbeddedAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.EntityImpl.EntityAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.EnumeratedImpl.EnumeratedAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.GeneratedValueImpl.GeneratedValueAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.IdClassImpl.IdClassAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.IdImpl.IdAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.InheritanceImpl.InheritanceAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.JoinColumnImpl.JoinColumnAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.JoinColumnsImpl.JoinColumnsAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.JoinTableImpl.JoinTableAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.LobImpl.LobAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.ManyToManyImpl.ManyToManyAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.ManyToOneImpl.ManyToOneAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.MapKeyImpl.MapKeyAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.MappedSuperclassImpl.MappedSuperclassAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.NamedNativeQueriesImpl.NamedNativeQueriesAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.NamedNativeQueryImpl.NamedNativeQueryAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.NamedQueriesImpl.NamedQueriesAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.NamedQueryImpl.NamedQueryAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.OneToManyImpl.OneToManyAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.OneToOneImpl.OneToOneAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.OrderByImpl.OrderByAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.PrimaryKeyJoinColumnImpl.PrimaryKeyJoinColumnAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.PrimaryKeyJoinColumnsImpl.PrimaryKeyJoinColumnsAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.SecondaryTableImpl.SecondaryTableAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.SecondaryTablesImpl.SecondaryTablesAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.SequenceGeneratorImpl.SequenceGeneratorAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.TableGeneratorImpl.TableGeneratorAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.TableImpl.TableAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.TemporalImpl.TemporalAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.TransientImpl.TransientAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.VersionImpl.VersionAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.AssociationOverrideAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.AssociationOverridesAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.AttributeOverrideAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.AttributeOverridesAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.BasicAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.ColumnAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.DiscriminatorColumnAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.DiscriminatorValueAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.EmbeddableAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.EmbeddedAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.EmbeddedIdAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.EntityAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.EnumeratedAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.GeneratedValueAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.IdAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.IdClassAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.InheritanceAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.JoinColumnAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.JoinColumnsAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.JoinTableAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.LobAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.ManyToManyAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.ManyToOneAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.MapKeyAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.MappedSuperclassAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.NamedNativeQueriesAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.NamedNativeQueryAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.NamedQueriesAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.NamedQueryAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.OneToManyAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.OneToOneAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.OrderByAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.PrimaryKeyJoinColumnAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.PrimaryKeyJoinColumnsAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.SecondaryTableAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.SecondaryTablesAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.SequenceGeneratorAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.TableAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.TableGeneratorAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.TemporalAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.TransientAnnotationDefinition; +import org.eclipse.jpt.core.internal.resource.java.VersionAnnotationDefinition; import org.eclipse.jpt.core.resource.java.AnnotationDefinition; /** Index: src/org/eclipse/jpt/core/internal/platform/GenericJpaAnnotationProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaAnnotationProvider.java,v retrieving revision 1.7 diff -u -r1.7 GenericJpaAnnotationProvider.java --- src/org/eclipse/jpt/core/internal/platform/GenericJpaAnnotationProvider.java 10 Mar 2009 04:12:10 -0000 1.7 +++ src/org/eclipse/jpt/core/internal/platform/GenericJpaAnnotationProvider.java 6 Apr 2009 20:59:18 -0000 @@ -14,8 +14,6 @@ import org.eclipse.jdt.core.IAnnotation; import org.eclipse.jpt.core.JpaAnnotationDefinitionProvider; import org.eclipse.jpt.core.JpaAnnotationProvider; -import org.eclipse.jpt.core.resource.jar.JarResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.jar.JarResourcePersistentType; import org.eclipse.jpt.core.resource.java.Annotation; import org.eclipse.jpt.core.resource.java.AnnotationDefinition; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; @@ -28,6 +26,9 @@ /** * Delegate to annotation definition providers. + * The platform factory will build an instance of this annotation provider, + * passing in the appropriate array of annotation definition providers necessary + * to build the annotations for the platform (vendor and/or version). */ public class GenericJpaAnnotationProvider implements JpaAnnotationProvider @@ -42,7 +43,7 @@ // ********** annotation definition providers ********** - protected synchronized ListIterator annotationDefinitionProviders() { + protected ListIterator annotationDefinitionProviders() { return new ArrayListIterator(this.annotationDefinitionProviders); } @@ -69,20 +70,10 @@ return this.getTypeMappingAnnotationDefinition(annotationName).buildAnnotation(parent, type); } - public Annotation buildTypeMappingAnnotation(JarResourcePersistentType parent, IAnnotation jdtAnnotation) { - return null; -// TODO return this.getTypeMappingAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); + public Annotation buildTypeMappingAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { + return this.getTypeMappingAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); } - public Annotation buildNullTypeMappingAnnotation(JavaResourcePersistentType parent, Type type, String annotationName) { - return this.getTypeMappingAnnotationDefinition(annotationName).buildNullAnnotation(parent, type); - } - - public Annotation buildNullTypeMappingAnnotation(JarResourcePersistentType parent, String annotationName) { - return null; -// TODO return this.getTypeMappingAnnotationDefinition(annotationName).buildNullAnnotation(parent); - } - protected AnnotationDefinition getTypeMappingAnnotationDefinition(String annotationName) { AnnotationDefinition annotationDefinition = getAnnotationDefinition(annotationName, this.typeMappingAnnotationDefinitions()); if (annotationDefinition == null) { @@ -111,18 +102,12 @@ return this.getTypeSupportingAnnotationDefinition(annotationName).buildAnnotation(parent, type); } - public Annotation buildTypeSupportingAnnotation(JarResourcePersistentType parent, IAnnotation jdtAnnotation) { - return null; -// TODO return this.getTypeSupportingAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); + public Annotation buildTypeSupportingAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { + return this.getTypeSupportingAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); } - public Annotation buildNullTypeSupportingAnnotation(JavaResourcePersistentType parent, Type type, String annotationName) { - return this.getTypeSupportingAnnotationDefinition(annotationName).buildNullAnnotation(parent, type); - } - - public Annotation buildNullTypeSupportingAnnotation(JarResourcePersistentType parent, String annotationName) { - return null; -// TODO return this.getTypeSupportingAnnotationDefinition(annotationName).buildNullAnnotation(parent); + public Annotation buildNullTypeSupportingAnnotation(JavaResourcePersistentType parent, String annotationName) { + return this.getTypeSupportingAnnotationDefinition(annotationName).buildNullAnnotation(parent); } protected AnnotationDefinition getTypeSupportingAnnotationDefinition(String annotationName) { @@ -156,18 +141,12 @@ return this.getAttributeMappingAnnotationDefinition(annotationName).buildAnnotation(parent, attribute); } - public Annotation buildAttributeMappingAnnotation(JarResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - return null; -// TODO return this.getAttributeMappingAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); + public Annotation buildAttributeMappingAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { + return this.getAttributeMappingAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); } - public Annotation buildNullAttributeMappingAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute, String annotationName) { - return this.getAttributeMappingAnnotationDefinition(annotationName).buildNullAnnotation(parent, attribute); - } - - public Annotation buildNullAttributeMappingAnnotation(JarResourcePersistentAttribute parent, String annotationName) { - return null; -// TODO return this.getAttributeMappingAnnotationDefinition(annotationName).buildNullAnnotation(parent); + public Annotation buildNullAttributeMappingAnnotation(JavaResourcePersistentAttribute parent, String annotationName) { + return this.getAttributeMappingAnnotationDefinition(annotationName).buildNullAnnotation(parent); } protected AnnotationDefinition getAttributeMappingAnnotationDefinition(String annotationName) { @@ -198,18 +177,12 @@ return this.getAttributeSupportingAnnotationDefinition(annotationName).buildAnnotation(parent, attribute); } - public Annotation buildAttributeSupportingAnnotation(JarResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - return null; -// TODO return this.getAttributeSupportingAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); - } - - public Annotation buildNullAttributeSupportingAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute, String annotationName) { - return this.getAttributeSupportingAnnotationDefinition(annotationName).buildNullAnnotation(parent, attribute); + public Annotation buildAttributeSupportingAnnotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { + return this.getAttributeSupportingAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation); } - public Annotation buildNullAttributeSupportingAnnotation(JarResourcePersistentAttribute parent, String annotationName) { - return null; -// TODO return this.getAttributeSupportingAnnotationDefinition(annotationName).buildNullAnnotation(parent); + public Annotation buildNullAttributeSupportingAnnotation(JavaResourcePersistentAttribute parent, String annotationName) { + return this.getAttributeSupportingAnnotationDefinition(annotationName).buildNullAnnotation(parent); } protected AnnotationDefinition getAttributeSupportingAnnotationDefinition(String annotationName) { Index: src/org/eclipse/jpt/core/internal/JarResourceModelProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JarResourceModelProvider.java,v retrieving revision 1.1 diff -u -r1.1 JarResourceModelProvider.java --- src/org/eclipse/jpt/core/internal/JarResourceModelProvider.java 9 Feb 2009 03:54:36 -0000 1.1 +++ src/org/eclipse/jpt/core/internal/JarResourceModelProvider.java 6 Apr 2009 20:59:11 -0000 @@ -17,7 +17,7 @@ import org.eclipse.jpt.core.JpaResourceModel; import org.eclipse.jpt.core.JpaResourceModelProvider; import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.resource.jar.JarResourcePackageFragmentRootImpl; +import org.eclipse.jpt.core.internal.resource.java.binary.BinaryPackageFragmentRoot; /** * JAR files @@ -55,7 +55,7 @@ */ public JpaResourceModel buildResourceModel(JpaProject jpaProject, IFile file) { IPackageFragmentRoot pfr = JavaCore.createJarPackageFragmentRootFrom(file); - return (pfr ==null) ? null : new JarResourcePackageFragmentRootImpl(pfr, jpaProject.getJpaPlatform().getAnnotationProvider()); + return (pfr ==null) ? null : new BinaryPackageFragmentRoot(pfr, jpaProject.getJpaPlatform().getAnnotationProvider()); } } Index: src/org/eclipse/jpt/core/internal/JavaResourceModelProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JavaResourceModelProvider.java,v retrieving revision 1.4 diff -u -r1.4 JavaResourceModelProvider.java --- src/org/eclipse/jpt/core/internal/JavaResourceModelProvider.java 5 Feb 2009 15:46:54 -0000 1.4 +++ src/org/eclipse/jpt/core/internal/JavaResourceModelProvider.java 6 Apr 2009 20:59:11 -0000 @@ -15,7 +15,7 @@ import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.JpaResourceModelProvider; import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.internal.resource.java.JavaResourceCompilationUnitImpl; +import org.eclipse.jpt.core.internal.resource.java.source.SourceCompilationUnit; import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; /** @@ -46,7 +46,7 @@ } public JavaResourceCompilationUnit buildResourceModel(JpaProject jpaProject, IFile file) { - return new JavaResourceCompilationUnitImpl( + return new SourceCompilationUnit( JavaCore.createCompilationUnitFrom(file), jpaProject.getJpaPlatform().getAnnotationProvider(), jpaProject.getJpaPlatform().getAnnotationEditFormatter(), Index: src/org/eclipse/jpt/core/internal/GenericJpaFile.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaFile.java,v retrieving revision 1.15 diff -u -r1.15 GenericJpaFile.java --- src/org/eclipse/jpt/core/internal/GenericJpaFile.java 10 Mar 2009 04:12:10 -0000 1.15 +++ src/org/eclipse/jpt/core/internal/GenericJpaFile.java 6 Apr 2009 20:59:11 -0000 @@ -19,6 +19,7 @@ import org.eclipse.jpt.core.JpaProject; import org.eclipse.jpt.core.JpaResourceModel; import org.eclipse.jpt.core.JpaStructureNode; +import org.eclipse.jpt.utility.internal.iterables.CloneIterable; import org.eclipse.jpt.utility.internal.iterators.CloneIterator; /** @@ -102,6 +103,10 @@ return new CloneIterator(this.rootStructureNodes.values()); } + protected Iterable getRootStructureNodes() { + return new CloneIterable(this.rootStructureNodes.values()); + } + public int rootStructureNodesSize() { return this.rootStructureNodes.size(); } @@ -121,12 +126,10 @@ } public JpaStructureNode getStructureNode(int textOffset) { - synchronized (this.rootStructureNodes) { - for (JpaStructureNode rootNode : this.rootStructureNodes.values()) { - JpaStructureNode node = rootNode.getStructureNode(textOffset); - if (node != null) { - return node; - } + for (JpaStructureNode rootNode : this.getRootStructureNodes()) { + JpaStructureNode node = rootNode.getStructureNode(textOffset); + if (node != null) { + return node; } } return null; Index: src/org/eclipse/jpt/core/internal/AbstractJpaProject.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java,v retrieving revision 1.6 diff -u -r1.6 AbstractJpaProject.java --- src/org/eclipse/jpt/core/internal/AbstractJpaProject.java 25 Mar 2009 04:16:36 -0000 1.6 +++ src/org/eclipse/jpt/core/internal/AbstractJpaProject.java 6 Apr 2009 20:59:11 -0000 @@ -44,9 +44,9 @@ import org.eclipse.jpt.core.internal.utility.PlatformTools; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit; import org.eclipse.jpt.core.resource.java.JavaResourceNode; +import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.xml.JpaXmlResource; import org.eclipse.jpt.db.Catalog; @@ -58,6 +58,7 @@ import org.eclipse.jpt.utility.internal.BitTools; import org.eclipse.jpt.utility.internal.StringTools; import org.eclipse.jpt.utility.internal.ThreadLocalCommandExecutor; +import org.eclipse.jpt.utility.internal.iterables.CloneIterable; import org.eclipse.jpt.utility.internal.iterators.CloneIterator; import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; @@ -381,6 +382,10 @@ return new CloneIterator(this.jpaFiles); // read-only } + protected Iterable getJpaFiles() { + return new CloneIterable(this.jpaFiles); // read-only + } + public int jpaFilesSize() { return this.jpaFiles.size(); } @@ -396,11 +401,9 @@ @Override public JpaFile getJpaFile(IFile file) { - synchronized (this.jpaFiles) { - for (JpaFile jpaFile : this.jpaFiles) { - if (jpaFile.getFile().equals(file)) { - return jpaFile; - } + for (JpaFile jpaFile : this.getJpaFiles()) { + if (jpaFile.getFile().equals(file)) { + return jpaFile; } } return null; @@ -443,14 +446,12 @@ * Return true if a JPA File was removed, false otherwise */ protected boolean removeJpaFile(IFile file) { - synchronized (this.jpaFiles) { - JpaFile jpaFile = this.getJpaFile(file); - if (jpaFile != null) { // a JpaFile is not added for every IFile - this.removeJpaFile(jpaFile); - return true; - } - return false; + JpaFile jpaFile = this.getJpaFile(file); + if (jpaFile != null) { // a JpaFile is not added for every IFile + this.removeJpaFile(jpaFile); + return true; } + return false; } /** @@ -619,7 +620,7 @@ protected Iterator javaResourceNodeRoots() { return new CompositeIterator( this.javaResourceCompilationUnits(), - this.jarResourcePackageFragmentRoots() + this.javaResourcePackageFragmentRoots() ); } @@ -627,14 +628,14 @@ // ********** JARs ********** // TODO - public JarResourcePackageFragmentRoot getJarResourcePackageFragmentRoot(String jarFileName) { + public JavaResourcePackageFragmentRoot getJavaResourcePackageFragmentRoot(String jarFileName) { // return this.getJarResourcePackageFragmentRoot(this.convertToPlatformFile(jarFileName)); - return this.getJarResourcePackageFragmentRoot(this.getProject().getFile(jarFileName)); + return this.getJavaResourcePackageFragmentRoot(this.getProject().getFile(jarFileName)); } - protected JarResourcePackageFragmentRoot getJarResourcePackageFragmentRoot(IFile jarFile) { - for (Iterator stream = this.jarResourcePackageFragmentRoots(); stream.hasNext(); ) { - JarResourcePackageFragmentRoot pfr = stream.next(); + protected JavaResourcePackageFragmentRoot getJavaResourcePackageFragmentRoot(IFile jarFile) { + for (Iterator stream = this.javaResourcePackageFragmentRoots(); stream.hasNext(); ) { + JavaResourcePackageFragmentRoot pfr = stream.next(); if (pfr.getFile().equals(jarFile)) { return pfr; } @@ -642,11 +643,11 @@ return null; } - protected Iterator jarResourcePackageFragmentRoots() { - return new TransformationIterator(this.jarJpaFiles()) { + protected Iterator javaResourcePackageFragmentRoots() { + return new TransformationIterator(this.jarJpaFiles()) { @Override - protected JarResourcePackageFragmentRoot transform(JpaFile jpaFile) { - return (JarResourcePackageFragmentRoot) jpaFile.getResourceModel(); + protected JavaResourcePackageFragmentRoot transform(JpaFile jpaFile) { + return (JavaResourcePackageFragmentRoot) jpaFile.getResourceModel(); } }; } Index: src/org/eclipse/jpt/core/context/PersistentType.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/PersistentType.java,v retrieving revision 1.16 diff -u -r1.16 PersistentType.java --- src/org/eclipse/jpt/core/context/PersistentType.java 18 Feb 2009 21:13:57 -0000 1.16 +++ src/org/eclipse/jpt/core/context/PersistentType.java 6 Apr 2009 20:59:11 -0000 @@ -17,7 +17,7 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter; /** - * + * Persistent type. * * Provisional API: This interface is part of an interim API that is still * under development and expected to change significantly before reaching @@ -28,9 +28,17 @@ public interface PersistentType extends JpaContextNode, JpaStructureNode, AccessHolder { + /** + * Return the persistent type's [fully-qualified] name. + * @see #getShortName() + */ String getName(); String NAME_PROPERTY = "name"; //$NON-NLS-1$ - + + /** + * Return the persistent type's short name. + * @see #getName() + */ String getShortName(); /** @@ -46,9 +54,11 @@ AccessType getOwnerDefaultAccess(); TypeMapping getMapping(); + String MAPPING_PROPERTY = "mapping"; //$NON-NLS-1$ + String getMappingKey(); + void setMappingKey(String key); - String MAPPING_PROPERTY = "mapping"; //$NON-NLS-1$ boolean isMapped(); @@ -79,13 +89,13 @@ * Return a read-only iterator of the contained {@link PersistentAttribute} */ ListIterator attributes(); + String ATTRIBUTES_LIST = "specifiedAttributes"; //$NON-NLS-1$ /** * Return the size of {@link PersistentAttribute}s list * @return */ int attributesSize(); - String SPECIFIED_ATTRIBUTES_LIST = "specifiedAttributes"; //$NON-NLS-1$ Iterator attributeNames(); Index: src/org/eclipse/jpt/core/context/jar/JarFile.java =================================================================== RCS file: src/org/eclipse/jpt/core/context/jar/JarFile.java diff -N src/org/eclipse/jpt/core/context/jar/JarFile.java --- src/org/eclipse/jpt/core/context/jar/JarFile.java 18 Feb 2009 21:13:57 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,41 +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.context.jar; - -import java.util.List; - -import org.eclipse.jpt.core.JpaStructureNode; -import org.eclipse.jpt.core.context.JpaContextNode; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - */ -public interface JarFile - extends JpaContextNode, JpaStructureNode -{ - - PersistentType getPersistentType(String typeName); - - void update(JarResourcePackageFragmentRoot jrpfr); - - /** - * Add to the list of current validation messages - */ - void validate(List messages, IReporter reporter); - -} Index: src/org/eclipse/jpt/core/internal/context/jar/GenericJarFile.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/context/jar/GenericJarFile.java diff -N src/org/eclipse/jpt/core/internal/context/jar/GenericJarFile.java --- src/org/eclipse/jpt/core/internal/context/jar/GenericJarFile.java 18 Feb 2009 21:13:57 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -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.context.jar; - -import java.util.List; - -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jpt.core.JpaNode; -import org.eclipse.jpt.core.JpaStructureNode; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.context.jar.JarFile; -import org.eclipse.jpt.core.internal.context.AbstractJpaContextNode; -import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericJarFile - extends AbstractJpaContextNode - implements JarFile -{ - protected JarResourcePackageFragmentRoot jarResourcePackageFragmentRoot; - - - // ********** constructor ********** - - public GenericJarFile(JpaNode parent, JarResourcePackageFragmentRoot jarResourcePackageFragmentRoot) { - super(parent); - this.jarResourcePackageFragmentRoot = jarResourcePackageFragmentRoot; - } - - - // ********** JpaStructureNode implementation ********** - - public String getId() { - return null; - } - - public IContentType getContentType() { - return JptCorePlugin.JAR_CONTENT_TYPE; - } - - public TextRange getSelectionTextRange() { - return null; - } - - public JpaStructureNode getStructureNode(int textOffset) { - return null; - } - - public void dispose() { - // nothing yet - } - - - // ********** JarFile implementation ********** - - public PersistentType getPersistentType(String typeName) { - return null; - } - - - // ********** updating ********** - - public void update(JarResourcePackageFragmentRoot jrpfr) { - this.jarResourcePackageFragmentRoot = jrpfr; - } - - - // ********** validation ********** - - public void validate(List messages, IReporter reporter) { - if (reporter.isCancelled()) { - throw new ValidationCancelledException(); - } - } - -} Index: src/org/eclipse/jpt/core/context/persistence/JarFileRef.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/persistence/JarFileRef.java,v retrieving revision 1.2 diff -u -r1.2 JarFileRef.java --- src/org/eclipse/jpt/core/context/persistence/JarFileRef.java 9 Feb 2009 03:54:36 -0000 1.2 +++ src/org/eclipse/jpt/core/context/persistence/JarFileRef.java 6 Apr 2009 20:59:11 -0000 @@ -12,7 +12,7 @@ import org.eclipse.jpt.core.JpaStructureNode; import org.eclipse.jpt.core.context.PersistentType; import org.eclipse.jpt.core.context.XmlContextNode; -import org.eclipse.jpt.core.context.jar.JarFile; +import org.eclipse.jpt.core.context.java.JarFile; import org.eclipse.jpt.core.resource.persistence.XmlJarFileRef; /** Index: src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentType.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentType.java,v retrieving revision 1.17 diff -u -r1.17 AbstractOrmPersistentType.java --- src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentType.java 24 Mar 2009 19:56:40 -0000 1.17 +++ src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentType.java 6 Apr 2009 20:59:16 -0000 @@ -254,7 +254,7 @@ this.specifiedPersistentAttributes.add(targetIndex, ormPersistentAttribute); newMapping.addToResourceModel(getResourceAttributes()); oldMapping.initializeOn(newMapping); - fireItemMoved(SPECIFIED_ATTRIBUTES_LIST, targetIndex, sourceIndex); + fireItemMoved(ATTRIBUTES_LIST, targetIndex, sourceIndex); } public void makePersistentAttributeVirtual(OrmPersistentAttribute ormPersistentAttribute) { @@ -304,7 +304,7 @@ newPersistentAttribute.setSpecifiedAccess(ormPersistentAttribute.getJavaPersistentAttribute().getSpecifiedAccess()); } - fireItemAdded(PersistentType.SPECIFIED_ATTRIBUTES_LIST, insertionIndex, newPersistentAttribute); + fireItemAdded(ATTRIBUTES_LIST, insertionIndex, newPersistentAttribute); fireItemRemoved(VIRTUAL_ATTRIBUTES_LIST, removalIndex, ormPersistentAttribute); } @@ -431,7 +431,7 @@ persistentAttribute.getMapping().addToResourceModel(resourceAttributes); persistentAttribute.getSpecifiedMapping().setName(attributeName); - fireItemAdded(PersistentType.SPECIFIED_ATTRIBUTES_LIST, index, persistentAttribute); + fireItemAdded(ATTRIBUTES_LIST, index, persistentAttribute); return persistentAttribute; } @@ -456,11 +456,11 @@ } protected void removeSpecifiedPersistentAttribute_(OrmPersistentAttribute ormPersistentAttribute) { - removeItemFromList(ormPersistentAttribute, this.specifiedPersistentAttributes, PersistentType.SPECIFIED_ATTRIBUTES_LIST); + removeItemFromList(ormPersistentAttribute, this.specifiedPersistentAttributes, ATTRIBUTES_LIST); } protected void moveSpecifiedPersistentAttribute_(int index, OrmPersistentAttribute attribute) { - moveItemInList(index, this.specifiedPersistentAttributes.indexOf(attribute), this.specifiedPersistentAttributes, PersistentType.SPECIFIED_ATTRIBUTES_LIST); + moveItemInList(index, this.specifiedPersistentAttributes.indexOf(attribute), this.specifiedPersistentAttributes, ATTRIBUTES_LIST); } public void removeSpecifiedPersistentAttribute(OrmPersistentAttribute ormPersistentAttribute) { @@ -470,7 +470,7 @@ if (getResourceAttributes().isUnset()) { this.typeMapping.getResourceTypeMapping().setAttributes(null); } - fireItemRemoved(PersistentType.SPECIFIED_ATTRIBUTES_LIST, index, ormPersistentAttribute); + fireItemRemoved(ATTRIBUTES_LIST, index, ormPersistentAttribute); } public String getName() { @@ -759,7 +759,7 @@ } if (!contextAttributeFound) { OrmPersistentAttribute ormPersistentAttribute = addSpecifiedPersistentAttribute(resourceMapping); - fireItemAdded(SPECIFIED_ATTRIBUTES_LIST, specifiedAttributesSize(), ormPersistentAttribute); + fireItemAdded(ATTRIBUTES_LIST, specifiedAttributesSize(), ormPersistentAttribute); } resourceIndex++; } Index: src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java,v retrieving revision 1.7 diff -u -r1.7 AbstractEntityMappings.java --- src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java 11 Mar 2009 17:19:15 -0000 1.7 +++ src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java 6 Apr 2009 20:59:16 -0000 @@ -54,6 +54,7 @@ import org.eclipse.jpt.db.Schema; import org.eclipse.jpt.db.SchemaContainer; import org.eclipse.jpt.utility.internal.CollectionTools; +import org.eclipse.jpt.utility.internal.iterables.CloneIterable; import org.eclipse.jpt.utility.internal.iterators.CloneIterator; import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; @@ -179,7 +180,7 @@ } public void changeMapping(OrmPersistentType ormPersistentType, OrmTypeMapping oldMapping, OrmTypeMapping newMapping) { - AccessType specifiedAccess = ormPersistentType.getSpecifiedAccess(); + AccessType savedAccess = ormPersistentType.getSpecifiedAccess(); ormPersistentType.dispose(); int sourceIndex = this.persistentTypes.indexOf(ormPersistentType); this.persistentTypes.remove(sourceIndex); @@ -190,12 +191,12 @@ newMapping.initializeFrom(oldMapping); //not sure where else to put this, need to set the access on the resource model - ormPersistentType.setSpecifiedAccess(specifiedAccess); + ormPersistentType.setSpecifiedAccess(savedAccess); fireItemMoved(PERSISTENT_TYPES_LIST, targetIndex, sourceIndex); } public OrmPersistentType getPersistentType(String fullyQualifiedTypeName) { - for (OrmPersistentType ormPersistentType : CollectionTools.iterable(persistentTypes())) { + for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) { if (ormPersistentType.isFor(fullyQualifiedTypeName)) { return ormPersistentType; } @@ -350,6 +351,10 @@ return new CloneListIterator(this.persistentTypes); } + protected Iterable getPersistentTypes() { + return new CloneIterable(this.persistentTypes); + } + public int persistentTypesSize() { return this.persistentTypes.size(); } @@ -609,7 +614,7 @@ //this needs to be handled both for className and persistentType.getName(). //moving on for now since I am just trying to get the ui compiled! just a warning that this isn't good api public boolean containsPersistentType(String className) { - for (OrmPersistentType persistentType : CollectionTools.iterable(persistentTypes())) { + for (OrmPersistentType persistentType : this.getPersistentTypes()) { if (persistentType.getName().equals(className)) { return true; } @@ -821,7 +826,7 @@ @Override public void postUpdate() { super.postUpdate(); - for (PersistentType persistentType : CollectionTools.iterable(this.persistentTypes())) { + for (PersistentType persistentType : this.getPersistentTypes()) { persistentType.postUpdate(); } } @@ -829,7 +834,7 @@ // ********** text ********** public JpaStructureNode getStructureNode(int textOffset) { - for (OrmPersistentType persistentType: CollectionTools.iterable(persistentTypes())) { + for (OrmPersistentType persistentType: this.getPersistentTypes()) { if (persistentType.contains(textOffset)) { return persistentType.getStructureNode(textOffset); } @@ -857,8 +862,8 @@ super.validate(messages, reporter); this.validateGenerators(messages); this.validateQueries(messages); - for (Iterator stream = this.persistentTypes(); stream.hasNext(); ) { - this.validatePersistentType(stream.next(), messages, reporter); + for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) { + this.validatePersistentType(ormPersistentType, messages, reporter); } } @@ -934,7 +939,7 @@ // ********** dispose ********** public void dispose() { - for (OrmPersistentType ormPersistentType : CollectionTools.iterable(persistentTypes())) { + for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) { ormPersistentType.dispose(); } } Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.core/META-INF/MANIFEST.MF,v retrieving revision 1.38 diff -u -r1.38 MANIFEST.MF --- META-INF/MANIFEST.MF 9 Feb 2009 03:54:36 -0000 1.38 +++ META-INF/MANIFEST.MF 6 Apr 2009 20:59:10 -0000 @@ -37,13 +37,11 @@ org.eclipse.xsd;bundle-version="[2.4.0,3.0.0)" Export-Package: org.eclipse.jpt.core, org.eclipse.jpt.core.context, - org.eclipse.jpt.core.context.jar, org.eclipse.jpt.core.context.java, org.eclipse.jpt.core.context.orm, org.eclipse.jpt.core.context.persistence, org.eclipse.jpt.core.internal;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.context;x-friends:="org.eclipse.jpt.ui", - org.eclipse.jpt.core.internal.context.jar;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.context.java;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.context.orm;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.context.persistence;x-friends:="org.eclipse.jpt.ui", @@ -52,8 +50,9 @@ org.eclipse.jpt.core.internal.platform;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.prefs;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.resource;x-friends:="org.eclipse.jpt.ui", - org.eclipse.jpt.core.internal.resource.jar;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.resource.java;x-friends:="org.eclipse.jpt.ui,org.eclipse.jpt.gen", + org.eclipse.jpt.core.internal.resource.java.binary;x-friends:="org.eclipse.jpt.ui", + org.eclipse.jpt.core.internal.resource.java.source;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.resource.orm;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.resource.orm.translators;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.resource.persistence;x-friends:="org.eclipse.jpt.ui", @@ -63,7 +62,6 @@ org.eclipse.jpt.core.internal.utility.jdt;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.internal.validation;x-friends:="org.eclipse.jpt.ui", org.eclipse.jpt.core.resource, - org.eclipse.jpt.core.resource.jar, org.eclipse.jpt.core.resource.java, org.eclipse.jpt.core.resource.orm, org.eclipse.jpt.core.resource.persistence, Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToManyAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToManyAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToManyAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToManyAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,92 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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; + +/** + * javax.persistence.Table + */ +public final class NullTableAnnotation + extends NullBaseTableAnnotation + implements TableAnnotation +{ + protected NullTableAnnotation(JavaResourcePersistentType parent) { + super(parent); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/core/resource/java/JavaResourcePackageFragmentRoot.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/JavaResourcePackageFragmentRoot.java diff -N src/org/eclipse/jpt/core/resource/java/JavaResourcePackageFragmentRoot.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/JavaResourcePackageFragmentRoot.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.resource.java; + +import java.util.ListIterator; + + +/** + * Java package fragement root + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface JavaResourcePackageFragmentRoot + extends JavaResourceNode.Root +{ + /** + * Return the package fragment root's package fragments. + */ + ListIterator packageFragments(); + + /** + * Return the size of the package fragment root's package fragments. + */ + int packageFragmentsSize(); + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTablesAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,117 @@ +/******************************************************************************* + * 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 + implements SecondaryTablesAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private final Vector secondaryTables = new Vector(); + + + 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 nestedAnnotations() { + return new CloneListIterator(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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/IdAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/IdAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/IdAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/IdAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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.context.java; + +import org.eclipse.jpt.core.context.Column; +import org.eclipse.jpt.core.internal.resource.java.NullOverrideAnnotation; +import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; +import org.eclipse.jpt.core.resource.java.ColumnAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; + +/** + * javax.persistence.AssociationOverride + */ +public class VirtualAttributeOverrideAnnotation + extends NullOverrideAnnotation + implements AttributeOverrideAnnotation +{ + private final VirtualAttributeOverrideColumnAnnotation column; + + + public VirtualAttributeOverrideAnnotation(JavaResourcePersistentMember parent, String name, Column column) { + super(parent, name); + this.column = new VirtualAttributeOverrideColumnAnnotation(this, column); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + protected AttributeOverrideAnnotation buildSupportingAnnotation() { + return (AttributeOverrideAnnotation) super.buildSupportingAnnotation(); + } + + // ****** column + public ColumnAnnotation getColumn() { + return this.column; + } + + public ColumnAnnotation getNonNullColumn() { + return this.getColumn(); + } + + public ColumnAnnotation addColumn() { + throw new UnsupportedOperationException(); + } + + public void removeColumn() { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullEmbeddedAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullEmbeddedAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullEmbeddedAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullEmbeddedAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdClassAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,115 @@ +/******************************************************************************* + * 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 + implements IdClassAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private String value; + + private String fullyQualifiedClassName; + + + public SourceIdClassAnnotation(JavaResourceNode parent, Type type) { + super(parent, type, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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 buildValueAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ID_CLASS__VALUE, SimpleTypeStringExpressionConverter.instance()); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedIdAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedIdAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedIdAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedIdAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/resource/java/NestableColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableColumnAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/NestableColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/NestableColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resource.java; + +/** + * Corresponds to the JPA annotation + * javax.persistence.Column + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestableColumnAnnotation + extends NestableAnnotation, ColumnAnnotation +{ + // combine two interfaces +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,107 @@ +/******************************************************************************* + * 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 ********** + + // ***** 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceMappedSuperclassAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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 + 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 + } + +} Index: src/org/eclipse/jpt/core/resource/java/NestableQueryHintAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableQueryHintAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/NestableQueryHintAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/NestableQueryHintAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resource.java; + +/** + * Corresponds to the JPA annotation + * javax.persistence.QueryHint + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestableQueryHintAnnotation + extends QueryHintAnnotation, NestableAnnotation +{ + // combine two interfaces +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnsAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,117 @@ +/******************************************************************************* + * 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 + implements JoinColumnsAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private final Vector joinColumns = new Vector(); + + + 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 nestedAnnotations() { + return new CloneListIterator(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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullOneToManyAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullOneToManyAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullOneToManyAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullOneToManyAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceOrderByAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,93 @@ +/******************************************************************************* + * 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 + implements OrderByAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private String value; + + + public SourceOrderByAnnotation(JavaResourceNode parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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 buildValueAdapter() { + return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ORDER_BY__VALUE, false); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorColumnAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullBasicAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,68 @@ +/******************************************************************************* + * 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 buildMappingAnnotation() { + return (BasicAnnotation) super.buildMappingAnnotation(); + } + + // ***** fetch + public FetchType getFetch() { + return null; + } + + public void setFetch(FetchType fetch) { + if (fetch != null) { + this.buildMappingAnnotation().setFetch(fetch); + } + } + + public TextRange getFetchTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** optional + public Boolean getOptional() { + return null; + } + + public void setOptional(Boolean optional) { + if (optional != null) { + this.buildMappingAnnotation().setOptional(optional); + } + } + + public TextRange getOptionalTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/ManyToManyAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/ManyToManyAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/ManyToManyAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/ManyToManyAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueriesAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueriesAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueriesAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueriesAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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 + implements NamedNativeQueriesAnnotation +{ + private final Vector namedNativeQueries; + + + public BinaryNamedNativeQueriesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.namedNativeQueries = this.buildNamedNativeQueries(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public ListIterator nestedAnnotations() { + return new CloneListIterator(this.namedNativeQueries); + } + + public int nestedAnnotationsSize() { + return this.namedNativeQueries.size(); + } + + private Vector buildNamedNativeQueries() { + Object[] jdtQueries = this.getJdtMemberValues(JPA.NAMED_NATIVE_QUERIES__VALUE); + Vector result = new Vector(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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/LobAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/LobAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/LobAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/LobAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/resource/java/AnnotationContainer.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/AnnotationContainer.java diff -N src/org/eclipse/jpt/core/resource/java/AnnotationContainer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/AnnotationContainer.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,100 @@ +/******************************************************************************* + * 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.resource.java; + +import java.util.ListIterator; + +import org.eclipse.jdt.core.dom.CompilationUnit; + +/** + * Common behavior for all annotation "containers". + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface AnnotationContainer +{ + /** + * Return the name of the container annotation. + * Used when traversing the AST. + */ + String getContainerAnnotationName(); + + /** + * Return the corresponding JDT DOM annotation from the specified + * AST compilation unit. Used as a starting point when traversing the AST. + */ + org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot); + + /** + * Return the name of the container annotation's element that is used + * to indicate the nested annotations (typically "value"). + * Used when traversing the AST. + */ + String getElementName(); + + /** + * Return the name of the nested annotations held by the container. + * Used when traversing the AST. + */ + String getNestableAnnotationName(); + + /** + * Return the nested annotations held by the container. + */ + ListIterator nestedAnnotations(); + + /** + * Return the number of nested annotations held by the container. + */ + int nestedAnnotationsSize(); + + /** + * Add a nested annotation to the container + * without firing change notification. + */ + T addNestedAnnotationInternal(); + + /** + * The specified nested annotation was added to the container at the + * specified index; notify interested parties. + */ + void nestedAnnotationAdded(int index, T nestedAnnotation); + + /** + * Move the nested annotation at the specified source index in the + * container to the specified target index without firing change notification. + * Return the moved nested annotation. + */ + T moveNestedAnnotationInternal(int targetIndex, int sourceIndex); + + /** + * A nested annotation was moved within the container annotation from the + * specified source index to the specified target index; notify interested + * parties. + */ + void nestedAnnotationMoved(int targetIndex, int sourceIndex); + + /** + * Remove the nested annotation at the specified index from the + * container without firing change notification. + */ + T removeNestedAnnotationInternal(int index); + + /** + * The specified nested annotation was removed from the container + * at the specified index; notify interested parties. + */ + void nestedAnnotationRemoved(int index, T nestedAnnotation); + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryClassFile.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryClassFile.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryClassFile.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryClassFile.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,68 @@ +/******************************************************************************* + * 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()); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToManyAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,132 @@ +/******************************************************************************* + * 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 TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); + + private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); + + private static final DeclarationAnnotationElementAdapter CASCADE_ADAPTER = buildCascadeAdapter(); + + private static final DeclarationAnnotationElementAdapter MAPPED_BY_ADAPTER = buildMappedByAdapter(); + private final AnnotationElementAdapter 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 getTargetEntityAdapter() { + return TARGET_ENTITY_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter getFetchAdapter() { + return FETCH_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter 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 buildTargetEntityAdapter() { + return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__TARGET_ENTITY); + } + + private static DeclarationAnnotationElementAdapter buildMappedByAdapter() { + return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__MAPPED_BY, false); // false = do not remove annotation when empty + } + + private static DeclarationAnnotationElementAdapter buildFetchAdapter() { + return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__FETCH); + } + + private static DeclarationAnnotationElementAdapter buildCascadeAdapter() { + return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_MANY__CASCADE); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToOneAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToOneAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToOneAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToOneAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,120 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnsAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnsAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnsAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnsAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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 + implements PrimaryKeyJoinColumnsAnnotation +{ + private final Vector pkJoinColumns; + + + public BinaryPrimaryKeyJoinColumnsAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.pkJoinColumns = this.buildPkJoinColumns(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public ListIterator nestedAnnotations() { + return new CloneListIterator(this.pkJoinColumns); + } + + public int nestedAnnotationsSize() { + return this.pkJoinColumns.size(); + } + + private Vector buildPkJoinColumns() { + Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.PRIMARY_KEY_JOIN_COLUMNS__VALUE); + Vector result = new Vector(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(); + } + +} + Index: src/org/eclipse/jpt/core/internal/resource/java/ManyToOneAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/ManyToOneAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/ManyToOneAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/ManyToOneAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/AccessAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AccessAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AccessAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/AccessAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.BinaryAccessAnnotation; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAccessAnnotation; +import org.eclipse.jpt.core.resource.java.AccessAnnotation; +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.utility.jdt.Member; + +/** + * javax.persistence.Access + */ +public class AccessAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new AccessAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private AccessAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceAccessAnnotation(parent, member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + return new NullAccessAnnotation(parent); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryAccessAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return AccessAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/MapKeyAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/MapKeyAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/MapKeyAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/MapKeyAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullOwnableRelationshipMappingAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,138 @@ +/******************************************************************************* + * 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 buildMappingAnnotation() { + return (OwnableRelationshipMappingAnnotation) super.buildMappingAnnotation(); + } + + // ***** target entity + public String getTargetEntity() { + return null; + } + + public void setTargetEntity(String targetEntity) { + if (targetEntity != null) { + this.buildMappingAnnotation().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.buildMappingAnnotation().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.buildMappingAnnotation().setFetch(fetch); + } + } + + public TextRange getFetchTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** cascade all + public boolean isCascadeAll() { + return false; + } + + public void setCascadeAll(boolean all) { + this.buildMappingAnnotation().setCascadeAll(all); + } + + // ***** cascade merge + public boolean isCascadeMerge() { + return false; + } + + public void setCascadeMerge(boolean merge) { + this.buildMappingAnnotation().setCascadeMerge(merge); + } + + // ***** cascade persist + public boolean isCascadePersist() { + return false; + } + + public void setCascadePersist(boolean persist) { + this.buildMappingAnnotation().setCascadePersist(persist); + } + + // ***** cascade refresh + public boolean isCascadeRefresh() { + return false; + } + + public void setCascadeRefresh(boolean refresh) { + this.buildMappingAnnotation().setCascadeRefresh(refresh); + } + + // ***** cascade remove + public boolean isCascadeRemove() { + return false; + } + + public void setCascadeRemove(boolean remove) { + this.buildMappingAnnotation().setCascadeRemove(remove); + } + + public TextRange getCascadeTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullAttributeOverrideColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,34 @@ +/******************************************************************************* + * 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 buildAnnotation() { + return this.getAttributeOverrideAnnotation().addColumn(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNode.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.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.resource.java.JavaResourcePackageFragmentRoot; +import org.eclipse.jpt.core.utility.TextRange; + +/** + * Binary convenience methods + */ +public abstract class BinaryNode + extends AbstractJavaResourceNode +{ + + // ********** construction ********** + + protected BinaryNode(JavaResourceNode parent) { + super(parent); + } + + + // ********** JavaResourceNode implementation ********** + + @Override + public JavaResourcePackageFragmentRoot getRoot() { + return (JavaResourcePackageFragmentRoot) super.getRoot(); + } + + 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/MappedSuperclassAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToOneAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToOneAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToOneAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryManyToOneAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,88 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/resource/java/NestableAssociationOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableAssociationOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/NestableAssociationOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/NestableAssociationOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resource.java; + +/** + * Corresponds to the JPA annotation + * javax.persistence.AssociationOverride + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestableAssociationOverrideAnnotation + extends AssociationOverrideAnnotation, NestableAnnotation +{ + // combine two interfaces +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryVersionAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryVersionAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryVersionAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryVersionAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySequenceGeneratorAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySequenceGeneratorAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySequenceGeneratorAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySequenceGeneratorAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,92 @@ +/******************************************************************************* + * 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 final class BinarySequenceGeneratorAnnotation + extends BinaryGeneratorAnnotation + implements SequenceGeneratorAnnotation +{ + private String sequenceName; + + + public 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratedValueAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,134 @@ +/******************************************************************************* + * 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 + implements GeneratedValueAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter STRATEGY_ADAPTER = buildStrategyAdapter(); + private final AnnotationElementAdapter strategyAdapter; + private GenerationType strategy; + + private static final DeclarationAnnotationElementAdapter GENERATOR_ADAPTER = buildGeneratorAdapter(); + private final AnnotationElementAdapter generatorAdapter; + private String generator; + + + public SourceGeneratedValueAnnotation(JavaResourceNode parent, Member member) { + super(parent, member, DECLARATION_ANNOTATION_ADAPTER); + this.strategyAdapter = new ShortCircuitAnnotationElementAdapter(member, STRATEGY_ADAPTER); + this.generatorAdapter = new ShortCircuitAnnotationElementAdapter(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 buildStrategyAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__STRATEGY, false); + } + + private static DeclarationAnnotationElementAdapter buildGeneratorAdapter() { + return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__GENERATOR, false); + } + +} Index: src/org/eclipse/jpt/core/context/java/JarFile.java =================================================================== RCS file: src/org/eclipse/jpt/core/context/java/JarFile.java diff -N src/org/eclipse/jpt/core/context/java/JarFile.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/context/java/JarFile.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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.context.java; + +import java.util.List; + +import org.eclipse.jpt.core.JpaStructureNode; +import org.eclipse.jpt.core.context.JpaContextNode; +import org.eclipse.jpt.core.context.PersistentType; +import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; +import org.eclipse.wst.validation.internal.provisional.core.IMessage; +import org.eclipse.wst.validation.internal.provisional.core.IReporter; + +/** + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface JarFile + extends JpaContextNode, JpaStructureNode +{ + + PersistentType getPersistentType(String typeName); + + void update(JavaResourcePackageFragmentRoot jrpfr); + + /** + * Add to the list of current validation messages + */ + void validate(List messages, IReporter reporter); + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,106 @@ +/******************************************************************************* + * 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(); + } + + + //************ JarOverrideAnnotation implementation **************** + + @Override + 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); +// } +// } + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnsAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/ColumnAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/ColumnAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/ColumnAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/ColumnAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/resource/java/JavaResourcePackageFragment.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/JavaResourcePackageFragment.java diff -N src/org/eclipse/jpt/core/resource/java/JavaResourcePackageFragment.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/JavaResourcePackageFragment.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,44 @@ +/******************************************************************************* + * 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.resource.java; + +import java.util.Iterator; +import java.util.ListIterator; + + +/** + * Java package fragment + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface JavaResourcePackageFragment + extends JavaResourceNode +{ + /** + * Return the package fragment's class files that contain "persistable" types. + */ + ListIterator classFiles(); + + /** + * Return the size of the package fragment's class files. + */ + int classFilesSize(); + + /** + * Return the package fragment's "persistable" resource types, as defined + * by the JPA spec. + */ + Iterator persistableTypes(); + +} Index: src/org/eclipse/jpt/core/internal/resource/java/VersionAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/VersionAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/VersionAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/VersionAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,195 @@ +/******************************************************************************* + * 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 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 ********** + + // ***** 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 uniqueConstraints() { + return new CloneListIterator(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 buildUniqueConstraints() { + Object[] jdtUniqueConstraints = this.getJdtMemberValues(this.getUniqueConstraintElementName()); + Vector result = new Vector(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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/DiscriminatorValueAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,101 @@ +/******************************************************************************* + * 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 final class BinaryAssociationOverrideAnnotation + extends BinaryOverrideAnnotation + implements NestableAssociationOverrideAnnotation +{ + private final Vector joinColumns; + + + public 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(); + } + + + // ********** JarOverrideAnnotation implementation ********** + + @Override + String getNameElementName() { + return JPA.ASSOCIATION_OVERRIDE__NAME; + } + + + // ********** AssociationOverrideAnnotation implementation ********** + + // ***** join columns + public ListIterator joinColumns() { + return new CloneListIterator(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 buildJoinColumns() { + Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.ASSOCIATION_OVERRIDE__JOIN_COLUMNS); + Vector result = new Vector(jdtJoinColumns.length); + for (Object jdtJoinColumn : jdtJoinColumns) { + result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); + } + return result; + } + + // TODO + private void updateJoinColumns() { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,224 @@ +/******************************************************************************* + * 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 lengthDeclarationAdapter; + private final AnnotationElementAdapter lengthAdapter; + private Integer length; + + private final DeclarationAnnotationElementAdapter precisionDeclarationAdapter; + private final AnnotationElementAdapter precisionAdapter; + private Integer precision; + + private final DeclarationAnnotationElementAdapter scaleDeclarationAdapter; + private final AnnotationElementAdapter 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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceMapKeyAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,98 @@ +/******************************************************************************* + * 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 + implements MapKeyAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildNameAdapter(); + private final AnnotationElementAdapter nameAdapter; + private String name; + + + public SourceMapKeyAnnotation(JavaResourceNode parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + this.nameAdapter = new ShortCircuitAnnotationElementAdapter(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 buildNameAdapter() { + return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.MAP_KEY__NAME, false); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NamedQueryAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceInheritanceAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,95 @@ +/******************************************************************************* + * 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 + implements InheritanceAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter STRATEGY_ADAPTER = buildStrategyAdapter(); + private final AnnotationElementAdapter strategyAdapter; + private InheritanceType strategy; + + + public SourceInheritanceAnnotation(JavaResourcePersistentType parent, Type type) { + super(parent, type, DECLARATION_ANNOTATION_ADAPTER); + this.strategyAdapter = new ShortCircuitAnnotationElementAdapter(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 buildStrategyAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.INHERITANCE__STRATEGY); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceUniqueConstraintAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,192 @@ +/******************************************************************************* + * 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.NestedIndexedDeclarationAnnotationAdapter; +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 + implements NestableUniqueConstraintAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.UNIQUE_CONSTRAINT); + + private final DeclarationAnnotationElementAdapter columnNamesDeclarationAdapter; + private final AnnotationElementAdapter columnNamesAdapter; + private final Vector columnNames = new Vector(); + + + 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 buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitArrayAnnotationElementAdapter(this.member, daea); + } + + private static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, AnnotationStringArrayExpressionConverter.forStrings()); + } + + private static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { + return new ConversionDeclarationAnnotationElementAdapter(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 columnNames() { + return new CloneListIterator(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); + } + + + // ********** static methods ********** + + static NestableUniqueConstraintAnnotation createSecondaryTableUniqueConstraint(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter declarationAnnotationAdapter, int index) { + return new SourceUniqueConstraintAnnotation(parent, member, buildSecondaryTableUniqueConstraintAnnotationAdapter(declarationAnnotationAdapter, index)); + } + + private static IndexedDeclarationAnnotationAdapter buildSecondaryTableUniqueConstraintAnnotationAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter, int index) { + return new NestedIndexedDeclarationAnnotationAdapter(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); + } + + static NestableUniqueConstraintAnnotation createJoinTableUniqueConstraint(JavaResourceNode parent, Member member, int index) { + return new SourceUniqueConstraintAnnotation(parent, member, buildJoinTableUniqueConstraintAnnotationAdapter(index)); + } + + private static IndexedDeclarationAnnotationAdapter buildJoinTableUniqueConstraintAnnotationAdapter(int index) { + return new NestedIndexedDeclarationAnnotationAdapter(SourceJoinTableAnnotation.DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); + } + + static NestableUniqueConstraintAnnotation createTableUniqueConstraint(JavaResourceNode parent, Member member, int index) { + return new SourceUniqueConstraintAnnotation(parent, member, buildTableUniqueConstraintAnnotationAdapter(index)); + } + + private static IndexedDeclarationAnnotationAdapter buildTableUniqueConstraintAnnotationAdapter(int index) { + return new NestedIndexedDeclarationAnnotationAdapter(SourceTableAnnotation.DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); + } + + static NestableUniqueConstraintAnnotation createTableGeneratorUniqueConstraint(JavaResourceNode parent, Member member, int index) { + return new SourceUniqueConstraintAnnotation(parent, member, buildTableGeneratorUniqueConstraintAnnotationAdapter(index)); + } + + private static IndexedDeclarationAnnotationAdapter buildTableGeneratorUniqueConstraintAnnotationAdapter(int index) { + return new NestedIndexedDeclarationAnnotationAdapter(SourceTableGeneratorAnnotation.DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/AnnotationContainerTools.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,251 @@ +/******************************************************************************* + * 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.List; +import java.util.ListIterator; + +import org.eclipse.jdt.core.dom.ASTVisitor; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.core.dom.MarkerAnnotation; +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.internal.utility.jdt.JDTTools; +import org.eclipse.jpt.core.resource.java.AnnotationContainer; +import org.eclipse.jpt.core.resource.java.NestableAnnotation; +import org.eclipse.jpt.utility.internal.CollectionTools; +import org.eclipse.jpt.utility.internal.HashBag; + +/** + * 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 NestableAnnotation addNestedAnnotation(int index, AnnotationContainer 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 void moveNestedAnnotation(int targetIndex, int sourceIndex, AnnotationContainer 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 void synchJavaAnnotationsAfterMove(int targetIndex, int sourceIndex, AnnotationContainer 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 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 void removeNestedAnnotation(int index, AnnotationContainer 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 void synchJavaAnnotationsAfterRemove(int index, AnnotationContainer annotationContainer) { + List nestableAnnotations = CollectionTools.list(annotationContainer.nestedAnnotations()); + for (int i = index; i < nestableAnnotations.size(); i++) { + 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 void initialize(AnnotationContainer annotationContainer, CompilationUnit astRoot) { + // ignore the nested JDT annotations themselves + // (maybe someday we can use them during initialization...) + int size = getNestedJdtAnnotations(astRoot, annotationContainer).size(); + for (int i = 0; i < size; i++) { + T nestedAnnotation = annotationContainer.addNestedAnnotationInternal(); + nestedAnnotation.initialize(astRoot); + } + } + + /** + * Use the annotation visitor to gather up the nested JDT DOM annotations. + */ + private static HashBag getNestedJdtAnnotations(CompilationUnit astRoot, AnnotationContainer annotationContainer) { + AnnotationVisitor visitor = new AnnotationVisitor(annotationContainer); + annotationContainer.getContainerJdtAnnotation(astRoot).accept(visitor); + return visitor.jdtAnnotations; + } + + /** + * 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 void update(AnnotationContainer annotationContainer, CompilationUnit astRoot) { + HashBag jdtAnnotations = getNestedJdtAnnotations(astRoot, annotationContainer); + for (ListIterator stream = annotationContainer.nestedAnnotations(); stream.hasNext(); ) { + T nestedAnnotation = stream.next(); + org.eclipse.jdt.core.dom.Annotation jdtAnnotation = nestedAnnotation.getJdtAnnotation(astRoot); + if (jdtAnnotations.isEmpty()) { + // no more JDT DOM 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); + } else { + if (jdtAnnotations.remove(jdtAnnotation)) { + // matching JDT DOM annotation found - update the nested annotation + nestedAnnotation.update(astRoot); + } else { + throw new IllegalStateException("invalid nested annotation: " + nestedAnnotation); //$NON-NLS-1$ + } + } + } + // add nested annotations for the remaining JDT DOM annotations + int start = annotationContainer.nestedAnnotationsSize(); + int size = start + jdtAnnotations.size(); + for (int i = start; i < size; i++) { + T nestedAnnotation = annotationContainer.addNestedAnnotationInternal(); + nestedAnnotation.initialize(astRoot); + annotationContainer.nestedAnnotationAdded(i, nestedAnnotation); + } + } + + private AnnotationContainerTools() { + super(); + throw new UnsupportedOperationException(); + } + + + // ********** annotation visitor ********** + + /** + * Gather up the nested JDT annotations. + */ + static class AnnotationVisitor + extends ASTVisitor + { + final AnnotationContainer annotationContainer; + final HashBag jdtAnnotations = new HashBag(); + + AnnotationVisitor(AnnotationContainer annotationContainer) { + super(); + this.annotationContainer = annotationContainer; + } + + /** + * MarkerAnnotation children: + * typeName - Name + * we probably don't need to visit a MarkerAnnotation's children + * since it doesn't hold anything interesting... + */ + @Override + public boolean visit(MarkerAnnotation node) { + return this.visit_(node); + } + + /** + * SingleMemberAnnotation children: + * typeName - Name + * value - Expression (which can be an Annotation) + */ + @Override + public boolean visit(SingleMemberAnnotation node) { + return this.visit_(node); + } + + /** + * NormalAnnotation children: + * typeName - Name + * values - MemberValuePair + */ + @Override + public boolean visit(NormalAnnotation node) { + return this.visit_(node); + } + + /** + * MemberValuePair children: + * name - SimpleName + * value - Expression (which can be an Annotation) + */ + @Override + public boolean visit(MemberValuePair node) { + // only process the children if the mvp's name matches the container's element name + return node.getName().getFullyQualifiedName().equals(this.annotationContainer.getElementName()); + } + + boolean visit_(org.eclipse.jdt.core.dom.Annotation jdtAnnotation) { + String jdtAnnotationName = JDTTools.resolveAnnotation(jdtAnnotation); + if (jdtAnnotationName == null) { + return false; // unknown annotation - skip its children + } + if (jdtAnnotationName.equals(this.annotationContainer.getContainerAnnotationName())) { + return true; // process the container annotation's children + } + if (jdtAnnotationName.equals(this.annotationContainer.getNestableAnnotationName())) { + this.jdtAnnotations.add(jdtAnnotation); + return false; // no need to visit the nested annotation's children + } + return false; // ignore other annotations + } + + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAccessAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAccessAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAccessAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAccessAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,76 @@ +/******************************************************************************* + * 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.AccessAnnotation; +import org.eclipse.jpt.core.resource.java.AccessType; +import org.eclipse.jpt.core.resource.java.JPA; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +import org.eclipse.jpt.core.utility.TextRange; + +/** + * javax.persistence.Access + */ +public final class BinaryAccessAnnotation + extends BinaryAnnotation + implements AccessAnnotation +{ + private AccessType value; + + + public BinaryAccessAnnotation(JavaResourcePersistentMember 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()); + } + + @Override + public void toString(StringBuilder sb) { + sb.append(this.value); + } + + + // ********** AccessAnnotation implementation ********** + + // ***** value + public AccessType getValue() { + return this.value; + } + + public void setValue(AccessType value) { + throw new UnsupportedOperationException(); + } + + private void setValue_(AccessType value) { + AccessType old = this.value; + this.value = value; + this.firePropertyChanged(VALUE_PROPERTY, old, value); + } + + private AccessType buildValue() { + return AccessType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA.ACCESS__VALUE)); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryInheritanceAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryInheritanceAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryInheritanceAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryInheritanceAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,71 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,240 @@ +/******************************************************************************* + * 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.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.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.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.AssociationOverride + */ +public final class SourceAssociationOverrideAnnotation + extends SourceOverrideAnnotation + implements NestableAssociationOverrideAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private final Vector joinColumns = new Vector(); + private final JoinColumnsAnnotationContainer joinColumnsContainer = new JoinColumnsAnnotationContainer(); + + + // ********** construction/initialization ********** + + public 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 + String getNameElementName() { + return JPA.ASSOCIATION_OVERRIDE__NAME; + } + + + // ********** AssociationOverrideAnnotation implementation ********** + + // ***** join columns + public ListIterator joinColumns() { + return new CloneListIterator(this.joinColumns); + } + + ListIterator nestableJoinColumns() { + return new CloneListIterator(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); + } + } + + + // ********** static methods ********** + + public static SourceAssociationOverrideAnnotation createAssociationOverride(JavaResourceNode parent, Member member) { + return new SourceAssociationOverrideAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); + } + + static SourceAssociationOverrideAnnotation createNestedAssociationOverride(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { + IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); + IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa); + return new SourceAssociationOverrideAnnotation(parent, member, idaa, annotationAdapter); + } + + protected static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { + return new NestedIndexedDeclarationAnnotationAdapter(attributeOverridesAdapter, index, JPA.ASSOCIATION_OVERRIDE); + } + + + // ********** join column container ********** + + /** + * adapt the AnnotationContainer interface to the override's join columns + */ + class JoinColumnsAnnotationContainer + implements AnnotationContainer + { + 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 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); + } + + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/TableGeneratorAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/InheritanceAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/InheritanceAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/InheritanceAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/InheritanceAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/AssociationOverrideAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.BinaryAssociationOverrideAnnotation; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAssociationOverrideAnnotation; +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 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 SourceAssociationOverrideAnnotation.createAssociationOverride(parent, member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryAssociationOverrideAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return AssociationOverrideAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBasicAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBasicAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBasicAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBasicAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/EmbeddedIdAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceQueryHintAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,170 @@ +/******************************************************************************* + * 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 + implements NestableQueryHintAnnotation +{ + private final DeclarationAnnotationElementAdapter nameDeclarationAdapter; + private final AnnotationElementAdapter nameAdapter; + private String name; + + private final DeclarationAnnotationElementAdapter valueDeclarationAdapter; + private final AnnotationElementAdapter 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 buildAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(this.member, daea); + } + + private DeclarationAnnotationElementAdapter buildNameAdapter(DeclarationAnnotationAdapter adapter) { + return ConversionDeclarationAnnotationElementAdapter.forStrings(adapter, JPA.QUERY_HINT__NAME); + } + + private DeclarationAnnotationElementAdapter 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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,77 @@ +/******************************************************************************* + * 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.NestableUniqueConstraintAnnotation; +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 NAME_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__NAME); + + private static final DeclarationAnnotationElementAdapter SCHEMA_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE__SCHEMA); + + private static final DeclarationAnnotationElementAdapter 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 getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + // ignore the daa passed in, @Table is never nested + return NAME_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + // ignore the daa passed in, @Table is never nested + return SCHEMA_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + // ignore the daa passed in, @Table is never nested + return CATALOG_ADAPTER; + } + + @Override + String getUniqueConstraintsElementName() { + return JPA.TABLE__UNIQUE_CONSTRAINTS; + } + + @Override + NestableUniqueConstraintAnnotation buildUniqueConstraint(int index) { + return SourceUniqueConstraintAnnotation.createTableUniqueConstraint(this, this.member, index); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceAssociationOverridesAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,117 @@ +/******************************************************************************* + * 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 final class SourceAssociationOverridesAnnotation + extends SourceAnnotation + implements AssociationOverridesAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private final Vector associationOverrides = new Vector(); + + + public 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 nestedAnnotations() { + return new CloneListIterator(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; + } + + private NestableAssociationOverrideAnnotation buildAssociationOverride(int index) { + return SourceAssociationOverrideAnnotation.createNestedAssociationOverride(this, this.member, index, this.daa); + } + + 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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratedValueAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratedValueAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratedValueAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratedValueAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,101 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,115 @@ +/******************************************************************************* + * 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 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 pkJoinColumns() { + return new CloneListIterator(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 buildPkJoinColumns() { + Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.SECONDARY_TABLE__PK_JOIN_COLUMNS); + Vector result = new Vector(jdtJoinColumns.length); + for (Object jdtJoinColumn : jdtJoinColumns) { + result.add(new BinaryPrimaryKeyJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); + } + return result; + } + + // TODO + private void updatePkJoinColumns() { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceIdAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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 + 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 + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueriesAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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 + implements NamedQueriesAnnotation +{ + private final Vector namedQueries; + + + public BinaryNamedQueriesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.namedQueries = this.buildNamedQueries(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public ListIterator nestedAnnotations() { + return new CloneListIterator(this.namedQueries); + } + + public int nestedAnnotationsSize() { + return this.namedQueries.size(); + } + + private Vector buildNamedQueries() { + Object[] jdtQueries = this.getJdtMemberValues(JPA.NAMED_QUERIES__VALUE); + Vector result = new Vector(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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/JoinColumnsAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPrimaryKeyJoinColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,87 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverridesAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,117 @@ +/******************************************************************************* + * 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 + implements AttributeOverridesAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private final Vector attributesOverrides = new Vector(); + + + 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 nestedAnnotations() { + return new CloneListIterator(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.createNestedAttributeOverride(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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceVersionAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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 + 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 + } + +} Index: src/org/eclipse/jpt/core/resource/java/NestablePrimaryKeyJoinColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestablePrimaryKeyJoinColumnAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/NestablePrimaryKeyJoinColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/NestablePrimaryKeyJoinColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resource.java; + +/** + * Corresponds to the JPA annotation + * javax.persistence.PrimaryKeyJoinColumn + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestablePrimaryKeyJoinColumnAnnotation + extends PrimaryKeyJoinColumnAnnotation, NestableAnnotation +{ + // combine two interfaces +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdClassAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdClassAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdClassAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdClassAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueryAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,441 @@ +/******************************************************************************* + * 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.ListIterator; +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.JavaResourceClassFile; +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.iterables.CloneIterable; +import org.eclipse.jpt.utility.internal.iterators.CloneIterator; +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 fields; + + private final Vector methods; + + private AccessType access; + + + // ********** construction/initialization ********** + + BinaryPersistentType(JavaResourceClassFile 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(); + 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 buildMappingAnnotation(IAnnotation jdtAnnotation) { + return this.getAnnotationProvider().buildTypeMappingAnnotation(this, jdtAnnotation); + } + + @Override + Annotation buildSupportingAnnotation(IAnnotation jdtAnnotation) { + return this.getAnnotationProvider().buildTypeSupportingAnnotation(this, jdtAnnotation); + } + + @Override + Annotation buildNullSupportingAnnotation(String annotationName) { + return this.getAnnotationProvider().buildNullTypeSupportingAnnotation(this, annotationName); + } + + @Override + ListIterator validMappingAnnotationNames() { + return this.getAnnotationProvider().typeMappingAnnotationNames(); + } + + @Override + ListIterator validSupportingAnnotationNames() { + return this.getAnnotationProvider().typeSupportingAnnotationNames(); + } + + + // ********** 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(); + } + + // ***** superclass qualified name + public String getSuperClassQualifiedName() { + return this.superClassQualifiedName; + } + + private void setSuperClassQualifiedName(String superClassQualifiedName) { + String old = this.superClassQualifiedName; + this.superClassQualifiedName = superClassQualifiedName; + this.firePropertyChanged(SUPER_CLASS_QUALIFIED_NAME_PROPERTY, old, superClassQualifiedName); + } + + private String buildSuperClassQualifiedName() { + try { + return this.getMember().getSuperclassName(); + } 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); + } + + /** + * check only persistable attributes + */ + public boolean hasAnyAttributePersistenceAnnotations() { + for (Iterator stream = this.persistableAttributes(); stream.hasNext(); ) { + if (stream.next().hasAnyPersistenceAnnotations()) { + return true; + } + } + return false; + } + + @Override + public IType getMember() { + return (IType) super.getMember(); + } + + + // ********** fields ********** + + public Iterator fields() { + return new CloneIterator(this.fields); + } + + private Iterable getFields() { + return new CloneIterable(this.fields); + } + + public Iterator persistableFields() { + return this.persistableMembers(this.fields()); + } + + public Iterator persistableFieldsWithSpecifiedFieldAccess() { + return new FilteringIterator(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 remove) { + this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION); + } + + private Vector buildFields() { + IField[] jdtFields = this.getFields(this.getMember()); + Vector result = new Vector(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 methods() { + return new CloneIterator(this.methods); + } + + private Iterable getMethods() { + return new CloneIterable(this.methods); + } + + public Iterator persistableProperties() { + return persistableMembers(this.methods()); + } + + public Iterator persistablePropertiesWithSpecifiedPropertyAccess() { + return new FilteringIterator(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 remove) { + this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION); + } + + private Vector buildMethods() { + IMethod[] jdtMethods = this.getMethods(this.getMember()); + Vector result = new Vector(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 persistableAttributes() { + return new CompositeIterator( + this.persistableFields(), + this.persistableProperties() + ); + } + + public Iterator 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 persistableAttributesForFieldAccessType() { + return new CompositeIterator( + this.persistableFields(), + this.persistablePropertiesWithSpecifiedPropertyAccess() + ); + } + + @SuppressWarnings("unchecked") + private Iterator persistableAttributesForPropertyAccessType() { + return new CompositeIterator( + this.persistableProperties(), + this.persistableFieldsWithSpecifiedFieldAccess() + ); + } + + + 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(); + } + + } + + + // ********** unsupported JavaResourcePersistentType implementation ********** + + public Iterator types() { + throw new UnsupportedOperationException(); + } + + public Iterator allTypes() { + throw new UnsupportedOperationException(); + } + + public Iterator persistableTypes() { + throw new UnsupportedOperationException(); + } + + public Iterator allPersistableTypes() { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceManyToOneAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,133 @@ +/******************************************************************************* + * 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 TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); + + private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); + + private static final DeclarationAnnotationElementAdapter CASCADE_ADAPTER = buildCascadeAdapter(); + + private static final DeclarationAnnotationElementAdapter OPTIONAL_ADAPTER = buildOptionalAdapter(); + private final AnnotationElementAdapter 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 getTargetEntityAdapter() { + return TARGET_ENTITY_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter getFetchAdapter() { + return FETCH_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter 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 buildTargetEntityAdapter() { + return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__TARGET_ENTITY); + } + + private static DeclarationAnnotationElementAdapter buildFetchAdapter() { + return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__FETCH); + } + + private static DeclarationAnnotationElementAdapter buildOptionalAdapter() { + return buildOptionalAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__OPTIONAL); + } + + private static DeclarationAnnotationElementAdapter buildCascadeAdapter() { + return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.MANY_TO_ONE__CASCADE); + } + + private static DeclarationAnnotationElementAdapter buildOptionalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, BooleanExpressionConverter.instance()); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,608 @@ +/******************************************************************************* + * 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.ListIterator; +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.Counter; +import org.eclipse.jpt.utility.internal.iterables.CloneIterable; +import org.eclipse.jpt.utility.internal.iterators.CloneIterator; +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 + implements JavaResourcePersistentType +{ + private String name; + + private String qualifiedName; + + private String superClassQualifiedName; + + private boolean abstract_; // 'abstract' is a reserved word + + private final Vector types; + + private final Vector fields; + + private final Vector 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(); + this.fields = new Vector(); + this.methods = new Vector(); + } + + @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 + Annotation buildMappingAnnotation(String mappingAnnotationName) { + return this.getAnnotationProvider().buildTypeMappingAnnotation(this, this.member, mappingAnnotationName); + } + + @Override + Annotation buildSupportingAnnotation(String annotationName) { + return this.getAnnotationProvider().buildTypeSupportingAnnotation(this, this.member, annotationName); + } + + @Override + Annotation buildNullSupportingAnnotation(String annotationName) { + return this.getAnnotationProvider().buildNullTypeSupportingAnnotation(this, annotationName); + } + + @Override + ListIterator validMappingAnnotationNames() { + return this.getAnnotationProvider().typeMappingAnnotationNames(); + } + + @Override + ListIterator validSupportingAnnotationNames() { + return this.getAnnotationProvider().typeSupportingAnnotationNames(); + } + + @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(SUPER_CLASS_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); + } + + /** + * check only persistable attributes + */ + public boolean hasAnyAttributePersistenceAnnotations() { + for (Iterator stream = this.persistableAttributes(); stream.hasNext(); ) { + if (stream.next().hasAnyPersistenceAnnotations()) { + return true; + } + } + return false; + } + + + // ********** types ********** + + public Iterator types() { + return new CloneIterator(this.types); // read-only + } + + private Iterable getTypes() { + return new CloneIterable(this.types); // read-only + } + + public Iterator allTypes() { + return new TreeIterator(this) { + @Override + protected Iterator children(JavaResourcePersistentType type) { + return type.types(); + } + }; + } + + public Iterator persistableTypes() { + return this.persistableMembers(this.types()); + } + + public Iterator allPersistableTypes() { + return this.persistableMembers(this.allTypes()); + } + + 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 remove) { + this.removeItemsFromCollection(remove, this.types, TYPES_COLLECTION); + } + + + // ********** fields ********** + + public Iterator fields() { + return new CloneIterator(this.fields); + } + + private Iterable getFields() { + return new CloneIterable(this.fields); + } + + public Iterator persistableFields() { + return this.persistableMembers(this.fields()); + } + + public Iterator persistableFieldsWithSpecifiedFieldAccess() { + return new FilteringIterator(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 remove) { + this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION); + } + + + // ********** methods ********** + + public Iterator methods() { + return new CloneIterator(this.methods); + } + + private Iterable getMethods() { + return new CloneIterable(this.methods); + } + + public Iterator persistableProperties() { + return this.persistableMembers(this.methods()); + } + + public Iterator persistablePropertiesWithSpecifiedPropertyAccess() { + return new FilteringIterator(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 remove) { + this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION); + } + + + // ********** attributes ********** + + @SuppressWarnings("unchecked") + public Iterator persistableAttributes() { + return new CompositeIterator( + this.persistableFields(), + this.persistableProperties() + ); + } + + public Iterator 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 persistableAttributesForFieldAccessType() { + return new CompositeIterator( + this.persistableFields(), + this.persistablePropertiesWithSpecifiedPropertyAccess() + ); + } + + @SuppressWarnings("unchecked") + private Iterator persistableAttributesForPropertyAccessType() { + return new CompositeIterator( + 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 typesToRemove = new HashSet(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 fieldsToRemove = new HashSet(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 methodsToRemove = new HashSet(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 fragments(FieldDeclaration fd) { + return fd.fragments(); + } + + + // ********** CounterMap ********** + + private static class CounterMap { + private final HashMap counters; + + protected CounterMap(int initialCapacity) { + super(); + this.counters = new HashMap(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(); + } + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceTableGeneratorAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,434 @@ +/******************************************************************************* + * 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.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.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 NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__NAME); + + private static final DeclarationAnnotationElementAdapter INITIAL_VALUE_ADAPTER = buildIntegerAdapter(JPA.TABLE_GENERATOR__INITIAL_VALUE); + + private static final DeclarationAnnotationElementAdapter ALLOCATION_SIZE_ADAPTER = buildIntegerAdapter(JPA.TABLE_GENERATOR__ALLOCATION_SIZE); + + private static final DeclarationAnnotationElementAdapter TABLE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__TABLE); + private final AnnotationElementAdapter tableAdapter; + private String table; + + private static final DeclarationAnnotationElementAdapter SCHEMA_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__SCHEMA); + private final AnnotationElementAdapter schemaAdapter; + private String schema; + + private static final DeclarationAnnotationElementAdapter CATALOG_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__CATALOG); + private final AnnotationElementAdapter catalogAdapter; + private String catalog; + + private static final DeclarationAnnotationElementAdapter PK_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_NAME); + private final AnnotationElementAdapter pkColumnNameAdapter; + private String pkColumnName; + + private static final DeclarationAnnotationElementAdapter VALUE_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__VALUE_COLUMN_NAME); + private final AnnotationElementAdapter valueColumnNameAdapter; + private String valueColumnName; + + private static final DeclarationAnnotationElementAdapter PK_COLUMN_VALUE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_VALUE); + private final AnnotationElementAdapter pkColumnValueAdapter; + private String pkColumnValue; + + private final Vector uniqueConstraints = new Vector(); + 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 getNameAdapter() { + return NAME_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter getInitialValueAdapter() { + return INITIAL_VALUE_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter 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 uniqueConstraints() { + return new CloneListIterator(this.uniqueConstraints); + } + + ListIterator nestableUniqueConstraints() { + return new CloneListIterator(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; + } + + private NestableUniqueConstraintAnnotation buildUniqueConstraint(int index) { + return SourceUniqueConstraintAnnotation.createTableGeneratorUniqueConstraint(this, this.member, index); + } + + 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 buildAdapter(String elementName) { + return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); + } + + private static DeclarationAnnotationElementAdapter 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 + { + 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 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); + } + + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceSequenceGeneratorAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,123 @@ +/******************************************************************************* + * 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 final class SourceSequenceGeneratorAnnotation + extends SourceGeneratorAnnotation + implements SequenceGeneratorAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__NAME); + + private static final DeclarationAnnotationElementAdapter INITIAL_VALUE_ADAPTER = buildIntegerAdapter(JPA.SEQUENCE_GENERATOR__INITIAL_VALUE); + + private static final DeclarationAnnotationElementAdapter ALLOCATION_SIZE_ADAPTER = buildIntegerAdapter(JPA.SEQUENCE_GENERATOR__ALLOCATION_SIZE); + + private static final DeclarationAnnotationElementAdapter SEQUENCE_NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__SEQUENCE_NAME); + private final AnnotationElementAdapter sequenceNameAdapter; + private String sequenceName; + + + public 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 getNameAdapter() { + return NAME_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter getInitialValueAdapter() { + return INITIAL_VALUE_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter 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 ********** + + private static DeclarationAnnotationElementAdapter buildAdapter(String elementName) { + return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); + } + + private static DeclarationAnnotationElementAdapter buildIntegerAdapter(String elementName) { + return buildIntegerAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryLobAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryLobAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryLobAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryLobAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,58 @@ +/******************************************************************************* + * 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 buildAnnotation() { + return (DiscriminatorColumnAnnotation) this.buildSupportingAnnotation(); + } + + // ***** discriminator type + public DiscriminatorType getDiscriminatorType() { + return null; + } + + public void setDiscriminatorType(DiscriminatorType discriminatorType) { + if (discriminatorType != null) { + this.buildAnnotation().setDiscriminatorType(discriminatorType); + } + } + + // ***** length + public Integer getLength() { + return null; + } + + public void setLength(Integer length) { + if (length != null) { + this.buildAnnotation().setLength(length); + } + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueriesAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/AssociationOverridesAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.BinaryAssociationOverridesAnnotation; +import org.eclipse.jpt.core.internal.resource.java.source.SourceAssociationOverridesAnnotation; +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 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 SourceAssociationOverridesAnnotation(parent, member); + } + + public AssociationOverridesAnnotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryAssociationOverridesAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return AssociationOverridesAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/AttributeOverrideAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 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.createAttributeOverride(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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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.JavaResourcePersistentMember; +import org.eclipse.jpt.core.resource.java.OverrideAnnotation; +import org.eclipse.jpt.core.utility.TextRange; + +/** + * Common behavior for null versions of + * javax.persistence.AttributeOverride + * and + * javax.persistence.AssociationOverride + */ +public abstract class NullOverrideAnnotation + extends NullAnnotation + implements OverrideAnnotation +{ + private final String name; + + public NullOverrideAnnotation(JavaResourcePersistentMember parent, String name) { + super(parent); + this.name = name; + } + + @Override + protected OverrideAnnotation buildSupportingAnnotation() { + return (OverrideAnnotation) super.buildSupportingAnnotation(); + } + + @Override + public void toString(StringBuilder sb) { + sb.append(this.name); + } + + // ***** name + public String getName() { + return this.name; + } + + public void setName(String name) { + if (name != null) { + this.buildSupportingAnnotation().setName(name); + } + } + + public TextRange getNameTextRange(CompilationUnit astRoot) { + return null; + } + + public boolean nameTouches(int pos, CompilationUnit astRoot) { + return false; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToOneAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,172 @@ +/******************************************************************************* + * 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 TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); + + private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); + + private static final DeclarationAnnotationElementAdapter CASCADE_ADAPTER = buildCascadeAdapter(); + + private static final DeclarationAnnotationElementAdapter OPTIONAL_ADAPTER = buildOptionalAdapter(); + private final AnnotationElementAdapter optionalAdapter; + private Boolean optional; + + private static final DeclarationAnnotationElementAdapter MAPPED_BY_ADAPTER = buildMappedByAdapter(); + private final AnnotationElementAdapter 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 getTargetEntityAdapter() { + return TARGET_ENTITY_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter getFetchAdapter() { + return FETCH_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter 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 buildTargetEntityAdapter() { + return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__TARGET_ENTITY); + } + + private static DeclarationAnnotationElementAdapter buildMappedByAdapter() { + return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__MAPPED_BY, false); // false = do not remove annotation when empty + } + + private static DeclarationAnnotationElementAdapter buildFetchAdapter() { + return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__FETCH); + } + + private static DeclarationAnnotationElementAdapter buildOptionalAdapter() { + return buildOptionalAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__OPTIONAL); + } + + private static DeclarationAnnotationElementAdapter buildOptionalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, BooleanExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildCascadeAdapter() { + return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_ONE__CASCADE); + } + + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullEnumeratedAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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 buildSupportingAnnotation() { + return (EnumeratedAnnotation) super.buildSupportingAnnotation(); + } + + // ***** value + public EnumType getValue() { + return null; + } + + public void setValue(EnumType value) { + if (value != null) { + this.buildSupportingAnnotation().setValue(value); + } + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedQueriesAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,117 @@ +/******************************************************************************* + * 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 + implements NamedQueriesAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private final Vector namedQueries = new Vector(); + + + 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 nestedAnnotations() { + return new CloneListIterator(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); + } + +} Index: src/org/eclipse/jpt/core/resource/java/BaseNamedQueryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/BaseNamedQueryAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/BaseNamedQueryAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/BaseNamedQueryAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,108 @@ +/******************************************************************************* + * 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.resource.java; + +import java.util.ListIterator; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.utility.TextRange; + +/** + * Common protocol among: + * javax.persistence.NamedQuery + * javax.persistence.NamedNativeQuery + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface BaseNamedQueryAnnotation + extends Annotation +{ + /** + * Corresponds to the 'name' element of the *Query annotation. + * Return null if the element does not exist in Java. + */ + String getName(); + String NAME_PROPERTY = "name"; //$NON-NLS-1$ + + /** + * Corresponds to the 'name' element of the *Query annotation. + * Set to null to remove the element. + */ + void setName(String name); + + /** + * Return the {@link TextRange} for the 'name' element. If element + * does not exist return the {@link TextRange} for the *Query annotation. + */ + TextRange getNameTextRange(CompilationUnit astRoot); + + + /** + * Corresponds to the 'query' element of the *Query annotation. + * Return null if the element does not exist in Java. + */ + String getQuery(); + String QUERY_PROPERTY = "query"; //$NON-NLS-1$ + + /** + * Corresponds to the 'query' element of the *Query annotation. + * Set to null to remove the element. + */ + void setQuery(String query); + + /** + * Return the {@link TextRange} for the 'query' element. If element + * does not exist return the {@link TextRange} for the *Query annotation. + */ + TextRange getQueryTextRange(CompilationUnit astRoot); + + + /** + * Corresponds to the 'hints' element of the *Query annotation. + * Return an empty iterator if the element does not exist in Java. + */ + ListIterator hints(); + String HINTS_LIST = "hints"; //$NON-NLS-1$ + + /** + * Corresponds to the 'hints' element of the *Query annotation. + */ + int hintsSize(); + + /** + * Corresponds to the 'hints' element of the *Query annotation. + */ + QueryHintAnnotation hintAt(int index); + + /** + * Corresponds to the 'hints' element of the *Query annotation. + */ + int indexOfHint(QueryHintAnnotation hint); + + /** + * Corresponds to the 'hints' element of the *Query annotation. + */ + QueryHintAnnotation addHint(int index); + + /** + * Corresponds to the 'hints' element of the *Query annotation. + */ + void moveHint(int targetIndex, int sourceIndex); + + /** + * Corresponds to the 'hints' element of the *Query annotation. + */ + void removeHint(int index); + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceAttributeOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,153 @@ +/******************************************************************************* + * 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 + 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 createAttributeOverride(JavaResourceNode parent, Member member) { + return new SourceAttributeOverrideAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); + } + + static SourceAttributeOverrideAnnotation createNestedAttributeOverride(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); + } + +} Index: src/org/eclipse/jpt/core/resource/java/NestableUniqueConstraintAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableUniqueConstraintAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/NestableUniqueConstraintAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/NestableUniqueConstraintAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resource.java; + +/** + * Corresponds to the JPA annotation + * javax.persistence.UniqueConstraint + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestableUniqueConstraintAnnotation + extends UniqueConstraintAnnotation, NestableAnnotation +{ + // combine two interfaces +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceEntityAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,94 @@ +/******************************************************************************* + * 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 + implements EntityAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildNameAdapter(); + private final AnnotationElementAdapter nameAdapter; + private String name; + + + public SourceEntityAnnotation(JavaResourcePersistentType parent, Type type) { + super(parent, type, DECLARATION_ANNOTATION_ADAPTER); + this.nameAdapter = new ShortCircuitAnnotationElementAdapter(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 buildNameAdapter() { + return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ENTITY__NAME, false); // false = do not remove annotation when empty + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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 + 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 + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/EmbeddedAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/EmbeddedAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/EmbeddedAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/EmbeddedAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentAttribute.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,404 @@ +/******************************************************************************* + * 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.resource.java.AccessAnnotation; +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 + implements JavaResourcePersistentAttribute +{ + private int modifiers; + + private String typeName; + + private boolean typeIsInterface; + + private boolean typeIsEnum; + + private final Vector typeSuperclassNames = new Vector(); + + private final Vector typeInterfaceNames = new Vector(); + + private final Vector typeTypeArgumentNames = new Vector(); + + + /** + * 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 + Annotation buildMappingAnnotation(String mappingAnnotationName) { + return this.getAnnotationProvider().buildAttributeMappingAnnotation(this, this.member, mappingAnnotationName); + } + + @Override + Annotation buildSupportingAnnotation(String annotationName) { + return this.getAnnotationProvider().buildAttributeSupportingAnnotation(this, this.member, annotationName); + } + + @Override + Annotation buildNullSupportingAnnotation(String annotationName) { + return this.getAnnotationProvider().buildNullAttributeSupportingAnnotation(this, annotationName); + } + + public Annotation getNullMappingAnnotation(String annotationName) { + return (annotationName == null) ? null : this.buildNullMappingAnnotation(annotationName); + } + + private Annotation buildNullMappingAnnotation(String annotationName) { + return this.getAnnotationProvider().buildNullAttributeMappingAnnotation(this, annotationName); + } + + @Override + ListIterator validMappingAnnotationNames() { + return this.getAnnotationProvider().attributeMappingAnnotationNames(); + } + + @Override + ListIterator validSupportingAnnotationNames() { + return this.getAnnotationProvider().attributeSupportingAnnotationNames(); + } + + public boolean isFor(MethodSignature signature, int occurrence) { + return ((MethodAttribute) this.member).matches(signature, occurrence); + } + + + // ******** JavaResourcePersistentAttribute implementation ******** + + public String getName() { + return this.member.getAttributeName(); + } + + public boolean isField() { + return this.member.isField(); + } + + public boolean isProperty() { + return ! this.isField(); + } + + public boolean hasAnyPersistenceAnnotations() { + return (this.mappingAnnotationsSize() > 0) + || (this.supportingAnnotationsSize() > 0); + } + + public AccessType getSpecifiedAccess() { + AccessAnnotation accessAnnotation = (AccessAnnotation) this.getSupportingAnnotation(AccessAnnotation.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 typeSuperclassNames() { + return new CloneListIterator(this.typeSuperclassNames); + } + + private void setTypeSuperclassNames(List typeSuperclassNames) { + this.synchronizeList(typeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_COLLECTION); + } + + private List buildTypeSuperclassNames(CompilationUnit astRoot) { + ITypeBinding typeBinding = this.getTypeBinding(astRoot); + if (typeBinding == null) { + return Collections.emptyList(); + } + ArrayList names = new ArrayList(); + typeBinding = typeBinding.getSuperclass(); + while (typeBinding != null) { + names.add(typeBinding.getQualifiedName()); + typeBinding = typeBinding.getSuperclass(); + } + return names; + } + + // ***** type interface hierarchy + public Iterator typeInterfaceNames() { + return new CloneIterator(this.typeInterfaceNames); + } + +// private boolean typeInterfaceNamesContains(String interfaceName) { +// return this.typeInterfaceNames.contains(interfaceName); +// } +// + private void setTypeInterfaceNames(Collection typeInterfaceNames) { + this.synchronizeCollection(typeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION); + } + + private Collection buildTypeInterfaceNames(CompilationUnit astRoot) { + ITypeBinding typeBinding = this.getTypeBinding(astRoot); + if (typeBinding == null) { + return Collections.emptySet(); + } + HashSet names = new HashSet(); + while (typeBinding != null) { + this.addInterfaceNamesTo(typeBinding, names); + typeBinding = typeBinding.getSuperclass(); + } + return names; + } + + private void addInterfaceNamesTo(ITypeBinding typeBinding, HashSet names) { + for (ITypeBinding interfaceBinding : typeBinding.getInterfaces()) { + names.add(interfaceBinding.getQualifiedName()); + this.addInterfaceNamesTo(interfaceBinding, names); // recurse + } + } + + // ***** type type argument names + public ListIterator typeTypeArgumentNames() { + return new CloneListIterator(this.typeTypeArgumentNames); + } + + public int typeTypeArgumentNamesSize() { + return this.typeTypeArgumentNames.size(); + } + + public String getTypeTypeArgumentName(int index) { + return this.typeTypeArgumentNames.get(index); + } + + private void setTypeTypeArgumentNames(List typeTypeArgumentNames) { + this.synchronizeList(typeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_COLLECTION); + } + + /** + * 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") + */ + private List 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 names = new ArrayList(typeArguments.length); + for (ITypeBinding typeArgument : typeArguments) { + if (typeArgument == null) { + names.add(null); + } else { + names.add(typeArgument.getTypeDeclaration().getQualifiedName()); + } + } + return names; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedQueryAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,50 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,325 @@ +/******************************************************************************* + * 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.ShortCircuitAnnotationElementAdapter; +import org.eclipse.jpt.core.resource.java.AnnotationContainer; +import org.eclipse.jpt.core.resource.java.BaseTableAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourceNode; +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.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 + implements BaseTableAnnotation +{ + final DeclarationAnnotationElementAdapter nameDeclarationAdapter; + final AnnotationElementAdapter nameAdapter; + String name; + + final DeclarationAnnotationElementAdapter schemaDeclarationAdapter; + final AnnotationElementAdapter schemaAdapter; + String schema; + + final DeclarationAnnotationElementAdapter catalogDeclarationAdapter; + final AnnotationElementAdapter catalogAdapter; + String catalog; + + final Vector uniqueConstraints = new Vector(); + 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 buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(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 ********** + + // ***** 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 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 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 getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter); + + // ***** unique constraints + public ListIterator uniqueConstraints() { + return new CloneListIterator(this.uniqueConstraints); + } + + ListIterator nestableUniqueConstraints() { + return new CloneListIterator(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; + } + + abstract NestableUniqueConstraintAnnotation buildUniqueConstraint(int index); + + 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); + } + + + // ********** unique constraint container ********** + + /** + * adapt the AnnotationContainer interface to the table's unique constraints + */ + class UniqueConstraintsAnnotationContainer + implements AnnotationContainer + { + 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 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); + } + + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryQueryHintAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryQueryHintAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryQueryHintAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryQueryHintAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,101 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/JoinColumnAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/JoinColumnAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/JoinColumnAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/JoinColumnAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullTemporalAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,56 @@ +/******************************************************************************* + * 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 buildSupportingAnnotation() { + return (TemporalAnnotation) super.buildSupportingAnnotation(); + } + + + // ********** TemporalAnnotation implementation ********** + + // ***** value + public TemporalType getValue() { + return null; + } + + public void setValue(TemporalType value) { + if (value != null) { + this.buildSupportingAnnotation().setValue(value); + } + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceGeneratorAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,169 @@ +/******************************************************************************* + * 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 + implements GeneratorAnnotation +{ + final DeclarationAnnotationElementAdapter nameDeclarationAdapter; + final AnnotationElementAdapter nameAdapter; + String name; + + final DeclarationAnnotationElementAdapter initialValueDeclarationAdapter; + final AnnotationElementAdapter initialValueAdapter; + Integer initialValue; + + final DeclarationAnnotationElementAdapter allocationSizeDeclarationAdapter; + final AnnotationElementAdapter 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); + } + + AnnotationElementAdapter buildAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(this.member, daea); + } + + AnnotationElementAdapter buildIntegerAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(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 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 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 getAllocationSizeAdapter(); + + + // ********** static methods ********** + + static DeclarationAnnotationElementAdapter buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return ConversionDeclarationAnnotationElementAdapter.forStrings(annotationAdapter, elementName); + } + + static DeclarationAnnotationElementAdapter buildIntegerAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, NumberIntegerExpressionConverter.instance()); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/SecondaryTablesAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/EnumeratedAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/EnumeratedAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/EnumeratedAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/EnumeratedAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,82 @@ +/******************************************************************************* + * 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 buildAnnotation() { + return (ColumnAnnotation) this.buildSupportingAnnotation(); + } + + // ***** length + public Integer getLength() { + return null; + } + + public void setLength(Integer length) { + if (length != null) { + this.buildAnnotation().setLength(length); + } + } + + public TextRange getLengthTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** scale + public Integer getScale() { + return null; + } + + public void setScale(Integer scale) { + if (scale != null) { + this.buildAnnotation().setScale(scale); + } + } + + public TextRange getScaleTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** precision + public Integer getPrecision() { + return null; + } + + public void setPrecision(Integer precision) { + if (precision != null) { + this.buildAnnotation().setPrecision(precision); + } + } + + public TextRange getPrecisionTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueriesAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,117 @@ +/******************************************************************************* + * 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 + implements NamedNativeQueriesAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private final Vector namedNativeQueries = new Vector(); + + + 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 nestedAnnotations() { + return new CloneListIterator(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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedNativeQueryAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,206 @@ +/******************************************************************************* + * 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 resultClassDeclarationAdapter; + private final AnnotationElementAdapter resultClassAdapter; + private String resultClass; + + private String fullyQualifiedResultClassName; + + private final DeclarationAnnotationElementAdapter resultSetMappingDeclarationAdapter; + private final AnnotationElementAdapter 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 buildResultClassAdapter(DeclarationAnnotationAdapter daAdapter) { + return new ConversionDeclarationAnnotationElementAdapter(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 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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NamedNativeQueryAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,141 @@ +/******************************************************************************* + * 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 DISCRIMINATOR_TYPE_ADAPTER = buildDiscriminatorTypeAdapter(); + private final AnnotationElementAdapter discriminatorTypeAdapter; + private DiscriminatorType discriminatorType; + + private final DeclarationAnnotationElementAdapter lengthDeclarationAdapter; + private final AnnotationElementAdapter lengthAdapter; + private Integer length; + + + public SourceDiscriminatorColumnAnnotation(JavaResourcePersistentType parent, Member member, DeclarationAnnotationAdapter daa) { + super(parent, member, daa); + this.discriminatorTypeAdapter = new ShortCircuitAnnotationElementAdapter(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) { + super.initializeFrom(oldAnnotation); + DiscriminatorColumnAnnotation oldColumn = (DiscriminatorColumnAnnotation) oldAnnotation; + this.setLength(oldColumn.getLength()); + this.setDiscriminatorType(oldColumn.getDiscriminatorType()); + } + + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildDiscriminatorTypeAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/IdClassAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/IdClassAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/IdClassAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/IdClassAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceOneToManyAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,131 @@ +/******************************************************************************* + * 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 TARGET_ENTITY_ADAPTER = buildTargetEntityAdapter(); + + private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); + + private static final DeclarationAnnotationElementAdapter CASCADE_ADAPTER = buildCascadeAdapter(); + + private static final DeclarationAnnotationElementAdapter MAPPED_BY_ADAPTER = buildMappedByAdapter(); + private final AnnotationElementAdapter 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 getTargetEntityAdapter() { + return TARGET_ENTITY_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter getFetchAdapter() { + return FETCH_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter 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 buildTargetEntityAdapter() { + return buildTargetEntityAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__TARGET_ENTITY); + } + + private static DeclarationAnnotationElementAdapter buildMappedByAdapter() { + return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__MAPPED_BY, false); // false = do not remove annotation when empty + } + + private static DeclarationAnnotationElementAdapter buildFetchAdapter() { + return buildFetchAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__FETCH); + } + + private static DeclarationAnnotationElementAdapter buildCascadeAdapter() { + return buildEnumArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ONE_TO_MANY__CASCADE); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,161 @@ +/******************************************************************************* + * 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 referencedColumnNameDeclarationAdapter; + private final AnnotationElementAdapter 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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullJoinColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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 buildAnnotation() { + 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddedIdAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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 + 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 + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,55 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorValueAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorValueAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorValueAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorValueAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentMember.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,623 @@ +/******************************************************************************* + * 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.ListIterator; +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.CollectionTools; +import org.eclipse.jpt.utility.internal.iterables.CloneIterable; +import org.eclipse.jpt.utility.internal.iterators.CloneIterator; +import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; +import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; +import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator; + +/** + * Java source persistent member (annotations, "persistable") + */ +abstract class SourcePersistentMember + extends SourceNode + implements JavaResourcePersistentMember +{ + final E member; + + /** + * mapping annotations; no duplicates (java compiler has an error for + * duplicates) + */ + final Vector mappingAnnotations; + + /** + * supporting annotations; no duplicates (java compiler has an error for + * duplicates) + */ + final Vector supportingAnnotations; + + boolean persistable; + + + // ********** construction/initialization ********** + + SourcePersistentMember(JavaResourceNode parent, E member) { + super(parent); + this.member = member; + this.mappingAnnotations = new Vector(); + this.supportingAnnotations = new Vector(); + } + + 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.annotationIsValidSupportingAnnotation(jdtAnnotationName)) { + if (this.selectAnnotationNamed(this.supportingAnnotations, jdtAnnotationName) == null) { // ignore duplicates + Annotation annotation = this.buildSupportingAnnotation(jdtAnnotationName); + annotation.initialize(astRoot); + this.supportingAnnotations.add(annotation); + } + } else if (this.annotationIsValidMappingAnnotation(jdtAnnotationName)) { + if (this.selectAnnotationNamed(this.mappingAnnotations, jdtAnnotationName) == null) { // ignore duplicates + Annotation annotation = this.buildMappingAnnotation(jdtAnnotationName); + annotation.initialize(astRoot); + this.mappingAnnotations.add(annotation); + } + } + } + + + // ********** mapping annotations ********** + + public Iterator mappingAnnotations() { + return new CloneIterator(this.mappingAnnotations); + } + + private Iterable getMappingAnnotations() { + return new CloneIterable(this.mappingAnnotations); + } + + public int mappingAnnotationsSize() { + return this.mappingAnnotations.size(); + } + + // TODO need property change notification on this mappingAnnotation changing + // from the context model we don't really care if their are multiple mapping + // annotations, just which one we need to use + public Annotation getMappingAnnotation() { + Iterable annotations = this.getMappingAnnotations(); + for (ListIterator stream = this.validMappingAnnotationNames(); stream.hasNext();) { + Annotation annotation = this.selectAnnotationNamed(annotations, stream.next()); + if (annotation != null) { + return annotation; + } + } + return null; + } + + public Annotation getMappingAnnotation(String annotationName) { + return this.selectAnnotationNamed(this.getMappingAnnotations(), annotationName); + } + + /** + * Remove all other *mapping* annotations that exist; not just the one + * returned by #getMappingAnnotation(). #getMappingAnnotation() returns the + * first mapping annotation found in the source. If there were multiple + * mapping annotations (which is a validation error) then calling this + * method would not work because the new mapping annotation would be added + * to the end of the list of annotations. + */ + public Annotation setMappingAnnotation(String annotationName) { + Collection removedAnnotations = null; + Annotation newMapping = null; + if (annotationName == null) { + removedAnnotations = this.removeMappingAnnotations(); + } else { + if (this.selectAnnotationNamed(this.mappingAnnotations, annotationName) != null) { + throw new IllegalStateException("duplicate mapping annotation: " + annotationName); //$NON-NLS-1$ + } + + removedAnnotations = this.removeMappingAnnotations(); + + newMapping = this.buildMappingAnnotation(annotationName); + this.mappingAnnotations.add(newMapping); + newMapping.newAnnotation(); + this.fireItemAdded(MAPPING_ANNOTATIONS_COLLECTION, newMapping); + } + // hold change notifications until the end so a project update does not + // occur before we are finished removing the old mapping(s) and/or adding + // the new mapping + this.fireItemsRemoved(MAPPING_ANNOTATIONS_COLLECTION, removedAnnotations); + return newMapping; + } + + /** + * Remove all mapping annotations that already exist. No change notification + * is fired. Return the removed annotations. + */ + private Collection removeMappingAnnotations() { + ArrayList removedAnnotations = null; + for (String mappingAnnotationName : CollectionTools.iterable(this.validMappingAnnotationNames())) { + Annotation mappingAnnotation = this.selectAnnotationNamed(this.mappingAnnotations, mappingAnnotationName); + if (mappingAnnotation != null) { + // only need to delete one, since we do not hold duplicates + this.mappingAnnotations.remove(mappingAnnotation); + mappingAnnotation.removeAnnotation(); + if (removedAnnotations == null) { + removedAnnotations = new ArrayList(); + } + removedAnnotations.add(mappingAnnotation); + } + } + return (removedAnnotations != null) ? removedAnnotations : Collections.emptySet(); + } + + abstract Annotation buildMappingAnnotation(String mappingAnnotationName); + + private boolean annotationIsValidMappingAnnotation(String annotationName) { + return CollectionTools.contains(this.validMappingAnnotationNames(), annotationName); + } + + abstract ListIterator validMappingAnnotationNames(); + + + // ********** supporting annotations ********** + + public Iterator supportingAnnotations() { + return new CloneIterator(this.supportingAnnotations); + } + + private Iterable getSupportingAnnotations() { + return new CloneIterable(this.supportingAnnotations); + } + + public int supportingAnnotationsSize() { + return this.supportingAnnotations.size(); + } + + public Annotation getSupportingAnnotation(String annotationName) { + return this.selectAnnotationNamed(this.getSupportingAnnotations(), annotationName); + } + + public Annotation getNonNullSupportingAnnotation(String annotationName) { + Annotation annotation = this.getSupportingAnnotation(annotationName); + return (annotation != null) ? annotation : this.buildNullSupportingAnnotation(annotationName); + } + + abstract Annotation buildNullSupportingAnnotation(String annotationName); + + public Annotation addSupportingAnnotation(String annotationName) { + Annotation annotation = this.buildSupportingAnnotation(annotationName); + this.supportingAnnotations.add(annotation); + annotation.newAnnotation(); + this.fireItemAdded(SUPPORTING_ANNOTATIONS_COLLECTION, annotation); + return annotation; + } + + abstract Annotation buildSupportingAnnotation(String annotationName); + + public void removeSupportingAnnotation(String annotationName) { + Annotation annotation = this.getSupportingAnnotation(annotationName); + if (annotation != null) { + this.removeSupportingAnnotation(annotation); + } + } + + private void removeSupportingAnnotation(Annotation annotation) { + this.supportingAnnotations.remove(annotation); + annotation.removeAnnotation(); + this.fireItemRemoved(SUPPORTING_ANNOTATIONS_COLLECTION, annotation); + } + + private boolean annotationIsValidSupportingAnnotation(String annotationName) { + return CollectionTools.contains(this.validSupportingAnnotationNames(), annotationName); + } + + abstract ListIterator validSupportingAnnotationNames(); + + + // ********** supporting "combo" annotations ********** + + public ListIterator supportingAnnotations(String nestableAnnotationName, String containerAnnotationName) { + ContainerAnnotation containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName); + if (containerAnnotation != null) { + return containerAnnotation.nestedAnnotations(); + } + + NestableAnnotation nestableAnnotation = this.getSupportingNestableAnnotation(nestableAnnotationName); + if (nestableAnnotation != null) { + return new SingleElementListIterator(nestableAnnotation); + } + + return EmptyListIterator.instance(); + } + + // minimize scope of suppressed warnings + @SuppressWarnings("unchecked") + private ContainerAnnotation getSupportingContainerAnnotation(String annotationName) { + return (ContainerAnnotation) this.getSupportingAnnotation(annotationName); + } + + private NestableAnnotation getSupportingNestableAnnotation(String annotationName) { + return (NestableAnnotation) this.getSupportingAnnotation(annotationName); + } + + /** + * 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 addSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { + ContainerAnnotation containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName); + if (containerAnnotation != null) { + // ignore any stand-alone nestable annotations and just add to the container annotation + return AnnotationContainerTools.addNestedAnnotation(index, containerAnnotation); + } + + NestableAnnotation standAloneAnnotation = this.getSupportingNestableAnnotation(nestableAnnotationName); + if (standAloneAnnotation == null) { + // add a stand-alone nestable annotation since neither the nestable nor the container exist + return (NestableAnnotation) this.addSupportingAnnotation(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 containerAnnotation = this.buildSupportingContainerAnnotation(containerAnnotationName); + this.supportingAnnotations.add(containerAnnotation); + containerAnnotation.newAnnotation(); + + NestableAnnotation nestedAnnotation0 = containerAnnotation.addNestedAnnotationInternal(); + nestedAnnotation0.newAnnotation(); + + NestableAnnotation nestedAnnotation1 = containerAnnotation.addNestedAnnotationInternal(); + nestedAnnotation1.newAnnotation(); + + this.removeSupportingAnnotation(standAloneAnnotation); + + this.fireItemAdded(SUPPORTING_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; + } + + // minimize scope of suppressed warnings + @SuppressWarnings("unchecked") + private ContainerAnnotation buildSupportingContainerAnnotation(String annotationName) { + return (ContainerAnnotation) this.buildSupportingAnnotation(annotationName); + } + + public void moveSupportingAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) { + this.moveAnnotation(targetIndex, sourceIndex, this.getSupportingContainerAnnotation(containerAnnotationName)); + } + + private void moveAnnotation(int targetIndex, int sourceIndex, ContainerAnnotation containerAnnotation) { + AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, containerAnnotation); + } + + public void removeSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { + ContainerAnnotation containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName); + if (containerAnnotation == null) { // assume the index is 0 + this.removeSupportingAnnotation(this.getSupportingAnnotation(nestableAnnotationName)); + } else { + this.removeSupportingAnnotation(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 removeSupportingAnnotation(int index, ContainerAnnotation containerAnnotation) { + AnnotationContainerTools.removeNestedAnnotation(index, containerAnnotation); + switch (containerAnnotation.nestedAnnotationsSize()) { + case 0: + this.removeSupportingAnnotation(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 containerAnnotation) { + NestableAnnotation lastNestedAnnotation = containerAnnotation.nestedAnnotations().next(); + this.supportingAnnotations.remove(containerAnnotation); + containerAnnotation.removeAnnotation(); + + NestableAnnotation standAloneAnnotation = (NestableAnnotation) this.buildSupportingAnnotation(lastNestedAnnotation.getAnnotationName()); + this.supportingAnnotations.add(standAloneAnnotation); + standAloneAnnotation.newAnnotation(); + this.fireItemRemoved(SUPPORTING_ANNOTATIONS_COLLECTION, containerAnnotation); + this.fireItemAdded(SUPPORTING_ANNOTATIONS_COLLECTION, standAloneAnnotation); + standAloneAnnotation.initializeFrom(lastNestedAnnotation); + } + + + // ********** 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 isPersisted() { + return this.getMappingAnnotation() != null; + } + + 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 mappingAnnotationsToRemove = new HashSet(this.mappingAnnotations); + HashSet supportingAnnotationsToRemove = new HashSet(this.supportingAnnotations); + + this.member.getBodyDeclaration(astRoot).accept(this.buildUpdateAnnotationVisitor(astRoot, mappingAnnotationsToRemove, supportingAnnotationsToRemove)); + + for (Annotation annotation : mappingAnnotationsToRemove) { + this.removeItemFromCollection(annotation, this.mappingAnnotations, MAPPING_ANNOTATIONS_COLLECTION); + } + for (Annotation annotation : supportingAnnotationsToRemove) { + this.removeItemFromCollection(annotation, this.supportingAnnotations, SUPPORTING_ANNOTATIONS_COLLECTION); + } + } + + private ASTVisitor buildUpdateAnnotationVisitor(CompilationUnit astRoot, Set mappingAnnotationsToRemove, Set supportingAnnotationsToRemove) { + return new UpdateAnnotationVisitor(astRoot, this.member.getBodyDeclaration(astRoot), mappingAnnotationsToRemove, supportingAnnotationsToRemove); + } + + void addOrUpdateAnnotation(org.eclipse.jdt.core.dom.Annotation node, CompilationUnit astRoot, Set mappingAnnotationsToRemove, Set supportingAnnotationsToRemove) { + String jdtAnnotationName = JDTTools.resolveAnnotation(node); + if (jdtAnnotationName == null) { + return; + } + if (this.annotationIsValidSupportingAnnotation(jdtAnnotationName)) { + this.addOrUpdateSupportingAnnotation(jdtAnnotationName, astRoot, supportingAnnotationsToRemove); + return; + } + if (this.annotationIsValidMappingAnnotation(jdtAnnotationName)) { + this.addOrUpdateMappingAnnotation(jdtAnnotationName, astRoot, mappingAnnotationsToRemove); + return; + } + } + + private void addOrUpdateSupportingAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set supportingAnnotationsToRemove) { + Annotation annotation = this.selectAnnotationNamed(supportingAnnotationsToRemove, jdtAnnotationName); + if (annotation != null) { + annotation.update(astRoot); + supportingAnnotationsToRemove.remove(annotation); + } else { + annotation = this.buildSupportingAnnotation(jdtAnnotationName); + annotation.initialize(astRoot); + this.addItemToCollection(annotation, this.supportingAnnotations, SUPPORTING_ANNOTATIONS_COLLECTION); + } + } + + private void addOrUpdateMappingAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set mappingAnnotationsToRemove) { + Annotation annotation = this.selectAnnotationNamed(mappingAnnotationsToRemove, jdtAnnotationName); + if (annotation != null) { + annotation.update(astRoot); + mappingAnnotationsToRemove.remove(annotation); + } else { + annotation = this.buildMappingAnnotation(jdtAnnotationName); + annotation.initialize(astRoot); + this.addItemToCollection(annotation, this.mappingAnnotations, MAPPING_ANNOTATIONS_COLLECTION); + } + } + + + // ********** miscellaneous ********** + + public void resolveTypes(CompilationUnit astRoot) { + this.setPersistable(this.buildPersistable(astRoot)); + } + + private Annotation selectAnnotationNamed(Iterable 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 + */ + Iterator persistableMembers(Iterator members) { + return new FilteringIterator(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 mappingAnnotationsToRemove; + protected final Set supportingAnnotationsToRemove; + + protected UpdateAnnotationVisitor(CompilationUnit astRoot, BodyDeclaration bodyDeclaration, Set mappingAnnotationsToRemove, Set supportingAnnotationsToRemove) { + super(astRoot, bodyDeclaration); + this.mappingAnnotationsToRemove = mappingAnnotationsToRemove; + this.supportingAnnotationsToRemove = supportingAnnotationsToRemove; + } + + @Override + protected void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation node) { + SourcePersistentMember.this.addOrUpdateAnnotation(node, this.astRoot, this.mappingAnnotationsToRemove, this.supportingAnnotationsToRemove); + } + + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryUniqueConstraintAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryUniqueConstraintAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryUniqueConstraintAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryUniqueConstraintAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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 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 columnNames() { + return new CloneListIterator(this.columnNames); + } + + public int columnNamesSize() { + return this.columnNames.size(); + } + + private Vector buildColumnNames() { + Object[] jdtColumnNames = this.getJdtMemberValues(JPA.UNIQUE_CONSTRAINT__COLUMN_NAMES); + Vector result = new Vector(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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentMember.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,288 @@ +/******************************************************************************* + * 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.ListIterator; +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.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.CloneIterable; +import org.eclipse.jpt.utility.internal.iterators.CloneIterator; +import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; +import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; +import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator; + +/** + * binary persistent member + */ +abstract class BinaryPersistentMember + extends BinaryNode + implements JavaResourcePersistentMember +{ + /** JDT member adapter */ + final Adapter adapter; + + /** mapping annotations */ + final Vector mappingAnnotations = new Vector(); + + /** supporting annotations */ + final Vector supportingAnnotations = new Vector(); + + 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.annotationIsValidSupportingAnnotation(jdtAnnotation)) { + this.supportingAnnotations.add(this.buildSupportingAnnotation(jdtAnnotation)); + } else if (this.annotationIsValidMappingAnnotation(jdtAnnotation)) { + this.mappingAnnotations.add(this.buildMappingAnnotation(jdtAnnotation)); + } + } + + + // ********** updating ********** + + @Override + public void update() { + super.update(); + this.updateAnnotations(); + this.setPersistable(this.buildPersistable()); + } + + // TODO + private void updateAnnotations() { + throw new UnsupportedOperationException(); + } + + + // ********** mapping annotations ********** + + public Iterator mappingAnnotations() { + return new CloneIterator(this.mappingAnnotations); + } + + private Iterable getMappingAnnotations() { + return new CloneIterable(this.mappingAnnotations); + } + + public int mappingAnnotationsSize() { + return this.mappingAnnotations.size(); + } + + public Annotation getMappingAnnotation() { + Iterable annotations = this.getMappingAnnotations(); + for (ListIterator stream = this.validMappingAnnotationNames(); stream.hasNext();) { + Annotation annotation = this.getAnnotation(annotations, stream.next()); + if (annotation != null) { + return annotation; + } + } + return null; + } + + public Annotation getMappingAnnotation(String annotationName) { + return this.getAnnotation(this.getMappingAnnotations(), annotationName); + } + + private boolean annotationIsValidMappingAnnotation(IAnnotation jdtAnnotation) { + return CollectionTools.contains(this.validMappingAnnotationNames(), jdtAnnotation.getElementName()); + } + + abstract ListIterator validMappingAnnotationNames(); + + abstract Annotation buildMappingAnnotation(IAnnotation jdtAnnotation); + + + // ********** supporting annotations ********** + + public Iterator supportingAnnotations() { + return new CloneIterator(this.supportingAnnotations); + } + + private Iterable getSupportingAnnotations() { + return new CloneIterable(this.supportingAnnotations); + } + + public int supportingAnnotationsSize() { + return this.supportingAnnotations.size(); + } + + public ListIterator supportingAnnotations(String nestableAnnotationName, String containerAnnotationName) { + ContainerAnnotation containerAnnotation = this.getSupportingContainerAnnotation(containerAnnotationName); + if (containerAnnotation != null) { + return containerAnnotation.nestedAnnotations(); + } + NestableAnnotation nestableAnnotation = this.getSupportingNestableAnnotation(nestableAnnotationName); + return (nestableAnnotation == null) ? EmptyListIterator.instance() : new SingleElementListIterator(nestableAnnotation); + } + + private NestableAnnotation getSupportingNestableAnnotation(String annotationName) { + return (NestableAnnotation) this.getSupportingAnnotation(annotationName); + } + + public Annotation getSupportingAnnotation(String annotationName) { + return this.getAnnotation(this.getSupportingAnnotations(), annotationName); + } + + public Annotation getNonNullSupportingAnnotation(String annotationName) { + Annotation annotation = this.getSupportingAnnotation(annotationName); + return (annotation != null) ? annotation : this.buildNullSupportingAnnotation(annotationName); + } + + abstract Annotation buildNullSupportingAnnotation(String annotationName); + + abstract Annotation buildSupportingAnnotation(IAnnotation jdtAnnotation); + + private boolean annotationIsValidSupportingAnnotation(IAnnotation jdtAnnotation) { + return CollectionTools.contains(this.validSupportingAnnotationNames(), jdtAnnotation.getElementName()); + } + + abstract ListIterator validSupportingAnnotationNames(); + + @SuppressWarnings("unchecked") + private ContainerAnnotation getSupportingContainerAnnotation(String annotationName) { + return (ContainerAnnotation) this.getSupportingAnnotation(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 isPersisted() { + return this.getMappingAnnotation() != null; + } + + + // ********** miscellaneous ********** + + public IMember getMember() { + return this.adapter.getMember(); + } + + private Annotation getAnnotation(Iterable annotations, String annotationName) { + for (Annotation annotation : annotations) { + if (annotation.getAnnotationName().equals(annotationName)) { + return annotation; + } + } + return null; + } + + /** + * convenience method + */ + Iterator persistableMembers(Iterator members) { + return new FilteringIterator(members) { + @Override + protected boolean accept(T m) { + return m.isPersistable(); + } + }; + } + + 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 { + IMember getMember(); + boolean isPersistable(); + IAnnotation[] getAnnotations() throws JavaModelException; + } + + + // ********** unsupported JavaResourcePersistentMember implementation ********** + + public Annotation setMappingAnnotation(String annotationName) { + throw new UnsupportedOperationException(); + } + + public Annotation addSupportingAnnotation(String annotationName) { + throw new UnsupportedOperationException(); + } + + public Annotation addSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { + throw new UnsupportedOperationException(); + } + + public void moveSupportingAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) { + throw new UnsupportedOperationException(); + } + + public void removeSupportingAnnotation(String annotationName) { + throw new UnsupportedOperationException(); + } + + public void removeSupportingAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) { + 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceSecondaryTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,276 @@ +/******************************************************************************* + * 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.NestableUniqueConstraintAnnotation; +import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation; +import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation; +import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation; +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 pkJoinColumns = new Vector(); + 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 getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__NAME); + } + + @Override + DeclarationAnnotationElementAdapter getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__SCHEMA); + } + + @Override + DeclarationAnnotationElementAdapter getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + return ConversionDeclarationAnnotationElementAdapter.forStrings(declarationAnnotationAdapter, JPA.SECONDARY_TABLE__CATALOG); + } + + @Override + String getUniqueConstraintsElementName() { + return JPA.SECONDARY_TABLE__UNIQUE_CONSTRAINTS; + } + + @Override + NestableUniqueConstraintAnnotation buildUniqueConstraint(int index) { + return SourceUniqueConstraintAnnotation.createSecondaryTableUniqueConstraint(this, this.member, this.daa, index); + } + + + // ************* SecondaryTable implementation ******************* + + // ***** pk join columns + public ListIterator pkJoinColumns() { + return new CloneListIterator(this.pkJoinColumns); + } + + ListIterator nestablePkJoinColumns() { + return new CloneListIterator(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; + } + + public void initializeFrom(NestableAnnotation oldAnnotation) { + SecondaryTableAnnotation oldTable = (SecondaryTableAnnotation) 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); + } + 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 + { + 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 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); + } + + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseNamedQueryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseNamedQueryAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseNamedQueryAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseNamedQueryAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,154 @@ +/******************************************************************************* + * 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 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 hints() { + return new CloneListIterator(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 buildHints() { + Object[] jdtHints = this.getJdtMemberValues(this.getHintsElementName()); + Vector result = new Vector(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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullJoinTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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.JavaResourcePersistentAttribute; +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 final class NullJoinTableAnnotation + extends NullBaseTableAnnotation + implements JoinTableAnnotation +{ + protected NullJoinTableAnnotation(JavaResourcePersistentAttribute parent) { + super(parent); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + protected JoinTableAnnotation buildSupportingAnnotation() { + return (JoinTableAnnotation) super.buildSupportingAnnotation(); + } + + // ***** join columns + public ListIterator 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) { + throw new UnsupportedOperationException(); + } + + public void moveJoinColumn(int targetIndex, int sourceIndex) { + throw new UnsupportedOperationException(); + } + + public void removeJoinColumn(int index) { + throw new UnsupportedOperationException(); + } + + // ***** inverse join columns + public ListIterator 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) { + throw new UnsupportedOperationException(); + } + + public void moveInverseJoinColumn(int targetIndex, int sourceIndex) { + throw new UnsupportedOperationException(); + } + + public void removeInverseJoinColumn(int index) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEntityAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEntityAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEntityAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEntityAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,75 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnsAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnsAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnsAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnsAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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 + implements JoinColumnsAnnotation +{ + private final Vector joinColumns; + + + public BinaryJoinColumnsAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.joinColumns = this.buildJoinColumns(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public ListIterator nestedAnnotations() { + return new CloneListIterator(this.joinColumns); + } + + public int nestedAnnotationsSize() { + return this.joinColumns.size(); + } + + private Vector buildJoinColumns() { + Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.JOIN_COLUMNS__VALUE); + Vector result = new Vector(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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullInheritanceAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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 buildSupportingAnnotation() { + return (InheritanceAnnotation) super.buildSupportingAnnotation(); + } + + // ***** strategy + public InheritanceType getStrategy() { + return null; + } + + public void setStrategy(InheritanceType strategy) { + if (strategy != null) { + this.buildSupportingAnnotation().setStrategy(strategy); + } + } + + public TextRange getStrategyTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,146 @@ +/******************************************************************************* + * 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 + 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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,115 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/resource/java/NestableAttributeOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableAttributeOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/NestableAttributeOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/NestableAttributeOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resource.java; + +/** + * Corresponds to the JPA annotation + * javax.persistence.AttributeOverride + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestableAttributeOverrideAnnotation + extends AttributeOverrideAnnotation, NestableAnnotation +{ + // combine two interfaces +} Index: src/org/eclipse/jpt/core/resource/java/NestableJoinColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableJoinColumnAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/NestableJoinColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/NestableJoinColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resource.java; + +/** + * Corresponds to the JPA annotation + * javax.persistence.JoinColumn + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestableJoinColumnAnnotation + extends JoinColumnAnnotation, NestableAnnotation +{ + // combine two interfaces +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,351 @@ +/******************************************************************************* + * 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.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.NestableJoinColumnAnnotation; +import org.eclipse.jpt.core.resource.java.NestableUniqueConstraintAnnotation; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; +import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; +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 final class SourceJoinTableAnnotation + extends SourceBaseTableAnnotation + implements JoinTableAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JoinTableAnnotation.ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__NAME); + + private static final DeclarationAnnotationElementAdapter SCHEMA_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__SCHEMA); + + private static final DeclarationAnnotationElementAdapter CATALOG_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__CATALOG); + + private final Vector joinColumns = new Vector(); + private final JoinColumnsAnnotationContainer joinColumnsContainer = new JoinColumnsAnnotationContainer(); + + private final Vector inverseJoinColumns = new Vector(); + private final InverseJoinColumnsContainerAnnotation inverseJoinColumnsContainer = new InverseJoinColumnsContainerAnnotation(); + + + public SourceJoinTableAnnotation(JavaResourceNode parent, Member member) { + super(parent, member, DECLARATION_ANNOTATION_ADAPTER); + } + + 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 getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + // ignore the daa passed in, @JoinTable is never nested + return NAME_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + // ignore the daa passed in, @JoinTable is never nested + return SCHEMA_ADAPTER; + } + + @Override + DeclarationAnnotationElementAdapter getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { + // ignore the daa passed in, @JoinTable is never nested + return CATALOG_ADAPTER; + } + + @Override + String getUniqueConstraintsElementName() { + return JPA.JOIN_TABLE__UNIQUE_CONSTRAINTS; + } + + @Override + NestableUniqueConstraintAnnotation buildUniqueConstraint(int index) { + return SourceUniqueConstraintAnnotation.createJoinTableUniqueConstraint(this, this.member, index); + } + + + // ********** JoinTableAnnotation implementation ********** + + // ***** join columns + public ListIterator joinColumns() { + return new CloneListIterator(this.joinColumns); + } + + ListIterator nestableJoinColumns() { + return new CloneListIterator(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.createJoinTableJoinColumn(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); + } + + // ***** inverse join columns + public ListIterator inverseJoinColumns() { + return new CloneListIterator(this.inverseJoinColumns); + } + + ListIterator nestableInverseJoinColumns() { + return new CloneListIterator(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 SourceJoinColumnAnnotation.createJoinTableInverseJoinColumn(this, this.member, index); + } + + 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); + } + + + // ********** annotation containers ********** + + abstract class AbstractJoinColumnAnnotationContainer + implements AnnotationContainer + { + 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 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 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); + } + + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullBaseTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,124 @@ +/******************************************************************************* + * 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.JavaResourcePersistentMember; +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(JavaResourcePersistentMember parent) { + super(parent); + } + + @Override + protected BaseTableAnnotation buildSupportingAnnotation() { + return (BaseTableAnnotation) super.buildSupportingAnnotation(); + } + + // ***** name + public String getName() { + return null; + } + + public void setName(String name) { + if (name != null) { + this.buildSupportingAnnotation().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.buildSupportingAnnotation().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.buildSupportingAnnotation().setCatalog(catalog); + } + } + + public TextRange getCatalogTextRange(CompilationUnit astRoot) { + return null; + } + + public boolean catalogTouches(int pos, CompilationUnit astRoot) { + return false; + } + + // ***** unique constraints + public ListIterator 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.buildSupportingAnnotation().addUniqueConstraint(index); + } + + public void moveUniqueConstraint(int targetIndex, int sourceIndex) { + throw new UnsupportedOperationException(); + } + + public void removeUniqueConstraint(int index) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAccessAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceAccessAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceAccessAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceAccessAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,94 @@ +/******************************************************************************* + * 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.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.AccessAnnotation; +import org.eclipse.jpt.core.resource.java.AccessType; +import org.eclipse.jpt.core.resource.java.JPA; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; +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.Access + */ +public final class SourceAccessAnnotation + extends SourceAnnotation + implements AccessAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private AccessType value; + + + public SourceAccessAnnotation(JavaResourcePersistentMember parent, Member member) { + super(parent, member, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(member, 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); + } + + + // ********** AccessAnnotation implementation ********** + + // ***** value + public AccessType getValue() { + return this.value; + } + + public void setValue(AccessType value) { + if (this.attributeValueHasNotChanged(this.value, value)) { + return; + } + AccessType old = this.value; + this.value = value; + this.valueAdapter.setValue(AccessType.toJavaAnnotationValue(value)); + this.firePropertyChanged(VALUE_PROPERTY, old, value); + } + + private AccessType buildValue(CompilationUnit astRoot) { + return AccessType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + return this.getElementTextRange(VALUE_ADAPTER, astRoot); + } + + // ********** static methods ********** + + private static DeclarationAnnotationElementAdapter buildValueAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ACCESS__VALUE); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceDiscriminatorValueAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,94 @@ +/******************************************************************************* + * 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 + implements DiscriminatorValueAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private String value; + + + public SourceDiscriminatorValueAnnotation(JavaResourceNode parent, Type type) { + super(parent, type, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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 buildValueAdapter() { + return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_VALUE__VALUE); + } + +} Index: src/org/eclipse/jpt/core/resource/java/BaseTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/BaseTableAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/BaseTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/BaseTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,147 @@ +/******************************************************************************* + * 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.resource.java; + +import java.util.ListIterator; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.utility.TextRange; + +/** + * Common protocol among: + * javax.persistence.Table + * javax.persistence.JoinTable + * javax.persistence.SecondaryTable + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface BaseTableAnnotation + extends Annotation +{ + /** + * Corresponds to the 'name' element of the *Table annotation. + * Return null if the element does not exist in Java. + */ + String getName(); + String NAME_PROPERTY = "name"; //$NON-NLS-1$ + + /** + * Corresponds to the 'name' element of the *Table annotation. + * Set to null to remove the element. + */ + void setName(String name); + + /** + * Return the {@link TextRange} for the 'name' element. If the element + * does not exist return the {@link TextRange} for the *Table annotation. + */ + TextRange getNameTextRange(CompilationUnit astRoot); + + /** + * Return whether the specified position touches the 'name' element. + * Return false if the element does not exist. + */ + boolean nameTouches(int pos, CompilationUnit astRoot); + + + /** + * Corresponds to the 'schema' element of the *Table annotation. + * Return null if the element does not exist in Java. + */ + String getSchema(); + String SCHEMA_PROPERTY = "schema"; //$NON-NLS-1$ + + /** + * Corresponds to the 'schema' element of the *Table annotation. + * Set to null to remove the element. + */ + void setSchema(String schema); + + /** + * Return the {@link TextRange} for the 'schema' element. If the element + * does not exist return the {@link TextRange} for the *Table annotation. + */ + TextRange getSchemaTextRange(CompilationUnit astRoot); + + /** + * Return whether the specified position touches the 'schema' element. + * Return false if the element does not exist. + */ + boolean schemaTouches(int pos, CompilationUnit astRoot); + + + /** + * Corresponds to the 'catalog' element of the *Table annotation. + * Return null if the element does not exist in Java. + */ + String getCatalog(); + String CATALOG_PROPERTY = "catalog"; //$NON-NLS-1$ + + /** + * Corresponds to the 'catalog' element of the *Table annotation. + * Set to null to remove the element. + */ + void setCatalog(String catalog); + + /** + * Return the {@link TextRange} for the 'catalog' element. If the element + * does not exist return the {@link TextRange} for the *Table annotation. + */ + TextRange getCatalogTextRange(CompilationUnit astRoot); + + /** + * Return whether the specified position touches the 'catalog' element. + * Return false if the element does not exist. + */ + boolean catalogTouches(int pos, CompilationUnit astRoot); + + + /** + * Corresponds to the 'uniqueConstraints' element of the *Table annotation. + * Return an empty iterator if the element does not exist in Java. + */ + ListIterator uniqueConstraints(); + String UNIQUE_CONSTRAINTS_LIST = "uniqueConstraints"; //$NON-NLS-1$ + + /** + * Corresponds to the 'uniqueConstraints' element of the *Table annotation. + */ + int uniqueConstraintsSize(); + + /** + * Corresponds to the 'uniqueConstraints' element of the *Table annotation. + */ + UniqueConstraintAnnotation uniqueConstraintAt(int index); + + /** + * Corresponds to the 'uniqueConstraints' element of the *Table annotation. + */ + int indexOfUniqueConstraint(UniqueConstraintAnnotation uniqueConstraint); + + /** + * Corresponds to the 'uniqueConstraints' element of the *Table annotation. + */ + UniqueConstraintAnnotation addUniqueConstraint(int index); + + /** + * Corresponds to the 'uniqueConstraints' element of the *Table annotation. + */ + void moveUniqueConstraint(int targetIndex, int sourceIndex); + + /** + * Corresponds to the 'uniqueConstraints' element of the *Table annotation. + */ + void removeUniqueConstraint(int index); + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceCompilationUnit.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,265 @@ +/******************************************************************************* + * 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 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.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 ********** + + public Iterator persistableTypes() { + return (this.persistentType == null) ? + EmptyIterator.instance() : + this.persistentType.allPersistableTypes(); + } + + 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 resolveBinding() on the TypeDeclaration returns null + * 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 ? (TypeDeclaration) atd : null; + } + } + return null; + } + + // minimize scope of suppressed warnings + @SuppressWarnings("unchecked") + protected static List 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.persistentType.getName()); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEmbeddedAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNode.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNode.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceNode.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceNode.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/OneToManyAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/OneToManyAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/OneToManyAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/OneToManyAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceEmbeddableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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 + 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 + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratorAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratorAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratorAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryGeneratorAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,129 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverridesAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverridesAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverridesAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAttributeOverridesAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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 + implements AttributeOverridesAnnotation +{ + private final Vector attributeOverrides; + + + public BinaryAttributeOverridesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.attributeOverrides = this.buildAttributeOverrides(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public ListIterator nestedAnnotations() { + return new CloneListIterator(this.attributeOverrides); + } + + public int nestedAnnotationsSize() { + return this.attributeOverrides.size(); + } + + private Vector buildAttributeOverrides() { + Object[] jdtAttributeOverrides = this.getJdtMemberValues(JPA.ATTRIBUTE_OVERRIDES__VALUE); + Vector result = new Vector(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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMappedSuperclassAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMappedSuperclassAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMappedSuperclassAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMappedSuperclassAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,113 @@ +/******************************************************************************* + * 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 + implements OverrideAnnotation +{ + final DeclarationAnnotationElementAdapter nameDeclarationAdapter; + final AnnotationElementAdapter 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(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); + } + + 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/EntityAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/EntityAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/EntityAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/EntityAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/AttributeOverridesAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryContainerAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,71 @@ +/******************************************************************************* + * 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 + extends BinaryAnnotation + implements ContainerAnnotation +{ + + 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/TemporalAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/TemporalAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/TemporalAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/TemporalAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,166 @@ +/******************************************************************************* + * 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.ListIterator; +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.JpaResourceModelListener; +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.ListenerList; +import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; +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 BinaryNode + implements JavaResourcePackageFragmentRoot +{ + /** JDT package fragment root */ + private final IPackageFragmentRoot packageFragmentRoot; + + /** pluggable annotation provider */ + private final JpaAnnotationProvider annotationProvider; + + /** listeners notified whenever the resource model changes */ + private final ListenerList resourceModelListenerList; + + /** package fragments in the JAR */ + private final Vector packageFragments; + + + // ********** construction/initialization ********** + + public BinaryPackageFragmentRoot(IPackageFragmentRoot packageFragmentRoot, JpaAnnotationProvider annotationProvider) { + super(null); // the package fragment root is the root of its sub-tree + this.packageFragmentRoot = packageFragmentRoot; + this.annotationProvider = annotationProvider; + this.resourceModelListenerList = new ListenerList(JpaResourceModelListener.class); + this.packageFragments = this.buildPackageFragments(); + } + + private Vector buildPackageFragments() { + Vector result = new Vector(); + for (IJavaElement pf : this.getJDTChildren()) { + result.add(new BinaryPackageFragment(this, (IPackageFragment) pf)); + } + return result; + } + + + // ********** overrides ********** + + @Override + protected boolean requiresParent() { + return false; + } + + @Override + public JavaResourcePackageFragmentRoot getRoot() { + return this; + } + + @Override + public IFile getFile() { + return (IFile) this.packageFragmentRoot.getResource(); + } + + @Override + public JpaAnnotationProvider getAnnotationProvider() { + return this.annotationProvider; + } + + @Override + public void update() { + super.update(); + this.updatePackageFragments(); + } + + // TODO + private void updatePackageFragments() { + throw new UnsupportedOperationException(); + } + + + // ********** JavaResourceNode.Root implementation ********** + + public Iterator persistableTypes() { + return new CompositeIterator(this.persistableTypeIterators()); + } + + private Iterator> persistableTypeIterators() { + return new TransformationIterator>(this.packageFragments()) { + @Override + protected Iterator transform(JavaResourcePackageFragment pf) { + return pf.persistableTypes(); + } + }; + } + + 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); + } + + + // ********** JavaResourcePackageFragmentRoot implementation ********** + + public ListIterator packageFragments() { + return new CloneListIterator(this.packageFragments); + } + + public int packageFragmentsSize() { + return this.packageFragments.size(); + } + + + // ********** misc ********** + + private IJavaElement[] getJDTChildren() { + try { + return this.packageFragmentRoot.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.getFile().getName()); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceJoinColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,206 @@ +/******************************************************************************* + * 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 referencedColumnNameDeclarationAdapter; + private final AnnotationElementAdapter 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 createJoinTableJoinColumn(JavaResourceNode parent, Member member, int index) { + return new SourceJoinColumnAnnotation(parent, member, buildJoinTableAnnotationAdapter(index)); + } + + private static IndexedDeclarationAnnotationAdapter buildJoinTableAnnotationAdapter(int index) { + return new NestedIndexedDeclarationAnnotationAdapter(SourceJoinTableAnnotation.DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__JOIN_COLUMNS, index, JPA.JOIN_COLUMN); + } + + static NestableJoinColumnAnnotation createJoinTableInverseJoinColumn(JavaResourceNode parent, Member member, int index) { + return new SourceJoinColumnAnnotation(parent, member, buildJoinTableInverseAnnotationAdapter(index)); + } + + private static IndexedDeclarationAnnotationAdapter buildJoinTableInverseAnnotationAdapter(int index) { + return new NestedIndexedDeclarationAnnotationAdapter(SourceJoinTableAnnotation.DECLARATION_ANNOTATION_ADAPTER, JPA.JOIN_TABLE__INVERSE_JOIN_COLUMNS, 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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTransientAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTransientAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTransientAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTransientAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueryAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueryAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryNamedNativeQueryAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,119 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullBaseColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,111 @@ +/******************************************************************************* + * 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 abstract BaseColumnAnnotation buildAnnotation(); + + // ***** table + public String getTable() { + return null; + } + + public void setTable(String table) { + if (table != null) { + this.buildAnnotation().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.buildAnnotation().setUnique(unique); + } + } + + public TextRange getUniqueTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** updatable + public Boolean getUpdatable() { + return null; + } + + public void setUpdatable(Boolean updatable) { + if (updatable != null) { + this.buildAnnotation().setUpdatable(updatable); + } + } + + public TextRange getUpdatableTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** insertable + public Boolean getInsertable() { + return null; + } + + public void setInsertable(Boolean insertable) { + if (insertable != null) { + this.buildAnnotation().setInsertable(insertable); + } + } + + public TextRange getInsertableTextRange(CompilationUnit astRoot) { + return null; + } + + // ***** nullable + public Boolean getNullable() { + return null; + } + + public void setNullable(Boolean nullable) { + if (nullable != null) { + this.buildAnnotation().setNullable(nullable); + } + } + + public TextRange getNullableTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,237 @@ +/******************************************************************************* + * 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 tableDeclarationAdapter; + final AnnotationElementAdapter tableAdapter; + String table; + + final DeclarationAnnotationElementAdapter uniqueDeclarationAdapter; + final AnnotationElementAdapter uniqueAdapter; + Boolean unique; + + final DeclarationAnnotationElementAdapter nullableDeclarationAdapter; + final AnnotationElementAdapter nullableAdapter; + Boolean nullable; + + final DeclarationAnnotationElementAdapter insertableDeclarationAdapter; + final AnnotationElementAdapter insertableAdapter; + Boolean insertable; + + final DeclarationAnnotationElementAdapter updatableDeclarationAdapter; + final AnnotationElementAdapter 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()); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/OrderByAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/OrderByAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/OrderByAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/OrderByAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/resource/java/NestableNamedQueryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableNamedQueryAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/NestableNamedQueryAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/NestableNamedQueryAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resource.java; + +/** + * Corresponds to the JPA annotation + * javax.persistence.NamedQuery + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestableNamedQueryAnnotation + extends NamedQueryAnnotation, NestableAnnotation +{ + // combines two annotation +} Index: src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/PrimaryKeyJoinColumnAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryBaseColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,184 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/resource/java/JavaResourceClassFile.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/JavaResourceClassFile.java diff -N src/org/eclipse/jpt/core/resource/java/JavaResourceClassFile.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/JavaResourceClassFile.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.resource.java; + + +/** + * Java class file + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface JavaResourceClassFile + extends JavaResourceNode +{ + /** + * Return the class file's persistent type. + */ + JavaResourcePersistentType getPersistentType(); + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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. + */ + protected IMemberValuePair getJdtMemberValuePair(String memberName) { + for (IMemberValuePair pair : this.getJdtMemberValuePairs()) { + if (pair.getMemberName().equals(memberName)) { + return pair; + } + } + return null; + } + + protected 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/GeneratedValueAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceLobAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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 + 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 + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceEnumeratedAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,95 @@ +/******************************************************************************* + * 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 + implements EnumeratedAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private EnumType value; + + + public SourceEnumeratedAnnotation(JavaResourceNode parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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 buildValueAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.ENUMERATED__VALUE, false); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/EmbeddableAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/EmbeddableAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/EmbeddableAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/EmbeddableAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceTemporalAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceTemporalAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceTemporalAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceTemporalAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,95 @@ +/******************************************************************************* + * 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 + implements TemporalAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private final AnnotationElementAdapter valueAdapter; + private TemporalType value; + + + public SourceTemporalAnnotation(JavaResourceNode parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter(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 buildValueAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.TEMPORAL__VALUE); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullAssociationOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullAssociationOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullAssociationOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullAssociationOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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 java.util.ListIterator; + +import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; +import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; + +/** + * javax.persistence.AssociationOverride + */ +public final class NullAssociationOverrideAnnotation + extends NullOverrideAnnotation + implements AssociationOverrideAnnotation +{ + + public NullAssociationOverrideAnnotation(JavaResourcePersistentType parent, String name) { + super(parent, name); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + @Override + protected AssociationOverrideAnnotation buildSupportingAnnotation() { + return (AssociationOverrideAnnotation) super.buildSupportingAnnotation(); + } + + // ***** join columns + public ListIterator joinColumns() { + return EmptyListIterator.instance(); + } + + public JoinColumnAnnotation joinColumnAt(int index) { + throw new UnsupportedOperationException(); + } + + public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { + throw new UnsupportedOperationException(); + } + + public int joinColumnsSize() { + return 0; + } + + public JoinColumnAnnotation addJoinColumn(int index) { + throw new UnsupportedOperationException(); + } + + public void removeJoinColumn(int index) { + throw new UnsupportedOperationException(); + } + + public void moveJoinColumn(int targetIndex, int sourceIndex) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/JoinTableAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/JoinTableAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/JoinTableAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/JoinTableAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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.JavaResourcePersistentAttribute; +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 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((JavaResourcePersistentAttribute) parent); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinaryJoinTableAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return JoinTableAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/OneToOneAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/OneToOneAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/OneToOneAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/OneToOneAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinTableAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryJoinTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,162 @@ +/******************************************************************************* + * 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 joinColumns; + private final Vector 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 joinColumns() { + return new CloneListIterator(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 buildJoinColumns() { + Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.JOIN_TABLE__JOIN_COLUMNS); + Vector result = new Vector(jdtJoinColumns.length); + for (Object jdtJoinColumn : jdtJoinColumns) { + result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); + } + return result; + } + + // TODO + private void updateJoinColumns() { + throw new UnsupportedOperationException(); + } + + // ***** inverse join columns + public ListIterator inverseJoinColumns() { + return new CloneListIterator(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 buildInverseJoinColumns() { + Object[] jdtJoinColumns = this.getJdtMemberValues(JPA.JOIN_TABLE__INVERSE_JOIN_COLUMNS); + Vector result = new Vector(jdtJoinColumns.length); + for (Object jdtJoinColumn : jdtJoinColumns) { + result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); + } + return result; + } + + // TODO + private void updateInverseJoinColumns() { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOverrideAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOverrideAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOverrideAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOverrideAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,78 @@ +/******************************************************************************* + * 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()); + } + + abstract String getNameElementName(); + + public TextRange getNameTextRange(CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + + public boolean nameTouches(int pos, CompilationUnit astRoot) { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/SecondaryTableAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToManyAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToManyAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToManyAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOneToManyAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,92 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/context/java/GenericJarFile.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/context/java/GenericJarFile.java diff -N src/org/eclipse/jpt/core/internal/context/java/GenericJarFile.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/context/java/GenericJarFile.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,131 @@ +/******************************************************************************* + * 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.context.java; + +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.jpt.core.JpaNode; +import org.eclipse.jpt.core.JpaStructureNode; +import org.eclipse.jpt.core.JptCorePlugin; +import org.eclipse.jpt.core.context.AccessType; +import org.eclipse.jpt.core.context.PersistentType; +import org.eclipse.jpt.core.context.java.JarFile; +import org.eclipse.jpt.core.context.java.JavaPersistentType; +import org.eclipse.jpt.core.internal.context.AbstractJpaContextNode; +import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.utility.internal.CollectionTools; +import org.eclipse.jpt.utility.internal.iterables.CloneIterable; +import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; +import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException; +import org.eclipse.wst.validation.internal.provisional.core.IMessage; +import org.eclipse.wst.validation.internal.provisional.core.IReporter; + +public class GenericJarFile + extends AbstractJpaContextNode + implements JarFile, PersistentType.Owner +{ + protected JavaResourcePackageFragmentRoot jarResourcePackageFragmentRoot; + protected final Vector javaPersistentTypes = new Vector(); + + + // ********** constructor/initialization ********** + + public GenericJarFile(JpaNode parent, JavaResourcePackageFragmentRoot jarResourcePackageFragmentRoot) { + super(parent); + this.jarResourcePackageFragmentRoot = jarResourcePackageFragmentRoot; + CollectionTools.addAll(this.javaPersistentTypes, this.buildJavaPersistentTypes()); + } + + protected Iterator buildJavaPersistentTypes() { + return new TransformationIterator(this.jarResourcePackageFragmentRoot.persistableTypes()) { + @Override + protected JavaPersistentType transform(JavaResourcePersistentType jrpt) { + return GenericJarFile.this.buildJavaPersistentType(jrpt); + } + }; + } + + protected JavaPersistentType buildJavaPersistentType(JavaResourcePersistentType jrpt) { + return this.getJpaFactory().buildJavaPersistentType(this, jrpt); + } + + + // ********** JpaStructureNode implementation ********** + + public String getId() { + return null; + } + + public IContentType getContentType() { + return JptCorePlugin.JAR_CONTENT_TYPE; + } + + public TextRange getSelectionTextRange() { + return null; + } + + public JpaStructureNode getStructureNode(int textOffset) { + return null; + } + + public void dispose() { + // nothing yet + } + + + // ********** JarFile implementation ********** + + public PersistentType getPersistentType(String typeName) { + for (JavaPersistentType pt : this.getJavaPersistentTypes()) { + if (pt.getName().equals(typeName)) { + return pt; + } + } + return null; + } + + protected Iterable getJavaPersistentTypes() { + return new CloneIterable(this.javaPersistentTypes); + } + + + // ********** PersistentType.Owner implementation ********** + + public AccessType getDefaultPersistentTypeAccess() { + return this.getPersistenceUnit().getDefaultAccess(); + } + + public AccessType getOverridePersistentTypeAccess() { + // no access type at this level overrides any local access type specification + return null; + } + + + // ********** updating ********** + + public void update(JavaResourcePackageFragmentRoot jrpfr) { + this.jarResourcePackageFragmentRoot = jrpfr; + } + + + // ********** validation ********** + + public void validate(List messages, IReporter reporter) { + if (reporter.isCancelled()) { + throw new ValidationCancelledException(); + } + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEnumeratedAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEnumeratedAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEnumeratedAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryEnumeratedAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,71 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourcePrimaryKeyJoinColumnsAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,117 @@ +/******************************************************************************* + * 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 + implements PrimaryKeyJoinColumnsAnnotation +{ + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private final Vector pkJoinColumns = new Vector(); + + + 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 nestedAnnotations() { + return new CloneListIterator(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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullPrimaryKeyJoinColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,55 @@ +/******************************************************************************* + * 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 buildAnnotation() { + 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceBasicAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,131 @@ +/******************************************************************************* + * 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 + implements BasicAnnotation +{ + private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); + + private static final DeclarationAnnotationElementAdapter OPTIONAL_ADAPTER = buildOptionalAdapter(); + private final AnnotationElementAdapter optionalAdapter; + private Boolean optional; + + private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); + private final AnnotationElementAdapter fetchAdapter; + private FetchType fetch; + + + public SourceBasicAnnotation(JavaResourcePersistentAttribute parent, Attribute attribute) { + super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); + this.optionalAdapter = new ShortCircuitAnnotationElementAdapter(attribute, OPTIONAL_ADAPTER); + this.fetchAdapter = new ShortCircuitAnnotationElementAdapter(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 buildOptionalAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__OPTIONAL, false, BooleanExpressionConverter.instance()); + } + + private static DeclarationAnnotationElementAdapter buildFetchAdapter() { + return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__FETCH, false); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/BasicAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/BasicAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/BasicAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/BasicAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullDiscriminatorValueAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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 buildSupportingAnnotation() { + return (DiscriminatorValueAnnotation) super.buildSupportingAnnotation(); + } + + // ***** value + public String getValue() { + return null; + } + + public void setValue(String value) { + if (value != null) { + this.buildSupportingAnnotation().setValue(value); + } + } + + public TextRange getValueTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/TableAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/TableAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/TableAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/TableAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceBaseNamedQueryAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,305 @@ +/******************************************************************************* + * 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 + implements BaseNamedQueryAnnotation +{ + final DeclarationAnnotationElementAdapter nameDeclarationAdapter; + final AnnotationElementAdapter nameAdapter; + String name; + + final DeclarationAnnotationElementAdapter queryDeclarationAdapter; + final AnnotationElementAdapter queryAdapter; + String query; + + final Vector hints = new Vector(); + 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 buildAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(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 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 buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) { + return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, this.getQueryElementName()); + } + + abstract String getQueryElementName(); + + // ***** hints + public ListIterator hints() { + return new CloneListIterator(this.hints); + } + + ListIterator nestableHints() { + return new CloneListIterator(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 + { + 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 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); + } + + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullOneToOneAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,52 @@ +/******************************************************************************* + * 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 buildMappingAnnotation() { + return (OneToOneAnnotation) super.buildMappingAnnotation(); + } + + // ***** optional + public Boolean getOptional() { + return null; + } + + public void setOptional(Boolean optional) { + if (optional != null) { + this.buildMappingAnnotation().setOptional(optional); + } + } + + public TextRange getOptionalTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceNamedColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,168 @@ +/******************************************************************************* + * 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 + implements NamedColumnAnnotation +{ + private final DeclarationAnnotationElementAdapter nameDeclarationAdapter; + private final AnnotationElementAdapter nameAdapter; + private String name; + + private final DeclarationAnnotationElementAdapter columnDefinitionDeclarationAdapter; + private final AnnotationElementAdapter 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 buildStringElementAdapter(String elementName) { + return ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, elementName); + } + + DeclarationAnnotationElementAdapter buildBooleanElementAdapter(String elementName) { + return new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName, BooleanExpressionConverter.instance()); + } + + DeclarationAnnotationElementAdapter buildIntegerElementAdapter(String elementName) { + return new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName, NumberIntegerExpressionConverter.instance()); + } + + AnnotationElementAdapter buildShortCircuitElementAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(this.member, daea); + } + + AnnotationElementAdapter buildShortCircuitBooleanElementAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(this.member, daea); + } + + AnnotationElementAdapter buildShortCircuitIntegerElementAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(this.member, daea); + } + + AnnotationElementAdapter 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 ********** + + // ***** 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()); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPackageFragment.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,229 @@ +/******************************************************************************* + * 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.ListIterator; +import java.util.Vector; + +import org.eclipse.core.runtime.IProgressMonitor; +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.internal.utility.jdt.JPTTools; +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 */ + private final Vector classFiles; + + + // ********** construction/initialization ********** + + BinaryPackageFragment(JavaResourcePackageFragmentRoot parent, IPackageFragment packageFragment) { + super(parent); + this.packageFragment = packageFragment; + this.classFiles = this.buildClassFiles(); + } + + private Vector buildClassFiles() { + Vector result = new Vector(); + for (IJavaElement child : this.getJDTChildren()) { + IClassFile classFile = (IClassFile) child; + IType type = this.findType(classFile); + if (this.typeIsPersistable(type)) { // we only hold persistable types + result.add(new BinaryClassFile(this, classFile, type)); + } + } + return result; + } + + /** + * Return the JDT type corresponding to the specified class file + * by searching the Java project's build path; as opposed to taking + * the type directly from the class file, since another type with the + * same name *may* precede the class file on the build path. + */ + private IType findType(IClassFile classFile) { + IType type = classFile.getType(); + try { + return type.getJavaProject().findType(type.getFullyQualifiedName(), (IProgressMonitor) null); + } catch (JavaModelException ex) { + return null; // ignore exception? + } + } + + private boolean typeIsPersistable(IType type) { + return (type != null) + && type.exists() + && JPTTools.typeIsPersistable(new JPTToolsAdapter(type)); + } + + + // ********** JarResourceNode implementation ********** + + @Override + public void update() { + super.update(); + this.updateClassFiles(); + } + + // TODO + private void updateClassFiles() { + throw new UnsupportedOperationException(); + } + + + // ********** JavaResourcePackageFragment implementation ********** + + public ListIterator classFiles() { + return new CloneListIterator(this.classFiles); + } + + public int classFilesSize() { + return this.classFiles.size(); + } + + public Iterator persistableTypes() { + return new TransformationIterator(this.classFiles()) { + @Override + protected JavaResourcePersistentType transform(JavaResourceClassFile classFile) { + return classFile.getPersistentType(); // we only hold persistable 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()); + } + + + // ********** JPT tools adapter ********** + + /** + * JPTTools needs an adapter so it can work with either an IType + * or an ITypeBinding etc. + */ + protected 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; // ??? + } + + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/SequenceGeneratorAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * 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.BinarySequenceGeneratorAnnotation; +import org.eclipse.jpt.core.internal.resource.java.source.SourceSequenceGeneratorAnnotation; +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 class SequenceGeneratorAnnotationDefinition + implements AnnotationDefinition +{ + // singleton + private static final AnnotationDefinition INSTANCE = new SequenceGeneratorAnnotationDefinition(); + + /** + * Return the singleton. + */ + public static AnnotationDefinition instance() { + return INSTANCE; + } + + /** + * Ensure single instance. + */ + private SequenceGeneratorAnnotationDefinition() { + super(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) { + return new SourceSequenceGeneratorAnnotation(parent, member); + } + + public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) { + throw new UnsupportedOperationException(); + } + + public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { + return new BinarySequenceGeneratorAnnotation(parent, jdtAnnotation); + } + + public String getAnnotationName() { + return SequenceGeneratorAnnotation.ANNOTATION_NAME; + } + +} Index: src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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.context.java; + +import org.eclipse.jpt.core.context.Column; +import org.eclipse.jpt.core.internal.resource.java.NullAttributeOverrideColumnAnnotation; +import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation; + +/** + * javax.persistence.Column + */ +public class VirtualAttributeOverrideColumnAnnotation + extends NullAttributeOverrideColumnAnnotation +{ + private Column column; + + public VirtualAttributeOverrideColumnAnnotation(AttributeOverrideAnnotation parent, Column column) { + super(parent); + this.column = column; + } + + @Override + public String getName() { + return this.column.getSpecifiedName(); + } + + @Override + public String getColumnDefinition() { + return this.column.getColumnDefinition(); + } + + @Override + public String getTable() { + return this.column.getSpecifiedTable(); + } + + @Override + public Boolean getInsertable() { + return this.column.getSpecifiedInsertable(); + } + + @Override + public Boolean getUpdatable() { + return this.column.getSpecifiedUpdatable(); + } + + @Override + public Boolean getNullable() { + return this.column.getSpecifiedNullable(); + } + + @Override + public Boolean getUnique() { + return this.column.getSpecifiedUnique(); + } + + @Override + public Integer getLength() { + return this.column.getSpecifiedLength(); + } + + @Override + public Integer getScale() { + return this.column.getSpecifiedScale(); + } + + @Override + public Integer getPrecision() { + return this.column.getSpecifiedPrecision(); + } + +} Index: src/org/eclipse/jpt/core/resource/java/NestableNamedNativeQueryAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableNamedNativeQueryAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/NestableNamedNativeQueryAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/NestableNamedNativeQueryAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resource.java; + +/** + * Corresponds to the JPA annotation + * javax.persistence.NamedNativeQuery + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestableNamedNativeQueryAnnotation + extends NamedNativeQueryAnnotation, NestableAnnotation +{ + // combine two interfaces +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMapKeyAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMapKeyAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMapKeyAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryMapKeyAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryRelationshipMappingAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryRelationshipMappingAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryRelationshipMappingAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryRelationshipMappingAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,212 @@ +/******************************************************************************* + * 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.CollectionTools; + +/** + * 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 = CollectionTools.contains(cascadeTypes, CascadeType.ALL); + this.cascadeMerge = CollectionTools.contains(cascadeTypes, CascadeType.MERGE); + this.cascadePersist = CollectionTools.contains(cascadeTypes, CascadeType.PERSIST); + this.cascadeRefresh = CollectionTools.contains(cascadeTypes, CascadeType.REFRESH); + this.cascadeRemove = CollectionTools.contains(cascadeTypes, CascadeType.REMOVE); + } + + @Override + public void update() { + super.update(); + this.setTargetEntity_(this.buildTargetEntity()); + this.setFetch_(this.buildFetch()); + + CascadeType[] cascadeTypes = this.buildCascadeTypes(); + this.setCascadeAll_(CollectionTools.contains(cascadeTypes, CascadeType.ALL)); + this.setCascadeMerge_(CollectionTools.contains(cascadeTypes, CascadeType.MERGE)); + this.setCascadePersist_(CollectionTools.contains(cascadeTypes, CascadeType.PERSIST)); + this.setCascadeRefresh_(CollectionTools.contains(cascadeTypes, CascadeType.REFRESH)); + this.setCascadeRemove_(CollectionTools.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((String[]) 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); + } + +} Index: src/org/eclipse/jpt/core/resource/java/NestableSecondaryTableAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/resource/java/NestableSecondaryTableAnnotation.java diff -N src/org/eclipse/jpt/core/resource/java/NestableSecondaryTableAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/resource/java/NestableSecondaryTableAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resource.java; + +/** + * Corresponds to the JPA annotation + * javax.persistence.SecondaryTable + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + */ +public interface NestableSecondaryTableAnnotation + extends SecondaryTableAnnotation, NestableAnnotation +{ + // combine two interfaces +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceRelationshipMappingAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,315 @@ +/******************************************************************************* + * 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.CollectionTools; + +/** + * javax.persistence.ManyToMany + * javax.persistence.ManyToOne + * javax.persistence.OneToMany + * javax.persistence.OneToOne + */ +abstract class SourceRelationshipMappingAnnotation + extends SourceAnnotation + implements RelationshipMappingAnnotation +{ + final DeclarationAnnotationElementAdapter targetEntityDeclarationAdapter; + final AnnotationElementAdapter targetEntityAdapter; + String targetEntity; + + String fullyQualifiedTargetEntityClassName; + + final DeclarationAnnotationElementAdapter fetchDeclarationAdapter; + final AnnotationElementAdapter fetchAdapter; + FetchType fetch; + + final DeclarationAnnotationElementAdapter cascadeDeclarationAdapter; + final AnnotationElementAdapter 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(attribute, this.cascadeDeclarationAdapter); + } + + AnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(this.member, daea); + } + + AnnotationElementAdapter buildBooleanAnnotationElementAdapter(DeclarationAnnotationElementAdapter daea) { + return new ShortCircuitAnnotationElementAdapter(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 = CollectionTools.contains(cascadeTypes, CascadeType.ALL); + this.cascadeMerge = CollectionTools.contains(cascadeTypes, CascadeType.MERGE); + this.cascadePersist = CollectionTools.contains(cascadeTypes, CascadeType.PERSIST); + this.cascadeRefresh = CollectionTools.contains(cascadeTypes, CascadeType.REFRESH); + this.cascadeRemove = CollectionTools.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(CollectionTools.contains(cascadeTypes, CascadeType.ALL)); + this.setCascadeMerge(CollectionTools.contains(cascadeTypes, CascadeType.MERGE)); + this.setCascadePersist(CollectionTools.contains(cascadeTypes, CascadeType.PERSIST)); + this.setCascadeRefresh(CollectionTools.contains(cascadeTypes, CascadeType.REFRESH)); + this.setCascadeRemove(CollectionTools.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 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 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 = CollectionTools.contains(cascadeTypes, cascadeType); + if (set) { + if ( ! present) { + this.setCascadeTypes(CollectionTools.add(cascadeTypes, cascadeType)); + } + } else { + if (present) { + this.setCascadeTypes(CollectionTools.remove(cascadeTypes, cascadeType)); + } + } + } + + public TextRange getCascadeTextRange(CompilationUnit astRoot) { + return getElementTextRange(this.cascadeDeclarationAdapter, astRoot); + } + + /** + * return the Java adapter's 'cascade' element adapter config + */ + abstract DeclarationAnnotationElementAdapter 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 buildTargetEntityAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + // TODO what about QualifiedType? + return buildAnnotationElementAdapter(annotationAdapter, elementName, SimpleTypeStringExpressionConverter.instance()); + } + + static DeclarationAnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); + } + + static DeclarationAnnotationElementAdapter buildFetchAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return new EnumDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false); + } + + static DeclarationAnnotationElementAdapter buildEnumArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return new EnumArrayDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NamedQueriesAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,87 @@ +/******************************************************************************* + * 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: Set the type or attribute's mapping annotation + * and return it. + * Pre-condition: The annotation's parent must be a persistent member + * (type or attribute). + */ + protected Annotation buildMappingAnnotation() { + return this.getMember().setMappingAnnotation(this.getAnnotationName()); + } + + /** + * Convenience method: Add to the type or attribute's list of "supporting" + * annotations and return the newly created annotation. + * Pre-condition: The annotation's parent must be a persistent member + * (type or attribute). + */ + protected Annotation buildSupportingAnnotation() { + return this.getMember().addSupportingAnnotation(this.getAnnotationName()); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTemporalAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTemporalAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTemporalAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTemporalAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,71 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/TransientAnnotationDefinition.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/TransientAnnotationDefinition.java diff -N src/org/eclipse/jpt/core/internal/resource/java/TransientAnnotationDefinition.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/TransientAnnotationDefinition.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentAttribute.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,629 @@ +/******************************************************************************* + * 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.resource.java.AccessAnnotation; +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 typeSuperclassNames = new Vector(); + + private final Vector typeInterfaceNames = new Vector(); + + private final Vector typeTypeArgumentNames = new Vector(); + + + 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(); + this.typeIsInterface = this.buildTypeIsInterface(); + this.typeIsEnum = this.buildTypeIsEnum(); + this.typeSuperclassNames.addAll(this.buildTypeSuperclassNames()); + this.typeInterfaceNames.addAll(this.buildTypeInterfaceNames()); + this.typeTypeArgumentNames.addAll(this.buildTypeTypeArgumentNames()); + } + + + // ******** overrides ******** + + @Override + public void update() { + super.update(); + this.setModifiers(this.buildModifiers()); + this.setTypeName(this.buildTypeName()); + this.setTypeIsInterface(this.buildTypeIsInterface()); + this.setTypeIsEnum(this.buildTypeIsEnum()); + this.setTypeSuperclassNames(this.buildTypeSuperclassNames()); + this.setTypeInterfaceNames(this.buildTypeInterfaceNames()); + this.setTypeTypeArgumentNames(this.buildTypeTypeArgumentNames()); + } + + @Override + public void toString(StringBuilder sb) { + sb.append(this.getName()); + } + + + // ********** BinaryPersistentMember implementation ********** + + private Adapter getAdapter() { + return (Adapter) this.adapter; + } + + @Override + Annotation buildMappingAnnotation(IAnnotation jdtAnnotation) { + return this.getAnnotationProvider().buildAttributeMappingAnnotation(this, jdtAnnotation); + } + + @Override + Annotation buildSupportingAnnotation(IAnnotation jdtAnnotation) { + return this.getAnnotationProvider().buildAttributeSupportingAnnotation(this, jdtAnnotation); + } + + @Override + Annotation buildNullSupportingAnnotation(String annotationName) { + return this.getAnnotationProvider().buildNullAttributeSupportingAnnotation(this, annotationName); + } + + public Annotation getNullMappingAnnotation(String annotationName) { + return (annotationName == null) ? null : this.buildNullMappingAnnotation(annotationName); + } + + private Annotation buildNullMappingAnnotation(String annotationName) { + return this.getAnnotationProvider().buildNullAttributeMappingAnnotation(this, annotationName); + } + + @Override + ListIterator validMappingAnnotationNames() { + return this.getAnnotationProvider().attributeMappingAnnotationNames(); + } + + @Override + ListIterator validSupportingAnnotationNames() { + return this.getAnnotationProvider().attributeSupportingAnnotationNames(); + } + + + // ********** JavaResourcePersistentAttribute implementation ********** + + public String getName() { + return this.getAdapter().getAttributeName(); + } + + public boolean isField() { + return this.getAdapter().isField(); + } + + public boolean isProperty() { + return ! this.isField(); + } + + public boolean isFor(MethodSignature methodSignature, int occurrence) { + throw new UnsupportedOperationException(); + } + + public boolean hasAnyPersistenceAnnotations() { + return (this.mappingAnnotationsSize() > 0) + || (this.supportingAnnotationsSize() > 0); + } + + public AccessType getSpecifiedAccess() { + AccessAnnotation accessAnnotation = (AccessAnnotation) this.getSupportingAnnotation(AccessAnnotation.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 arguments + */ + 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 = this.getType(); // shouldn't be an array... + 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 = this.getType(); // shouldn't be an array... + try { + return (type != null) && type.isEnum(); + } catch (JavaModelException ex) { + JptCorePlugin.log(ex); + return false; + } + } + + // ***** type superclass hierarchy + public ListIterator typeSuperclassNames() { + return new CloneListIterator(this.typeSuperclassNames); + } + + public boolean typeSuperclassNamesContains(String superclassName) { + return this.typeSuperclassNames.contains(superclassName); + } + + private void setTypeSuperclassNames(List typeSuperclassNames) { + this.synchronizeList(typeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_COLLECTION); + } + + private List buildTypeSuperclassNames() { + IType type = this.getType(); + if (type == null) { + return Collections.emptyList(); + } + + ArrayList names = new ArrayList(); + type = this.findSuperclass(type); + while (type != null) { + names.add(type.getFullyQualifiedName()); + type = this.findSuperclass(type); + } + return names; + } + + // ***** type interface hierarchy + public Iterator typeInterfaceNames() { + return new CloneIterator(this.typeInterfaceNames); + } + + public boolean typeInterfaceNamesContains(String interfaceName) { + return this.typeInterfaceNames.contains(interfaceName); + } + + private void setTypeInterfaceNames(Collection typeInterfaceNames) { + this.synchronizeCollection(typeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION); + } + + private Collection buildTypeInterfaceNames() { + IType type = this.getType(); + if (type == null) { + return Collections.emptySet(); + } + + HashSet names = new HashSet(); + while (type != null) { + this.addInterfaceNamesTo(type, names); + type = this.findSuperclass(type); + } + return names; + } + + private void addInterfaceNamesTo(IType type, HashSet 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 typeTypeArgumentNames() { + return new CloneListIterator(this.typeTypeArgumentNames); + } + + public int typeTypeArgumentNamesSize() { + return this.typeTypeArgumentNames.size(); + } + + public String getTypeTypeArgumentName(int index) { + return this.typeTypeArgumentNames.get(index); + } + + private void setTypeTypeArgumentNames(List typeTypeArgumentNames) { + this.synchronizeList(typeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_COLLECTION); + } + + /** + * 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") + */ + private List buildTypeTypeArgumentNames() { + String typeSignature = this.getTypeSignature(); + if (typeSignature == null) { + return Collections.emptyList(); + } + + String[] typeArgumentSignatures = Signature.getTypeArguments(typeSignature); + if (typeArgumentSignatures.length == 0) { + return Collections.emptyList(); + } + + ArrayList names = new ArrayList(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]; + + /** + * Strip off the type signature's parameters if present. + * Convert to a readable string. + */ + private static String convertTypeSignatureToTypeName(String typeSignature) { + return (typeSignature == null) ? null : convertTypeSignatureToTypeName_(typeSignature); + } + + /** + * no null check + */ + private static String convertTypeSignatureToTypeName_(String typeSignature) { + return Signature.toString(Signature.getTypeErasure(typeSignature)); + } + + 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 ********** + + interface Adapter extends BinaryPersistentMember.Adapter { + String getAttributeName(); + boolean isField(); + String getTypeSignature() throws JavaModelException; + } + + static class FieldAdapter implements Adapter { + private 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(this.field)); + } + + 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. + */ + static class JPTToolsAdapter implements JPTTools.FieldAdapter { + private final IField field; + + JPTToolsAdapter(IField field) { + super(); + if (field == null) { + throw new NullPointerException(); + } + this.field = field; + } + + public int getModifiers() { + try { + return this.field.getFlags(); + } catch (JavaModelException ex) { + JptCorePlugin.log(ex); + return 0; + } + } + + } + + } + + static class MethodAdapter implements Adapter { + private final IMethod method; + + MethodAdapter(IMethod method) { + super(); + this.method = method; + } + + public IMethod getMember() { + return this.method; + } + + public boolean isPersistable() { + return JPTTools.methodIsPersistablePropertyGetter(new JPTToolsAdapter(this.method)); + } + + 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. + */ + static class JPTToolsAdapter implements JPTTools.MethodAdapter { + private final IMethod method; + + JPTToolsAdapter(IMethod method) { + super(); + if (method == null) { + throw new NullPointerException(); + } + this.method = method; + } + + public String getName() { + return this.method.getElementName(); + } + + public int getModifiers() { + try { + return this.method.getFlags(); + } catch (JavaModelException ex) { + JptCorePlugin.log(ex); + return 0; + } + } + + public String getReturnTypeName() { + try { + return this.method.getReturnType(); + } catch (JavaModelException ex) { + JptCorePlugin.log(ex); + return null; + } + } + + public boolean isConstructor() { + try { + return this.method.isConstructor(); + } catch (JavaModelException ex) { + JptCorePlugin.log(ex); + return false; + } + } + + public int getParametersLength() { + return this.method.getParameterTypes().length; + } + + public JPTTools.MethodAdapter getSibling(String name) { + for (IMethod sibling : this.getSiblings()) { + if ((sibling.getParameterTypes().length == 0) + && sibling.getElementName().equals(name)) { + return new JPTToolsAdapter(sibling); + } + } + return null; + } + + public JPTTools.MethodAdapter getSibling(String name, String parameterTypeName) { + for (IMethod sibling : this.getSiblings()) { + String[] parmTypes = sibling.getParameterTypes(); + if ((parmTypes.length == 1) + && parmTypes[0].equals(parameterTypeName) + && sibling.getElementName().equals(name)) { + return new JPTToolsAdapter(sibling); + } + } + return null; + } + + private IMethod[] getSiblings() { + try { + return this.method.getDeclaringType().getMethods(); + } catch (JavaModelException ex) { + JptCorePlugin.log(ex); + return EMPTY_METHOD_ARRAY; + } + } + private static final IMethod[] EMPTY_METHOD_ARRAY = new IMethod[0]; + + } + + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverridesAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverridesAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverridesAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryAssociationOverridesAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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 final class BinaryAssociationOverridesAnnotation + extends BinaryContainerAnnotation + implements AssociationOverridesAnnotation +{ + private final Vector associationOverrides; + + + public BinaryAssociationOverridesAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.associationOverrides = this.buildAssociationOverrides(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public ListIterator nestedAnnotations() { + return new CloneListIterator(this.associationOverrides); + } + + public int nestedAnnotationsSize() { + return this.associationOverrides.size(); + } + + private Vector buildAssociationOverrides() { + Object[] jdtAssociationOverrides = this.getJdtMemberValues(JPA.ASSOCIATION_OVERRIDES__VALUE); + Vector result = new Vector(jdtAssociationOverrides.length); + for (Object jdtAssociationOverride : jdtAssociationOverrides) { + result.add(new BinaryAssociationOverrideAnnotation(this, (IAnnotation) jdtAssociationOverride)); + } + return result; + } + + @Override + public void update() { + super.update(); + this.updateAssociationOverrides(); + } + + // TODO + private void updateAssociationOverrides() { + throw new UnsupportedOperationException(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryIdAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOrderByAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOrderByAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOrderByAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryOrderByAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,64 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryDiscriminatorColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,100 @@ +/******************************************************************************* + * 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); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTablesAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTablesAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTablesAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinarySecondaryTablesAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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 + implements SecondaryTablesAnnotation +{ + private final Vector secondaryTables; + + + public BinarySecondaryTablesAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { + super(parent, jdtAnnotation); + this.secondaryTables = this.buildSecondaryTables(); + } + + public String getAnnotationName() { + return ANNOTATION_NAME; + } + + public ListIterator nestedAnnotations() { + return new CloneListIterator(this.secondaryTables); + } + + public int nestedAnnotationsSize() { + return this.secondaryTables.size(); + } + + private Vector buildSecondaryTables() { + Object[] jdtSecondaryTables = this.getJdtMemberValues(JPA.JOIN_COLUMNS__VALUE); + Vector result = new Vector(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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,163 @@ +/******************************************************************************* + * 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(); + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/NullNamedColumnAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,67 @@ +/******************************************************************************* + * 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); + } + + protected abstract NamedColumnAnnotation buildAnnotation(); + + // ***** name + public String getName() { + return null; + } + + public void setName(String name) { + if (name != null) { + this.buildAnnotation().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.buildAnnotation().setColumnDefinition(columnDefinition); + } + } + + public TextRange getColumnDefinitionTextRange(CompilationUnit astRoot) { + return null; + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/source/SourceTransientAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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 + 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 + } + +} Index: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableGeneratorAnnotation.java =================================================================== RCS file: src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableGeneratorAnnotation.java diff -N src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableGeneratorAnnotation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryTableGeneratorAnnotation.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,293 @@ +/******************************************************************************* + * 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 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 uniqueConstraints() { + return new CloneListIterator(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 buildUniqueConstraints() { + Object[] jdtUniqueConstraints = this.getJdtMemberValues(JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS); + Vector result = new Vector(jdtUniqueConstraints.length); + for (Object jdtUniqueConstraint : jdtUniqueConstraints) { + result.add(new BinaryUniqueConstraintAnnotation(this, (IAnnotation) jdtUniqueConstraint)); + } + return result; + } + + // TODO + private void updateUniqueConstraints() { + throw new UnsupportedOperationException(); + } + +} #P org.eclipse.jpt.ui Index: src/org/eclipse/jpt/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java,v retrieving revision 1.6 diff -u -r1.6 JavaPersistentTypeItemContentProvider.java --- src/org/eclipse/jpt/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java 28 Jan 2009 06:18:32 -0000 1.6 +++ src/org/eclipse/jpt/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java 6 Apr 2009 20:59:27 -0000 @@ -40,7 +40,7 @@ @Override protected CollectionValueModel buildChildrenModel() { return new ListCollectionValueModelAdapter( - new ListAspectAdapter(PersistentType.SPECIFIED_ATTRIBUTES_LIST, getModel()) { + new ListAspectAdapter(PersistentType.ATTRIBUTES_LIST, getModel()) { @Override protected ListIterator listIterator_() { return subject.attributes(); Index: src/org/eclipse/jpt/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java =================================================================== RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java,v retrieving revision 1.5 diff -u -r1.5 OrmPersistentTypeItemContentProvider.java --- src/org/eclipse/jpt/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java 28 Jan 2009 06:18:32 -0000 1.5 +++ src/org/eclipse/jpt/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java 6 Apr 2009 20:59:27 -0000 @@ -51,7 +51,7 @@ protected CollectionValueModel buildSpecifiedPersistentAttributesCollectionHolder() { return new ListCollectionValueModelAdapter( - new ListAspectAdapter(PersistentType.SPECIFIED_ATTRIBUTES_LIST, getModel()) { + new ListAspectAdapter(PersistentType.ATTRIBUTES_LIST, getModel()) { @Override protected ListIterator listIterator_() { return subject.specifiedAttributes();