|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectinfo.monitorenter.util.StringUtil
public class StringUtil
Nice static helpers for working with Strings. Maybe not always the fastest solution to call in here, but working. Also usabel for seeing examples and cutting code for manual inlining.
| Method Summary | |
|---|---|
static String |
appendSpaces(String s,
int count)
Appends the given amount of spaces to the String. |
static void |
ArraysToString(List objects)
Little String output - helper that modifies the given LinkedList by getting it's Objects and replace them by their toString() - representation. |
static String |
ArrayToString(Object isArr)
If the given Object is no Array, it's toString - method is invoked. |
static String |
getNewLine()
Only call this method once (not in a loop) and keep the result. |
static StringUtil |
instance()
|
static int |
longestStringRepresentation(List objects)
No data is changed in the given List at all. |
static Map.Entry |
prefixIntersection(String a,
String b)
This may be useful for comparison of canonical paths. |
static String |
setSize(String s,
int length)
Appends the necessary amount of spaces to the string until it has the givn length. |
static void |
toLongestString(List objects)
Only use this method in following case: You have got an AbstractList or subclass containing Objects you do not know. You want to transform all Elements in the List to Strings. There might be Array's in the Object (whose toString method will return only their hashcode). What happens? All Objects, even primitive Arrays in your List will be turned to String- representation. The result will replace the old position of the Object in the given List. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static StringUtil instance()
public static final String setSize(String s,
int length)
s - the String to expand.length - the desired length of the String to be returned.
public static final String appendSpaces(String s,
int count)
s - count - public static final String ArrayToString(Object isArr)
Primitive Arrays: "["+isArr[0]+","+isArr[1]+.. ..+isArr[isArr.length-1]+"]"
Object Arrays : "["+isArr[0].toString()+","+isArr[1].toString()+.. ..+isArr[isArr.length-1].toString+"]"
Two or three - dimensional Arrays are not supported (should be reflected in a special output method, e.g.as a field)
other Objects: toString()
isArr - The Array to represent as String.
public static final void ArraysToString(List objects)
public static final void toLongestString(List objects)
public static final int longestStringRepresentation(List objects)
Primitive Arrays: as performed by this classes @see #ArrayToString . Object Arrays : as performed by this classes @see #ArrayToString other Objects: toString() (as performed by this classes @see #ArrayToString ).
public static String getNewLine()
public static Map.Entry prefixIntersection(String a,
String b)
| a | b | .getKey() | .getValue() |
|---|---|---|---|
| computer | compare | comp | are |
| compare | computer | comp | uter |
| computer | put | "" | "" |
| c:/work/myproject/bin/ | c:/work/myproject/bin/cpdetector/io/ClassFileFilter.class | c:/work/myproject/bin/ | cpdetector/io/ClassFileFilter.class |
| c:/work/myproject/bin/cpdetector/io/ClassFileFilter.class | c:/work/myproject/bin/ | c:/work/myproject/bin/ | "" |
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||