|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object gate.util.Strings
public class Strings
Some utilities for use with Strings.
Constructor Summary | |
---|---|
Strings()
|
Method Summary | |
---|---|
static String |
addLineNumbers(String text)
Helper method to add line numbers to a string |
static String |
addLineNumbers(String text,
int startLine)
|
static String |
addPadding(String pad,
int n)
Add n pad characters to pad. |
static String |
crop(String text,
int maxLength)
Crop the text in the middle if too long. |
static String |
getFileSep()
Get local fashion for file separators (e.g. "/"). |
static String |
getNl()
Get local fashion for newlines. |
static String |
getPathSep()
Get local fashion for path separators (e.g. ":"). |
static String |
humanReadableByteCount(long bytes,
boolean base10)
Converts a size given as a number of bytes (e.g. a file size) to a human-readable string. |
static Map<String,String> |
toMap(String string)
Get back a Map of String*String from its String representation. |
static LinkedHashSet<String> |
toSet(String string,
String separator)
Get back a Set of String from its String representation. |
static String |
toString(LinkedHashSet<String> set)
Create a String representation of a Set of String with the format [value, value]. |
static String |
toString(Map<String,String> map)
Create a String representation of a Map of String*String with the format {key=value, key=value}. |
static String |
toString(Object object)
Convert about any object to a human readable string. |
static String |
unescape(String str)
A method to unescape Java strings, returning a string containing escape sequences into the respective character. i.e. "\" followed by "t" is turned into the tab character. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Strings()
Method Detail |
---|
public static String getNl()
public static String getPathSep()
public static String getFileSep()
public static String addPadding(String pad, int n)
public static String addLineNumbers(String text)
public static String addLineNumbers(String text, int startLine)
public static String unescape(String str)
str
- the string to unescape
public static String humanReadableByteCount(long bytes, boolean base10)
bytes
- the size to be converted.base10
- if true
then the multiplier used is 10^3 (i.e.
1000 bytes are reported as 1kB, etc.); otherwise 1024 is used as a
multiplier (1024 bytes is 1KiB, etc.).
public static String toString(Object object)
Arrays.deepToString(Object[])
to convert an array or
a collection.
object
- object to be converted to a string
public static String toString(LinkedHashSet<String> set)
set
- set to convert to one String
toSet(String, String)
public static String toString(Map<String,String> map)
map
- map to convert to one String
toMap(String)
public static LinkedHashSet<String> toSet(String string, String separator)
string
- String to convert to a Listseparator
- String that delimits the element of the set
toString(java.util.LinkedHashSet)
public static Map<String,String> toMap(String string)
string
- String to convert to a Map
toString(java.util.Map)
public static String crop(String text, int maxLength)
text
- text to cropmaxLength
- maximum length of the text
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |