Class ConvertMetadata


  • public class ConvertMetadata
    extends ORMetadata
    Object to hold onto convert metadata. 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 initialized in the initXMLObject method. - when loading from annotations, the constructor accepts the metadata accessor this metadata was loaded from. Used it to look up any 'companion' annotation needed for processing. - methods should be preserved in alphabetical order.
    Since:
    EclipseLink 2.5
    Author:
    Guy Pelletier
    • Constructor Detail

      • ConvertMetadata

        public ConvertMetadata()
        INTERNAL: Used for XML loading.
    • Method Detail

      • disableConversion

        public boolean disableConversion()
        INTERNAL: Return true if any auto apply converter should be disabled.
      • equals

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

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

        public String getAttributeName()
        INTERNAL: Used for OX mapping.
      • getConverterClass

        public MetadataClass getConverterClass()
        INTERNAL:
      • getConverterClassName

        public String getConverterClassName()
        INTERNAL: Used for OX mapping.
      • getDisableConversion

        public Boolean getDisableConversion()
        INTERNAL: Used for OX mapping.
      • getText

        protected String getText()
        INTERNAL: Used for OX mapping. Any ORMetadata that supported mixed types, that is, text or other metadata should override this method.
        Overrides:
        getText in class ORMetadata
      • hasAttributeName

        public boolean hasAttributeName()
        INTERNAL:
      • hasConverterClass

        public boolean hasConverterClass()
        INTERNAL:
      • isForMapKey

        public boolean isForMapKey()
        INTERNAL: Return true if this convert metadata is for a map key. Way to tell is if there is an attribute name that begins with "key". Calling this method will also update the attribute name on the first call to it. This call is made when sorting convert annotations. Unlike XML, where the user can sort through <convert> and <map-key-convert> elements, there is only a single Convert annotation that uses a "key" prefix on the attribute name to signify a map key convert. An unforunate decision by the JPA spec committee, but we can make it work of course.
      • process

        public void process​(DatabaseMapping mapping,
                            MetadataClass referenceClass,
                            ClassAccessor accessor,
                            String embeddedAttributeName)
        INTERNAL: Apply convert for @ElementCollection mapping where we expect @Convert annotation to contain attributeName="value.<name>".
        Parameters:
        mapping - Database attribute mapping.
        referenceClass - JPA annotated class.
        accessor - Class accessor.
        embeddedAttributeName - Content of <name> from attributeName="value.<name>".
      • process

        public void process​(DatabaseMapping mapping,
                            MetadataClass referenceClass,
                            ClassAccessor accessor,
                            boolean isForMapKey)
        INTERNAL: By the time we get here, we have the mapping that needs to have the convert applied to. Do some validation checks along with some embedded mapping traversing if need be and apply the converter. Will look an auto-apply converter as well if one is not specified directly.
        Parameters:
        mapping - Database attribute mapping.
        referenceClass - JPA annotated class.
        accessor - Class accessor.
        isForMapKey - Is this converter for MapKey?
      • setAttributeName

        public void setAttributeName​(String attributeName)
        INTERNAL: Used for OX mapping.
      • setConverterClassName

        public void setConverterClassName​(String converterClassName)
        INTERNAL: Used for OX mapping.
      • setDisableConversion

        public void setDisableConversion​(Boolean disableConversion)
        INTERNAL: Used for OX mapping.
      • setText

        public void setText​(String text)
        INTERNAL: Used for OX mapping.