Top Fields Constructors Methods
com.ctc.wstx.util

public final Class StringUtil

extends Object
Class Inheritance
Imports
java.util.Collection, .Iterator

Field Summary

Modifier and TypeField and Description
pack-priv static final char
private static final int
EOS

Internal constant used to denote END-OF-STRING

private static final char
pack-priv static String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
public static String
concatEntries(Collection<?> coll, String sep, String lastSep)

public static boolean
public static boolean
equalEncodings(String str1, String str2)

Method that implements a loose String compairon for encoding Strings.

public static String
public static boolean
public static boolean
isAllWhitespace(char[] ch, int start, int len)

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)

public static boolean
matches(String str, char[] cbuf, int offset, int len)

public static String

Returns:

Normalized String, if any white space was removed or normalized; null if no changes were necessary.
normalizeSpaces
(char[]
Buffer that contains the String to check
buf
,
int
Offset of the first character of the text to check in the buffer
origStart
,
int
Offset of the character following the last character of the text (as per usual Java API convention)
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).

public static String
trimEncoding(String str, boolean upperCase)

Method that will remove all non-alphanumeric characters, and optionally upper-case included letters, from the given String.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHAR_SPACEback to summary
pack-priv static final char CHAR_SPACE
EOSback to summary
private static final int EOS

Internal constant used to denote END-OF-STRING

INT_SPACEback to summary
private static final char INT_SPACE
sLFback to summary
pack-priv static String sLF

Constructor Detail

StringUtilback to summary
public StringUtil()

Method Detail

appendLFback to summary
public static void appendLF(StringBuilder sb)
concatEntriesback to summary
public static String concatEntries(Collection<?> coll, String sep, String lastSep)
encodingStartsWithback to summary
public static boolean encodingStartsWith(String enc, String prefix)
equalEncodingsback to summary
public static boolean equalEncodings(String str1, String str2)

Method that implements a loose String compairon for encoding Strings. It will work like String#equalsIgnoreCase, except that it will also ignore all hyphen, underscore and space characters.

getLFback to summary
public static String getLF()
isAllWhitespaceback to summary
public static boolean isAllWhitespace(String str)
isAllWhitespaceback to summary
public static boolean isAllWhitespace(char[] ch, int start, int len)
isSpaceback to summary
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)

Annotations
@SuppressWarnings:cast
matchesback to summary
public static boolean matches(String str, char[] cbuf, int offset, int len)
normalizeSpacesback to summary
public static 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:char[]

Buffer that contains the String to check

origStart:int

Offset of the first character of the text to check in the buffer

origEnd:int

Offset of the character following the last character of the text (as per usual Java API convention)

Returns:String

Normalized String, if any white space was removed or normalized; null if no changes were necessary.

trimEncodingback to summary
public static String trimEncoding(String str, boolean upperCase)

Method that will remove all non-alphanumeric characters, and optionally upper-case included letters, from the given String.