Class XMLParserUtils

java.lang.Object
org.exolab.castor.xml.util.XMLParserUtils

public class XMLParserUtils extends Object
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
  • Field Details

    • LOG

      static final org.apache.commons.logging.Log LOG
      Logger to be used.
  • 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:
      properties - the Properties to read parser features from
      defaultFeatures - any default features to use
      validation - Whether to enable validation or not.
      namespaces - Whether to enable namespace support for not.
      xmlReader - The XMLReader instance to configure.
    • getSAXParser

      public static SAXParser getSAXParser(boolean validation, boolean namespaces)
      To get a SAXParser instance which is then used to get either parser or XMLReader.
      Parameters:
      validation - validation flag to set into parser factory
      namespaces - namespace flag to set into parser factory
      Returns:
      the SAXParser for further use
    • instantiateXMLReader

      public static XMLReader instantiateXMLReader(String className)
      Instantiates an XMLReader instance directly, using Class.forName(String) to obtain the Class instance, and uses Class.newInstance() to create the actual instance.
      Parameters:
      className - The class name of the XMLReader instance to be instantiated.
      Returns:
      An XMLReader instance.
    • instantiateParser

      public static Parser instantiateParser(String className)
      Instantiates an Parser instance directly, using Class.forName(String) to obtain the Class instance, and uses Class.newInstance() to create the actual instance.
      Parameters:
      className - The class name of the Parser instance to be instantiated.
      Returns:
      An Parser instance.
    • getParser

      public static Parser getParser(AbstractProperties properties, String features)
    • getSerializer

      public static Serializer getSerializer(AbstractProperties properties)
      See Also:
    • getOutputFormat

      public static OutputFormat getOutputFormat(AbstractProperties properties)
      See Also:
    • getSerializerFactory

      public static XMLSerializerFactory getSerializerFactory(String serializerFactoryName)
      Returns the currently configured XMLSerializerFactory instance.
      Parameters:
      serializerFactoryName - the class name of the serializer factory
      Returns:
      XMLSerializerFactory to use by Castor