org.kahina.core.io.util
Class XMLUtilities

java.lang.Object
  extended by org.kahina.core.io.util.XMLUtilities

public class XMLUtilities
extends Object


Constructor Summary
XMLUtilities()
           
 
Method Summary
static boolean attrBoolVal(Element el, String attrName)
           
static Color attrColorVal(Element el, String attrName)
          Constructs a color from an attribute value in an XML document.
static int attrIntVal(Element el, String attrName)
           
static String attrStrVal(Element el, String attrName)
           
static List<Element> getChildElements(Element el)
           
static List<Element> getElements(Element el, String elName)
           
static Document newEmptyDocument()
           
static Document parseXMLFile(File f, boolean validating)
          parse an XML file
static void writeXML(Node node, String outfile)
          Generates an XML file at a specified path containing the contents of a DOM node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtilities

public XMLUtilities()
Method Detail

parseXMLFile

public static Document parseXMLFile(File f,
                                    boolean validating)
parse an XML file

Parameters:
f - the XML file
validating - toggle validation
Returns:
the parsed document

newEmptyDocument

public static Document newEmptyDocument()

writeXML

public static void writeXML(Node node,
                            String outfile)
Generates an XML file at a specified path containing the contents of a DOM node

Parameters:
node - - the DOM node whose content is output into the file
outfile - - the path to the XML file that is to be generated

attrBoolVal

public static boolean attrBoolVal(Element el,
                                  String attrName)

attrColorVal

public static Color attrColorVal(Element el,
                                 String attrName)
Constructs a color from an attribute value in an XML document. Expects the color to be encoded as color(R,G,B). Outputs an informative error message and returns Color.WHITE on error.

Parameters:
el - the element whose attribute we access
attrName - name of the attribute whose value encodes the color
Returns:
the color at the specified element and attribute

attrIntVal

public static int attrIntVal(Element el,
                             String attrName)

attrStrVal

public static String attrStrVal(Element el,
                                String attrName)

getElements

public static List<Element> getElements(Element el,
                                        String elName)

getChildElements

public static List<Element> getChildElements(Element el)