cst.util
Class CSTXMLParsingUtility

java.lang.Object
  extended by cst.util.CSTXMLParsingUtility

public class CSTXMLParsingUtility
extends java.lang.Object

A utility class that parses parts of XML files using the DOM parser libraries.


 Copyright 2010 Medical Research Council Unit for Lifelong Health and Ageing
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing, software 
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.  
 

Version:
1.0
Author:
Kevin Garwood (kgarwood@users.sourceforge.net)

Constructor Summary
CSTXMLParsingUtility()
           
 
Method Summary
static java.lang.String escapeXml(java.lang.String str)
          Convenience method for escaping XML characters in a given String.
static java.lang.String getCData(org.w3c.dom.Element element)
           
static org.w3c.dom.Element getElement(org.w3c.dom.Node node, java.lang.String tagName)
           
protected  org.w3c.dom.Element getElement(org.w3c.dom.Node node, java.lang.String tagName, java.lang.String elementName)
           
static java.lang.String getElementValue(org.w3c.dom.Node parentNode, java.lang.String tagName)
           
static java.lang.String getFieldValue(org.w3c.dom.Element element)
          convenience routine for extracting the text value for an element
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node)
           
static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Element element)
           
static java.lang.String getValue(org.w3c.dom.Element element)
           
static boolean interpretBooleanValue(java.lang.String value)
           
static int interpretIntegerValue(java.lang.String value)
           
protected static boolean isRequired(java.lang.String minOccurs)
           
protected static boolean isRequiredOrOptional(java.lang.String minOccurs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSTXMLParsingUtility

public CSTXMLParsingUtility()
Method Detail

escapeXml

public static java.lang.String escapeXml(java.lang.String str)
Convenience method for escaping XML characters in a given String. It translates: The method does not throw a NullPointerException if the given String is null. Instead, it returns a null.

Parameters:
str - The string to be escaped.
Returns:
the string with all XML characters escaped.

isRequired

protected static boolean isRequired(java.lang.String minOccurs)

isRequiredOrOptional

protected static boolean isRequiredOrOptional(java.lang.String minOccurs)

getNextSiblingElement

public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Element element)

getFieldValue

public static java.lang.String getFieldValue(org.w3c.dom.Element element)
convenience routine for extracting the text value for an element


getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node node)

getCData

public static java.lang.String getCData(org.w3c.dom.Element element)

getElementValue

public static java.lang.String getElementValue(org.w3c.dom.Node parentNode,
                                               java.lang.String tagName)

getElement

public static org.w3c.dom.Element getElement(org.w3c.dom.Node node,
                                             java.lang.String tagName)

getElement

protected org.w3c.dom.Element getElement(org.w3c.dom.Node node,
                                         java.lang.String tagName,
                                         java.lang.String elementName)

getValue

public static java.lang.String getValue(org.w3c.dom.Element element)

interpretIntegerValue

public static int interpretIntegerValue(java.lang.String value)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

interpretBooleanValue

public static boolean interpretBooleanValue(java.lang.String value)