com.gridsystems
Class XmlUtils

java.lang.Object
  extended by com.gridsystems.XmlUtils

public final class XmlUtils
extends java.lang.Object

XmlUtils type.

Author:
Rodrigo Ruiz

Method Summary
static org.w3c.dom.Document createDocument()
          Creates a new empty XML document.
static javax.xml.parsers.DocumentBuilder getBuilder()
          Gets a document builder instance.
static org.w3c.dom.Document getResourceAsDocument(java.lang.ClassLoader cl, java.lang.String resName)
          Gets a resource as a Document instance.
static org.w3c.dom.Document getResourceAsDocument(java.lang.String resName)
          Gets a resource from the current context class-loader as a Document instance.
static org.w3c.dom.Document parse(java.io.File f)
          Parses a document from the given source.
static org.w3c.dom.Document parse(org.xml.sax.InputSource src)
          Parses a document from the given source.
static org.w3c.dom.Document parse(java.io.InputStream is)
          Parses a document from the given source.
static org.w3c.dom.Document parse(java.io.Reader reader)
          Parses a document from the given source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBuilder

public static javax.xml.parsers.DocumentBuilder getBuilder()
                                                    throws javax.xml.parsers.ParserConfigurationException
Gets a document builder instance.

Returns:
An instance
Throws:
javax.xml.parsers.ParserConfigurationException - If an error occurs

createDocument

public static org.w3c.dom.Document createDocument()
                                           throws javax.xml.parsers.ParserConfigurationException
Creates a new empty XML document.

Returns:
A Document instance
Throws:
javax.xml.parsers.ParserConfigurationException - If the builder cannot be instantiated

parse

public static org.w3c.dom.Document parse(org.xml.sax.InputSource src)
                                  throws javax.xml.parsers.ParserConfigurationException,
                                         org.xml.sax.SAXException,
                                         java.io.IOException
Parses a document from the given source.

Parameters:
src - The source to parse
Returns:
The parsed document
Throws:
javax.xml.parsers.ParserConfigurationException - If the builder cannot be instantiated
org.xml.sax.SAXException - If a syntax error is found
java.io.IOException - If an error occurs reading the source

parse

public static org.w3c.dom.Document parse(java.io.InputStream is)
                                  throws javax.xml.parsers.ParserConfigurationException,
                                         org.xml.sax.SAXException,
                                         java.io.IOException
Parses a document from the given source.

Parameters:
is - The stream to parse
Returns:
The parsed document
Throws:
javax.xml.parsers.ParserConfigurationException - If the builder cannot be instantiated
org.xml.sax.SAXException - If a syntax error is found
java.io.IOException - If an error occurs reading the stream

parse

public static org.w3c.dom.Document parse(java.io.File f)
                                  throws javax.xml.parsers.ParserConfigurationException,
                                         org.xml.sax.SAXException,
                                         java.io.IOException
Parses a document from the given source.

Parameters:
f - The file to parse
Returns:
The parsed document
Throws:
javax.xml.parsers.ParserConfigurationException - If the builder cannot be instantiated
org.xml.sax.SAXException - If a syntax error is found
java.io.IOException - If an error occurs reading the stream

parse

public static org.w3c.dom.Document parse(java.io.Reader reader)
                                  throws javax.xml.parsers.ParserConfigurationException,
                                         org.xml.sax.SAXException,
                                         java.io.IOException
Parses a document from the given source.

Parameters:
reader - The reader to parse
Returns:
The parsed document
Throws:
javax.xml.parsers.ParserConfigurationException - If the builder cannot be instantiated
org.xml.sax.SAXException - If a syntax error is found
java.io.IOException - If an error occurs reading the stream

getResourceAsDocument

public static org.w3c.dom.Document getResourceAsDocument(java.lang.String resName)
                                                  throws javax.xml.parsers.ParserConfigurationException,
                                                         org.xml.sax.SAXException,
                                                         java.io.IOException
Gets a resource from the current context class-loader as a Document instance.

Parameters:
resName - The name of the resource to load
Returns:
A Document instance
Throws:
javax.xml.parsers.ParserConfigurationException - If the parser cannot be instantiated
org.xml.sax.SAXException - If a syntax error is found in the parsed XML
java.io.IOException - If an I/O error occurs while reading the resource

getResourceAsDocument

public static org.w3c.dom.Document getResourceAsDocument(java.lang.ClassLoader cl,
                                                         java.lang.String resName)
                                                  throws javax.xml.parsers.ParserConfigurationException,
                                                         org.xml.sax.SAXException,
                                                         java.io.IOException
Gets a resource as a Document instance.

Parameters:
cl - The ClassLoader to use
resName - The name of the resource to load
Returns:
A Document instance
Throws:
javax.xml.parsers.ParserConfigurationException - If the parser cannot be instantiated
org.xml.sax.SAXException - If a syntax error is found in the parsed XML
java.io.IOException - If an I/O error occurs while reading the resource


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.