org.xiruss.util
Class DataUtil

java.lang.Object
  extended by org.xiruss.util.DataUtil

public class DataUtil
extends java.lang.Object


Field Summary
(package private) static org.apache.log4j.Logger logger
           
 
Constructor Summary
DataUtil()
           
 
Method Summary
static java.lang.String byteToHex(byte b)
           
static java.lang.String charToHex(char c)
           
static java.lang.String echoEndTag(org.w3c.dom.Element elem)
           
static java.lang.String echoStartTag(org.w3c.dom.Element elem)
           
static java.lang.String escapeUnicodeString(java.lang.String inString)
           
static java.lang.String escapeXmlMarkup(java.lang.String line)
           
static org.w3c.dom.Element getAttHolder(org.w3c.dom.Element startNode, java.lang.String attName)
          Returns element that exhibits the specified attribute, walking up the element hierarchy.
static long getCharacterCount(java.io.File inFile, java.lang.String charSetName)
           
static java.lang.String getCharacterEncodingForFile(java.io.File inFile)
          Returns the characater encoding for the file.
static org.w3c.dom.Element getElement(org.w3c.dom.Element parentElem, java.lang.String tagName)
          Returns the element with the specified tag name.
static java.util.List getElementChildren(org.w3c.dom.Element elem)
           
static ElementIterator getElementChildrenIterator(org.w3c.dom.Element elem)
           
static java.lang.String getElementContent(org.w3c.dom.Element elem)
          Returns the string content of an element (e.g., xsl:value-of()).
static java.lang.String getElementLanguage(org.w3c.dom.Element elemNode, java.lang.String defaultLangCode)
          Returns the language code associated with the specified element.
static org.w3c.dom.Element getFirstElementChild(org.w3c.dom.Element elemNode)
          Returns the first element node within the children of the specified element.
static int getIntForHexChar(char hexChar)
           
static java.lang.String getMimeTypeForFile(java.io.File memberFile)
           
static boolean hasElementChildren(org.w3c.dom.Element elemNode)
          Returns true if the input element has element children.
static byte[] hexToBytes(java.lang.String hexString)
           
static boolean isTextFile(java.io.File inFile)
          Returns true if the input file appears to be a text file.
static java.lang.String lastPathToken(java.lang.String path)
          Returns the last token of a tokenized file path.
static java.lang.String readUnicodeFile(java.lang.String filePath, java.lang.String encoding)
          Given the path to a file in the specified encoding, returns a single string with the contents of that file.
static java.lang.String stripAngleBrackets(java.lang.String toStrip)
           
static java.util.Vector<java.lang.String> tokenizePath(java.lang.String path)
           
static void writeCollationRulesForLocale(java.util.Locale locale, java.lang.String outFilePath)
           
static void writeUnicodeFile(java.lang.String outString, java.lang.String filePath, java.lang.String encoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger
Constructor Detail

DataUtil

public DataUtil()
Method Detail

stripAngleBrackets

public static java.lang.String stripAngleBrackets(java.lang.String toStrip)

hexToBytes

public static byte[] hexToBytes(java.lang.String hexString)

echoStartTag

public static java.lang.String echoStartTag(org.w3c.dom.Element elem)

echoEndTag

public static java.lang.String echoEndTag(org.w3c.dom.Element elem)

getAttHolder

public static org.w3c.dom.Element getAttHolder(org.w3c.dom.Element startNode,
                                               java.lang.String attName)
Returns element that exhibits the specified attribute, walking up the element hierarchy.

Parameters:
startNode - The node to check first. It's ancestors will be interogated until the attribute is found or the root is reached.
attName - The name of the attribute to find.
Returns:
Returns the element or null if not found.
Throws:
I18nServiceError

getFirstElementChild

public static org.w3c.dom.Element getFirstElementChild(org.w3c.dom.Element elemNode)
Returns the first element node within the children of the specified element.

Parameters:
elemNode - The element whose first element child is to be returned.

hasElementChildren

public static boolean hasElementChildren(org.w3c.dom.Element elemNode)
Returns true if the input element has element children.

Parameters:
elemNode -

getElementContent

public static java.lang.String getElementContent(org.w3c.dom.Element elem)
Returns the string content of an element (e.g., xsl:value-of()).

Parameters:
elem - Element to get the value of.

getElementLanguage

public static java.lang.String getElementLanguage(org.w3c.dom.Element elemNode,
                                                  java.lang.String defaultLangCode)
Returns the language code associated with the specified element.

Parameters:
elemNode - The whose language value is to be returned.
defaultLangCode - The default language code to return if there is no explicit language code.

getElement

public static org.w3c.dom.Element getElement(org.w3c.dom.Element parentElem,
                                             java.lang.String tagName)
                                      throws DataUtilException
Returns the element with the specified tag name. Throws an exception if element not found or if more than one found.

Throws:
DataUtilException

getIntForHexChar

public static int getIntForHexChar(char hexChar)

escapeUnicodeString

public static java.lang.String escapeUnicodeString(java.lang.String inString)

byteToHex

public static java.lang.String byteToHex(byte b)

charToHex

public static java.lang.String charToHex(char c)

readUnicodeFile

public static java.lang.String readUnicodeFile(java.lang.String filePath,
                                               java.lang.String encoding)
                                        throws DataUtilException
Given the path to a file in the specified encoding, returns a single string with the contents of that file.

Parameters:
filePath - The local path to the file
encoding - The encoding name: UTF8, UTF16, etc.
Throws:
DataUtilException

writeUnicodeFile

public static void writeUnicodeFile(java.lang.String outString,
                                    java.lang.String filePath,
                                    java.lang.String encoding)
                             throws DataUtilException
Throws:
DataUtilException

writeCollationRulesForLocale

public static void writeCollationRulesForLocale(java.util.Locale locale,
                                                java.lang.String outFilePath)
                                         throws DataUtilException
Throws:
DataUtilException

getMimeTypeForFile

public static java.lang.String getMimeTypeForFile(java.io.File memberFile)
Parameters:
memberFile -
Returns:

isTextFile

public static boolean isTextFile(java.io.File inFile)
Returns true if the input file appears to be a text file.

Parameters:
inFile -
Returns:

getCharacterEncodingForFile

public static java.lang.String getCharacterEncodingForFile(java.io.File inFile)
                                                    throws java.io.FileNotFoundException,
                                                           java.io.IOException
Returns the characater encoding for the file.

Parameters:
inFile -
Returns:
Throws:
java.io.FileNotFoundException
java.io.IOException

escapeXmlMarkup

public static java.lang.String escapeXmlMarkup(java.lang.String line)
Parameters:
line -
Returns:

tokenizePath

public static java.util.Vector<java.lang.String> tokenizePath(java.lang.String path)
Parameters:
docKey -
Returns:

getCharacterCount

public static long getCharacterCount(java.io.File inFile,
                                     java.lang.String charSetName)
Parameters:
inFile -
Returns:

lastPathToken

public static java.lang.String lastPathToken(java.lang.String path)
Returns the last token of a tokenized file path.

Returns:

getElementChildren

public static java.util.List getElementChildren(org.w3c.dom.Element elem)

getElementChildrenIterator

public static ElementIterator getElementChildrenIterator(org.w3c.dom.Element elem)