org.apache.openjpa.persistence.jdbc
Class XMLPersistenceMappingSerializer

java.lang.Object
  extended by org.apache.openjpa.lib.meta.XMLMetaDataSerializer
      extended by org.apache.openjpa.lib.meta.CFMetaDataSerializer
          extended by org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer
              extended by org.apache.openjpa.persistence.jdbc.XMLPersistenceMappingSerializer
All Implemented Interfaces:
MetaDataSerializer, AbstractCFMetaDataFactory.Serializer

public class XMLPersistenceMappingSerializer
extends XMLPersistenceMetaDataSerializer

Serializes persistence mapping to XML.

Since:
0.4.0
Author:
Steve Kim

Nested Class Summary
protected  class XMLPersistenceMappingSerializer.MappingSerializationComparator
          Extends XMLPersistenceMappingSerializer.MappingSerializationComparator for store-specific tags such as <sql-result-set-mapping>.
 
Nested classes/interfaces inherited from class org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer
XMLPersistenceMetaDataSerializer.SerializationComparator
 
Field Summary
 
Fields inherited from class org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer
TYPE_CLASS_QUERIES, TYPE_CLASS_SEQS, TYPE_META, TYPE_QUERY, TYPE_SEQ
 
Fields inherited from interface org.apache.openjpa.lib.meta.MetaDataSerializer
APPEND, COMPACT, PRETTY, VERBOSE
 
Constructor Summary
XMLPersistenceMappingSerializer(JDBCConfiguration conf)
          Constructor.
 
Method Summary
 void addAll(MetaDataRepository repos)
          Add all components in the given repository to the set to be serialized.
protected  void addCommments(Object obj)
           
 void addQueryResultMapping(QueryResultMapping meta)
          Adds the given result set mapping to local cache.
protected  void addSystemMappingElements(Collection toSerialize)
          Add system-level mapping elements to be serialized.
 void clear()
          Clear the set of metadatas to be serialized.
protected  EnumType getEnumType(FieldMapping field)
          Return enum type for the field.
protected  PersistenceStrategy getStrategy(FieldMetaData fmd)
          Return the serialized strategy name.
 boolean getSyncMappingInfo()
          Whether to automatically synchronize mapping info with data available from mapped components before serialization.
protected  XMLPersistenceMetaDataSerializer.SerializationComparator newSerializationComparator()
          Create a new comparator for ordering objects that are to be serialized.
 boolean removeAll(MetaDataRepository repos)
          Remove all the components in the given repository from the set to be serialized.
 boolean removeQueryResultMapping(QueryResultMapping meta)
          Removes given result set mapping from the local cache.
protected  boolean serializeAttributeOverride(FieldMetaData fmd, FieldMetaData orig)
          Always returns false by default.
protected  void serializeAttributeOverrideMappingContent(FieldMetaData fmd, FieldMetaData orig)
          Serialize attribute override mapping content.
protected  void serializeClass(ClassMetaData meta, boolean access)
          Serialize class metadata.
protected  void serializeClassMappingContent(ClassMetaData mapping)
          Serialize class mapping content.
protected  void serializeFieldMappingContent(FieldMetaData fmd, PersistenceStrategy strategy)
          Serialize field mapping content; this will be called before #serializeValueMappingContent.
protected  void serializeInheritanceContent(ClassMetaData mapping)
          Serialize inheritance content.
protected  void serializeOrderColumn(FieldMetaData fmd)
          Serialize order column.
protected  void serializeQueryMappings(ClassMetaData meta)
          Serialize query mappings.
protected  void serializeSequence(SequenceMetaData meta)
          Serialize sequence metadata.
protected  void serializeSystemMappingElement(Object obj)
          Serialize unknown mapping element at system level.
 void setSyncMappingInfo(boolean sync)
          Whether to automatically synchronize mapping info with data available from mapped components before serialization.
protected  int type(Object o)
          Return the type constant for the given object based on its runtime class.
 
Methods inherited from class org.apache.openjpa.persistence.XMLPersistenceMetaDataSerializer
addClassMappingAttributes, addFieldMappingAttributes, addMetaData, addQueryMetaData, addSequenceMetaData, addStrategyMappingAttributes, getConfiguration, getMode, getObjects, getPackage, getSerializeAnnotations, getSourceFile, isMappingMode, isMappingMode, isMappingMode, isMetaDataMode, isQueryMode, removeMetaData, removeQueryMetaData, removeSequenceMetaData, serialize, setMode, setMode, setSerializeAnnotations
 
Methods inherited from class org.apache.openjpa.lib.meta.CFMetaDataSerializer
getClassName, getPackage, groupByPackage, setPackage
 
Methods 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, startElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.openjpa.lib.meta.MetaDataSerializer
serialize, serialize, serialize, serialize
 

Constructor Detail

XMLPersistenceMappingSerializer

public XMLPersistenceMappingSerializer(JDBCConfiguration conf)
Constructor. Supply configuration.

Method Detail

getSyncMappingInfo

public boolean getSyncMappingInfo()
Whether to automatically synchronize mapping info with data available from mapped components before serialization. Defaults to false.


setSyncMappingInfo

public void setSyncMappingInfo(boolean sync)
Whether to automatically synchronize mapping info with data available from mapped components before serialization. Defaults to false.


addQueryResultMapping

public void addQueryResultMapping(QueryResultMapping meta)
Adds the given result set mapping to local cache.


removeQueryResultMapping

public boolean removeQueryResultMapping(QueryResultMapping meta)
Removes given result set mapping from the local cache.


addAll

public void addAll(MetaDataRepository repos)
Description copied from class: XMLPersistenceMetaDataSerializer
Add all components in the given repository to the set to be serialized.

Specified by:
addAll in interface AbstractCFMetaDataFactory.Serializer
Overrides:
addAll in class XMLPersistenceMetaDataSerializer

removeAll

public boolean removeAll(MetaDataRepository repos)
Description copied from class: XMLPersistenceMetaDataSerializer
Remove all the components in the given repository from the set to be serialized.

Overrides:
removeAll in class XMLPersistenceMetaDataSerializer
Returns:
true if any components removed, false if none in set

clear

public void clear()
Description copied from class: XMLPersistenceMetaDataSerializer
Clear the set of metadatas to be serialized.

Overrides:
clear in class XMLPersistenceMetaDataSerializer

addCommments

protected void addCommments(Object obj)
                     throws SAXException
Throws:
SAXException

serializeClass

protected void serializeClass(ClassMetaData meta,
                              boolean access)
                       throws SAXException
Description copied from class: XMLPersistenceMetaDataSerializer
Serialize class metadata.

Overrides:
serializeClass in class XMLPersistenceMetaDataSerializer
Throws:
SAXException

serializeClassMappingContent

protected void serializeClassMappingContent(ClassMetaData mapping)
                                     throws SAXException
Description copied from class: XMLPersistenceMetaDataSerializer
Serialize class mapping content. Does nothing by default.

Overrides:
serializeClassMappingContent in class XMLPersistenceMetaDataSerializer
Throws:
SAXException

serializeInheritanceContent

protected void serializeInheritanceContent(ClassMetaData mapping)
                                    throws SAXException
Description copied from class: XMLPersistenceMetaDataSerializer
Serialize inheritance content. Does nothing by default.

Overrides:
serializeInheritanceContent in class XMLPersistenceMetaDataSerializer
Throws:
SAXException

serializeAttributeOverride

protected boolean serializeAttributeOverride(FieldMetaData fmd,
                                             FieldMetaData orig)
Description copied from class: XMLPersistenceMetaDataSerializer
Always returns false by default.

Overrides:
serializeAttributeOverride in class XMLPersistenceMetaDataSerializer

serializeAttributeOverrideMappingContent

protected void serializeAttributeOverrideMappingContent(FieldMetaData fmd,
                                                        FieldMetaData orig)
                                                 throws SAXException
Description copied from class: XMLPersistenceMetaDataSerializer
Serialize attribute override mapping content. Does nothing by default,

Overrides:
serializeAttributeOverrideMappingContent in class XMLPersistenceMetaDataSerializer
Throws:
SAXException

getStrategy

protected PersistenceStrategy getStrategy(FieldMetaData fmd)
Description copied from class: XMLPersistenceMetaDataSerializer
Return the serialized strategy name.

Overrides:
getStrategy in class XMLPersistenceMetaDataSerializer

serializeFieldMappingContent

protected void serializeFieldMappingContent(FieldMetaData fmd,
                                            PersistenceStrategy strategy)
                                     throws SAXException
Description copied from class: XMLPersistenceMetaDataSerializer
Serialize field mapping content; this will be called before #serializeValueMappingContent. Does nothing by default.

Overrides:
serializeFieldMappingContent in class XMLPersistenceMetaDataSerializer
Throws:
SAXException

serializeOrderColumn

protected void serializeOrderColumn(FieldMetaData fmd)
                             throws SAXException
Serialize order column.

Overrides:
serializeOrderColumn in class XMLPersistenceMetaDataSerializer
Throws:
SAXException

getEnumType

protected EnumType getEnumType(FieldMapping field)
Return enum type for the field.


newSerializationComparator

protected XMLPersistenceMetaDataSerializer.SerializationComparator newSerializationComparator()
Description copied from class: XMLPersistenceMetaDataSerializer
Create a new comparator for ordering objects that are to be serialized.

Overrides:
newSerializationComparator in class XMLPersistenceMetaDataSerializer

addSystemMappingElements

protected void addSystemMappingElements(Collection toSerialize)
Description copied from class: XMLPersistenceMetaDataSerializer
Add system-level mapping elements to be serialized. Does nothing by default.

Overrides:
addSystemMappingElements in class XMLPersistenceMetaDataSerializer

type

protected int type(Object o)
Description copied from class: XMLPersistenceMetaDataSerializer
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.

Overrides:
type in class XMLPersistenceMetaDataSerializer

serializeSystemMappingElement

protected void serializeSystemMappingElement(Object obj)
                                      throws SAXException
Description copied from class: XMLPersistenceMetaDataSerializer
Serialize unknown mapping element at system level.

Overrides:
serializeSystemMappingElement in class XMLPersistenceMetaDataSerializer
Throws:
SAXException

serializeQueryMappings

protected void serializeQueryMappings(ClassMetaData meta)
                               throws SAXException
Description copied from class: XMLPersistenceMetaDataSerializer
Serialize query mappings. Does nothing by default.

Overrides:
serializeQueryMappings in class XMLPersistenceMetaDataSerializer
Throws:
SAXException

serializeSequence

protected void serializeSequence(SequenceMetaData meta)
                          throws SAXException
Description copied from class: XMLPersistenceMetaDataSerializer
Serialize sequence metadata.

Overrides:
serializeSequence in class XMLPersistenceMetaDataSerializer
Throws:
SAXException


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.