org.jscience.architecture.traffic.xml
Class XMLUtils

java.lang.Object
  extended by org.jscience.architecture.traffic.xml.XMLUtils

public class XMLUtils
extends java.lang.Object

This class contains a few static utility methods that are used by the various parts of the XML parser


Constructor Summary
XMLUtils()
           
 
Method Summary
static java.lang.String fromXMLString(java.lang.String s)
          Decodes a string which is encoded with toXMLString.
static java.lang.String getGenericName(java.lang.String fullName)
          Convert a full XML name to its generic name.
static java.lang.String getGenericName(java.lang.String fullName, boolean removeArrays)
          Convert a full XML name to its generic name.
static java.lang.String getLastName(java.lang.String fullName)
          Calculates the last name of a XML path name
static java.lang.String getLastName(XMLSerializable object)
          Calculates the last name of a XMLSerializable object
static int getLevel(java.lang.String fullName)
          Calculates the level of a XML path name
static java.lang.String getParentName(java.lang.String fullName)
          Calculates the parent path name of a XML path name
static java.lang.String getParentName(XMLSerializable object)
          Calculates the parent path name of a XML path name
static java.lang.String getSpecificLastName(java.lang.String fullName)
          Takes the last name of a full XML tag name.
static void loadSecondStage(java.util.Enumeration e, java.util.Dictionary dictionaries)
          Load the second stage of an enumeration of objects that implement TwoStageLoader
static void setParentName(java.util.Enumeration e, java.lang.String newParentName)
          Sets new parentNames for every element in an enumeration of XMLSerializables.
static java.lang.String toXMLString(java.lang.String s)
          Encodes characters which can confuse the XML parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtils

public XMLUtils()
Method Detail

getLastName

public static java.lang.String getLastName(java.lang.String fullName)
Calculates the last name of a XML path name

Parameters:
fullName - The path name
Returns:
Its last name

getLastName

public static java.lang.String getLastName(XMLSerializable object)
Calculates the last name of a XMLSerializable object

Parameters:
object - The XMLSerializable object
Returns:
Its last name

getParentName

public static java.lang.String getParentName(java.lang.String fullName)
Calculates the parent path name of a XML path name

Parameters:
fullName - The path name
Returns:
The path of its parent

getParentName

public static java.lang.String getParentName(XMLSerializable object)
Calculates the parent path name of a XML path name

Parameters:
object - The XMLSerializable object
Returns:
The path of its parent

getLevel

public static int getLevel(java.lang.String fullName)
Calculates the level of a XML path name

Parameters:
fullName - The path name
Returns:
the level

toXMLString

public static java.lang.String toXMLString(java.lang.String s)
Encodes characters which can confuse the XML parser. Every non-alphanumeric string should be processed by this method before saving!

Parameters:
s - The string to encode
Returns:
The result

fromXMLString

public static java.lang.String fromXMLString(java.lang.String s)
Decodes a string which is encoded with toXMLString.

Parameters:
s - The string to decode
Returns:
The result

getGenericName

public static java.lang.String getGenericName(java.lang.String fullName)
Convert a full XML name to its generic name. This is done by checking if each part of the name is complex (if it consists of a generic name plus a specific name). If so, then the specific part is removed. Array elements are also removed from the name. Example of a complex name : model.infrastructure.node-edge.spdata Result of getGenericName : model.infrastructure.node.spdata

Parameters:
fullName - The XML name
Returns:
The result

getGenericName

public static java.lang.String getGenericName(java.lang.String fullName,
                                              boolean removeArrays)
Convert a full XML name to its generic name. This is done by checking if each part of the name is complex (if it consists of a generic name plus a specific name). If so, then the specific part is removed. Example of a complex name : model.infrastructure.node-edge.spdata Result of getGenericName : model.infrastructure.node.spdata

Parameters:
fullName - The XML name
removeArrays - Wether array elements have to be removed from the name.
Returns:
The result

getSpecificLastName

public static java.lang.String getSpecificLastName(java.lang.String fullName)
Takes the last name of a full XML tag name. If it consists of a generic part and a specific part, then the generic part is removed. examples : "model.infrastructure.node-edge" becomes "edge" : "model.infrastructure' becomes "infrastructure"

Parameters:
fullName - The full XML tag name to convert
Returns:
The result

loadSecondStage

public static void loadSecondStage(java.util.Enumeration e,
                                   java.util.Dictionary dictionaries)
                            throws XMLInvalidInputException,
                                   XMLTreeException
Load the second stage of an enumeration of objects that implement TwoStageLoader

Parameters:
e - The enumeration of TwoStageLoaders
dictionaries - The main dictionary to load them with
Throws:
XMLInvalidInputException - If one of the elements in the enumeration is not a TwoStageLoader
XMLTreeException - DOCUMENT ME!

setParentName

public static void setParentName(java.util.Enumeration e,
                                 java.lang.String newParentName)
                          throws XMLTreeException
Sets new parentNames for every element in an enumeration of XMLSerializables.

Parameters:
e - The enumeration of XMLSerializables
newParentName - The new p
Throws:
XMLTreeException - If one of the elements in the enumeration is not XMLSerializable