org.pz.platypus.utilities
Class TextTransforms

java.lang.Object
  extended by org.pz.platypus.utilities.TextTransforms

public class TextTransforms
extends java.lang.Object

Miscellaneous routines for manipulating text in various ways

Author:
alb

Constructor Summary
TextTransforms()
           
 
Method Summary
static java.lang.String charArrayToString(char[] chars)
          converts a char[] to a string.
static java.lang.String charArrayToString(char[] chars, int start, int end)
          converts part (or all) of a char[] to a string.
static java.lang.String lop(java.lang.String text, int count)
          Truncates count number of bytes from the front (left end) of a string
static java.lang.String replaceSubstringAtLocation(java.lang.String baseString, java.lang.String oldSubstring, java.lang.String newSubstring, int startPoint)
          Replace a substring at a specific location in a String with a new substring.
static java.lang.String truncate(java.lang.String text, int count)
          Truncates count number of bytes from the back (right end) of a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTransforms

public TextTransforms()
Method Detail

charArrayToString

public static java.lang.String charArrayToString(char[] chars)
converts a char[] to a string. Note the toString() method of a char[] does not do this.

Parameters:
chars - the char array
Returns:
the equivalent string, or null if an error occurred

charArrayToString

public static java.lang.String charArrayToString(char[] chars,
                                                 int start,
                                                 int end)
converts part (or all) of a char[] to a string. Note: the toString() method os a char[] does not do this.

Parameters:
chars - the char array
start - starting point
end - ending point
Returns:
the string for the section of chars; or null, if an error occurred

replaceSubstringAtLocation

public static java.lang.String replaceSubstringAtLocation(java.lang.String baseString,
                                                          java.lang.String oldSubstring,
                                                          java.lang.String newSubstring,
                                                          int startPoint)
Replace a substring at a specific location in a String with a new substring. Note that the location is needed because the base string could include multiple instances of the substring to be replaced.

Parameters:
baseString - the basic string in which the substitutions are made
oldSubstring - the substring to be replaced
newSubstring - the replacement substring
startPoint - location of the substing
Returns:
the new string with the substitution completed

truncate

public static java.lang.String truncate(java.lang.String text,
                                        int count)
Truncates count number of bytes from the back (right end) of a string

Parameters:
text - the string to truncate
count - how many bytes to truncate
Returns:
the truncated string or, in the case of error, the original string.

lop

public static java.lang.String lop(java.lang.String text,
                                   int count)
Truncates count number of bytes from the front (left end) of a string

Parameters:
text - the string to truncate
count - how much to truncate
Returns:
the truncated string or, in the case of error, the original string.


Copyright © 2008-10 Pacific Data Works LLC