org.apache.tools.ant.util

Class JAXPUtils

public class JAXPUtils extends Object

Collection of helper methods that retrieve a ParserFactory or Parsers and Readers.

This class will create only a single factory instance.

Since: Ant 1.5

Method Summary
static DocumentBuildergetDocumentBuilder()
Returns a newly created DocumentBuilder.
static XMLReadergetNamespaceXMLReader()
Returns a newly created SAX 2 XMLReader, which is namespace aware
static SAXParserFactorygetNSParserFactory()
Returns the parser factory to use to create namespace aware parsers.
static ParsergetParser()
Returns a newly created SAX 1 Parser, using the default parser factory.
static SAXParserFactorygetParserFactory()
Returns the parser factory to use.
static StringgetSystemId(File file)
This is a best attempt to provide a URL.toExternalForm() from a file URL.
static XMLReadergetXMLReader()
Returns a newly created SAX 2 XMLReader, using the default parser factory.
static SAXParserFactorynewParserFactory()
Returns a new parser factory instance.

Method Detail

getDocumentBuilder

public static DocumentBuilder getDocumentBuilder()
Returns a newly created DocumentBuilder.

Returns: a DocumentBuilder

Since: Ant 1.6

getNamespaceXMLReader

public static XMLReader getNamespaceXMLReader()
Returns a newly created SAX 2 XMLReader, which is namespace aware

Returns: a SAX 2 XMLReader.

Since: Ant 1.6

See Also: JAXPUtils

getNSParserFactory

public static SAXParserFactory getNSParserFactory()
Returns the parser factory to use to create namespace aware parsers.

Returns: a SAXParserFactory to use which supports manufacture of namespace aware parsers

Since: Ant 1.6

getParser

public static Parser getParser()
Returns a newly created SAX 1 Parser, using the default parser factory.

Returns: a SAX 1 Parser.

Since: Ant 1.5

See Also: JAXPUtils

getParserFactory

public static SAXParserFactory getParserFactory()
Returns the parser factory to use. Only one parser factory is ever created by this method and is then cached for future use.

Returns: a SAXParserFactory to use

Since: Ant 1.5

getSystemId

public static String getSystemId(File file)
This is a best attempt to provide a URL.toExternalForm() from a file URL. Some parsers like Crimson choke on uri that are made of backslashed paths (ie windows) as it is does not conform URI specifications.

Parameters: file the file to create the system id from.

Returns: the systemid corresponding to the given file.

Since: Ant 1.5.2

getXMLReader

public static XMLReader getXMLReader()
Returns a newly created SAX 2 XMLReader, using the default parser factory.

Returns: a SAX 2 XMLReader.

Since: Ant 1.5

See Also: JAXPUtils

newParserFactory

public static SAXParserFactory newParserFactory()
Returns a new parser factory instance.

Since: Ant 1.5

Copyright