Top Description Fields Constructors Methods
org.eclipse.persistence.internal.jpa.metadata.converters

public Class ConvertMetadata

extends ORMetadata
Class Inheritance
Imports
org.eclipse.persistence.exceptions.ValidationException, org.eclipse.persistence.internal.jpa.metadata.ORMetadata, org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor, org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor, org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor, org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject, .MetadataAnnotation, .MetadataClass, org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappings, org.eclipse.persistence.internal.mappings.converters.AttributeNamePrefix, org.eclipse.persistence.mappings.DatabaseMapping

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.
Author
Guy Pelletier
Since
EclipseLink 2.5

Field Summary

Modifier and TypeField and Description
private String
private MetadataClass
private String
private Boolean
private Boolean
private String
Inherited from org.eclipse.persistence.internal.jpa.metadata.ORMetadata:
m_project

Constructor Summary

AccessConstructor and Description
public
ConvertMetadata()

INTERNAL: Used for XML loading.

public
ConvertMetadata(MetadataAnnotation convert, MetadataAccessor accessor)

INTERNAL: Used for annotation loading.

Method Summary

Modifier and TypeMethod and Description
private void
apply(final DatabaseMapping
Database attribute mapping.
mapping
,
final MetadataClass
JPA annotated class.
referenceClass
,
final ClassAccessor
Class accessor.
accessor
,
final boolean
Is this converter for MapKey?
isForMapKey
)

INTERNAL: Apply converter class.

public boolean
disableConversion()

INTERNAL: Return true if any auto apply converter should be disabled.

public boolean
equals(Object
the reference object with which to compare.
objectToCompare
)

Implements abstract org.eclipse.persistence.internal.jpa.metadata.ORMetadata.equals.

INTERNAL:
public String
getAttributeName()

INTERNAL: Used for OX mapping.

public MetadataClass
getConverterClass()

INTERNAL:

public String
getConverterClassName()

INTERNAL: Used for OX mapping.

public Boolean
getDisableConversion()

INTERNAL: Used for OX mapping.

protected String
public boolean
hasAttributeName()

INTERNAL:

public boolean
hasConverterClass()

INTERNAL:

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public void
public boolean
isForMapKey()

INTERNAL: Return true if this convert metadata is for a map key.

public void
process(final DatabaseMapping
Database attribute mapping.
mapping
,
final MetadataClass
JPA annotated class.
referenceClass
,
final ClassAccessor
Class accessor.
accessor
,
final String
Content of <name> from attributeName="value.<name>".
embeddedAttributeName
)

INTERNAL: Apply convert for @ElementCollection mapping where we expect @Convert annotation to contain attributeName="value.

public void
process(final DatabaseMapping
Database attribute mapping.
mapping
,
final MetadataClass
JPA annotated class.
referenceClass
,
final ClassAccessor
Class accessor.
accessor
,
final boolean
Is this converter for MapKey?
isForMapKey
)

INTERNAL: By the time we get here, we have the mapping that needs to have the convert applied to.

public void
setAttributeName(String attributeName)

INTERNAL: Used for OX mapping.

public void
setConverterClassName(String converterClassName)

INTERNAL: Used for OX mapping.

public void
setDisableConversion(Boolean disableConversion)

INTERNAL: Used for OX mapping.

public void
setText(String text)

INTERNAL: Used for OX mapping.

private MetadataClass
verify(final DatabaseMapping
Database attribute mapping.
mapping
,
final MetadataClass
JPA annotated class.
referenceClass
,
final ClassAccessor
Class accessor.
accessor
,
final String
Content of <name> from attributeName="value.<name>". This value shall never be null when @ElementCollection mapping is being processed.
embeddedAttributeName
)

INTERNAL: Verify mapping passed to register AttributeConverter class.

Inherited from org.eclipse.persistence.internal.jpa.metadata.ORMetadata:
getAccessibleObjectgetAccessibleObjectNamegetAnnotationgetBoxedTypegetDatabaseTypeEnumgetEntityMappingsgetFullyQualifiedClassNamegetIdentifiergetJavaClassgetJavaClassNamegetLoadergetLocationgetLoggergetMetadataClassgetMetadataClassgetMetadataClassgetMetadataFactorygetNamegetPrimitiveClassForNamegetProjectgetXMLElementhasIdentifierhasTextinitXMLClassNameinitXMLObjectinitXMLObjectsinitXMLTextObjectloadedFromAnnotationloadedFromEclipseLinkXMLloadedFromXMLmergemergeORObjectListsmergeORObjectsmergeSimpleObjectsreloadEntityreloadMappedSuperclasssetAccessibleObjectsetEntityMappingssetFieldNamesetFieldNamesetProjectshouldOverridevaluesMatchvaluesMatch

Field Detail

m_attributeNameback to summary
private String m_attributeName
m_converterClassback to summary
private MetadataClass m_converterClass
m_converterClassNameback to summary
private String m_converterClassName
m_disableConversionback to summary
private Boolean m_disableConversion
m_isForMapKeyback to summary
private Boolean m_isForMapKey
m_textback to summary
private String m_text

Constructor Detail

ConvertMetadataback to summary
public ConvertMetadata()

INTERNAL: Used for XML loading.

ConvertMetadataback to summary
public ConvertMetadata(MetadataAnnotation convert, MetadataAccessor accessor)

INTERNAL: Used for annotation loading.

Method Detail

applyback to summary
private void apply(final DatabaseMapping mapping, final MetadataClass referenceClass, final ClassAccessor accessor, final boolean isForMapKey)

INTERNAL: Apply converter class.

Parameters
mapping:DatabaseMapping

Database attribute mapping.

referenceClass:MetadataClass

JPA annotated class.

accessor:ClassAccessor

Class accessor.

isForMapKey:boolean

Is this converter for MapKey?

disableConversionback to summary
public boolean disableConversion()

INTERNAL: Return true if any auto apply converter should be disabled.

equalsback to summary
public boolean equals(Object objectToCompare)

Implements abstract org.eclipse.persistence.internal.jpa.metadata.ORMetadata.equals.

INTERNAL:

Parameters
objectToCompare:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getAttributeNameback to summary
public String getAttributeName()

INTERNAL: Used for OX mapping.

getConverterClassback to summary
public MetadataClass getConverterClass()

INTERNAL:

getConverterClassNameback to summary
public String getConverterClassName()

INTERNAL: Used for OX mapping.

getDisableConversionback to summary
public Boolean getDisableConversion()

INTERNAL: Used for OX mapping.

getTextback to summary
protected String getText()

Overrides org.eclipse.persistence.internal.jpa.metadata.ORMetadata.getText.

INTERNAL: Used for OX mapping. Any ORMetadata that supported mixed types, that is, text or other metadata should override this method.

Annotations
@Override
hasAttributeNameback to summary
public boolean hasAttributeName()

INTERNAL:

hasConverterClassback to summary
public boolean hasConverterClass()

INTERNAL:

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
initXMLObjectback to summary
public void initXMLObject(MetadataAccessibleObject accessibleObject, XMLEntityMappings entityMappings)

Overrides org.eclipse.persistence.internal.jpa.metadata.ORMetadata.initXMLObject.

INTERNAL:

Annotations
@Override
isForMapKeyback to summary
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.

processback to summary
public void process(final DatabaseMapping mapping, final MetadataClass referenceClass, final ClassAccessor accessor, final String embeddedAttributeName)

INTERNAL: Apply convert for @ElementCollection mapping where we expect @Convert annotation to contain attributeName="value.<name>".

Parameters
mapping:DatabaseMapping

Database attribute mapping.

referenceClass:MetadataClass

JPA annotated class.

accessor:ClassAccessor

Class accessor.

embeddedAttributeName:String

Content of <name> from attributeName="value.<name>".

processback to summary
public void process(final DatabaseMapping mapping, final MetadataClass referenceClass, final ClassAccessor accessor, final 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:DatabaseMapping

Database attribute mapping.

referenceClass:MetadataClass

JPA annotated class.

accessor:ClassAccessor

Class accessor.

isForMapKey:boolean

Is this converter for MapKey?

setAttributeNameback to summary
public void setAttributeName(String attributeName)

INTERNAL: Used for OX mapping.

setConverterClassNameback to summary
public void setConverterClassName(String converterClassName)

INTERNAL: Used for OX mapping.

setDisableConversionback to summary
public void setDisableConversion(Boolean disableConversion)

INTERNAL: Used for OX mapping.

setTextback to summary
public void setText(String text)

INTERNAL: Used for OX mapping.

verifyback to summary
private MetadataClass verify(final DatabaseMapping mapping, final MetadataClass referenceClass, final ClassAccessor accessor, final String embeddedAttributeName) throws ValidationException

INTERNAL: Verify mapping passed to register AttributeConverter class.

Parameters
mapping:DatabaseMapping

Database attribute mapping.

referenceClass:MetadataClass

JPA annotated class.

accessor:ClassAccessor

Class accessor.

embeddedAttributeName:String

Content of <name> from attributeName="value.<name>". This value shall never be null when @ElementCollection mapping is being processed.