|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.xml.LimeXMLUtils
Contains utility methods
Constructor Summary | |
LimeXMLUtils()
|
Method Summary | |
static java.lang.String |
capitalizeFirst(java.lang.String str)
takes a string and returns the same string with the first letter capitalized |
static byte[] |
compress(byte[] data)
|
static Response |
createResponse(java.lang.String xml)
Creates a Response instance from the passed xml string |
static java.lang.String |
encodeXML(java.lang.String inData)
Parses the passed string, and encodes the special characters (used in xml for special purposes) with the appropriate codes. |
static java.util.List |
getAttributes(org.w3c.dom.NamedNodeMap nodeMap)
|
static java.lang.String |
getAttributeValue(org.w3c.dom.NamedNodeMap attributes,
java.lang.String soughtAttribute)
Returns the value of the specified attribute |
static org.w3c.dom.Document |
getDocument(java.io.File file)
Returns an instance of org.w3c.dom.Document after parsing the passed xml file |
static java.util.List |
getElements(org.w3c.dom.NodeList nodeList)
Extracts only the Element nodes from a NodeList. |
static org.xml.sax.InputSource |
getInputSource(java.io.File file)
Returns an instance of InputSource after reading the file, and trimming the extraneous white spaces. |
static Response[] |
getResponseArray(java.util.List xmlDocuments)
Converts the given list of xml documents to an array of responses |
static java.lang.String |
getText(org.w3c.dom.NodeList nodeList)
Collapses a list of CDATASection, Text, and predefined EntityReference nodes into a single string. |
static byte[] |
hashFile(java.io.File toHash)
Hashes the file using bits and pieces of the file. |
static boolean |
isMP3File(java.io.File in)
|
static boolean |
isMP3File(java.lang.String in)
|
static boolean |
match(LimeXMLDocument replyDoc,
LimeXMLDocument queryDoc)
Compares the queryDoc with the replyDoc and finds out if the replyDoc is a match for the queryDoc |
static boolean |
notValidXML(java.lang.String inputStr)
Does an approximate check on the passed string for xml validity |
static java.lang.String |
processColName(java.lang.String colName)
picks up the last strng in the colName and return it. |
static byte[] |
readFully(java.io.InputStream in)
Reads all the bytes from the passed input stream till end of stream reached. |
static byte[] |
uncompress(byte[] data)
|
static void |
writeEscapedString(java.io.Writer writer,
java.lang.String string)
Writes string into writer, escaping &, ', ", <, and >
with the XML excape strings. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LimeXMLUtils()
Method Detail |
public static org.xml.sax.InputSource getInputSource(java.io.File file) throws java.io.IOException
file
- The file from where to read
java.io.IOException
- If file doesnt get opened or other I/O problemspublic static org.w3c.dom.Document getDocument(java.io.File file) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
file
- The file from where to read
java.io.IOException
- If file doesnt get opened or other I/O problems
javax.xml.parsers.ParserConfigurationException
- if problem in getting parser
org.xml.sax.SAXException
- If any problem in parsingpublic static java.lang.String getAttributeValue(org.w3c.dom.NamedNodeMap attributes, java.lang.String soughtAttribute)
attributes
- attribute nodes in which to search for the
specified attributesoughtAttribute
- The attribute whose value is sought
public static java.util.List getElements(org.w3c.dom.NodeList nodeList)
public static java.util.List getAttributes(org.w3c.dom.NamedNodeMap nodeMap)
public static java.lang.String getText(org.w3c.dom.NodeList nodeList)
public static void writeEscapedString(java.io.Writer writer, java.lang.String string) throws java.io.IOException
string
into writer, escaping &, ', ", <, and >
with the XML excape strings.
java.io.IOException
public static Response createResponse(java.lang.String xml)
public static byte[] readFully(java.io.InputStream in) throws java.io.IOException
in
- The input stream to read from
java.io.IOException
- If any I/O exception occurs while reading datapublic static boolean match(LimeXMLDocument replyDoc, LimeXMLDocument queryDoc)
queryDoc
- The query DocumentreplyDoc
- potential reply Document
public static boolean isMP3File(java.lang.String in)
public static boolean isMP3File(java.io.File in)
public static Response[] getResponseArray(java.util.List xmlDocuments)
xmlDocuments
- List (of LimeXMLDocument) of xml documentst that
need to be converted to instances of Response class
public static java.lang.String encodeXML(java.lang.String inData)
public static java.lang.String capitalizeFirst(java.lang.String str)
11/2/01 Also replaces any "_" with " "
public static java.lang.String processColName(java.lang.String colName)
public static byte[] compress(byte[] data)
public static byte[] uncompress(byte[] data) throws java.io.IOException
java.io.IOException
public static byte[] hashFile(java.io.File toHash) throws java.io.IOException
java.io.IOException
- if hashing failed for any reason.public static boolean notValidXML(java.lang.String inputStr)
inputStr
- The string to be tested
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |