Package org.apache.openjpa.persistence
Class AnnotationPersistenceMetaDataSerializer
- java.lang.Object
- 
- org.apache.openjpa.persistence.AnnotationPersistenceMetaDataSerializer
 
- 
- All Implemented Interfaces:
- MetaDataSerializer,- AbstractCFMetaDataFactory.Serializer
 - Direct Known Subclasses:
- AnnotationPersistenceMappingSerializer
 
 public class AnnotationPersistenceMetaDataSerializer extends java.lang.Object implements AbstractCFMetaDataFactory.Serializer Serializes persistence metadata as annotations. 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:
- 1.0.0
- Author:
- Steve Kim, Gokhan Ergul
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classAnnotationPersistenceMetaDataSerializer.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 AnnotationPersistenceMetaDataSerializer(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 AnnotationBuilderaddAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annType, ClassMetaData meta)Creates an an annotation builder for the specified class metadata and adds it to list of builders.protected AnnotationBuilderaddAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annType, FieldMetaData meta)Creates an an annotation builder for the specified class metadata and adds it to list of builders.protected AnnotationBuilderaddAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annType, QueryMetaData meta)Creates an an annotation builder for the specified class metadata and adds it to list of builders.protected AnnotationBuilderaddAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annType, SequenceMetaData meta)Creates an an annotation builder for the specified class metadata and adds it to list of builders.protected voidaddAnnotation(AnnotationBuilder ab, java.lang.Object meta)protected voidaddAnnotation(AnnotationBuilder ab, ClassMetaData meta)Add an annotation builder to list of builders for the specified class metadata.protected voidaddAnnotation(AnnotationBuilder ab, FieldMetaData meta)Add an annotation builder to list of builders for the specified field metadata.protected voidaddAnnotation(AnnotationBuilder ab, QueryMetaData meta)Add an annotation builder to list of builders for the specified query metadata.protected voidaddAnnotation(AnnotationBuilder ab, SequenceMetaData meta)Add an annotation builder to list of builders for the specified sequence metadata.protected voidaddClassMappingAnnotations(ClassMetaData mapping)Add mapping attributes for the given class.protected voidaddFieldMappingAttributes(FieldMetaData fmd, FieldMetaData orig, AnnotationBuilder ab)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, AnnotationBuilder ab)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.LoggetLog()The log to write to.intgetMode()The serialization mode according to the expected document type.protected java.util.CollectiongetObjects()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 AnnotationBuildernewAnnotationBuilder(java.lang.Class<? extends java.lang.annotation.Annotation> annType)Creates a new annotation builder for the specified annotation type.protected AnnotationPersistenceMetaDataSerializer.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.voidserialize(int flags)Serialize the current set of objects to the files from which they were parsed.voidserialize(java.io.File file, int flags)Serialize the current set of objects to the given file.voidserialize(java.io.Writer out, int flags)Serialize the current set of objects to the given stream.protected voidserialize(java.util.Collection objects)voidserialize(java.util.Map output, int flags)Serialize the current set of objects to the files from which they were parsed.protected booleanserializeAttributeOverride(FieldMetaData fmd, FieldMetaData orig)Always returns false by default.protected voidserializeAttributeOverrideMappingContent(FieldMetaData fmd, FieldMetaData orig, AnnotationBuilder ab)Serialize attribute override mapping content.protected voidserializeClass(ClassMetaData meta)Serialize class metadata.protected voidserializeClassMappingContent(ClassMetaData mapping)Serialize class mapping content.protected voidserializeFieldMappingContent(FieldMetaData fmd, PersistenceStrategy strategy, AnnotationBuilder ab)Serialize field mapping content; this will be called before#serializeValueMappingContent.protected voidserializeInheritanceContent(ClassMetaData mapping)Serialize inheritance content.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.voidsetLog(Log log)The log to write to.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.protected inttype(java.lang.Object o)Return the type constant for the given object based on its runtime class.protected voidwriteAnnotations(java.lang.Object meta, java.util.List<AnnotationBuilder> builders, java.util.Map output)
 
- 
- 
- 
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- 
AnnotationPersistenceMetaDataSerializerpublic AnnotationPersistenceMetaDataSerializer(OpenJPAConfiguration conf) Constructor. Supply configuration.
 
- 
 - 
Method Detail- 
getConfigurationpublic OpenJPAConfiguration getConfiguration() Configuration.
 - 
getLogpublic Log getLog() The log to write to.
 - 
setLogpublic void setLog(Log log) The log to write to.
 - 
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.
 - 
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. OPENJPA-1360 - Allow @Column attributes when meta.isEmbeddedOnly()
 - 
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.
 - 
addSystemMappingElementsprotected void addSystemMappingElements(java.util.Collection toSerialize) Add system-level mapping elements to be serialized. Does nothing by default.
 - 
newSerializationComparatorprotected AnnotationPersistenceMetaDataSerializer.SerializationComparator newSerializationComparator() Create a new comparator for ordering objects that are to be serialized.
 - 
newAnnotationBuilderprotected AnnotationBuilder newAnnotationBuilder(java.lang.Class<? extends java.lang.annotation.Annotation> annType) Creates a new annotation builder for the specified annotation type.
 - 
addAnnotationprotected void addAnnotation(AnnotationBuilder ab, java.lang.Object meta) 
 - 
addAnnotationprotected void addAnnotation(AnnotationBuilder ab, ClassMetaData meta) Add an annotation builder to list of builders for the specified class metadata.
 - 
addAnnotationprotected void addAnnotation(AnnotationBuilder ab, FieldMetaData meta) Add an annotation builder to list of builders for the specified field metadata.
 - 
addAnnotationprotected void addAnnotation(AnnotationBuilder ab, SequenceMetaData meta) Add an annotation builder to list of builders for the specified sequence metadata.
 - 
addAnnotationprotected void addAnnotation(AnnotationBuilder ab, QueryMetaData meta) Add an annotation builder to list of builders for the specified query metadata.
 - 
addAnnotationprotected AnnotationBuilder addAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annType, ClassMetaData meta) Creates an an annotation builder for the specified class metadata and adds it to list of builders.
 - 
addAnnotationprotected AnnotationBuilder addAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annType, FieldMetaData meta) Creates an an annotation builder for the specified class metadata and adds it to list of builders.
 - 
addAnnotationprotected AnnotationBuilder addAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annType, SequenceMetaData meta) Creates an an annotation builder for the specified class metadata and adds it to list of builders.
 - 
addAnnotationprotected AnnotationBuilder addAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annType, QueryMetaData meta) Creates an an annotation builder for the specified class metadata and adds it to list of builders.
 - 
serializeprotected void serialize(java.util.Collection objects) 
 - 
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) Serialize unknown mapping element at system level.
 - 
serializeSequenceprotected void serializeSequence(SequenceMetaData meta) Serialize sequence metadata.
 - 
serializeClassprotected void serializeClass(ClassMetaData meta) Serialize class metadata.
 - 
addClassMappingAnnotationsprotected void addClassMappingAnnotations(ClassMetaData mapping) Add mapping attributes for the given class. Does nothing by default
 - 
serializeClassMappingContentprotected void serializeClassMappingContent(ClassMetaData mapping) Serialize class mapping content. Does nothing by default.
 - 
serializeInheritanceContentprotected void serializeInheritanceContent(ClassMetaData mapping) Serialize inheritance content. Does nothing by default.
 - 
serializeQueryMappingsprotected void serializeQueryMappings(ClassMetaData meta) Serialize query mappings. Does nothing by default.
 - 
addFieldMappingAttributesprotected void addFieldMappingAttributes(FieldMetaData fmd, FieldMetaData orig, AnnotationBuilder ab) Add mapping attributes for the given field. Does nothing by default.
 - 
serializeAttributeOverrideprotected boolean serializeAttributeOverride(FieldMetaData fmd, FieldMetaData orig) Always returns false by default.
 - 
serializeAttributeOverrideMappingContentprotected void serializeAttributeOverrideMappingContent(FieldMetaData fmd, FieldMetaData orig, AnnotationBuilder ab) Serialize attribute override mapping content. Does nothing by default,
 - 
getStrategyprotected PersistenceStrategy getStrategy(FieldMetaData fmd) Return the serialized strategy name.
 - 
serializeFieldMappingContentprotected void serializeFieldMappingContent(FieldMetaData fmd, PersistenceStrategy strategy, AnnotationBuilder ab) Serialize field mapping content; this will be called before#serializeValueMappingContent. Does nothing by default.
 - 
addStrategyMappingAttributesprotected void addStrategyMappingAttributes(FieldMetaData fmd, AnnotationBuilder ab) Set mapping attributes for strategy. Sets mapped-by by default.
 - 
getObjectsprotected java.util.Collection getObjects() 
 - 
writeAnnotationsprotected void writeAnnotations(java.lang.Object meta, java.util.List<AnnotationBuilder> builders, java.util.Map output)
 - 
serializepublic void serialize(java.util.Map output, int flags) throws java.io.IOExceptionDescription copied from interface:MetaDataSerializerSerialize the current set of objects to the files from which they were parsed. The objects must implement theSourceTrackerinterface.- Specified by:
- serializein interface- MetaDataSerializer
- Parameters:
- output- if null, then serialize directly to the file system; otherwise, populate the specified- Mapwith keys that are the- Fileinstances, and values that are the- Stringcontents of the MetaData
- flags- bit flags specifying the output flags; e.g.- MetaDataSerializer.PRETTY
- Throws:
- java.io.IOException
 
 - 
serializepublic void serialize(java.io.File file, int flags) throws java.io.IOExceptionDescription copied from interface:MetaDataSerializerSerialize the current set of objects to the given file.- Specified by:
- serializein interface- MetaDataSerializer
- flags- bit flags specifying the output flags; e.g.- MetaDataSerializer.PRETTY|- MetaDataSerializer.APPEND
- Throws:
- java.io.IOException
 
 - 
serializepublic void serialize(java.io.Writer out, int flags) throws java.io.IOExceptionDescription copied from interface:MetaDataSerializerSerialize the current set of objects to the given stream.- Specified by:
- serializein interface- MetaDataSerializer
- flags- bit flags specifying the output flags; e.g.- MetaDataSerializer.PRETTY
- Throws:
- java.io.IOException
 
 - 
serializepublic void serialize(int flags) throws java.io.IOExceptionDescription copied from interface:MetaDataSerializerSerialize the current set of objects to the files from which they were parsed. Any objects for which a source file cannot be determined will not be included in the output.- Specified by:
- serializein interface- MetaDataSerializer
- Parameters:
- flags- bit flags specifying the output flags; e.g.- MetaDataSerializer.PRETTY
- Throws:
- java.io.IOException
 
 - 
getClassMetaDatapublic java.util.Map<java.lang.String,ClassMetaData> getClassMetaData() Returns the stored ClassMetaData
 
- 
 
-