Package com.adobe.xfa.ut
Class StringUtils
java.lang.Object
com.adobe.xfa.ut.StringUtils
This class provides some utility methods that were available in jfString, but
are not part of the Java String interface.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<String> Publicly available case-insensitive comparator.static final Comparator<String> Compares Strings based on UCS codepoint values.static final StringSet of characters considered to be white space. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanequalsWithNull(String s1, String s2) General-purpose string equality comparison for strings that may be null.static intfindNoCase(CharSequence source, CharSequence target, int fromIndex) Scan a string for a string, but ignore case.static Comparator<String> Return a comparator that performs case-insensitive string comparisons.static booleanEmpty string test.static LonglongNumber(String s) static LonglongNumber(String s, int radix) static Integerstatic Integerstatic StringparseToken(StringBuilder source) static voidreplace(StringBuilder buf, char find, char rep) static voidreplace(StringBuilder buf, char find, char rep, int start, int limit) static longstatic longsafeLongNumber(String s, int radix) static intsafeNumber(String s) static intsafeNumber(String s, int radix) static intskipOver(CharSequence src, String sSkip, int nOffset) Scan this string for the first character not in the given set.static intskipUntil(CharSequence src, String sSkip, int nOffset) Scan this string for the first character in the given set.static StringReplaces specified characters in the current string with their entity references.static Stringstatic StringtoXML(String sSrc, StringUtils.ToXMLType eTargetType, String sOthers, char cRangeMin, char cRangeMax, String sExclude) Replaces specified characters in the current string with their entity references.static Stringstatic voidtrim(StringBuilder buf) Remove white space from the end of a string buffer.static Stringstatic voidtrimStart(StringBuilder buf) Remove white space from the start of a string buffer.
-
Field Details
-
CASE_INSENSITIVE_COMPARATOR
Publicly available case-insensitive comparator. You can also use the static method getCaseInsensitiveComparator() to get one. -
UCS_CODEPOINT_COMPARATOR
Compares Strings based on UCS codepoint values. -
WHITE_SPACE
Set of characters considered to be white space.- See Also:
-
-
Method Details
-
equalsWithNull
General-purpose string equality comparison for strings that may be null. This method compares two strings for equality, allowing for possible null references and non-interned strings.- Parameters:
s1- First string to compare.s2- First string to compare.- Returns:
- True if the strings are equal; false if not. Note that two null references would be considered equal.
-
findNoCase
Scan a string for a string, but ignore case. The only ASCII case folding is considered. Comparisons are done on a character by character basis (i.e., Unicode not code points are not considered).- Parameters:
source- the string being searched.target- the string to search for.fromIndex- the index to begin searching from.- Returns:
- the start position for where the string was found. If the string was not found, -1.
-
getCaseInsensitiveComparator
Return a comparator that performs case-insensitive string comparisons.- Returns:
- A comparator that performs case insensitive comparisons.
-
isEmpty
Empty string test. Short-hand to test a string for null pointer or empty condition.- Parameters:
s- String to be tested.- Returns:
- True if the given string reference is null or empty; false otherwise.
-
number
-
number
-
longNumber
-
longNumber
-
parseToken
-
replace
-
replace
-
safeNumber
-
safeNumber
-
safeLongNumber
-
safeLongNumber
-
skipOver
Scan this string for the first character not in the given set. Similar to strspn().- Parameters:
sSkip- - the characters to scan fornOffset- - the position where to start the scan. Default = 0- Returns:
- The position, relative to nOffset, for the first character not found in the given set
-
skipUntil
Scan this string for the first character in the given set. Similar to strcspn().- Parameters:
src- - the string to scansSkip- - the characters to scan fornOffset- - the position where to start the scan. Default = 0.- Returns:
- The position, relative to nOffset, for the first character found in the given set
-
trim
Remove white space from the end of a string buffer.- Parameters:
buf- - String buffer to be trimmed.
-
trimStart
Remove white space from the start of a string buffer.- Parameters:
buf- - String buffer to be trimmed.
-
trim
-
trimStart
-
toXML
-
toXML
public static String toXML(String sSrc, StringUtils.ToXMLType eTargetType, String sOthers, char cRangeMin, char cRangeMax, String sExclude) Replaces specified characters in the current string with their entity references.'&' is replaced with "&" '<' is replaced with "<" if eTargetType = XMLTEXT '>' is replaced with ">" if eTargetType = XMLATTRIBUTE_WITH_DQUOTE '"' is replaced with """ if eTargetType = XMLATTRIBUTE_WITH_QUOTE ''' is replaced with "'"Any characters found in sOthers are replaced with entity references. Any characters found inbetween and including the cRangeStart and cRangeEnd are replaced with entity references.- Parameters:
sSrc- the source string.eTargetType- an enum indicating the target xml type.sOthers- a list of characters to be encoded in this string.cRangeMin- Any characters greater than or equal to this char are encoded with their entity references.cRangeMax- Any characters less than or equal to this char are encoded with their entity references.sExclude- a list of characters NOT to be encoded in this string.- Returns:
- The converted string.
-
toXHTML
Replaces specified characters in the current string with their entity references. and wraps the text in andelements.
'&' is replaced with "&" '<' is replaced with "<" '>' is replaced with ">"
All line feeds are are replaced with
.- Parameters:
sSrc- the source string.bIncludePI- true if the string should be prefixed with invalid input: '<'?xml version="1.0"?>.- Returns:
- The converted string.
-