Class MetadataAccessor

  • Direct Known Subclasses:
    ClassAccessor, MappingAccessor

    public abstract class MetadataAccessor
    extends ORMetadata
    INTERNAL: Common metadata accessor level for mappings and classes. Key notes: - any metadata mapped from XML to this class must be compared in the equals method. - any metadata mapped from XML to this class must be handled in the merge method. (merging is done at the accessor/mapping level) - any metadata mapped from XML to this class must be initialized in the initXMLObject method. - methods should be preserved in alphabetical order.
    Since:
    TopLink EJB 3.0 Reference Implementation
    Author:
    Guy Pelletier
    • Method Detail

      • equals

        public boolean equals​(Object objectToCompare)
        INTERNAL:
        Specified by:
        equals in class ORMetadata
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getAccess

        public String getAccess()
        INTERNAL: Used for OX mapping.
      • getAnnotatedElement

        public MetadataAnnotatedElement getAnnotatedElement()
        INTERNAL: Return the annotated element for this accessor.
      • getAnnotatedElementName

        public String getAnnotatedElementName()
        INTERNAL: Return the annotated element name for this accessor.
      • getAnnotation

        public MetadataAnnotation getAnnotation​(Class<?> annotation)
        INTERNAL: Return the annotation if it exists. This method should only be called for non JPA annotations as loading those annotations classes is ok (and available). JPA annotations should be referenced only by name as to not introduce a compile dependency.
      • getAnnotation

        protected abstract MetadataAnnotation getAnnotation​(String annotation)
        INTERNAL: Return the annotation if it exists.
      • getAttributeName

        public String getAttributeName()
        INTERNAL: Return the attribute name for this accessor.
      • getDefaultAttributeName

        protected String getDefaultAttributeName()
        INTERNAL: Return the upper cased attribute name for this accessor. Used when defaulting.
      • getDescriptor

        public MetadataDescriptor getDescriptor()
        INTERNAL: Return the MetadataDescriptor for this accessor.
      • getDescriptorJavaClass

        public MetadataClass getDescriptorJavaClass()
        INTERNAL: Return the java class tied to this class accessor's descriptor.
      • getJavaClass

        public MetadataClass getJavaClass()
        INTERNAL: Return the java class associated with this accessor's descriptor.
      • getJavaClassName

        protected String getJavaClassName()
        INTERNAL: Return the java class that defines this accessor.
      • getName

        public String getName()
        INTERNAL: Used for OX mapping.
      • getPartitioned

        public String getPartitioned()
        INTERNAL: Used for OX mapping.
      • getReferencedField

        protected DatabaseField getReferencedField​(String referencedColumnName,
                                                   MetadataDescriptor referenceDescriptor,
                                                   String context)
        INTERNAL: Return the referenced field. If the referencedColumnName is not specified, it will default to the primary key of the referenced table.
      • getReferencedField

        protected DatabaseField getReferencedField​(String referencedColumnName,
                                                   MetadataDescriptor referenceDescriptor,
                                                   String context,
                                                   boolean isForAggregateCollection)
        INTERNAL: Return the referenced field. If the referencedColumnName is not specified, it will default to the primary key of the referenced table.
      • getUpperCaseShortJavaClassName

        protected String getUpperCaseShortJavaClassName()
        INTERNAL: Return the upper case java class that defines this accessor.
      • getValue

        protected Integer getValue​(Integer value,
                                   Integer defaultValue)
        INTERNAL: Helper method to return a string value if specified, otherwise returns the default value.
      • getValue

        protected String getValue​(String value,
                                  String defaultValue)
        INTERNAL: Helper method to return a string value if specified, otherwise returns the default value.
      • hasAccess

        public boolean hasAccess()
        INTERNAL:
      • hasAccessMethods

        public boolean hasAccessMethods()
        INTERNAL:
      • initAccess

        public void initAccess()
        INTERNAL: Called from annotation and xml initialization.
      • initXMLAccessor

        public void initXMLAccessor​(MetadataDescriptor descriptor,
                                    MetadataProject project)
        INTERNAL: This method should be subclassed in those methods that need to do extra initialization.
      • isAnnotationPresent

        public boolean isAnnotationPresent​(Class<? extends Annotation> annotation)
        INTERNAL: Return true if the annotation exists. This method should only be called for non native annotations (i.e. JPA) as loading native annotations classes is ok since we know they are available from the jar. JPA annotations should be referenced only by name as to not introduce a compile dependency.
      • isAnnotationPresent

        public abstract boolean isAnnotationPresent​(String annotation)
        INTERNAL: Return the annotation if it exists.
      • isProcessed

        public abstract boolean isProcessed()
        Subclasses must handle this flag.
      • merge

        public void merge​(ORMetadata metadata)
        INTERNAL: We currently limit this merging to the ClassAccessor level.
        Overrides:
        merge in class ORMetadata
      • process

        public abstract void process()
        INTERNAL: Every accessor knows how to process themselves since they have all the information they need.
      • processConverters

        public void processConverters()
        INTERNAL: Process and add the globally defined converters to the project.
      • processCustomConverters

        protected void processCustomConverters()
        INTERNAL: Process the XML defined converters and check for a Converter annotation.
      • processObjectTypeConverters

        protected void processObjectTypeConverters()
        INTERNAL: Process the XML defined object type converters and check for an ObjectTypeConverter annotation.
      • processPartitioned

        public void processPartitioned​(String name)
        Set the policy on the descriptor or mapping.
      • processPartitioning

        protected void processPartitioning()
        Process the partitioning policies defined on this element.
      • processStructConverters

        protected void processStructConverters()
        INTERNAL: Process the XML defined struct converters and check for a StructConverter annotation.
      • processTable

        protected void processTable​(TableMetadata table,
                                    String defaultName)
        INTERNAL: Common table processing for table, secondary table, join table and collection table.
      • processTypeConverters

        protected void processTypeConverters()
        INTERNAL: Process a the XML defined type converters and check for a TypeConverter annotation.
      • processSerializedConverters

        protected void processSerializedConverters()
        INTERNAL: Process a the XML defined serialized converters and check for a SerializedConverter annotation.
      • setAccess

        public void setAccess​(String access)
        INTERNAL: Used for OX mapping.
      • setAccessMethods

        public void setAccessMethods​(AccessMethodsMetadata accessMethods)
        INTERNAL: Used for OX mapping.
      • setConverters

        public void setConverters​(List<ConverterMetadata> converters)
        INTERNAL: Used for OX mapping.
      • setDescriptor

        public void setDescriptor​(MetadataDescriptor descriptor)
        INTERNAL: Set the metadata descriptor for this accessor. When setting the descriptor on entities, the owning descriptor is set to this descriptor.
      • setHashPartitioning

        public void setHashPartitioning​(HashPartitioningMetadata hashPartitioning)
        INTERNAL: Used for OX mapping.
      • setName

        public void setName​(String name)
        INTERNAL: Used for OX mapping.
      • setPartitioned

        public void setPartitioned​(String partitioned)
        INTERNAL: Used for OX mapping.
      • setPartitioning

        public void setPartitioning​(PartitioningMetadata partitioning)
        INTERNAL: Used for OX mapping.
      • setPinnedPartitioning

        public void setPinnedPartitioning​(PinnedPartitioningMetadata pinnedPartitioning)
        INTERNAL: Used for OX mapping.
      • setProperties

        public void setProperties​(List<PropertyMetadata> properties)
        INTERNAL: Used for OX mapping.
      • setRangePartitioning

        public void setRangePartitioning​(RangePartitioningMetadata rangePartitioning)
        INTERNAL: Used for OX mapping.
      • setReplicationPartitioning

        public void setReplicationPartitioning​(ReplicationPartitioningMetadata replicationPartitioning)
        INTERNAL: Used for OX mapping.
      • setRoundRobinPartitioning

        public void setRoundRobinPartitioning​(RoundRobinPartitioningMetadata roundRobinPartitioning)
        INTERNAL: Used for OX mapping.
      • setStructConverters

        public void setStructConverters​(List<StructConverterMetadata> structConverters)
        INTERNAL: Used for OX mapping.
      • setTypeConverters

        public void setTypeConverters​(List<TypeConverterMetadata> typeConverters)
        INTERNAL: Used for OX mapping.
      • setUnionPartitioning

        public void setUnionPartitioning​(UnionPartitioningMetadata unionPartitioning)
        INTERNAL: Used for OX mapping.
      • setValuePartitioning

        public void setValuePartitioning​(ValuePartitioningMetadata valuePartitioning)
        INTERNAL: Used for OX mapping.