Package org.cip4.lib.xjdf.xml.internal
Class AbstractXmlParser<T>
java.lang.Object
org.cip4.lib.xjdf.xml.internal.AbstractXmlParser<T>
- Type Parameters:
T- Object type that will be parsed.
- Direct Known Subclasses:
XJdfParser,XJmfParser
Parsing logic for building a XML Document from DOM-Tree and the way around.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractXmlParser(javax.xml.bind.JAXBContext jaxbContext) Custom constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AbstractXmlValidatorCreate validator for validating documents.protected abstract com.sun.xml.bind.marshaller.NamespacePrefixMapperReturns a new specific NamespacePrefixMapper implementation.protected abstract StringReturns the XML Header for marshaling.protected final voidParse an XML Node to a W3C Node.protected final ObjectParse a W3C Node to a XML Node.final TParse a binary input stream to a object tree.protected final byte[]Parse the object tree of an document to a byte array.protected final byte[]Parse a object tree to a byte array.protected final voidparseXml(T obj, OutputStream os) Parse the object tree of an document to a binary output stream.protected final voidparseXml(T obj, OutputStream os, boolean skipValidation) Parse a object tree to a binary output stream.
-
Constructor Details
-
AbstractXmlParser
protected AbstractXmlParser(javax.xml.bind.JAXBContext jaxbContext) Custom constructor. Accepting a JAXBContextFactory for initializing.- Parameters:
jaxbContext- Context for JAXB-Handling.
-
-
Method Details
-
parseNode
Parse a W3C Node to a XML Node.- Parameters:
w3cNode- The W3C Node to be parsed.- Returns:
- The XML Node as object.
- Throws:
javax.xml.bind.JAXBException
-
parseNode
Parse an XML Node to a W3C Node.- Parameters:
xmlNode- The XML Node to be parsed.w3cNode- The W3C Result node.- Throws:
javax.xml.bind.JAXBException
-
parseXml
Parse the object tree of an document to a byte array.- Parameters:
obj- Object tree for parsing.- Returns:
- XML-representation of the document as array of bytes.
- Throws:
javax.xml.bind.JAXBExceptionIOException
-
parseXml
Parse the object tree of an document to a binary output stream.- Parameters:
obj- Object tree for parsing.os- OutputStream the write the document to.- Throws:
javax.xml.bind.ValidationException- Is thrown in case document is not valid and validation process is not being skipped.javax.xml.bind.JAXBException
-
parseXml
protected final byte[] parseXml(T obj, boolean skipValidation) throws IOException, javax.xml.bind.JAXBException Parse a object tree to a byte array.- Parameters:
obj- Object tree for parsing.skipValidation- Skip validation.- Returns:
- Document as Byte Array.
- Throws:
IOExceptionjavax.xml.bind.JAXBException
-
parseXml
protected final void parseXml(T obj, OutputStream os, boolean skipValidation) throws javax.xml.bind.JAXBException Parse a object tree to a binary output stream.- Parameters:
obj- Object tree object for parsing.os- Target OutputStream where document is being parsed.skipValidation- Indicates whether or not validation has to be skipped.- Throws:
javax.xml.bind.ValidationException- Is thrown in case the document is not valid and validation process is not being skipped.javax.xml.bind.JAXBException
-
parseStream
Parse a binary input stream to a object tree.- Parameters:
is- Binary document input stream for parsing.- Returns:
- Object tree parsed from binary input stream.
- Throws:
javax.xml.bind.JAXBException
-
getNamespacePrefixMapper
protected abstract com.sun.xml.bind.marshaller.NamespacePrefixMapper getNamespacePrefixMapper()Returns a new specific NamespacePrefixMapper implementation.- Returns:
- New specific NamespacePrefixMapper implementation.
-
getXmlHeader
Returns the XML Header for marshaling.- Returns:
- XML Header as String
-
createValidator
Create validator for validating documents.- Returns:
- Validator
-