paulscode.sound.utils
Class XMLNode

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

public class XMLNode
extends java.lang.Object

The XMLNode class contains an XML tag's name, its parameters, and a handle to the next XMLNode.

XMLNode 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


Field Summary
protected  java.lang.String contents
          Entire contents of the XML tag.
protected  java.lang.String name
          Name of the XML tag.
protected  XMLNode next
          Handle to the next XMLNode.
protected  java.util.HashMap<java.lang.String,java.lang.String> parameters
          Hashmap containing parameter/value pairs for this tag.
 
Constructor Summary
XMLNode(java.lang.String XMLText)
          Constructor: Parses the specified XML text and generates a list of nodes.
 
Method Summary
 java.lang.String contents()
          Returns the entire contents of this tag.
 void displayParameters()
          Prints out the name of this tag and all of its parameters and their values.
protected static void errorMessage(java.lang.String message)
          Prints an error message.
 java.lang.String get(java.lang.String parameter)
          Returns the value of the specified parameter.
 boolean hasNext()
          Checks if there is another XMLNode after this one.
 java.lang.String name()
          Returns the name of this tag.
 XMLNode next()
          Returns the next XMLNode.
 java.util.HashMap<java.lang.String,java.lang.String> parameters()
          Returns a hashmap containing all parameters and their values.
protected  void processTagContents(java.lang.String tagContents)
          Processes a tag's contents, extracting the name and each parameter/value pair.
static void setVerbose(boolean val)
          Sets whether or not to print out messages while loading (default = false).
protected static void warningMessage(java.lang.String message)
          Prints a warning message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Name of the XML tag.


contents

protected java.lang.String contents
Entire contents of the XML tag.


parameters

protected java.util.HashMap<java.lang.String,java.lang.String> parameters
Hashmap containing parameter/value pairs for this tag.


next

protected XMLNode next
Handle to the next XMLNode.

Constructor Detail

XMLNode

public XMLNode(java.lang.String XMLText)
Constructor: Parses the specified XML text and generates a list of nodes. NOTE: The text must have been processed, and longer have any newlines or leading and trailing spaces, and all words must be seperated by single spaces.

Parameters:
XMLText - String containing the XML.
Method Detail

name

public java.lang.String name()
Returns the name of this tag.

Returns:
Tag name, or "" for none.

contents

public java.lang.String contents()
Returns the entire contents of this tag.

Returns:
Tag contents, or "" for none.

hasNext

public boolean hasNext()
Checks if there is another XMLNode after this one.

Returns:
True if there are more nodes.

next

public XMLNode next()
Returns the next XMLNode.

Returns:
Next node, or null if this is the last one.

get

public java.lang.String get(java.lang.String parameter)
Returns the value of the specified parameter.

Returns:
Parameter's value, or "" for none.

parameters

public java.util.HashMap<java.lang.String,java.lang.String> parameters()
Returns a hashmap containing all parameters and their values.

Returns:
String, String pairs.

displayParameters

public void displayParameters()
Prints out the name of this tag and all of its parameters and their values.


processTagContents

protected void processTagContents(java.lang.String tagContents)
Processes a tag's contents, extracting the name and each parameter/value pair.

Parameters:
tagContents - String containing everything between the XML brackets.

setVerbose

public static void setVerbose(boolean val)
Sets whether or not to print out messages while loading (default = false).

Parameters:
val - True to show debug messages.

errorMessage

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

Parameters:
message - Error message to print.

warningMessage

protected static void warningMessage(java.lang.String message)
Prints a warning message.

Parameters:
message - Warning message to print.