org.docx4j.openpackaging.parts
Class JaxbXmlPart
java.lang.Object
org.docx4j.openpackaging.Base
org.docx4j.openpackaging.parts.Part
org.docx4j.openpackaging.parts.JaxbXmlPart
- Direct Known Subclasses:
- DocPropsCorePart, DocPropsCustomPart, DocPropsExtendedPart, DocumentPart, FontTablePart, NumberingDefinitionsPart, StyleDefinitionsPart, ThemePart
public abstract class JaxbXmlPart
- extends Part
OPC Parts are either XML, or binary (or text) documents.
Most are XML documents.
docx4j aims to represent XML parts using JAXB.
Any XML Part for which we have a JAXB representation (eg the main
document part) should extend this Part.
This class provides only one of the methods for serializing (marshalling) the
Java content tree back into XML data found in
javax.xml.bind.Marshaller interface. You can always use
any of the others by getting the jaxbElement required by those
methods.
Insofar as unmarshalling is concerned, at present it doesn't
contain all the methods in javax.xml.bind.unmarshaller interface.
This is because the content always comes from the same place
(ie from a zip file or JCR via org.docx4j.io.*).
TODO - what is the best thing to unmarshall from?
|
Field Summary |
java.lang.Object |
jaxbElement
The content tree (ie JAXB representation of the Part) |
| Fields inherited from class org.docx4j.openpackaging.Base |
partName |
|
Method Summary |
java.lang.Object |
getJaxbElement()
|
void |
marshal(org.w3c.dom.Node node)
Marshal the content tree rooted at jaxbElement into a DOM tree. |
void |
marshal(java.io.OutputStream os)
Marshal the content tree rooted at jaxbElement into an output
stream. |
void |
setJAXBContext(javax.xml.bind.JAXBContext jc)
|
void |
setJaxbElement(java.lang.Object jaxbElement)
|
abstract java.lang.Object |
unmarshal(java.io.InputStream is)
Unmarshal XML data from the specified InputStream and return the
resulting content tree. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
jaxbElement
public java.lang.Object jaxbElement
- The content tree (ie JAXB representation of the Part)
JaxbXmlPart
public JaxbXmlPart(PartName partName)
throws InvalidFormatException
- Throws:
InvalidFormatException
JaxbXmlPart
public JaxbXmlPart(PartName partName,
javax.xml.bind.JAXBContext jc)
throws InvalidFormatException
- Throws:
InvalidFormatException
getJaxbElement
public java.lang.Object getJaxbElement()
marshal
public void marshal(org.w3c.dom.Node node)
throws javax.xml.bind.JAXBException
- Marshal the content tree rooted at jaxbElement into a DOM tree.
Used by SaveToJCR.
- Parameters:
node - DOM nodes will be added as children of this node.
This parameter must be a Node that accepts children
(Document,
DocumentFragment, or
Element)
- Throws:
javax.xml.bind.JAXBException - If any unexpected problem occurs during the marshalling.
marshal
public void marshal(java.io.OutputStream os)
throws javax.xml.bind.JAXBException
- Marshal the content tree rooted at jaxbElement into an output
stream. Used by SaveToZipFIle.
- Parameters:
os - XML will be added to this stream.
- Throws:
javax.xml.bind.JAXBException - If any unexpected problem occurs during the marshalling.
setJAXBContext
public void setJAXBContext(javax.xml.bind.JAXBContext jc)
setJaxbElement
public void setJaxbElement(java.lang.Object jaxbElement)
unmarshal
public abstract java.lang.Object unmarshal(java.io.InputStream is)
throws javax.xml.bind.JAXBException
- Unmarshal XML data from the specified InputStream and return the
resulting content tree. Validation event location information may be
incomplete when using this form of the unmarshal API.
Implements Unmarshal Global Root Element.
- Parameters:
is - the InputStream to unmarshal XML data from
- Returns:
- the newly created root object of the java content tree
- Throws:
javax.xml.bind.JAXBException - If any unexpected errors occur while unmarshalling