Package com.ctc.wstx.util
Class StringUtil
- java.lang.Object
-
- com.ctc.wstx.util.StringUtil
-
public final class StringUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static char
CHAR_SPACE
private static int
EOS
Internal constant used to denote END-OF-STRINGprivate static char
INT_SPACE
(package private) static java.lang.String
sLF
-
Constructor Summary
Constructors Constructor Description StringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
appendLF(java.lang.StringBuilder sb)
static java.lang.String
concatEntries(java.util.Collection<?> coll, java.lang.String sep, java.lang.String lastSep)
static boolean
encodingStartsWith(java.lang.String enc, java.lang.String prefix)
static boolean
equalEncodings(java.lang.String str1, java.lang.String str2)
Method that implements a loose String compairon for encoding Strings.static java.lang.String
getLF()
static boolean
isAllWhitespace(char[] ch, int start, int len)
static boolean
isAllWhitespace(java.lang.String str)
static boolean
isSpace(char c)
Note that it is assumed that any "weird" white space (xml 1.1 LSEP and NEL) have been replaced by canonical alternatives (linefeed for element content, regular space for attributes)static boolean
matches(java.lang.String str, char[] cbuf, int offset, int len)
static java.lang.String
normalizeSpaces(char[] buf, int origStart, int origEnd)
Method that will check character array passed, and remove all "extra" spaces (leading and trailing space), and normalize other white space (more than one consequtive space character replaced with a single space).static java.lang.String
trimEncoding(java.lang.String str, boolean upperCase)
Method that will remove all non-alphanumeric characters, and optionally upper-case included letters, from the given String.
-
-
-
Field Detail
-
CHAR_SPACE
static final char CHAR_SPACE
- See Also:
- Constant Field Values
-
INT_SPACE
private static final char INT_SPACE
- See Also:
- Constant Field Values
-
sLF
static java.lang.String sLF
-
EOS
private static final int EOS
Internal constant used to denote END-OF-STRING- See Also:
- Constant Field Values
-
-
Method Detail
-
getLF
public static java.lang.String getLF()
-
appendLF
public static void appendLF(java.lang.StringBuilder sb)
-
concatEntries
public static java.lang.String concatEntries(java.util.Collection<?> coll, java.lang.String sep, java.lang.String lastSep)
-
normalizeSpaces
public static java.lang.String normalizeSpaces(char[] buf, int origStart, int origEnd)
Method that will check character array passed, and remove all "extra" spaces (leading and trailing space), and normalize other white space (more than one consequtive space character replaced with a single space).NOTE: we only remove explicit space characters (char code 0x0020); the reason being that other white space must have come from non-normalizable sources, ie. via entity expansion, and is thus not to be normalized
- Parameters:
buf
- Buffer that contains the String to checkorigStart
- Offset of the first character of the text to check in the bufferorigEnd
- Offset of the character following the last character of the text (as per usual Java API convention)- Returns:
- Normalized String, if any white space was removed or normalized; null if no changes were necessary.
-
isAllWhitespace
public static boolean isAllWhitespace(java.lang.String str)
-
isAllWhitespace
public static boolean isAllWhitespace(char[] ch, int start, int len)
-
equalEncodings
public static boolean equalEncodings(java.lang.String str1, java.lang.String str2)
Method that implements a loose String compairon for encoding Strings. It will work likeString.equalsIgnoreCase(java.lang.String)
, except that it will also ignore all hyphen, underscore and space characters.
-
encodingStartsWith
public static boolean encodingStartsWith(java.lang.String enc, java.lang.String prefix)
-
trimEncoding
public static java.lang.String trimEncoding(java.lang.String str, boolean upperCase)
Method that will remove all non-alphanumeric characters, and optionally upper-case included letters, from the given String.
-
matches
public static boolean matches(java.lang.String str, char[] cbuf, int offset, int len)
-
isSpace
public static final boolean isSpace(char c)
Note that it is assumed that any "weird" white space (xml 1.1 LSEP and NEL) have been replaced by canonical alternatives (linefeed for element content, regular space for attributes)
-
-