com.limegroup.gnutella.xml
Class XMLStringUtils

java.lang.Object
  extended bycom.limegroup.gnutella.xml.XMLStringUtils

public class XMLStringUtils
extends java.lang.Object

Provides utility methods to process the canonicalized strings we use to represent XML document structure. The structure is explained below:

So as to preserve the structure, Structure.Field will be represented as Structure__Field (Double Underscore is being used as a delimiter to represent the structure).

In case of multiple structured values with same name, as might occur while using + or * in the regular expressions in schema, those should be represented as using the array index using the __ notation (withouth the square brackets) for e.g. myarray[0].name ==> myarray__0__name

attribute names for an element in the XML schema should be postfixed with __ (double underscore). So element.attribute ==> element__attribute__


Field Summary
static java.lang.String AUDIO_SCHEMA_TAG
          The xml tag for audio schemas.
static java.lang.String DELIMITER
          Delimiter used to preserve the structural information in the canonicalized xml field strings
static java.lang.String MAX_ENDING
          Fields ending with this string are supposed to be representing MAX value in the xml queries
static java.lang.String MIN_ENDING
          Fields ending with this string are supposed to be representing MIN value in the xml queries
static java.lang.String VIDEO_SCHEMA_TAG
          The xml tag for video schemas.
static java.lang.String XML_DOC_START_IDENTIFIER
          Theh minimal part of the the string that is used as a ademiliter between xml documents, when stored in a file.
static java.lang.String XML_VERSION_DELIM
          The xml tag describing the version of xml used.
 
Constructor Summary
XMLStringUtils()
           
 
Method Summary
static java.lang.String getDomainName(java.lang.String schemaURI)
          Returns the domain name part from the passed schemaURI
static java.util.List split(java.lang.String canonicalizedField)
          Breaks the given string (which confirms to the pattern defined above in the class description) into a list (of strings) such that the first element in the list is the top most structural element, and the last one the actual field/attribute name
static java.util.List tokenize(java.lang.String content, java.lang.String delimiter)
          Tokenizes the given string based upon the delimiter passed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELIMITER

public static final java.lang.String DELIMITER
Delimiter used to preserve the structural information in the canonicalized xml field strings

See Also:
Constant Field Values

MAX_ENDING

public static final java.lang.String MAX_ENDING
Fields ending with this string are supposed to be representing MAX value in the xml queries

See Also:
Constant Field Values

MIN_ENDING

public static final java.lang.String MIN_ENDING
Fields ending with this string are supposed to be representing MIN value in the xml queries

See Also:
Constant Field Values

XML_DOC_START_IDENTIFIER

public static final java.lang.String XML_DOC_START_IDENTIFIER
Theh minimal part of the the string that is used as a ademiliter between xml documents, when stored in a file.

See Also:
Constant Field Values

XML_VERSION_DELIM

public static final java.lang.String XML_VERSION_DELIM
The xml tag describing the version of xml used. Used primarly as a delimiter for xml in a Query Reply.

See Also:
Constant Field Values

AUDIO_SCHEMA_TAG

public static final java.lang.String AUDIO_SCHEMA_TAG
The xml tag for audio schemas.

See Also:
Constant Field Values

VIDEO_SCHEMA_TAG

public static final java.lang.String VIDEO_SCHEMA_TAG
The xml tag for video schemas.

See Also:
Constant Field Values
Constructor Detail

XMLStringUtils

public XMLStringUtils()
Method Detail

split

public static java.util.List split(java.lang.String canonicalizedField)
Breaks the given string (which confirms to the pattern defined above in the class description) into a list (of strings) such that the first element in the list is the top most structural element, and the last one the actual field/attribute name

Parameters:
canonicalizedField - The string thats needed to be split
Returns:
List (of strings) . The first element in the list is the top most structural element, and the last one the actual field/attribute name

tokenize

public static java.util.List tokenize(java.lang.String content,
                                      java.lang.String delimiter)
Tokenizes the given string based upon the delimiter passed. No characters are lost from the string (delimiter becomes the start of the tokenized string)

Parameters:
content - The string to be tokenized
delimiter - delimits/identifies the various parts of the content
Returns:
List (of String) of strings formed by chopping the original content

getDomainName

public static java.lang.String getDomainName(java.lang.String schemaURI)
Returns the domain name part from the passed schemaURI

Parameters:
schemaURI - The schema URI whose corresponding domain name to be returned
Returns:
the domain name part from the passed schemaURI. e.g. if passed schemaURI is "http://www.limewire.com/schemas/book.xsd", the return value is "book". If the passed string is "book.xsd", the return value is "book"