Jeospace API

org.jeospace.xml
Class XMLUtilities

java.lang.Object
  extended byorg.jeospace.xml.XMLUtilities

public abstract class XMLUtilities
extends java.lang.Object

Utility methods for retrieving xml DOM objects from a URL and for obtaining named document Elements.

Version:
$Revision: 1.1.1.1 $
Author:
Rex Melton
See Also:
Document, Element, URL

Constructor Summary
protected XMLUtilities()
          Protected Constructor
 
Method Summary
static org.w3c.dom.Document createNewDocument()
          Create and return a new empty xml DOM object
static java.util.List getChildElements(org.w3c.dom.Element e)
          Return the child Elements of the argument Element
static org.w3c.dom.Document getDocument(org.xml.sax.InputSource is, org.xml.sax.XMLReader reader)
          Create and return a new xml DOM object parsed through an XMLReader from the argument InputSource.
static org.w3c.dom.Document getDocument(java.lang.String documentUrl)
          Create and return a new xml DOM object parsed from the argument url string
static org.w3c.dom.Document getDocument(java.net.URL url)
          Create and return a new xml DOM object parsed from the argument URL
static org.w3c.dom.Document getDocument(java.net.URL baseURL, java.lang.String relativeUrlString)
          Create and return a new xml DOM object parsed from the argument url parameters
static org.w3c.dom.Element getElement(java.lang.String tag, org.w3c.dom.Element e)
          Return the first child Element of the argument Element that matches the argument tagName
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Element e)
          Return the first child Element of the argument Element
static void printNode(org.w3c.dom.Node node, java.io.PrintStream stream)
          Print out a document node to the specified PrintStream.
static void putDocument(org.w3c.dom.Document doc, java.net.URI uri)
          Write out the argument document to the specified URI
static java.lang.String[] slice(java.lang.String string, int[][] indices, java.lang.String[] slices)
          Segment the argument String into an array of substrings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtilities

protected XMLUtilities()
Protected Constructor

Method Detail

getDocument

public static org.w3c.dom.Document getDocument(java.net.URL url)
Create and return a new xml DOM object parsed from the argument URL

Parameters:
url - the document URL
Returns:
a new xml DOM object parsed from the argument URL, or null if one cannot be created.

getDocument

public static org.w3c.dom.Document getDocument(java.net.URL baseURL,
                                               java.lang.String relativeUrlString)
Create and return a new xml DOM object parsed from the argument url parameters

Parameters:
baseURL - the context URL
relativeUrlString - the document path relative to the base URL
Returns:
a new xml DOM object parsed from the argument url parameters, or null if one cannot be created.

getDocument

public static org.w3c.dom.Document getDocument(java.lang.String documentUrl)
Create and return a new xml DOM object parsed from the argument url string

Parameters:
documentUrl - the url string
Returns:
a new xml DOM object parsed from the argument url string, or null if one cannot be created.

getDocument

public static org.w3c.dom.Document getDocument(org.xml.sax.InputSource is,
                                               org.xml.sax.XMLReader reader)
Create and return a new xml DOM object parsed through an XMLReader from the argument InputSource.

Parameters:
is - the InputSource
reader - the XMLReader
Returns:
a new xml DOM object, or null if one cannot be created.

createNewDocument

public static org.w3c.dom.Document createNewDocument()
Create and return a new empty xml DOM object

Returns:
a new empty xml DOM object, or null if one cannot be created.

putDocument

public static void putDocument(org.w3c.dom.Document doc,
                               java.net.URI uri)
Write out the argument document to the specified URI

Parameters:
doc - the document to write
uri - the uri indicating the local file to which to write the document.

getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Element e)
Return the first child Element of the argument Element

Parameters:
e - the argument Element
Returns:
the first child Element of the argument Element, null if the argument Element contains no child Elements

getChildElements

public static java.util.List getChildElements(org.w3c.dom.Element e)
Return the child Elements of the argument Element

Parameters:
e - the argument Element
Returns:
the List of child Elements of the argument Element

getElement

public static org.w3c.dom.Element getElement(java.lang.String tag,
                                             org.w3c.dom.Element e)
Return the first child Element of the argument Element that matches the argument tagName

Parameters:
tag - the tag name
e - the argument Element
Returns:
the first child Element matching the argument tagName, null if an Element with the tag name is not found.

printNode

public static void printNode(org.w3c.dom.Node node,
                             java.io.PrintStream stream)
Print out a document node to the specified PrintStream.

Parameters:
node - the document node.
stream - the ouptput PrintStream

slice

public static java.lang.String[] slice(java.lang.String string,
                                       int[][] indices,
                                       java.lang.String[] slices)
Segment the argument String into an array of substrings.

Parameters:
string - the String to segment
indices - an array of begin/end indices of the desired substrings. An end index of -1 indicates that the remainder of the String from the begin index should be returned.
slices - a String array to initialize with the return substrings. If slices is null, or is not of sufficient capacity, a new String array will be created and returned.
Returns:
the reference to the String array of substrings
Throws:
IndexOutOfBoundsException - if the begin or end indices are invalid per the conditions of String.substring( ).

Jeospace API

Copyright © 2006 - jeospace.org