com.cometway.util
Class StringTools

java.lang.Object
  extended by com.cometway.util.StringTools

public class StringTools
extends java.lang.Object

A set of utilities for manipulating strings.


Constructor Summary
StringTools()
           
 
Method Summary
static java.lang.String[] commaToArray(java.lang.String in)
          This method parses a comma separated String of elements and returns them in an array
static java.lang.String decodeBinHex(java.lang.String binhex)
          This method decodes BinHex 4.0 data.
static java.lang.String decodeBinHex(java.lang.String binhex, boolean decodeMac, boolean verbose)
          This method decodes BinHex 4.0 data.
static java.awt.Dimension getDimension(java.lang.String in)
          returns a the number of rows (lines/Height) and columns (Width) of a string as a java.awt.Dimension
static int getIntParam(java.lang.String[] args, java.lang.String sw)
          returns an int value of a parameter 'sw' given all the parameters 'args'
static java.lang.String getParam(java.lang.String[] args, java.lang.String sw)
          returns a String value of the parameger 'sw' given all the parameter 'args'
static boolean hasParam(java.lang.String[] args, java.lang.String sw)
          returns true if 'sw' is a param within 'args', the list of parameters
static java.util.Vector pairCaseSensitiveSort(java.util.Vector in)
          Sorts Pairs within a vector based on the first object (which should be string)
static java.util.Vector pairSort(java.util.Vector in)
          Case-insensitive Sort of Pairs within a vector based on the first object (which should be string)
static java.lang.String[] parseArgs(java.lang.String in)
          Takes a string and parses them into arguments, preserving backslashes and double quotes.
static java.lang.String removeHTMLTags(java.lang.String in)
          returns a string without anything matching <*> (all HTML tags)
static java.lang.String truncateString(java.awt.Graphics g, java.lang.String inString, int length)
          Returns a string that is guaranteed to fit within 'length' using a FontMetrics of a graphics.
 
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

decodeBinHex

public static java.lang.String decodeBinHex(java.lang.String binhex)
This method decodes BinHex 4.0 data. The data is passed in as a String. If the decoded String is in Mac file format, the Data Fork will automatically be extracted and returned. The CRC will not be checked and the rest of the file will be discarded.

Parameters:
binhex - The BinHex 4.0 data to be decoded and converted.
Returns:
The decoded file and converted to non-Mac format.

decodeBinHex

public static java.lang.String decodeBinHex(java.lang.String binhex,
                                            boolean decodeMac,
                                            boolean verbose)
This method decodes BinHex 4.0 data. The data is passed in as a String. If the decodeMac flag is true, the Data Fork will be extracted out of the decoded Mac file and returned. The CRC will not be checked and the rest of the file will be discarded. If the verbose flag is true, all errors encountered in the BinHex 4.0 data and the Mac file header will be reported to System.err.

Parameters:
binhex - The BinHex 4.0 data to be decoded and/or converted.
decodeMac - If this is TRUE, decoded data will be converted from Mac format.
verbose - If this is TRUE, errors will be reported to System.err.
Returns:
The decoded and/or converted file.

commaToArray

public static java.lang.String[] commaToArray(java.lang.String in)
This method parses a comma separated String of elements and returns them in an array


getDimension

public static java.awt.Dimension getDimension(java.lang.String in)
returns a the number of rows (lines/Height) and columns (Width) of a string as a java.awt.Dimension
 There are some specifics: (h x w)
   ''                           will return  0 x 0
   '\n\n'                       will return  0 x 2
   '\na\na\n'           will return  1 x 3
   '\ra\ra'             will return  1 x 2
   '\n\rabc\n\rab'      will return  3 x 3
   '\r\nabcd\r\n'       will return  4 x 2
 

Parameters:
in - The string to find the max dimension of
Returns:
A Dimension of this String
See Also:
Dimension

getIntParam

public static int getIntParam(java.lang.String[] args,
                              java.lang.String sw)
returns an int value of a parameter 'sw' given all the parameters 'args'


getParam

public static java.lang.String getParam(java.lang.String[] args,
                                        java.lang.String sw)
returns a String value of the parameger 'sw' given all the parameter 'args'


hasParam

public static boolean hasParam(java.lang.String[] args,
                               java.lang.String sw)
returns true if 'sw' is a param within 'args', the list of parameters


removeHTMLTags

public static java.lang.String removeHTMLTags(java.lang.String in)
returns a string without anything matching <*> (all HTML tags)


pairCaseSensitiveSort

public static java.util.Vector pairCaseSensitiveSort(java.util.Vector in)
Sorts Pairs within a vector based on the first object (which should be string)


truncateString

public static java.lang.String truncateString(java.awt.Graphics g,
                                              java.lang.String inString,
                                              int length)
Returns a string that is guaranteed to fit within 'length' using a FontMetrics of a graphics.


pairSort

public static java.util.Vector pairSort(java.util.Vector in)
Case-insensitive Sort of Pairs within a vector based on the first object (which should be string)


parseArgs

public static java.lang.String[] parseArgs(java.lang.String in)
Takes a string and parses them into arguments, preserving backslashes and double quotes.