Class EncodeOrCheck
- java.lang.Object
-
- org.restlet.ext.jaxrs.internal.util.EncodeOrCheck
-
@Deprecated public class EncodeOrCheck extends java.lang.ObjectDeprecated.Will be removed in next minor release.Utility class to encode or check data.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFRAGMENT_FORBIDDENDeprecated.the characters forbidden in a fragment.static java.lang.StringGEN_DELIMITERSDeprecated.the gen-delimiter characters in URIsprivate static char[]HEX_DIGITSDeprecated.A table of hex digitsstatic java.lang.StringRESERVEDDeprecated.the reserved characters in URIsstatic java.lang.StringSUB_DELIMITERSDeprecated.the sub-delimiter characters in URIsstatic java.lang.StringTEMPL_PARAMSDeprecated.the additional allowed characters for template parameters in URIs.static java.lang.StringUNRESERVEDDeprecated.the unreserved characters in URIs
-
Constructor Summary
Constructors Constructor Description EncodeOrCheck()Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.Stringall(java.lang.CharSequence string, boolean encode)Deprecated.Checks / encodes all chars of the given char sequence.static voidcheckForInvalidUriChars(java.lang.CharSequence uriPart, int indexForErrMessage, java.lang.String errMessName)Deprecated.Checks, if the string contains characters that are reserved in URIs.(package private) static intencode(char toEncode, java.lang.StringBuilder stb)Deprecated.Appends the given character encoded (if not unreserved) to theStringBuilder.private static java.lang.StringencodeNotBraces(java.lang.CharSequence uriPart, boolean allowSemicolon, boolean encodeSlash)Deprecated.This methods encodes the given String, but doesn't encode braces.static java.lang.CharSequencefragment(java.lang.CharSequence fragment)Deprecated.static java.lang.CharSequencefullMatrix(java.lang.CharSequence matrix)Deprecated.encodes respectively checks a full matrix parameter list.static java.lang.CharSequencefullQuery(java.lang.CharSequence query, boolean encode)Deprecated.encodes respectively checks a full query.private static java.lang.CharSequencefullQueryOrMatrix(java.lang.CharSequence string, char delimiter, java.lang.String spaceReplace, boolean encode)Deprecated.static java.lang.Stringhost(java.lang.String host)Deprecated.Checks, if the host String contains is valid.static java.lang.StringnameOrValue(java.lang.Object nameOrValue, boolean encode, java.lang.String nameForMessage)Deprecated.Encodes the given string, if encoding is enabled.static java.lang.CharSequencepathSegmentsWithMatrix(java.lang.CharSequence path, boolean encode)Deprecated.static java.lang.CharSequencepathSegmentWithMatrix(java.lang.CharSequence pathSegments, boolean encode)Deprecated.private static java.lang.CharSequencepathSegmentWithMatrix(java.lang.CharSequence pathSegments, boolean encode, boolean encodeSlash)Deprecated.static java.lang.CharSequencepathWithoutMatrix(java.lang.CharSequence path)Deprecated.This methods encodes the given path, but doesn't encode braces.(package private) static voidprocessPercent(int i, boolean encode, java.lang.CharSequence uriPart, java.lang.StringBuilder stb)Deprecated.appends the '%' at the given position i to the given StringBuilder.private static intprocessTemplVarname(java.lang.CharSequence uriPart, int braceIndex, java.lang.StringBuilder stb)Deprecated.Reads and checks the template variable name.static java.lang.Stringscheme(java.lang.String scheme)Deprecated.Checks, if the String is a valid URI schemeprivate static java.lang.IllegalArgumentExceptionthrowIllegalArgExc(int index, java.lang.String errMessName, java.lang.Object illegalString, java.lang.String messageEnd)Deprecated.static voidtoHex(char toEncode, java.lang.StringBuilder stb)Deprecated.Appends the given character precent-encoded to theStringBuilder.private static voidtoHexOrReject(char c, java.lang.StringBuilder stb, boolean encode)Deprecated.if encode is true, the given char is appended as hex string to theStringBuilder.static java.lang.CharSequenceuserInfo(java.lang.CharSequence userInfo, boolean encode)Deprecated.
-
-
-
Field Detail
-
FRAGMENT_FORBIDDEN
public static final java.lang.String FRAGMENT_FORBIDDEN
Deprecated.the characters forbidden in a fragment.
-
GEN_DELIMITERS
public static final java.lang.String GEN_DELIMITERS
Deprecated.the gen-delimiter characters in URIs- See Also:
- Constant Field Values
-
HEX_DIGITS
private static final char[] HEX_DIGITS
Deprecated.A table of hex digits
-
SUB_DELIMITERS
public static final java.lang.String SUB_DELIMITERS
Deprecated.the sub-delimiter characters in URIs- See Also:
- Constant Field Values
-
TEMPL_PARAMS
public static final java.lang.String TEMPL_PARAMS
Deprecated.the additional allowed characters for template parameters in URIs.- See Also:
- Constant Field Values
-
RESERVED
public static final java.lang.String RESERVED
Deprecated.the reserved characters in URIs- See Also:
- Constant Field Values
-
UNRESERVED
public static final java.lang.String UNRESERVED
Deprecated.the unreserved characters in URIs- See Also:
- Constant Field Values
-
-
Method Detail
-
all
public static java.lang.String all(java.lang.CharSequence string, boolean encode) throws java.lang.IllegalArgumentExceptionDeprecated.Checks / encodes all chars of the given char sequence.- Parameters:
string-encode- true, if the value should be encoded, or false if not.- Returns:
- the enoced string (if it should be encoded)
- Throws:
java.lang.IllegalArgumentException- if encode is false and at least one character of the CharSequence is invalid.
-
checkForInvalidUriChars
public static void checkForInvalidUriChars(java.lang.CharSequence uriPart, int indexForErrMessage, java.lang.String errMessName) throws java.lang.IllegalArgumentExceptionDeprecated.Checks, if the string contains characters that are reserved in URIs.- Parameters:
uriPart-indexForErrMessage-errMessName-- Throws:
java.lang.IllegalArgumentException- if the CharSequence to test contains illegal characters.- See Also:
- RFC 3986, Section 2.2
-
encode
static int encode(char toEncode, java.lang.StringBuilder stb)Deprecated.Appends the given character encoded (if not unreserved) to theStringBuilder.- Parameters:
toEncode- the character to encode.stb- theStringBuilderto append.- Returns:
- the number of added chars
- See Also:
- RFC 3986, section 2.2
-
encodeNotBraces
private static java.lang.String encodeNotBraces(java.lang.CharSequence uriPart, boolean allowSemicolon, boolean encodeSlash) throws java.lang.IllegalArgumentExceptionDeprecated.This methods encodes the given String, but doesn't encode braces.- Parameters:
uriPart- the String to encodeallowSemicolon- if true, a ';' is encoded, otherwise anIllegalArgumentExceptionis thrown.encodeSlash- if encodeSlash is true, than slashes are also converted, otherwise not.- Returns:
- the encoded String
- Throws:
java.lang.IllegalArgumentException
-
fragment
public static java.lang.CharSequence fragment(java.lang.CharSequence fragment) throws java.lang.IllegalArgumentExceptionDeprecated.- Parameters:
fragment- the fragment, may contain URI template parameters. Must not be null.- Returns:
- the encoced character sequence (if it should be encoded)
- Throws:
java.lang.IllegalArgumentException- if encode is false and the fragment contains at least one invalid character.
-
fullMatrix
public static java.lang.CharSequence fullMatrix(java.lang.CharSequence matrix) throws java.lang.IllegalArgumentExceptionDeprecated.encodes respectively checks a full matrix parameter list.- Parameters:
matrix- matrix parameters to convert or check, may contain URI template parameters. Must not be null.- Returns:
- the encoced character sequence (if it should be encoded)
- Throws:
java.lang.IllegalArgumentException- if encode is false and at least one character is invalid.
-
fullQuery
public static java.lang.CharSequence fullQuery(java.lang.CharSequence query, boolean encode)Deprecated.encodes respectively checks a full query.- Parameters:
query- query to convert or check, may contain URI template parameters. Must not be null.encode-- Returns:
- the encoced character sequence (if it should be encoded)
-
fullQueryOrMatrix
private static java.lang.CharSequence fullQueryOrMatrix(java.lang.CharSequence string, char delimiter, java.lang.String spaceReplace, boolean encode) throws java.lang.IllegalArgumentExceptionDeprecated.- Parameters:
string-delimiter-spaceReplace- The String to replace a space with ("+" or "%20")encode-- Returns:
- Throws:
java.lang.IllegalArgumentException
-
host
public static java.lang.String host(java.lang.String host) throws java.lang.IllegalArgumentExceptionDeprecated.Checks, if the host String contains is valid.- Parameters:
host- Could include template variable names. Must not be null, will throw a NullPointerException.- Returns:
- the valid host.
- Throws:
java.lang.IllegalArgumentException- if the host contains an invalid character.
-
nameOrValue
public static java.lang.String nameOrValue(java.lang.Object nameOrValue, boolean encode, java.lang.String nameForMessage) throws java.lang.IllegalArgumentExceptionDeprecated.Encodes the given string, if encoding is enabled. If encoding is disabled, the methods checks the validaty of the containing characters.- Parameters:
nameOrValue- the string to encode or check. Must not be null; result are not defined. May contain URI template parameters.encode- if true, the String is encoded, if false it is checked, if all chars are valid.nameForMessage- The name for the message- Returns:
- the encoced character sequence (if it should be encoded)
- Throws:
java.lang.IllegalArgumentException- if the given String is null, or at least one char is invalid.
-
pathSegmentsWithMatrix
public static java.lang.CharSequence pathSegmentsWithMatrix(java.lang.CharSequence path, boolean encode)Deprecated.- Parameters:
path-encode-- Returns:
- the encoced character sequence (if it should be encoded)
-
pathSegmentWithMatrix
public static java.lang.CharSequence pathSegmentWithMatrix(java.lang.CharSequence pathSegments, boolean encode) throws java.lang.IllegalArgumentExceptionDeprecated.- Parameters:
pathSegments- the path to check; must not be null.encode-- Returns:
- the encoced character sequence (if it should be encoded)
- Throws:
java.lang.IllegalArgumentException- id encode is false and the path contains an invalid character.
-
pathSegmentWithMatrix
private static java.lang.CharSequence pathSegmentWithMatrix(java.lang.CharSequence pathSegments, boolean encode, boolean encodeSlash) throws java.lang.IllegalArgumentExceptionDeprecated.- Parameters:
pathSegments- the path to check; must not be null.encode-- Returns:
- Throws:
java.lang.IllegalArgumentException- id encode is false and the path contains an invalid character.
-
pathWithoutMatrix
public static java.lang.CharSequence pathWithoutMatrix(java.lang.CharSequence path) throws java.lang.IllegalArgumentExceptionDeprecated.This methods encodes the given path, but doesn't encode braces.- Parameters:
path- the path to encode- Returns:
- the encoded String
- Throws:
java.lang.IllegalArgumentException- if the path is not valid
-
processPercent
static void processPercent(int i, boolean encode, java.lang.CharSequence uriPart, java.lang.StringBuilder stb)Deprecated.appends the '%' at the given position i to the given StringBuilder.
Preconditions (not checked !!):- i > 0
- at position i is a '%'.
- Parameters:
i- the index in the uriPartencode-uriPart-stb-
-
processTemplVarname
private static int processTemplVarname(java.lang.CharSequence uriPart, int braceIndex, java.lang.StringBuilder stb) throws java.lang.IllegalArgumentExceptionDeprecated.Reads and checks the template variable name. The starting "{" is at given position i.- Parameters:
uriPart- the processed part of the uribraceIndex- the current for variable value (position of "{"). The method do not check, if this is the position of the '{'.stb- the StringBuilder to append the variable name with "{" and "}" to. Will be changed, also if an error occurs. May be null; then nothing is appended.- Returns:
- the position of the corresponding "}" to assign to the for variable.
- Throws:
java.lang.IllegalArgumentException- if the rest of the uriPart contains a '{' or no '}'.
-
scheme
public static java.lang.String scheme(java.lang.String scheme) throws java.lang.IllegalArgumentExceptionDeprecated.Checks, if the String is a valid URI scheme- Parameters:
scheme- the String to check. May contain template variables.- Returns:
- the valid scheme
- Throws:
java.lang.IllegalArgumentException- If the string is not a valid URI scheme.
-
throwIllegalArgExc
private static java.lang.IllegalArgumentException throwIllegalArgExc(int index, java.lang.String errMessName, java.lang.Object illegalString, java.lang.String messageEnd)Deprecated.- Parameters:
index- index, starting with zero.errMessName- the name of the string with illegal charactersillegalString- the illegal StringmessageEnd-- Returns:
-
toHex
public static void toHex(char toEncode, java.lang.StringBuilder stb)Deprecated.Appends the given character precent-encoded to theStringBuilder. Example: ' ' -> "%20%- Parameters:
toEncode-stb-
-
toHexOrReject
private static void toHexOrReject(char c, java.lang.StringBuilder stb, boolean encode) throws java.lang.IllegalArgumentExceptionDeprecated.if encode is true, the given char is appended as hex string to theStringBuilder. If encode is false, anIllegalArgumentExceptionis thrown.- Parameters:
c-stb-encode- true, if the value should be encoded, or false if not.- Throws:
java.lang.IllegalArgumentException
-
userInfo
public static java.lang.CharSequence userInfo(java.lang.CharSequence userInfo, boolean encode) throws java.lang.IllegalArgumentExceptionDeprecated.- Parameters:
userInfo- the URI user-info, may contain URI template parametersencode-- Returns:
- the encoced character sequence (if it should be encoded)
- Throws:
java.lang.IllegalArgumentException- if automatic encoding is disabled and the userInfo contains illegal characters, or if the userInfo is null.
-
-