3.4.7 Classes used in preparing the high-speed parse support function
Use the following classes while preparing the high-speed parse support function:
-
PreparsedObjectFactory
-
PreparsedObject
Each class is as follows:
- Organization of this subsection
(1) PreparsedObjectFactory class
(a) Description
Factory class used to generate the preparsed object.
The PreparsedObjectFactory class is not thread safe. Therefore, the same PreparsedObjectFactory cannot be accessed simultaneously from more than one thread. To avoid conflicts between threads, use one of the following methods in PreparsedObjectFactory class:
-
Each thread has one PreparsedObjectFactory instance.
-
Each thread exclusively accesses the PreparsedObjectFactory instance.
(b) Package and class names
com.cosminexus.jaxp.preparsedxml.PreparsedObjectFactory
(c) Format
public class PreparsedObjectFactory
(d) List of methods
Method name |
Function |
---|---|
Generate and return the factory for generating the preparsed object. |
|
Set up whether the namespace is enabled or disabled when the Pre-Parse XML document is parsed. |
|
Set up the error handler for receiving the errors that occur when parsing the Pre-Parse XML document. |
|
Set up the entity resolver for resolving the entities included in the Pre-Parse XML document. |
|
Set up whether to output the tuning information. |
|
Parse the Pre-Parse XML document, and then generate the preparsed object. |
(e) Method details
- newInstance method
-
- Description
-
Generates and returns the factory for generating the preparsed object.
- Format
public static PreparsedObjectFactory newInstance()
- Parameter
-
None
- Return value
-
This method returns the new instance of PreparsedObjectFactory.
- Exception
-
None
- setNamespaceAware method
-
- Description
-
Sets up whether the namespace is enabled or disabled when the Pre-Parse XML document is parsed.
By default, false is set up.
- Format
public void setNamespaceAware(boolean awareness)
- Parameter
-
-
awareness
Sets up whether the namespace is enabled or disabled.
true: The namespace is enabled
false: The namespace is disabled
-
- Return value
-
None
- Exception
-
None
- setErrorHandler method
-
- Description
-
Sets up the error handler for receiving the errors that occur when parsing the Pre-Parse XML document when the newPreparsedObject method is invoked.
By default, the operation is performed considering that the following error handler is set up:
class DefaultErrorHandler implements ErrorHandler { public void fatalError(SAXParseException e) throws SAXException { throw e; } public void error(SAXParseException e) throws SAXException { throw e; } public void warning(SAXParseException e) throws SAXException { // No operations } }
- Format
public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
- Parameter
-
-
errorHandler
Sets up the error handler. When null is set up, the default operation is performed.
-
- Return value
-
None
- Exception
-
None
- setEntityResolver method
-
- Description
-
Sets up the entity resolver for resolving the entities included in the Pre-Parse XML document when the newPreparsedObject method is invoked.
By default, the operation is performed considering that the following entity resolver is set up:
class DefaultEntityResolver implements EntityResolver { InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { returns null; // Always returns null } }
- Format
public void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
- Parameter
-
-
entityResolver
Sets up the entity resolver. When null, the default operation is performed.
-
- Return value
-
None
- Exception
-
None
- setTuningInfoFlag method
-
- Description
-
Sets up whether to output the tuning information.
By default, false is set.
To output the tuning information, you must set true in this method, and INFO in the system property com.cosminexus.jaxp.preparsedxml.tuning.level. For details about how to output the tuning information, see 3.4.9(3) How to output the tuning information.
- Format
public void setTuningInfoFlag(boolean state)
- Parameter
-
-
state
Sets up whether to output the tuning information.
true: The tuning information is output
false: The tuning information is not output
-
- Return value
-
None
- Exception
-
None
- newPreparsedObject method
-
- Description
-
Parse the Pre-Parse XML document, and generates the preparsed object.
- Format
-
public PreparsedObject newPreparsedObject(java.io.File xml)
throws IllegalArgumentException, SAXException, IOException
- Parameter
-
-
xml
Specifies the File object that indicates the Pre-Parse XML document. You cannot specify null.
-
- Return value
-
This method returns the new instance of PreparsedObject that is the preparsed object.
- Exception
-
-
IllegalArgumentException
This exception occurs when null is specified in the xml parameter.
-
SAXException
This exception occurs in the following cases:
- When an SAX error occurs while processing
- When an attempt is made to pre-parse XML1.1 document (for details, see 6.19.3 Notes on XML1.1)
-
IOException
This exception occurs when an I/O error occurs.
-
(2) PreparsedObject class
(a) Description
This class indicates the preparsed object.
(b) Package and class names
com.cosminexus.jaxp.preparsedxml.PreparsedObject
(c) Format
public class PreparsedObject
(d) List of methods
Method name |
Function |
---|---|
Returns whether the namespace set up when parsing the Pre-Parse XML document is enabled or disabled. |
|
Returns the error handler set up when parsing the Pre-Parse XML document. |
|
Returns the entity resolver set up when parsing the Pre-Parse XML document. |
(e) Method details
- isNamespaceAware method
-
- Description
-
Returns whether the namespace set up when parsing the Pre-Parse XML document is enabled or disabled.
- Format
public boolean isNamespaceAware()
- Parameter
-
None
- Return value
-
true: The namespace is enabled
false: The namespace is disabled
- Exception
-
None
- getErrorHandler method
-
- Description
-
Returns the error handler set up when parsing the Pre-Parse XML document.
- Format
public ErrorHandler getErrorHandler()
- Parameter
-
None
- Return value
-
This method returns the error handler set up when parsing the Pre-Parse XML document. Returns null if this method is not set up.
- Exception
-
None
- getEntityResolver method
-
- Description
-
Returns the entity resolver set up when parsing the Pre-Parse XML document.
- Format
public EntityResolver getEntityResolver()
- Parameter
-
None
- Return value
-
This method returns the entity resolver set up when parsing the Pre-Parse XML document. Returns null if this method is not set up.
- Exception
-
None