- java.lang.Object
-
- io.github.astrapi69.xml.parser.DocumentBuilderFactoryInitializer
-
public class DocumentBuilderFactoryInitializer extends java.lang.Object
The classDocumentBuilderFactoryInitializer
provides method for initializeDocumentBuilderFactory
,DocumentBuilder
,Document
andDOMSource
objects
-
-
Constructor Summary
Constructors Constructor Description DocumentBuilderFactoryInitializer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.w3c.dom.Document
newDocument(java.io.File xml)
Gets theDocument
from the given xml filestatic org.w3c.dom.Document
newDocument(java.lang.String xml)
Gets theDocument
from the given xml stringstatic javax.xml.parsers.DocumentBuilder
newDocumentBuilder()
Factory method for create a newDocumentBuilder
objectstatic javax.xml.parsers.DocumentBuilder
newDocumentBuilder(java.lang.String schema)
Factory method for create a newDocumentBuilder
objectstatic javax.xml.parsers.DocumentBuilderFactory
newDocumentBuilderFactory(java.lang.String schema)
Factory method for create a newDocumentBuilderFactory
objectstatic javax.xml.parsers.DocumentBuilderFactory
newDocumentBuilderFactory(java.lang.String schema, java.lang.String schemaLanguage, java.lang.String documentBuilderFactoryName, boolean namespaceAwareness, boolean factoryValidating)
Factory method for create a newDocumentBuilderFactory
objectstatic javax.xml.transform.dom.DOMSource
newDOMSource(java.io.File xml, org.xml.sax.ErrorHandler errorHandler)
Factory method for create a newDOMSource
object with the given error handlerstatic org.w3c.dom.Document
parse(java.io.File xml, org.xml.sax.ErrorHandler errorHandler)
Parses the given xml file and the given error handler
-
-
-
Method Detail
-
newDocumentBuilderFactory
public static javax.xml.parsers.DocumentBuilderFactory newDocumentBuilderFactory(java.lang.String schema, java.lang.String schemaLanguage, java.lang.String documentBuilderFactoryName, boolean namespaceAwareness, boolean factoryValidating)
Factory method for create a newDocumentBuilderFactory
object- Parameters:
schema
- the schemaschemaLanguage
- the schema languagedocumentBuilderFactoryName
- the name of the document builder factorynamespaceAwareness
- the flag if the namespace should be awarefactoryValidating
- the flag if the factory should validate- Returns:
- the document builder factory
-
newDocumentBuilderFactory
public static javax.xml.parsers.DocumentBuilderFactory newDocumentBuilderFactory(java.lang.String schema)
Factory method for create a newDocumentBuilderFactory
object- Parameters:
schema
- the schema- Returns:
- the document builder factory
-
newDocumentBuilder
public static javax.xml.parsers.DocumentBuilder newDocumentBuilder(java.lang.String schema) throws javax.xml.parsers.ParserConfigurationException
Factory method for create a newDocumentBuilder
object- Parameters:
schema
- the schema- Throws:
javax.xml.parsers.ParserConfigurationException
- if a DocumentBuilder cannot be created which satisfies the configuration requested.
-
newDocumentBuilder
public static javax.xml.parsers.DocumentBuilder newDocumentBuilder() throws javax.xml.parsers.ParserConfigurationException
Factory method for create a newDocumentBuilder
object- Throws:
javax.xml.parsers.ParserConfigurationException
- if a DocumentBuilder cannot be created which satisfies the configuration requested.
-
newDocument
public static org.w3c.dom.Document newDocument(java.io.File xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
Gets theDocument
from the given xml file- Parameters:
xml
- the xml file as string- Returns:
- the node list
- Throws:
javax.xml.parsers.ParserConfigurationException
- the parser configuration exceptionorg.xml.sax.SAXException
- is thrown if a sax parse error occursjava.io.IOException
- Signals that an I/O exception has occurred.
-
newDocument
public static org.w3c.dom.Document newDocument(java.lang.String xml) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
Gets theDocument
from the given xml string- Parameters:
xml
- the xml file as string- Returns:
- the node list
- Throws:
javax.xml.parsers.ParserConfigurationException
- the parser configuration exceptionorg.xml.sax.SAXException
- is thrown if a sax parse error occursjava.io.IOException
- Signals that an I/O exception has occurred.
-
parse
public static org.w3c.dom.Document parse(java.io.File xml, org.xml.sax.ErrorHandler errorHandler) throws org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException, java.io.IOException
Parses the given xml file and the given error handler- Parameters:
xml
- the xmlerrorHandler
- the error handler- Returns:
- the document
- Throws:
org.xml.sax.SAXException
- If a SAX error occurs during parsing.javax.xml.parsers.ParserConfigurationException
- if a DocumentBuilder cannot be created which satisfies the configuration requested.java.io.IOException
- Signals that an I/O exception has occurred.
-
newDOMSource
public static javax.xml.transform.dom.DOMSource newDOMSource(java.io.File xml, org.xml.sax.ErrorHandler errorHandler) throws org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException, java.io.IOException
Factory method for create a newDOMSource
object with the given error handler- Parameters:
xml
- the xmlerrorHandler
- the error handler- Returns:
- the dOM source
- Throws:
org.xml.sax.SAXException
- If a SAX error occurs during parsing.javax.xml.parsers.ParserConfigurationException
- if a DocumentBuilder cannot be created which satisfies the configuration requested.java.io.IOException
- Signals that an I/O exception has occurred.
-
-