|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.rice.cs.util.StringOps
public abstract class StringOps
A class to provide some convenient String operations as static methods. It's abstract to prevent (useless) instantiation, though it can be subclassed to provide convenient namespace importation of its methods.
Field Summary | |
---|---|
static String |
EOL
|
static char |
newline
|
static String |
NEWLINE
|
static char |
SEPARATOR
|
Constructor Summary | |
---|---|
StringOps()
|
Method Summary | |
---|---|
static List<List<List<String>>> |
commandLineToLists(String cmdline)
Convert a command line into a list of list of lists of individual arguments. |
static String |
compress(String s)
|
static String |
convertToLiteral(String s)
Converts the given string to a valid Java string literal. |
static String |
encodeHTML(String s)
Encode &, <, > and newlines as HTML entities. |
static String |
escapeFileName(String s)
Escapes spaces ' ' with the sequence " ", and a single '' with a double. |
static String |
flatten(String s)
Converts newline chars to SEPARATOR char (a solid black upright rectangle). |
static String |
getBlankString(int n)
Gets a string consisting of n blanks. |
static Pair<Integer,Integer> |
getOffsetAndLength(String fullString,
int startRow,
int startCol,
int endRow,
int endCol)
Gets the offset and length equivalent to the given pairs start and end row-col. |
static String |
getSimpleName(Class<?> c)
Returns the simple class name. |
static String |
getStackTrace()
Gets the stack trace of the current code. |
static String |
getStackTrace(Throwable t)
Gets the stack trace of the given Throwable as a String. |
static boolean |
isAnonymousClass(Class<?> c)
Returns true if the class is an anonymous inner class. |
static boolean |
isAsciiDigit(char c)
Character.isDigit answers true to some non-ascii digits. |
static boolean |
isMemberClass(Class<?> c)
Returns true if the class is a member class. |
static String |
memSizeToString(long l)
Return a string representing the approximate amount of memory specified in bytes. |
static String |
replace(String fullString,
String toReplace,
String replacement)
Takes theString fullString and replaces all instances of toReplace with replacement. |
static String |
replaceVariables(String str,
PropertyMaps props,
Lambda2<DrJavaProperty,PropertyMaps,String> getter)
Replace variables of the form "${variable}" with the value associated with the string "variable" in the provided hash table. |
static String |
splitStringAtWordBoundaries(String s,
int widthInChars,
String lineBreak,
String wordSepChars)
Split a string into lines at a certain width, at word boundaries. |
static String |
toString(boolean[] a)
This works just like java.util.Arrays.toString in Java 5.0 but is not version-specific. |
static String |
toString(byte[] a)
This works just like java.util.Arrays.toString in Java 5.0 but is not version-specific. |
static String |
toString(char[] a)
This works just like java.util.Arrays.toString in Java 5.0 but is not version-specific. |
static String |
toString(double[] a)
This works just like java.util.Arrays.toString in Java 5.0 but is not version-specific. |
static String |
toString(float[] a)
This works just like java.util.Arrays.toString in Java 5.0 but is not version-specific. |
static String |
toString(int[] a)
This works just like java.util.Arrays.toString in Java 5.0 but is not version-specific. |
static String |
toString(long[] a)
This works just like java.util.Arrays.toString in Java 5.0 but is not version-specific. |
static String |
toString(Object[] a)
This works just like java.util.Arrays.toString in Java 5.0 but is not version-specific. |
static String |
toString(short[] a)
This works just like java.util.Arrays.toString in Java 5.0 but is not version-specific. |
static String |
unescapeFileName(String s)
Unescapes spaces the sequence " " to a space ' ', and a double '' to a single. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String EOL
public static final String NEWLINE
public static final char newline
public static final char SEPARATOR
Constructor Detail |
---|
public StringOps()
Method Detail |
---|
public static String getBlankString(int n)
public static String replace(String fullString, String toReplace, String replacement)
public static String convertToLiteral(String s)
s
- the normal string to turn into a string literal
public static Pair<Integer,Integer> getOffsetAndLength(String fullString, int startRow, int startCol, int endRow, int endCol)
fullString
- the string in which to compute the offset/lengthstartRow
- the row on which the error starts, starting at one for the first rowstartCol
- the col on which the error starts, starting at one for the first columnendRow
- the row on which the error ends. Equals the startRow for one-line errorsendCol
- the character position on which the error ends. Equals the startCol for one-character errors.
public static String getStackTrace(Throwable t)
t
- the throwable object for which to get the stack trace
public static String getStackTrace()
public static boolean isAsciiDigit(char c)
public static boolean isAnonymousClass(Class<?> c)
c
- class to check
public static boolean isMemberClass(Class<?> c)
c
- class to check
public static String getSimpleName(Class<?> c)
c
- class for which to get the simple name
public static String toString(long[] a)
public static String toString(int[] a)
public static String toString(short[] a)
public static String toString(char[] a)
public static String toString(byte[] a)
public static String toString(boolean[] a)
public static String toString(float[] a)
public static String toString(double[] a)
public static String toString(Object[] a)
public static String encodeHTML(String s)
s
- string to encode
public static String compress(String s)
public static String flatten(String s)
public static String memSizeToString(long l)
l
- memory in bytes
public static String escapeFileName(String s)
s
- string to encode
public static String unescapeFileName(String s)
s
- string to encode
public static List<List<List<String>>> commandLineToLists(String cmdline)
public static String replaceVariables(String str, PropertyMaps props, Lambda2<DrJavaProperty,PropertyMaps,String> getter)
str
- input stringprops
- map with maps of variable-value pairsgetter
- lambda from a DrJavaProperty to String
public static String splitStringAtWordBoundaries(String s, int widthInChars, String lineBreak, String wordSepChars)
s
- string to splitwidthInChars
- approximate width of the new lineslineBreak
- string to be inserted at line breakswordSepChars
- string of characters that can serve as word separators
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |