paulscode.sound.utils
Class XMLParser

java.lang.Object
  extended by paulscode.sound.utils.XMLParser

public class XMLParser
extends java.lang.Object

The XMLParser class provides a somewhat limited interface for reading from and processing XML files.

XMLParser License:

You are free to use this class for any purpose, commercial or otherwise. You may modify this class or source code, and distribute it any way you like, provided the following conditions are met:
1) You may not falsely claim to be the author of this class or any unmodified portion of it.
2) You may not copyright this class or a modified version of it and then sue me for copyright infringement.
3) If you modify the source code, you must clearly document the changes made before redistributing the modified source code, so other users know it is not the original code.
4) You are not required to give me credit for this class in any derived work, but if you do, you must also mention my website: http://www.paulscode.com
5) I the author will not be responsible for any damages (physical, financial, or otherwise) caused by the use if this class or any portion of it.
6) I the author do not guarantee, warrant, or make any representations, either expressed or implied, regarding the use of this class or any portion of it.

Author: Paul Lamb
http://www.paulscode.com


Constructor Summary
XMLParser()
           
 
Method Summary
protected static void errorMessage(java.lang.String message)
          Prints an error message.
static java.lang.String getRawXML(java.net.URL xmlFile)
          Returns a string containing the raw XML that was read and processed from the specified file.
static XMLNode parseXML(java.net.URL xmlFile)
          Parses the XML data contained in the specified file, and returns a list of XML nodes.
static java.lang.String[] seperateWords(java.lang.String text)
          Splits a string on whitespace to generate an array of words.
static java.lang.String trimSpaces(java.lang.String text)
          Trims spaces from a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLParser

public XMLParser()
Method Detail

parseXML

public static XMLNode parseXML(java.net.URL xmlFile)
Parses the XML data contained in the specified file, and returns a list of XML nodes.

Parameters:
xmlFile - URL to an XML file.
Returns:
Handle to the first node.

getRawXML

public static java.lang.String getRawXML(java.net.URL xmlFile)
Returns a string containing the raw XML that was read and processed from the specified file. It longer has any newlines or leading and trailing spaces, and all words are seperated by single spaces.

Parameters:
xmlFile - URL to an XML file.
Returns:
Raw XML.

trimSpaces

public static java.lang.String trimSpaces(java.lang.String text)
Trims spaces from a string. The result no longer has any newlines or leading and trailing spaces, and all words are seperated by single spaces.

Parameters:
text - String to process.
Returns:
String with trimmed spaces.

seperateWords

public static java.lang.String[] seperateWords(java.lang.String text)
Splits a string on whitespace to generate an array of words.

Parameters:
text - String to process.
Returns:
String array containing the words.

errorMessage

protected static void errorMessage(java.lang.String message)
Prints an error message.

Parameters:
message - Error message to print.