|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.tridas.io.util.StringUtils
public class StringUtils
Some handy string utilities.
Method Summary | |
---|---|
static String |
addLefthandZeros(int argNum,
int argNumCharacters)
by daniel, for integer formatting |
static String |
bytesToHex(byte[] in)
|
static String[] |
chopString(String argString,
int argLength)
Chops the string into smaller strings with size of argLength. |
static String |
escapeForCSV(String input)
escapeForCSV given a string, replace any occurances of " with double "'s, and return it surrounded in "'s |
static String |
escapeForXML(String input)
Given a string, escape any < > & ' " characters for XML. |
static int[] |
extractInts(String s)
Convert a sequence of integers in a string into an array of ints. |
static String |
getIntialsFromName(String name,
Integer charLimitGuide)
Takes a full name and returns the initials. |
static String |
getSpaces(int num)
Get a specified number of species |
static Boolean |
isStringWholeInteger(String str)
Returns true if string can be interpreted as a whole number integer. |
static String |
leftPad(String text,
int size)
Pad some text on the left (i.e., right-align it) until it's a specified width. |
static String |
parseInitials(String fullName)
Returns upper case initials from a persons name. |
static String |
rightPad(String text,
int size)
|
static String |
rightPadWithTrim(String text,
int size)
Returns a string of a specified length. |
static String[] |
splitBy(String text,
char sep)
Split some text, using an arbitrary separator character. |
static String[] |
splitByLines(String text)
Split some text into lines. |
static String |
substitute(String str,
String source,
String target)
In a string, replace one substring with another. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String leftPad(String text, int size)
text
- string to padsize
- length of resulting string
public static String rightPadWithTrim(String text, int size)
text
- string to padsize
- length of resulting string
public static String rightPad(String text, int size)
public static String addLefthandZeros(int argNum, int argNumCharacters)
argNum
- argNumCharacters
-
public static String[] chopString(String argString, int argLength)
argString
- argLength
-
public static String[] splitByLines(String text)
"a\nb\nc"
becomes
String[]
{"a","b","c"}
.
text
- the text, separated by '\n'
chars
public static String[] splitBy(String text, char sep)
text
- the textsep
- the separator character to watch for
public static String getSpaces(int num)
num
-
public static int[] extractInts(String s)
For example, extractInts("1 2 3") = int[] { 1, 2, 3 }.
Bug: what happens if the string isn't parseable?
s
- the string to parse
public static String escapeForXML(String input)
input
- a string
public static String escapeForCSV(String input)
input
- a string
public static String substitute(String str, String source, String target)
If str contains source, return a new string with (the first occurrence of) source replaced by target.
If str doesn't contain source (or str is the empty string), returns str.
Think: str ~= s/source/target/
This is like Java 1.4's String.replaceFirst() method; when I decide to drop support for Java 1.3, I can use that method instead.
str
- the base stringsource
- the substring to look fortarget
- the replacement string to use
public static String bytesToHex(byte[] in)
public static String parseInitials(String fullName)
fullName
-
public static Boolean isStringWholeInteger(String str)
str
-
public static String getIntialsFromName(String name, Integer charLimitGuide)
name
- charLimitGuide
- = 2
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |