|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.internal.xtend.util.StringHelper
public class StringHelper
This class is a collection of helper functions for string handling.
Constructor Summary | |
---|---|
StringHelper()
|
Method Summary | |
---|---|
static boolean |
endsWithAny(java.lang.String str,
java.util.Collection<java.lang.String> prefixes)
tests if a string ends with any one of a collection of prefixes |
static boolean |
endsWithAny(java.lang.String str,
java.lang.String[] prefixes)
tests if a string ends with any one of a collection of prefixes |
static java.lang.String |
escape(java.lang.String src)
replaces special characters that affect formatting with non-formatting character sequences. |
static java.lang.String |
firstLower(java.lang.String str)
|
static java.lang.String |
firstUpper(java.lang.String str)
|
static int |
numMatches(java.lang.String s,
char ch)
returns the number of occurrences of a character in a string |
static int |
numMatches(java.lang.String s,
java.lang.String search)
returns the number of occurrences of a substring in a string |
static java.lang.String |
prettyPrint(java.util.Date date)
formats a date using the default locale settings. |
static java.lang.String |
prettyPrint(long num)
formats a number using the default locale settings. |
static java.lang.String |
prettyPrint(java.lang.Number num)
formats a number using the default locale settings. |
static java.lang.String |
replace(java.lang.String src,
java.lang.String search,
java.lang.String replace)
returns a new string in which one search string is replaced by another. |
static java.util.List<java.lang.String> |
split(java.lang.String value,
java.lang.String delimiter)
Splits a string around matches of the given delimiter character. |
static boolean |
startsWithAny(java.lang.String str,
java.util.Collection<java.lang.String> prefixes)
tests if a string starts with any one of a collection of prefixes |
static boolean |
startsWithAny(java.lang.String str,
java.lang.String[] prefixes)
tests if a string starts with any one of a collection of prefixes |
static java.lang.String |
strip(java.lang.String s,
int numStart,
int numEnd)
removes a number of characters from the beginning and the end of a string |
static java.lang.String |
substring(java.lang.String str,
int beginIndex)
same as String.substring, except that this version handles the case robustly when the index is out of bounds. |
static java.lang.String |
substring(java.lang.String str,
int beginIndex,
int endIndex)
same as String.substring(int, int) , except that this version handles the case robustly when one or both of the indexes is out of
bounds. |
static java.lang.String |
truncate(java.lang.String str,
int maxLen)
truncates a string regardless of its length. |
static java.lang.String |
unescape(java.lang.String src)
undoes the operations of escape |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringHelper()
Method Detail |
---|
public static java.lang.String prettyPrint(long num)
public static java.lang.String prettyPrint(java.lang.Number num)
public static java.lang.String prettyPrint(java.util.Date date)
public static java.lang.String replace(java.lang.String src, java.lang.String search, java.lang.String replace)
public static java.lang.String escape(java.lang.String src)
public static java.lang.String unescape(java.lang.String src)
escape
public static java.lang.String truncate(java.lang.String str, int maxLen)
public static java.lang.String substring(java.lang.String str, int beginIndex)
public static java.lang.String substring(java.lang.String str, int beginIndex, int endIndex)
String.substring(int, int)
, except that this version handles the case robustly when one or both of the indexes is out of
bounds.
public static java.lang.String strip(java.lang.String s, int numStart, int numEnd)
public static int numMatches(java.lang.String s, char ch)
public static int numMatches(java.lang.String s, java.lang.String search)
public static boolean startsWithAny(java.lang.String str, java.util.Collection<java.lang.String> prefixes)
public static boolean startsWithAny(java.lang.String str, java.lang.String[] prefixes)
public static boolean endsWithAny(java.lang.String str, java.util.Collection<java.lang.String> prefixes)
public static boolean endsWithAny(java.lang.String str, java.lang.String[] prefixes)
public static java.lang.String firstUpper(java.lang.String str)
public static java.lang.String firstLower(java.lang.String str)
public static java.util.List<java.lang.String> split(java.lang.String value, java.lang.String delimiter)
This method works similar to String.split(String)
but does not treat the delimiter as a regular expression. This makes it perform
better in most cases where this feature is not necessary. Furthermore this implies that trailing empty segments will not be part of the result.
Copied from org.eclipse.xtext.util.Strings
value
- the string to splitdelimiter
- the delimiting String (e.g. '.' or ':' or '::')
null
and the list does not contain any null
values.
java.lang.NullPointerException
- If the value
is null
String.split(String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |