com.planet_ink.coffee_mud.Libraries
Class XMLManager

java.lang.Object
  extended by com.planet_ink.coffee_mud.Libraries.StdLibrary
      extended by com.planet_ink.coffee_mud.Libraries.XMLManager
All Implemented Interfaces:
CMObject, CMLibrary, XMLLibrary, java.lang.Cloneable, java.lang.Comparable<CMObject>

public class XMLManager
extends StdLibrary
implements XMLLibrary


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.XMLLibrary
XMLLibrary.XMLpiece
 
Field Summary
 
Fields inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.XMLLibrary
FILE_XML_BOUNDARY, HEX_DIGITS
 
Constructor Summary
XMLManager()
           
 
Method Summary
protected  boolean acceptableTag(java.lang.StringBuffer str, int start, int end)
           
 java.lang.String convertXMLtoTag(java.lang.String TName, boolean Data)
          Return the outer wrapper and contents of an XML tag Data

Usage: Data+=XMLoTag("MODELOBJECTONE",VA.ModelObjectOne);
 java.lang.String convertXMLtoTag(java.lang.String TName, int Data)
          Return the outer wrapper and contents of an XML tag Data

Usage: Data+=XMLoTag("MODELOBJECTONE",VA.ModelObjectOne);
 java.lang.String convertXMLtoTag(java.lang.String TName, long Data)
          Return the outer wrapper and contents of an XML tag Data

Usage: Data+=XMLoTag("MODELOBJECTONE",VA.ModelObjectOne);
 java.lang.String convertXMLtoTag(java.lang.String TName, short Data)
          Return the outer wrapper and contents of an XML tag Data

Usage: Data+=XMLoTag("MODELOBJECTONE",VA.ModelObjectOne);
 java.lang.String convertXMLtoTag(java.lang.String TName, java.lang.String Data)
          Return the outer wrapper and contents of an XML tag Data

Usage: Data+=XMLoTag("MODELOBJECTONE",VA.ModelObjectOne);
 boolean getBoolFromPieces(java.util.List<XMLLibrary.XMLpiece> V, java.lang.String tag)
          Return the data value within a given XML block Data

Usage: String ThisColHead=getBoolFromPieces(ThisRow,"TD");
 java.util.List<XMLLibrary.XMLpiece> getContentsFromPieces(java.util.List<XMLLibrary.XMLpiece> V, java.lang.String tag)
          Returns the contents of a container tag, searched for in another container tags contents
 double getDoubleFromPieces(java.util.List<XMLLibrary.XMLpiece> V, java.lang.String tag)
          Return the data value within a given XML block Data

Usage: String ThisColHead=getDoubleFromPieces(ThisRow,"TD");
 int getIntFromPieces(java.util.List<XMLLibrary.XMLpiece> V, java.lang.String tag)
          Return the data value within a given XML block Data

Usage: String ThisColHead=getIntFromPieces(ThisRow,"TD");
 long getLongFromPieces(java.util.List<XMLLibrary.XMLpiece> V, java.lang.String tag)
          Return the data value within a given XML block Data

Usage: String ThisColHead=getLongFromPieces(ThisRow,"TD");
 java.lang.String getParmValue(java.util.Map<java.lang.String,java.lang.String> parmSet, java.lang.String Tag)
          Return a parameter value within an XML tag

Usage: String ThisColHead=getParmValue(parmSet,"TD");
 XMLLibrary.XMLpiece getPieceFromPieces(java.util.List<XMLLibrary.XMLpiece> V, java.lang.String tag)
          Returns the xml tag node for the given tag name, if found in the given tag container contents
 short getShortFromPieces(java.util.List<XMLLibrary.XMLpiece> V, java.lang.String tag)
          Return the data value within a given XML block Data

Usage: String ThisColHead=getShortFromPieces(ThisRow,"TD");
 java.lang.String getValFromPieces(java.util.List<XMLLibrary.XMLpiece> V, java.lang.String tag)
          Returns the value of the tag, if it exists in the given tag collection
 java.lang.String getXMLList(java.util.List<java.lang.String> V)
          Converts the given list of strings into a set of top-level xml tags called simply
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
protected  XMLLibrary.XMLpiece nextXML(java.lang.StringBuffer buf, XMLLibrary.XMLpiece parent, int start)
           
 java.util.List<XMLLibrary.XMLpiece> parseAllXML(java.lang.String buf)
          Parses all xml inside the given string buffer and returns the root tags as a container collection.
 java.util.List<XMLLibrary.XMLpiece> parseAllXML(java.lang.StringBuffer buf)
          Parses all xml inside the given stringbuffer and returns the root tags as a container collection.
 java.lang.String parseOutAngleBrackets(java.lang.String s)
          parse a tag value for safety

Usage: String val=parseOutAngleBrackets(ThisValue);
protected  java.lang.String parseOutParms(java.lang.String blk, java.util.Hashtable parmList)
           
protected  java.util.Hashtable parseParms(java.lang.String Blob)
           
 java.util.List<java.lang.String> parseXMLList(java.lang.String numberedList)
          Parses a list of single-level xml tags, together in string.
 java.lang.String restoreAngleBrackets(java.lang.String s)
          restore a tag value parsed for safety

Usage: String val=restoreAngleBrackets(ThisValue);
 java.lang.String returnXMLBlock(java.lang.String Blob, java.lang.String Tag)
          Return the contents of an XML tag, given the tag to search for

Usage: String XML=returnXMLBlock(Response,"PDIModelErrors");
 boolean returnXMLBoolean(java.lang.String Blob, java.lang.String Tag)
          Return the data value within a given XML block Data

Usage: String ThisColHead=returnXMLValue(ThisRow,"TD");
 java.lang.String returnXMLValue(java.lang.String Blob)
          Return the data value within the first XML block Data

Usage: String ThisColHead=returnXMLValue(ThisRow);
 java.lang.String returnXMLValue(java.lang.String Blob, java.lang.String Tag)
          Return the data value within a given XML block Data

Usage: String ThisColHead=returnXMLValue(ThisRow,"TD");
 double s_double(java.lang.String DOUBLE)
          Returns the double value of a string without crashing

Usage: dSize = WebIQBase.s_double(WebIQBase.getRes(AttStatsRes,"BlobSize"));
 int s_int(java.lang.String INT)
          Returns the integer value of a string without crashing

Usage: int num=s_int(CMD.substring(14));
 long s_long(java.lang.String LONG)
          Returns the long value of a string without crashing

Usage: int num=s_long(CMD.substring(14));
 short s_short(java.lang.String SHORT)
          Returns the short value of a string without crashing

Usage: int num=s_short(CMD.substring(14));
 
Methods inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
activate, compareTo, copyOf, getSupportThread, initializeClass, newInstance, propertiesLoaded, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.CMLibrary
activate, getSupportThread, propertiesLoaded, shutdown
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, initializeClass, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

XMLManager

public XMLManager()
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, MiscTech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Overrides:
ID in class StdLibrary
Returns:
the name of this class

parseOutAngleBrackets

public java.lang.String parseOutAngleBrackets(java.lang.String s)
Description copied from interface: XMLLibrary
parse a tag value for safety

Usage: String val=parseOutAngleBrackets(ThisValue);

Specified by:
parseOutAngleBrackets in interface XMLLibrary
Parameters:
s - String to parse
Returns:
String parsed value

restoreAngleBrackets

public java.lang.String restoreAngleBrackets(java.lang.String s)
Description copied from interface: XMLLibrary
restore a tag value parsed for safety

Usage: String val=restoreAngleBrackets(ThisValue);

Specified by:
restoreAngleBrackets in interface XMLLibrary
Parameters:
s - String to parse
Returns:
String unparsed value

s_double

public double s_double(java.lang.String DOUBLE)
Returns the double value of a string without crashing

Usage: dSize = WebIQBase.s_double(WebIQBase.getRes(AttStatsRes,"BlobSize"));

Parameters:
DOUBLE - String to convert
Returns:
double Double value of the string

s_int

public int s_int(java.lang.String INT)
Returns the integer value of a string without crashing

Usage: int num=s_int(CMD.substring(14));

Parameters:
INT - Integer value of string
Returns:
int Integer value of the string

s_short

public short s_short(java.lang.String SHORT)
Returns the short value of a string without crashing

Usage: int num=s_short(CMD.substring(14));

Parameters:
SHORT - Short value of string
Returns:
short Short value of the string

s_long

public long s_long(java.lang.String LONG)
Returns the long value of a string without crashing

Usage: int num=s_long(CMD.substring(14));

Parameters:
LONG - Long value of string
Returns:
long Long value of the string

convertXMLtoTag

public java.lang.String convertXMLtoTag(java.lang.String TName,
                                        java.lang.String Data)
Return the outer wrapper and contents of an XML tag Data

Usage: Data+=XMLoTag("MODELOBJECTONE",VA.ModelObjectOne);

Specified by:
convertXMLtoTag in interface XMLLibrary
Parameters:
TName - Tag name to use
Data - the data to embed
Returns:
String Information corresponding to the tname

convertXMLtoTag

public java.lang.String convertXMLtoTag(java.lang.String TName,
                                        int Data)
Return the outer wrapper and contents of an XML tag Data

Usage: Data+=XMLoTag("MODELOBJECTONE",VA.ModelObjectOne);

Specified by:
convertXMLtoTag in interface XMLLibrary
Parameters:
TName - Tag name to use
Data - the data to embed
Returns:
String Information corresponding to the tname

convertXMLtoTag

public java.lang.String convertXMLtoTag(java.lang.String TName,
                                        short Data)
Return the outer wrapper and contents of an XML tag Data

Usage: Data+=XMLoTag("MODELOBJECTONE",VA.ModelObjectOne);

Specified by:
convertXMLtoTag in interface XMLLibrary
Parameters:
TName - Tag name to use
Data - the data to embed
Returns:
String Information corresponding to the tname

convertXMLtoTag

public java.lang.String convertXMLtoTag(java.lang.String TName,
                                        boolean Data)
Return the outer wrapper and contents of an XML tag Data

Usage: Data+=XMLoTag("MODELOBJECTONE",VA.ModelObjectOne);

Specified by:
convertXMLtoTag in interface XMLLibrary
Parameters:
TName - Tag name to use
Data - the data to embed
Returns:
String Information corresponding to the tname

convertXMLtoTag

public java.lang.String convertXMLtoTag(java.lang.String TName,
                                        long Data)
Return the outer wrapper and contents of an XML tag Data

Usage: Data+=XMLoTag("MODELOBJECTONE",VA.ModelObjectOne);

Specified by:
convertXMLtoTag in interface XMLLibrary
Parameters:
TName - Tag name to use
Data - the data to embed
Returns:
String Information corresponding to the tname

returnXMLBlock

public java.lang.String returnXMLBlock(java.lang.String Blob,
                                       java.lang.String Tag)
Return the contents of an XML tag, given the tag to search for

Usage: String XML=returnXMLBlock(Response,"PDIModelErrors");

Specified by:
returnXMLBlock in interface XMLLibrary
Parameters:
Blob - String to searh
Tag - Tag name to search for
Returns:
String Information corresponding to the tname

parseOutParms

protected java.lang.String parseOutParms(java.lang.String blk,
                                         java.util.Hashtable parmList)

parseParms

protected java.util.Hashtable parseParms(java.lang.String Blob)

getValFromPieces

public java.lang.String getValFromPieces(java.util.List<XMLLibrary.XMLpiece> V,
                                         java.lang.String tag)
Description copied from interface: XMLLibrary
Returns the value of the tag, if it exists in the given tag collection

Specified by:
getValFromPieces in interface XMLLibrary
Parameters:
V - the tag collection (container tag)
tag - the tag to look for
Returns:
its value, or null

getContentsFromPieces

public java.util.List<XMLLibrary.XMLpiece> getContentsFromPieces(java.util.List<XMLLibrary.XMLpiece> V,
                                                                 java.lang.String tag)
Description copied from interface: XMLLibrary
Returns the contents of a container tag, searched for in another container tags contents

Specified by:
getContentsFromPieces in interface XMLLibrary
Parameters:
V - the container tags contents
tag - the tag to look for
Returns:
the tags contained in tag, or null

getPieceFromPieces

public XMLLibrary.XMLpiece getPieceFromPieces(java.util.List<XMLLibrary.XMLpiece> V,
                                              java.lang.String tag)
Description copied from interface: XMLLibrary
Returns the xml tag node for the given tag name, if found in the given tag container contents

Specified by:
getPieceFromPieces in interface XMLLibrary
Parameters:
V - the tag container contents
tag - the tag name
Returns:
the xml tag node for the given tag name

getBoolFromPieces

public boolean getBoolFromPieces(java.util.List<XMLLibrary.XMLpiece> V,
                                 java.lang.String tag)
Description copied from interface: XMLLibrary
Return the data value within a given XML block Data

Usage: String ThisColHead=getBoolFromPieces(ThisRow,"TD");

Specified by:
getBoolFromPieces in interface XMLLibrary
Parameters:
V - Pieces to search
tag - Tag to search for
Returns:
boolean Information from XML block

getIntFromPieces

public int getIntFromPieces(java.util.List<XMLLibrary.XMLpiece> V,
                            java.lang.String tag)
Description copied from interface: XMLLibrary
Return the data value within a given XML block Data

Usage: String ThisColHead=getIntFromPieces(ThisRow,"TD");

Specified by:
getIntFromPieces in interface XMLLibrary
Parameters:
V - Pieces to search
tag - Tag to search for
Returns:
int Information from XML block

getShortFromPieces

public short getShortFromPieces(java.util.List<XMLLibrary.XMLpiece> V,
                                java.lang.String tag)
Description copied from interface: XMLLibrary
Return the data value within a given XML block Data

Usage: String ThisColHead=getShortFromPieces(ThisRow,"TD");

Specified by:
getShortFromPieces in interface XMLLibrary
Parameters:
V - Pieces to search
tag - Tag to search for
Returns:
short Information from XML block

getLongFromPieces

public long getLongFromPieces(java.util.List<XMLLibrary.XMLpiece> V,
                              java.lang.String tag)
Description copied from interface: XMLLibrary
Return the data value within a given XML block Data

Usage: String ThisColHead=getLongFromPieces(ThisRow,"TD");

Specified by:
getLongFromPieces in interface XMLLibrary
Parameters:
V - Pieces to search
tag - Tag to search for
Returns:
long Information from XML block

getDoubleFromPieces

public double getDoubleFromPieces(java.util.List<XMLLibrary.XMLpiece> V,
                                  java.lang.String tag)
Description copied from interface: XMLLibrary
Return the data value within a given XML block Data

Usage: String ThisColHead=getDoubleFromPieces(ThisRow,"TD");

Specified by:
getDoubleFromPieces in interface XMLLibrary
Parameters:
V - Pieces to search
tag - Tag to search for
Returns:
double Information from XML block

acceptableTag

protected boolean acceptableTag(java.lang.StringBuffer str,
                                int start,
                                int end)

nextXML

protected XMLLibrary.XMLpiece nextXML(java.lang.StringBuffer buf,
                                      XMLLibrary.XMLpiece parent,
                                      int start)

parseAllXML

public java.util.List<XMLLibrary.XMLpiece> parseAllXML(java.lang.String buf)
Description copied from interface: XMLLibrary
Parses all xml inside the given string buffer and returns the root tags as a container collection.

Specified by:
parseAllXML in interface XMLLibrary
Parameters:
buf - the string to parse
Returns:
the parsed xml

parseAllXML

public java.util.List<XMLLibrary.XMLpiece> parseAllXML(java.lang.StringBuffer buf)
Description copied from interface: XMLLibrary
Parses all xml inside the given stringbuffer and returns the root tags as a container collection.

Specified by:
parseAllXML in interface XMLLibrary
Parameters:
buf - the string to parse
Returns:
the parsed xml

returnXMLValue

public java.lang.String returnXMLValue(java.lang.String Blob)
Description copied from interface: XMLLibrary
Return the data value within the first XML block Data

Usage: String ThisColHead=returnXMLValue(ThisRow);

Specified by:
returnXMLValue in interface XMLLibrary
Parameters:
Blob - String to searh
Returns:
String Information from first XML block

returnXMLValue

public java.lang.String returnXMLValue(java.lang.String Blob,
                                       java.lang.String Tag)
Description copied from interface: XMLLibrary
Return the data value within a given XML block Data

Usage: String ThisColHead=returnXMLValue(ThisRow,"TD");

Specified by:
returnXMLValue in interface XMLLibrary
Parameters:
Blob - String to search
Tag - Tag to search for
Returns:
String Information from XML block

returnXMLBoolean

public boolean returnXMLBoolean(java.lang.String Blob,
                                java.lang.String Tag)
Description copied from interface: XMLLibrary
Return the data value within a given XML block Data

Usage: String ThisColHead=returnXMLValue(ThisRow,"TD");

Specified by:
returnXMLBoolean in interface XMLLibrary
Parameters:
Blob - String to search
Tag - Tag to search for
Returns:
String Information from XML block

getParmValue

public java.lang.String getParmValue(java.util.Map<java.lang.String,java.lang.String> parmSet,
                                     java.lang.String Tag)
Description copied from interface: XMLLibrary
Return a parameter value within an XML tag

Usage: String ThisColHead=getParmValue(parmSet,"TD");

Specified by:
getParmValue in interface XMLLibrary
Parameters:
parmSet - set of parms to search
Tag - Tag to search for
Returns:
String Parameter value

getXMLList

public java.lang.String getXMLList(java.util.List<java.lang.String> V)
Description copied from interface: XMLLibrary
Converts the given list of strings into a set of top-level xml tags called simply

Specified by:
getXMLList in interface XMLLibrary
Parameters:
V - the list of strings
Returns:
the top level xml tags

parseXMLList

public java.util.List<java.lang.String> parseXMLList(java.lang.String numberedList)
Description copied from interface: XMLLibrary
Parses a list of single-level xml tags, together in string. This method assumes that the given string is a series of top level tags, with no child tags, and no attributes. It will parse the tags, and return their values (only) as a list of strings. Any deconversions for compatibility are also performed

Specified by:
parseXMLList in interface XMLLibrary
Parameters:
numberedList - the top level xml tags
Returns:
the list of strings with the values of those tags