Package org.apache.openjpa.lib.meta
Class XMLMetaDataSerializer
java.lang.Object
org.apache.openjpa.lib.meta.XMLMetaDataSerializer
- All Implemented Interfaces:
MetaDataSerializer
- Direct Known Subclasses:
CFMetaDataSerializer
,XMLSchemaSerializer
Abstract base type for serlializers that transfer groups of objects
to XML. Includes a way of serializing objects back to the XML files
they were parsed from. Serializers are not thread safe.
- Author:
- Abe White
-
Field Summary
Fields inherited from interface org.apache.openjpa.lib.meta.MetaDataSerializer
APPEND, COMPACT, PRETTY, VERBOSE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAttribute
(String name, String value) Add an attribute to the current group.protected void
addComments
(Object obj) Write the given entity's comments.protected void
addComments
(String[] comments) Add a comment to the stream.protected void
Add text to the current element.protected File
The backup file made for the current file being parsed.protected void
endElement
(String name) End the current element.protected Attributes
The current attributes.protected Map<File,
Collection<Object>> Returns aMap
with keys of theFile
to be written to, and values of aCollection
ofSourceTracker
instances.getLog()
The log to write to.protected abstract Collection<Object>
Return the current set of objects for serialization.protected File
getSourceFile
(Object obj) Return the source file for the given instance.protected boolean
Whether this serialization is in verbose mode.protected File
prepareWrite
(File file) Prepare to write to the given file.protected void
reset()
Reset serialization state for the next document.void
serialize
(int flags) Serialize the current set of objects to the files from which they were parsed.void
Serialize the current set of objects to the given file.void
Serialize the current set of objects to the given stream.protected abstract void
serialize
(Collection<Object> objs) Serialize the given set of objects.void
Serialize the current set of objects to the files from which they were parsed.void
Serialize the current set of objects to the given result.void
serialize
(ContentHandler handler, int flags) Serilize the current set of objects to a series of SAX events on the given handler.void
The log to write to.protected void
startElement
(String name) Start an element with the current attribute settings.
-
Constructor Details
-
XMLMetaDataSerializer
public XMLMetaDataSerializer()
-
-
Method Details
-
getLog
The log to write to. -
setLog
The log to write to. -
serialize
Description copied from interface:MetaDataSerializer
Serialize 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:
serialize
in interfaceMetaDataSerializer
- Parameters:
flags
- bit flags specifying the output flags; e.g.MetaDataSerializer.PRETTY
- Throws:
IOException
-
serialize
Description copied from interface:MetaDataSerializer
Serialize the current set of objects to the files from which they were parsed. The objects must implement theSourceTracker
interface.- Specified by:
serialize
in interfaceMetaDataSerializer
- Parameters:
output
- if null, then serialize directly to the file system; otherwise, populate the specifiedMap
with keys that are theFile
instances, and values that are theString
contents of the MetaDataflags
- bit flags specifying the output flags; e.g.MetaDataSerializer.PRETTY
- Throws:
IOException
-
prepareWrite
Prepare to write to the given file. Back up the file and make sure the path to it is created.- Throws:
IOException
-
getFileMap
Returns aMap
with keys of theFile
to be written to, and values of aCollection
ofSourceTracker
instances. -
getSourceFile
Return the source file for the given instance. By default, checks to see if the instance implementsSourceTracker
. -
serialize
Description copied from interface:MetaDataSerializer
Serialize the current set of objects to the given file.- Specified by:
serialize
in interfaceMetaDataSerializer
flags
- bit flags specifying the output flags; e.g.MetaDataSerializer.PRETTY
|MetaDataSerializer.APPEND
- Throws:
IOException
-
serialize
Description copied from interface:MetaDataSerializer
Serialize the current set of objects to the given stream.- Specified by:
serialize
in interfaceMetaDataSerializer
flags
- bit flags specifying the output flags; e.g.MetaDataSerializer.PRETTY
- Throws:
IOException
-
serialize
Serialize the current set of objects to the given result.- Throws:
SAXException
-
serialize
Serilize the current set of objects to a series of SAX events on the given handler.- Throws:
SAXException
-
isVerbose
protected boolean isVerbose()Whether this serialization is in verbose mode. -
currentBackupFile
The backup file made for the current file being parsed. -
startElement
Start an element with the current attribute settings. Clears the attributes as well.- Throws:
SAXException
-
endElement
End the current element.- Throws:
SAXException
-
addText
Add text to the current element.- Throws:
SAXException
-
addAttribute
Add an attribute to the current group. -
getAttributes
The current attributes. -
addComments
Add a comment to the stream.- Throws:
SAXException
-
addComments
Write the given entity's comments. By default, tests if entity isCommentable
.- Throws:
SAXException
-
reset
protected void reset()Reset serialization state for the next document. -
serialize
Serialize the given set of objects.- Throws:
SAXException
-
getObjects
Return the current set of objects for serialization.
-