Package org.exolab.castor.xml.util
Class XMLParserUtils
java.lang.Object
org.exolab.castor.xml.util.XMLParserUtils
A couple of routines to manipulate XMLParser instances. Mostly extracted from 'old'
LocalConfiguration class.
- Since:
- 1.1.3
- Version:
- $Id$
- Author:
- Joachim Grueneis, jgrueneis_at_gmail_dot_com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic OutputFormat
getOutputFormat
(AbstractProperties properties) static Parser
getParser
(AbstractProperties properties, String features) static SAXParser
getSAXParser
(boolean validation, boolean namespaces) To get a SAXParser instance which is then used to get either parser or XMLReader.static SAXParser
getSAXParser
(SAXParserFactory saxParserFactory) To get a SAXParser instance from a givenSAXParserFactory
, which is then used to obtain eitherParser
orXMLReader
.static SAXParserFactory
getSAXParserFactory
(boolean validation, boolean namespaces) To get a SAXParserFactory instance which is then used to obtain anSAXParser
instance.static Serializer
getSerializer
(AbstractProperties properties) static XMLSerializerFactory
getSerializerFactory
(String serializerFactoryName) Returns the currently configured XMLSerializerFactory instance.static Parser
instantiateParser
(String className) Instantiates anParser
instance directly, usingClass.forName(String)
to obtain theClass
instance, and usesClass.newInstance()
to create the actual instance.static XMLReader
instantiateXMLReader
(String className) Instantiates anXMLReader
instance directly, usingClass.forName(String)
to obtain theClass
instance, and usesClass.newInstance()
to create the actual instance.static void
setFeaturesOnXmlReader
(String parserFeatures, String parserFeaturesToDisable, boolean validation, boolean namespaces, XMLReader xmlReader) Sets features on XML reader instance.
-
Constructor Details
-
XMLParserUtils
public XMLParserUtils()
-
-
Method Details
-
setFeaturesOnXmlReader
public static void setFeaturesOnXmlReader(String parserFeatures, String parserFeaturesToDisable, boolean validation, boolean namespaces, XMLReader xmlReader) Sets features on XML reader instance.- Parameters:
validation
- Whether to enable validation or not.namespaces
- Whether to enable namespace support for not.xmlReader
- The XMLReader instance to configure.properties
- the Properties to read parser features fromdefaultFeatures
- any default features to use
-
getSAXParser
To get a SAXParser instance which is then used to get either parser or XMLReader.- Parameters:
validation
- validation flag to set into parser factorynamespaces
- namespace flag to set into parser factory- Returns:
- the SAXParser for further use
-
getSAXParser
To get a SAXParser instance from a givenSAXParserFactory
, which is then used to obtain eitherParser
orXMLReader
.- Returns:
- the
SAXParser
for further use
-
getSAXParserFactory
To get a SAXParserFactory instance which is then used to obtain anSAXParser
instance.- Parameters:
validation
- Whether to produce a validating SAX parser.namespaces
- Whether to provide namespace support.- Returns:
- the SAXParserFactory for further use
-
instantiateXMLReader
Instantiates anXMLReader
instance directly, usingClass.forName(String)
to obtain theClass
instance, and usesClass.newInstance()
to create the actual instance. -
instantiateParser
Instantiates anParser
instance directly, usingClass.forName(String)
to obtain theClass
instance, and usesClass.newInstance()
to create the actual instance. -
getParser
-
getSerializer
- See Also:
-
getOutputFormat
- See Also:
-
getSerializerFactory
Returns the currently configured XMLSerializerFactory instance.- Parameters:
serializerFactoryName
- the class name of the serializer factory- Returns:
- XMLSerializerFactory to use by Castor
-