Package org.apache.openjpa.persistence
Class XMLPersistenceMetaDataSerializer
java.lang.Object
org.apache.openjpa.lib.meta.XMLMetaDataSerializer
org.apache.openjpa.lib.meta.CFMetaDataSerializer
org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer
- All Implemented Interfaces:
MetaDataSerializer,AbstractCFMetaDataFactory.Serializer
- Direct Known Subclasses:
XMLPersistenceMappingSerializer
public class XMLPersistenceMetaDataSerializer
extends CFMetaDataSerializer
implements AbstractCFMetaDataFactory.Serializer
Serializes persistence metadata back to XML.
This class processes all object level tags that are store-agnostic.
However, it provides hooks for the subclasses to include store-specific
tags to be serialized both at <entity-mappings> and
<entity> level.
- Since:
- 0.4.0
- Author:
- Steve Kim
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classCompares clases, sequences, and queries to order them for serialization. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intFields inherited from interface org.apache.openjpa.lib.meta.MetaDataSerializer
APPEND, COMPACT, PRETTY, VERBOSE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAll(MetaDataRepository repos) Add all components in the given repository to the set to be serialized.protected voidaddClassMappingAttributes(ClassMetaData mapping) Add mapping attributes for the given class.protected voidaddFieldMappingAttributes(FieldMetaData fmd, FieldMetaData orig) Add mapping attributes for the given field.voidaddMetaData(ClassMetaData meta) Add a class meta data to the set to be serialized.voidAdd a query meta data to the set to be serialized.voidAdd a sequence meta data to the set to be serialized.protected voidSet mapping attributes for strategy.protected voidaddSystemMappingElements(Collection toSerialize) Add system-level mapping elements to be serialized.voidclear()Clear the set of metadatas to be serialized.Returns the stored ClassMetaDataConfiguration.intgetMode()The serialization mode according to the expected document type.protected CollectionReturn the current set of objects for serialization.protected StringgetPackage(Object obj) Return the package name of the given object, or null if not in a package.booleanWhether to serialize content originally specified in annotations.protected FilegetSourceFile(Object obj) Override to not overwrite annotations.protected PersistenceStrategygetStrategy(FieldMetaData fmd) Return the serialized strategy name.protected booleanConvenience method for interpretinggetMode().protected booleanisMappingMode(ClassMetaData meta) Convenience method for interpretinggetMode().protected booleanConvenience method for interpretinggetMode().protected booleanConvenience method for interpretinggetMode().protected booleanConvenience method for interpretinggetMode().Create a new comparator for ordering objects that are to be serialized.booleanremoveAll(MetaDataRepository repos) Remove all the components in the given repository from the set to be serialized.booleanremoveMetaData(ClassMetaData meta) Remove a metadata from the set to be serialized.booleanRemove a query metadata from the set to be serialized.booleanRemove a sequence metadata from the set to be serialized.protected voidserialize(Collection objects) Serialize the given set of objects.protected booleanserializeAttributeOverride(FieldMetaData fmd, FieldMetaData orig) Always returns false by default.protected voidSerialize attribute override mapping content.protected voidserializeClass(ClassMetaData meta, boolean access) Serialize class metadata.protected voidSerialize class mapping content.protected voidserializeFieldMappingContent(FieldMetaData fmd, PersistenceStrategy strategy) Serialize field mapping content; this will be called before#serializeValueMappingContent.protected voidserializeInheritanceContent(ClassMetaData mapping) Serialize inheritance content.protected voidOrder column is not processed as meta data, instead it can be processed as mapping data if in mapping mode.protected voidSerialize query mappings.protected voidSerialize sequence metadata.protected voidSerialize unknown mapping element at system level.voidsetMode(int mode) The serialization mode according to the expected document type.voidsetMode(int mode, boolean on) The serialization mode according to the expected document type.voidsetSerializeAnnotations(boolean annos) Whether to serialize content originally specified in annotations.protected intReturn the type constant for the given object based on its runtime class.Methods inherited from class org.apache.openjpa.lib.meta.CFMetaDataSerializer
getClassName, getPackage, groupByPackage, setPackageMethods inherited from class org.apache.openjpa.lib.meta.XMLMetaDataSerializer
addAttribute, addComments, addComments, addText, currentBackupFile, endElement, getAttributes, getFileMap, getLog, isVerbose, prepareWrite, reset, serialize, serialize, serialize, serialize, serialize, serialize, setLog, startElementMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.openjpa.lib.meta.MetaDataSerializer
serialize, serialize, serialize, serialize
-
Field Details
-
TYPE_SEQ
protected static final int TYPE_SEQ- See Also:
-
TYPE_QUERY
protected static final int TYPE_QUERY- See Also:
-
TYPE_META
protected static final int TYPE_META- See Also:
-
TYPE_CLASS_SEQS
protected static final int TYPE_CLASS_SEQS- See Also:
-
TYPE_CLASS_QUERIES
protected static final int TYPE_CLASS_QUERIES- See Also:
-
-
Constructor Details
-
XMLPersistenceMetaDataSerializer
Constructor. Supply configuration.
-
-
Method Details
-
getConfiguration
Configuration. -
getSerializeAnnotations
public boolean getSerializeAnnotations()Whether to serialize content originally specified in annotations. Defaults to true. -
setSerializeAnnotations
public void setSerializeAnnotations(boolean annos) Whether to serialize content originally specified in annotations. Defaults to true. -
getMode
public int getMode()The serialization mode according to the expected document type. The mode constants act as bit flags, and therefore can be combined. -
setMode
public void setMode(int mode) The serialization mode according to the expected document type. The mode constants act as bit flags, and therefore can be combined.- Specified by:
setModein interfaceAbstractCFMetaDataFactory.Serializer
-
setMode
public void setMode(int mode, boolean on) The serialization mode according to the expected document type. -
getSourceFile
Override to not overwrite annotations.- Overrides:
getSourceFilein classXMLMetaDataSerializer
-
isMetaDataMode
protected boolean isMetaDataMode()Convenience method for interpretinggetMode(). -
isQueryMode
protected boolean isQueryMode()Convenience method for interpretinggetMode(). -
isMappingMode
protected boolean isMappingMode()Convenience method for interpretinggetMode(). -
isMappingMode
Convenience method for interpretinggetMode(). Takes into account whether mapping information is loaded for the given instance. -
isMappingMode
Convenience method for interpretinggetMode(). Takes into account whether mapping information is loaded for the given instance. -
addMetaData
Add a class meta data to the set to be serialized.- Specified by:
addMetaDatain interfaceAbstractCFMetaDataFactory.Serializer
-
addSequenceMetaData
Add a sequence meta data to the set to be serialized.- Specified by:
addSequenceMetaDatain interfaceAbstractCFMetaDataFactory.Serializer
-
addQueryMetaData
Add a query meta data to the set to be serialized.- Specified by:
addQueryMetaDatain interfaceAbstractCFMetaDataFactory.Serializer
-
addAll
Add all components in the given repository to the set to be serialized.- Specified by:
addAllin interfaceAbstractCFMetaDataFactory.Serializer
-
removeMetaData
Remove a metadata from the set to be serialized.- Specified by:
removeMetaDatain interfaceAbstractCFMetaDataFactory.Serializer- Returns:
- true if removed, false if not in set
-
removeSequenceMetaData
Remove a sequence metadata from the set to be serialized.- Returns:
- true if removed, false if not in set
-
removeQueryMetaData
Remove a query metadata from the set to be serialized.- Returns:
- true if removed, false if not in set
-
removeAll
Remove all the components in the given repository from the set to be serialized.- Returns:
- true if any components removed, false if none in set
-
clear
public void clear()Clear the set of metadatas to be serialized. -
getObjects
Description copied from class:XMLMetaDataSerializerReturn the current set of objects for serialization.- Specified by:
getObjectsin classXMLMetaDataSerializer
-
addSystemMappingElements
Add system-level mapping elements to be serialized. Does nothing by default. -
newSerializationComparator
Create a new comparator for ordering objects that are to be serialized. -
serialize
Description copied from class:XMLMetaDataSerializerSerialize the given set of objects.- Specified by:
serializein classXMLMetaDataSerializer- Throws:
SAXException
-
getPackage
Description copied from class:CFMetaDataSerializerReturn the package name of the given object, or null if not in a package. Used byCFMetaDataSerializer.groupByPackage(java.util.Collection<java.lang.Object>). Returns null by default.- Overrides:
getPackagein classCFMetaDataSerializer
-
type
Return the type constant for the given object based on its runtime class. If the runtime class does not correspond to any of the known types then returns -1. This can happen for tags that are not handled at this store-agnostic level. -
serializeSystemMappingElement
Serialize unknown mapping element at system level.- Throws:
SAXException
-
serializeSequence
Serialize sequence metadata.- Throws:
SAXException
-
serializeClass
Serialize class metadata.- Throws:
SAXException
-
addClassMappingAttributes
Add mapping attributes for the given class. Does nothing by default- Throws:
SAXException
-
serializeClassMappingContent
Serialize class mapping content. Does nothing by default.- Throws:
SAXException
-
serializeInheritanceContent
Serialize inheritance content. Does nothing by default.- Throws:
SAXException
-
serializeQueryMappings
Serialize query mappings. Does nothing by default.- Throws:
SAXException
-
addFieldMappingAttributes
Add mapping attributes for the given field. Does nothing by default.- Throws:
SAXException
-
serializeAttributeOverride
Always returns false by default. -
serializeAttributeOverrideMappingContent
protected void serializeAttributeOverrideMappingContent(FieldMetaData fmd, FieldMetaData orig) throws SAXException Serialize attribute override mapping content. Does nothing by default,- Throws:
SAXException
-
getStrategy
Return the serialized strategy name. -
serializeFieldMappingContent
protected void serializeFieldMappingContent(FieldMetaData fmd, PersistenceStrategy strategy) throws SAXException Serialize field mapping content; this will be called before#serializeValueMappingContent. Does nothing by default.- Throws:
SAXException
-
addStrategyMappingAttributes
Set mapping attributes for strategy. Sets mapped-by by default.- Throws:
SAXException
-
serializeOrderColumn
Order column is not processed as meta data, instead it can be processed as mapping data if in mapping mode.- Throws:
SAXException
-
getClassMetaData
Returns the stored ClassMetaData
-