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 SummaryNested Classes Modifier and Type Class Description protected classXMLPersistenceMetaDataSerializer.SerializationComparatorCompares clases, sequences, and queries to order them for serialization.
 - 
Field SummaryFields Modifier and Type Field Description protected static intTYPE_CLASS_QUERIESprotected static intTYPE_CLASS_SEQSprotected static intTYPE_METAprotected static intTYPE_QUERYprotected static intTYPE_SEQ- 
Fields inherited from interface org.apache.openjpa.lib.meta.MetaDataSerializerAPPEND, COMPACT, PRETTY, VERBOSE
 
- 
 - 
Constructor SummaryConstructors Constructor Description XMLPersistenceMetaDataSerializer(OpenJPAConfiguration conf)Constructor.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(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.voidaddQueryMetaData(QueryMetaData meta)Add a query meta data to the set to be serialized.voidaddSequenceMetaData(SequenceMetaData meta)Add a sequence meta data to the set to be serialized.protected voidaddStrategyMappingAttributes(FieldMetaData fmd)Set mapping attributes for strategy.protected voidaddSystemMappingElements(java.util.Collection toSerialize)Add system-level mapping elements to be serialized.voidclear()Clear the set of metadatas to be serialized.java.util.Map<java.lang.String,ClassMetaData>getClassMetaData()Returns the stored ClassMetaDataOpenJPAConfigurationgetConfiguration()Configuration.intgetMode()The serialization mode according to the expected document type.protected java.util.CollectiongetObjects()Return the current set of objects for serialization.protected java.lang.StringgetPackage(java.lang.Object obj)Return the package name of the given object, or null if not in a package.booleangetSerializeAnnotations()Whether to serialize content originally specified in annotations.protected java.io.FilegetSourceFile(java.lang.Object obj)Override to not overwrite annotations.protected PersistenceStrategygetStrategy(FieldMetaData fmd)Return the serialized strategy name.protected booleanisMappingMode()Convenience method for interpretinggetMode().protected booleanisMappingMode(ClassMetaData meta)Convenience method for interpretinggetMode().protected booleanisMappingMode(ValueMetaData vmd)Convenience method for interpretinggetMode().protected booleanisMetaDataMode()Convenience method for interpretinggetMode().protected booleanisQueryMode()Convenience method for interpretinggetMode().protected XMLPersistenceMetaDataSerializer.SerializationComparatornewSerializationComparator()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.booleanremoveQueryMetaData(QueryMetaData meta)Remove a query metadata from the set to be serialized.booleanremoveSequenceMetaData(SequenceMetaData meta)Remove a sequence metadata from the set to be serialized.protected voidserialize(java.util.Collection objects)Serialize the given set of objects.protected booleanserializeAttributeOverride(FieldMetaData fmd, FieldMetaData orig)Always returns false by default.protected voidserializeAttributeOverrideMappingContent(FieldMetaData fmd, FieldMetaData orig)Serialize attribute override mapping content.protected voidserializeClass(ClassMetaData meta, boolean access)Serialize class metadata.protected voidserializeClassMappingContent(ClassMetaData mapping)Serialize 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 voidserializeOrderColumn(FieldMetaData fmd)Order column is not processed as meta data, instead it can be processed as mapping data if in mapping mode.protected voidserializeQueryMappings(ClassMetaData meta)Serialize query mappings.protected voidserializeSequence(SequenceMetaData meta)Serialize sequence metadata.protected voidserializeSystemMappingElement(java.lang.Object obj)Serialize 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 inttype(java.lang.Object o)Return the type constant for the given object based on its runtime class.- 
Methods inherited from class org.apache.openjpa.lib.meta.CFMetaDataSerializergetClassName, getPackage, groupByPackage, setPackage
 - 
Methods inherited from class org.apache.openjpa.lib.meta.XMLMetaDataSerializeraddAttribute, addComments, addComments, addText, currentBackupFile, endElement, getAttributes, getFileMap, getLog, isVerbose, prepareWrite, reset, serialize, serialize, serialize, serialize, serialize, serialize, setLog, startElement
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.openjpa.lib.meta.MetaDataSerializerserialize, serialize, serialize, serialize
 
- 
 
- 
- 
- 
Field Detail- 
TYPE_SEQprotected static final int TYPE_SEQ - See Also:
- Constant Field Values
 
 - 
TYPE_QUERYprotected static final int TYPE_QUERY - See Also:
- Constant Field Values
 
 - 
TYPE_METAprotected static final int TYPE_META - See Also:
- Constant Field Values
 
 - 
TYPE_CLASS_SEQSprotected static final int TYPE_CLASS_SEQS - See Also:
- Constant Field Values
 
 - 
TYPE_CLASS_QUERIESprotected static final int TYPE_CLASS_QUERIES - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
XMLPersistenceMetaDataSerializerpublic XMLPersistenceMetaDataSerializer(OpenJPAConfiguration conf) Constructor. Supply configuration.
 
- 
 - 
Method Detail- 
getConfigurationpublic OpenJPAConfiguration getConfiguration() Configuration.
 - 
getSerializeAnnotationspublic boolean getSerializeAnnotations() Whether to serialize content originally specified in annotations. Defaults to true.
 - 
setSerializeAnnotationspublic void setSerializeAnnotations(boolean annos) Whether to serialize content originally specified in annotations. Defaults to true.
 - 
getModepublic int getMode() The serialization mode according to the expected document type. The mode constants act as bit flags, and therefore can be combined.
 - 
setModepublic 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 interface- AbstractCFMetaDataFactory.Serializer
 
 - 
setModepublic void setMode(int mode, boolean on)The serialization mode according to the expected document type.
 - 
getSourceFileprotected java.io.File getSourceFile(java.lang.Object obj) Override to not overwrite annotations.- Overrides:
- getSourceFilein class- XMLMetaDataSerializer
 
 - 
isMetaDataModeprotected boolean isMetaDataMode() Convenience method for interpretinggetMode().
 - 
isQueryModeprotected boolean isQueryMode() Convenience method for interpretinggetMode().
 - 
isMappingModeprotected boolean isMappingMode() Convenience method for interpretinggetMode().
 - 
isMappingModeprotected boolean isMappingMode(ClassMetaData meta) Convenience method for interpretinggetMode(). Takes into account whether mapping information is loaded for the given instance.
 - 
isMappingModeprotected boolean isMappingMode(ValueMetaData vmd) Convenience method for interpretinggetMode(). Takes into account whether mapping information is loaded for the given instance.
 - 
addMetaDatapublic void addMetaData(ClassMetaData meta) Add a class meta data to the set to be serialized.- Specified by:
- addMetaDatain interface- AbstractCFMetaDataFactory.Serializer
 
 - 
addSequenceMetaDatapublic void addSequenceMetaData(SequenceMetaData meta) Add a sequence meta data to the set to be serialized.- Specified by:
- addSequenceMetaDatain interface- AbstractCFMetaDataFactory.Serializer
 
 - 
addQueryMetaDatapublic void addQueryMetaData(QueryMetaData meta) Add a query meta data to the set to be serialized.- Specified by:
- addQueryMetaDatain interface- AbstractCFMetaDataFactory.Serializer
 
 - 
addAllpublic void addAll(MetaDataRepository repos) Add all components in the given repository to the set to be serialized.- Specified by:
- addAllin interface- AbstractCFMetaDataFactory.Serializer
 
 - 
removeMetaDatapublic boolean removeMetaData(ClassMetaData meta) Remove a metadata from the set to be serialized.- Specified by:
- removeMetaDatain interface- AbstractCFMetaDataFactory.Serializer
- Returns:
- true if removed, false if not in set
 
 - 
removeSequenceMetaDatapublic boolean removeSequenceMetaData(SequenceMetaData meta) Remove a sequence metadata from the set to be serialized.- Returns:
- true if removed, false if not in set
 
 - 
removeQueryMetaDatapublic boolean removeQueryMetaData(QueryMetaData meta) Remove a query metadata from the set to be serialized.- Returns:
- true if removed, false if not in set
 
 - 
removeAllpublic boolean removeAll(MetaDataRepository repos) 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
 
 - 
clearpublic void clear() Clear the set of metadatas to be serialized.
 - 
getObjectsprotected java.util.Collection getObjects() Description copied from class:XMLMetaDataSerializerReturn the current set of objects for serialization.- Specified by:
- getObjectsin class- XMLMetaDataSerializer
 
 - 
addSystemMappingElementsprotected void addSystemMappingElements(java.util.Collection toSerialize) Add system-level mapping elements to be serialized. Does nothing by default.
 - 
newSerializationComparatorprotected XMLPersistenceMetaDataSerializer.SerializationComparator newSerializationComparator() Create a new comparator for ordering objects that are to be serialized.
 - 
serializeprotected void serialize(java.util.Collection objects) throws org.xml.sax.SAXExceptionDescription copied from class:XMLMetaDataSerializerSerialize the given set of objects.- Specified by:
- serializein class- XMLMetaDataSerializer
- Throws:
- org.xml.sax.SAXException
 
 - 
getPackageprotected java.lang.String getPackage(java.lang.Object obj) 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 class- CFMetaDataSerializer
 
 - 
typeprotected int type(java.lang.Object o) 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.
 - 
serializeSystemMappingElementprotected void serializeSystemMappingElement(java.lang.Object obj) throws org.xml.sax.SAXExceptionSerialize unknown mapping element at system level.- Throws:
- org.xml.sax.SAXException
 
 - 
serializeSequenceprotected void serializeSequence(SequenceMetaData meta) throws org.xml.sax.SAXException Serialize sequence metadata.- Throws:
- org.xml.sax.SAXException
 
 - 
serializeClassprotected void serializeClass(ClassMetaData meta, boolean access) throws org.xml.sax.SAXException Serialize class metadata.- Throws:
- org.xml.sax.SAXException
 
 - 
addClassMappingAttributesprotected void addClassMappingAttributes(ClassMetaData mapping) throws org.xml.sax.SAXException Add mapping attributes for the given class. Does nothing by default- Throws:
- org.xml.sax.SAXException
 
 - 
serializeClassMappingContentprotected void serializeClassMappingContent(ClassMetaData mapping) throws org.xml.sax.SAXException Serialize class mapping content. Does nothing by default.- Throws:
- org.xml.sax.SAXException
 
 - 
serializeInheritanceContentprotected void serializeInheritanceContent(ClassMetaData mapping) throws org.xml.sax.SAXException Serialize inheritance content. Does nothing by default.- Throws:
- org.xml.sax.SAXException
 
 - 
serializeQueryMappingsprotected void serializeQueryMappings(ClassMetaData meta) throws org.xml.sax.SAXException Serialize query mappings. Does nothing by default.- Throws:
- org.xml.sax.SAXException
 
 - 
addFieldMappingAttributesprotected void addFieldMappingAttributes(FieldMetaData fmd, FieldMetaData orig) throws org.xml.sax.SAXException Add mapping attributes for the given field. Does nothing by default.- Throws:
- org.xml.sax.SAXException
 
 - 
serializeAttributeOverrideprotected boolean serializeAttributeOverride(FieldMetaData fmd, FieldMetaData orig) Always returns false by default.
 - 
serializeAttributeOverrideMappingContentprotected void serializeAttributeOverrideMappingContent(FieldMetaData fmd, FieldMetaData orig) throws org.xml.sax.SAXException Serialize attribute override mapping content. Does nothing by default,- Throws:
- org.xml.sax.SAXException
 
 - 
getStrategyprotected PersistenceStrategy getStrategy(FieldMetaData fmd) Return the serialized strategy name.
 - 
serializeFieldMappingContentprotected void serializeFieldMappingContent(FieldMetaData fmd, PersistenceStrategy strategy) throws org.xml.sax.SAXException Serialize field mapping content; this will be called before#serializeValueMappingContent. Does nothing by default.- Throws:
- org.xml.sax.SAXException
 
 - 
addStrategyMappingAttributesprotected void addStrategyMappingAttributes(FieldMetaData fmd) throws org.xml.sax.SAXException Set mapping attributes for strategy. Sets mapped-by by default.- Throws:
- org.xml.sax.SAXException
 
 - 
serializeOrderColumnprotected void serializeOrderColumn(FieldMetaData fmd) throws org.xml.sax.SAXException Order column is not processed as meta data, instead it can be processed as mapping data if in mapping mode.- Throws:
- org.xml.sax.SAXException
 
 - 
getClassMetaDatapublic java.util.Map<java.lang.String,ClassMetaData> getClassMetaData() Returns the stored ClassMetaData
 
- 
 
-