Package com.linkedin.alpini.base.misc
Enum Class URLCodec
- All Implemented Interfaces:
Serializable,Comparable<URLCodec>,Constable
Copies of the implementation of
URLEncoder.encode(String, String) and
URLDecoder.decode(String, String) except with the following changes:
- Accept a
Charsetargument for the character set instead of a string which would causeCharset.forName(String)to be called. - Internally use
StringBuilderinstead ofStringBuffer. - These methods no longer throw a checked exception because it
no longer calls
Charset.forName(String). - These methods are annotated with
Nonnullannotations.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic CharSequencedecode(CharSequence s, Charset enc) Decodes aapplication/x-www-form-urlencodedstring using a specific encoding scheme.static StringDecodes aapplication/x-www-form-urlencodedstring using a specific encoding scheme.static CharSequenceencode(CharSequence s, Charset charset) Translates a string intoapplication/x-www-form-urlencodedformat using a specific encoding scheme.static StringTranslates a string intoapplication/x-www-form-urlencodedformat using a specific encoding scheme.static URLCodecReturns the enum constant of this class with the specified name.static URLCodec[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SINGLETON
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
encode
Translates a string intoapplication/x-www-form-urlencodedformat using a specific encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafe characters.Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.
- Parameters:
s-Stringto be translated.charset- The name of a supported character encoding.- Returns:
- the translated
String. - See Also:
-
encode
Translates a string intoapplication/x-www-form-urlencodedformat using a specific encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafe characters.Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.
- Parameters:
s-CharSequenceto be translated.charset- The name of a supported character encoding.- Returns:
- the translated CharSequence. Note that if a conversion was required, the returned CharSequence is shared thread local and that the caller is required to copy it.
- See Also:
-
decode
Decodes aapplication/x-www-form-urlencodedstring using a specific encoding scheme. The supplied encoding is used to determine what characters are represented by any consecutive sequences of the form "%xy".Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.
- Parameters:
s- theStringto decodeenc- The name of a supported character encoding.- Returns:
- the newly decoded
String - See Also:
-
decode
Decodes aapplication/x-www-form-urlencodedstring using a specific encoding scheme. The supplied encoding is used to determine what characters are represented by any consecutive sequences of the form "%xy".Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.
- Parameters:
s- theCharSequenceto decodeenc- The name of a supported character encoding.- Returns:
- the newly decoded CharSequence. Note that if a conversion was required, the returned CharSequence is shared thread local and that the caller is required to copy it.
- See Also:
-