org.jscience.ml.tigerxml.tools
Class StringTools

java.lang.Object
  extended by org.jscience.ml.tigerxml.tools.StringTools

public class StringTools
extends java.lang.Object

Provides methods related to Strings. This class is for static use.


Constructor Summary
StringTools()
           
 
Method Summary
static java.lang.String cleanXMLString(java.lang.String dirtyXMLString)
          Cleans an XML String by translating special characters into XML entity references.
 java.lang.String formatBytes(int bytes)
          Formats a given integer value interpreted as number of bytes to a String representing the value in bytes, KBs, MBs, GBs, or TBs.
static void main(java.lang.String[] args)
           
static int minEditDistance(java.lang.String strA, java.lang.String strB)
          Computes the Minumum Edit Distance between two String objects.
static java.util.ArrayList string2ArrayList(java.lang.String str)
          Returns an ArrayList consisting of the single characters (char) of the argument str.
static void writeStringToFile(java.lang.String str, java.lang.String fileName)
          Writes a given String to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTools

public StringTools()
Method Detail

cleanXMLString

public static final java.lang.String cleanXMLString(java.lang.String dirtyXMLString)
Cleans an XML String by translating special characters into XML entity references. E.g. '&', '<', '>' and '"' by '&amp;', '&lt;', '&gt;' and '&quot;', respectively, and all characters with ASCII code > 127 by the numeric representation.

Parameters:
dirtyXMLString - The XML String to be cleaned
Returns:
The cleaned XML String

formatBytes

public java.lang.String formatBytes(int bytes)
Formats a given integer value interpreted as number of bytes to a String representing the value in bytes, KBs, MBs, GBs, or TBs.

Parameters:
bytes - An integer representing a number of bytes.
Returns:
A String representing bytes in bytes, KBs, MBs, GBs, or TBs.

string2ArrayList

public static final java.util.ArrayList string2ArrayList(java.lang.String str)
Returns an ArrayList consisting of the single characters (char) of the argument str. Each character is packed into a String object.

Parameters:
str - The String to be expanded.
Returns:
An ArrayList of String objects - one String object for each character (char) of the argument str.

minEditDistance

public static final int minEditDistance(java.lang.String strA,
                                        java.lang.String strB)
Computes the Minumum Edit Distance between two String objects. The returned integer is the number of operations (substitution, deletion or insertion) necessary to transform one String to the other.

The Minimum Edit Distance has been used as a measure for similarity between strings. For a detailed description of the algorithm see:

Robert A. Wagner and Michael J. Fischer. 1974.
The string-to-string correction problem.
Journal of the ACM, 21(1):168 173.

Parameters:
strA - The first String.
strB - The second String.
Returns:
The minimum number of operations to transform strA into strB.

writeStringToFile

public static void writeStringToFile(java.lang.String str,
                                     java.lang.String fileName)
Writes a given String to a file.

Parameters:
fileName - The name of the file to be written.
str - The String to be written.

main

public static final void main(java.lang.String[] args)