public class StringUtils extends Object
StringUtils is a collection of String utilities in the web environment. Many of the methods of this class serve to get correct and cross-site scripting safe encoding for usage in HTML mark-up, JavaScript String, and URLs.
For performance reasons all encoding and decoding methods can be called with an own StringBuffer object to process on. Other function calls without StringBuffer lead to creation of own temporary StringBuffer. The advantage here is, that may a component, which already has implemented an own StringBufferPool, can use this pool to pass it to the encoding/decoding methods.
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
escapeScriptEndTag(String pStr)
Prepare a string to be used for a javascript string definition with particular care about script tag.
|
static String |
escapeScriptEndTag(StringBuffer sb,
String pStr)
Prepare a string to be used for a javascript string definition with particular care about script tag.
|
static String |
escapeSpace(String input)
Encode a space with +
Note that this function will call 'disableScriptSignatures'.
|
static String |
escapeToAttributeValue(String input)
Encode a string for output as an attribute string of a tag, no URLs!
|
static String |
escapeToAttributeValue(StringBuffer sb,
String input,
int maxLength)
Encode a string for output as an attribute string of a tag, no URLs!
|
static String |
escapeToAttributeValue(String input,
int maxLength)
Encode a string for output as an attribute string of a tag, no URLs!
|
static String |
escapeToHTML(String input)
Encode a string for output between tags (CASE1)
|
static String |
escapeToHTML(StringBuffer sb,
String input,
int maxLength)
Encode a string for output between tags (CASE1)
|
static String |
escapeToHTML(String input,
int maxLength)
Encode a string for output between tags (CASE1)
|
static String |
escapeToJS(String input)
Encode a string inside a JS string declaration (CASE5)
|
static String |
escapeToJS(StringBuffer sb,
String input,
int maxLength)
Encode a string inside a JS string declaration (CASE5)
|
static String |
escapeToJS(String input,
int maxLength)
Encode a string inside a JS string declaration (CASE5)
|
static String |
escapeToURL(String input)
Encode a string that represents a URL (CASE3)
Note that this function will call 'disableScriptSignatures'.
|
static String |
escapeToURL(StringBuffer sb,
String input,
int maxLength)
Encode a string that represents a URL (CASE3)
Note that this function will call 'disableScriptSignatures'.
|
static String |
escapeToURL(String input,
int maxLength)
Encode a string that represents a URL (CASE3)
Note that this function will call 'disableScriptSignatures'.
|
static String |
pathNormalize(String ps) |
static String[] |
tokenize(String szInput,
char delimiter)
Take the given string and chop it up into a series
of strings.
|
static String[] |
tokenize(String szInput,
String szDelim)
Take the given string and chop it up into a series
of strings.
|
static List |
tokenizeInList(String szInput,
char delimiter)
Take the given string and chop it up into a List.
|
static List |
tokenizeInList(String szInput,
String szDelim)
Take the given string and chop it up into a List
|
static String |
urlDecode(String s)
A trivial replacement of URLDecoder.decode
|
static String |
urlDecode(StringBuffer sb,
String s)
A trivial replacement of URLDecoder.decode
|
static String |
urlEncode(String s)
A trivial replacement of URLEncoder.encode
|
static String |
urlEncode(StringBuffer sb,
String s,
char[] forceEncode)
This is an extended version of the URLEncoder.encode method.
|
static String |
urlEncode(String s,
char[] forceEncode)
This is an extended version of the URLEncoder.encode method.
|
static String |
urlNormalize(String ps) |
static String |
urlNormalize2(String ps) |
public static String escapeToJS(String input)
input
- The string to parse.public static String escapeToJS(String input, int maxLength)
input
- The string to parse.maxLength
- The maximum length the String input SHOULD havepublic static String escapeToJS(StringBuffer sb, String input, int maxLength)
sb
- The StringBuffer to process the inputinput
- The string to parse.maxLength
- The maximum length the String input SHOULD havepublic static String escapeToHTML(String input)
input
- The string to parse.public static String escapeToHTML(String input, int maxLength)
input
- The string to parse.maxLength
- The maximum length the String input SHOULD havepublic static String escapeToHTML(StringBuffer sb, String input, int maxLength)
sb
- The StringBuffer to process the inputinput
- The string to parse.maxLength
- The maximum length the String input SHOULD havepublic static String escapeToAttributeValue(String input)
input
- The string to parse.public static String escapeToAttributeValue(String input, int maxLength)
input
- The string to parse.maxLength
- The maximum length the String input SHOULD havepublic static String escapeToAttributeValue(StringBuffer sb, String input, int maxLength)
sb
- The StringBuffer to process the inputinput
- The string to parse.maxLength
- The maximum length the String input SHOULD havepublic static String escapeToURL(String input)
input
- The string to parse.public static String escapeToURL(String input, int maxLength)
input
- The string to parse.maxLength
- The maximum length the String input SHOULD havepublic static String escapeToURL(StringBuffer sb, String input, int maxLength)
sb
- The StringBuffer to process the inputinput
- The string to parse.maxLength
- The maximum length the String input SHOULD havepublic static String escapeScriptEndTag(String pStr)
pStr
- The string to parse.public static String escapeScriptEndTag(StringBuffer sb, String pStr)
sb
- The StringBuffer to process the inputpStr
- The string to parse.public static String escapeSpace(String input)
input
- The string to parse.public static String urlEncode(StringBuffer sb, String s, char[] forceEncode)
sb
- The StringBuffer to process the inputs
- The String to be encodedforceEncode
- An array of chars that are to be encoded
explicitly. Note: forceEncode should NOT contain digits nor
the percent sign!!public static String urlEncode(String s, char[] forceEncode)
s
- The String to be encodedforceEncode
- An array of chars that are to be encoded
explicitly. Note: forceEncode should NOT contain digits nor
the percent sign!!public static String urlEncode(String s)
s
- The String to be encodedpublic static String urlDecode(StringBuffer sb, String s)
sb
- The StringBuffer to process the inputs
- The String to be encodedpublic static String urlDecode(String s)
s
- The String to be encodedpublic static String[] tokenize(String szInput, String szDelim)
szInput
- the input StringszDelim
- the delimiter stringpublic static List tokenizeInList(String szInput, String szDelim)
szInput
- the input StringszDelim
- the delimiter stringpublic static String[] tokenize(String szInput, char delimiter)
szInput
- the input Stringdelimiter
- the delimiter characterpublic static List tokenizeInList(String szInput, char delimiter)
szInput
- the input Stringdelimiter
- the delimiter characterAccess Rights |
---|
SC | DC | Public Part | ACH |
---|---|---|---|
[sap.com] ENGFACADE
|
[sap.com] tc/bl/security/lib
|
api
|
BC-JAS-SEC
|
[sap.com] ENGINEAPI
|
[sap.com]
|
-
|
BC-JAS-SEC
|
[sap.com] FRAMEWORK
|
[sap.com] tc/ui/faces
|
api
|
BC-WD-UR
|
Copyright 2018 SAP AG Complete Copyright Notice