|
Oracle Fusion Middleware Java API Reference for Oracle PDK Java 11g Release 1 (11.1.1) E10691-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.webdb.utils.HTTPUtils
public class HTTPUtils
This class contains various utility methods for encoding and decoding URIs
String
using the set of characters allowed in a URI, as defined
in RFC 2396 - "Uniform
Resource Identifiers (URI): Generic Syntax".
The method does not suffer from the limitations of the
java.net.URLEncoder
in that it provides control over the
character encoding used for character to byte conversions and is capable of
encoding characters that are encoded by a sequence of several bytes.
To convert a String
, each character is examined in turn:
a
' through 'z
',
'A
' through 'Z
', and '0
' through
'9
' remain the same.
-
', '_
',
'.
', '!
', '~
', '*
',
''
' , '(
', ')
', remain the same.
' is converted into a
plus sign '+
'.
%xy
", where xy is the two-digit
hexadecimal representation of the byte value.
Field Summary | |
---|---|
static int |
REQUEST_FOR_AUTHENTICATION
|
static int |
REQUEST_FOR_LOGOUT
|
Constructor Summary | |
---|---|
HTTPUtils()
|
Method Summary | |
---|---|
static byte[] |
base64Decode(java.lang.String string)
Decodes the supplied base 64 encoded string into its original byte array, using the standard base 64 decoding algorithm. |
static java.lang.String |
base64Encode(byte[] bytes)
Base64 encodes the supplied bytes array, using the standard base 64 encoding algorithm. |
static java.lang.String |
buildUrlAsString(java.lang.String scheme,
java.lang.String host,
int port,
java.lang.String path)
Build a fully qualified URL from the pieces provided. |
static java.lang.String |
decode(java.lang.String value,
java.lang.String encoding)
Decodes an encoded String. |
static java.lang.String |
decodeUTF(java.lang.String value)
Decodes an encoded UTF8 String. |
static java.lang.String |
encode(java.lang.String value,
java.lang.String encoding)
Encodes a String using the set of characters allowed in a URI. |
static java.lang.String |
encode(java.lang.String value,
java.lang.String encoding,
boolean usePlusEncoding)
Encodes a String using the set of characters allowed in a URI. |
static java.lang.String |
encodePathInfo(java.lang.String pathInfo)
Encodes the supplied URL path string into URL safe hex encoded characters, using the passed in charset to perform the char to byte conversion. |
static java.lang.String |
encodePathInfo(java.lang.String pathInfo,
java.lang.String charset)
Encodes the supplied URL path string into URL safe hex encoded characters, using the passed in charset to perform the char to byte conversion. |
static java.lang.String |
encodeScriptCharacters(java.lang.String url,
char[] scriptCharacters,
java.lang.String charSet)
Takes a string and URL encodes any invalid URL characters that appear in a defined fixed list using the specified character set. |
static java.lang.String |
encodeUTF(java.lang.String value)
Encodes a String using the set of characters allowed in a URI. |
static java.lang.String |
getCookie(java.lang.String cookieName,
java.lang.String cookies)
Extracts a cookie value from a list of cookies based on the name. |
static java.text.DateFormat |
getCookieDateFormat()
Returns the date format used for expiry times in type zero (Netscape) cookies. |
static boolean |
isErrorStatusCode(int statusCode)
Determines whether the given HTTP status code denotes a client or server error. |
static boolean |
isText(java.lang.String mimeType)
Return flag to indicate if the supplied mime type is text based. |
static boolean |
isXml(java.lang.String mimeType)
Return flag to indicate if the supplied mime type corresponds to XML based content. |
static boolean |
needsDecoding(java.lang.String token)
Determine if a value needs to be decoded using HTTPUtils.decode() This method assumes that a value is encoded. |
static java.lang.String |
setCookie(java.lang.String cookieName,
java.lang.String cookieValue,
java.lang.String cookies)
Sets a cookie value in a list of cookies based on the name. |
static java.lang.String |
toHTTPLocale(java.util.Locale locale)
Converts a Java Locale to a String in the format specified for the Accept-Language and xml:lang attribute, i.e. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int REQUEST_FOR_LOGOUT
public static final int REQUEST_FOR_AUTHENTICATION
Constructor Detail |
---|
public HTTPUtils()
Method Detail |
---|
public static java.text.DateFormat getCookieDateFormat()
public static java.lang.String buildUrlAsString(java.lang.String scheme, java.lang.String host, int port, java.lang.String path)
scheme
- server protocol.host
- server name.port
- server port.path
- properly encoded relative URL.
java.lang.IllegalArgumentException
- if scheme, host or port is null.public static java.lang.String encode(java.lang.String value, java.lang.String encoding, boolean usePlusEncoding) throws java.io.UnsupportedEncodingException
value
- String
to be translated.encoding
- the Java alias for the character encoding to be used to
convert non-ASCII characters into bytes (e.g. "UTF8"
).usePlusEncoding
- whether or not to encode spaces with plus signs
String
.
java.io.UnsupportedEncodingException
- if the given encoding is not a
recognised character encoding.public static java.lang.String encode(java.lang.String value, java.lang.String encoding) throws java.io.UnsupportedEncodingException
value
- String
to be translated.encoding
- the Java alias for the character encoding to be used to
convert non-ASCII characters into bytes (e.g. "UTF8"
).
String
.
java.io.UnsupportedEncodingException
- if the given encoding is not a
recognised character encoding.public static java.lang.String encodeUTF(java.lang.String value)
value
- String
to be translated.
String
.public static java.lang.String decode(java.lang.String value, java.lang.String encoding) throws java.io.UnsupportedEncodingException
value
- String
to be translated.encoding
- the Java alias for the character encoding to be used to
convert byte sequences into characters(e.g. "UTF8"
).
String
.
java.io.UnsupportedEncodingException
- if the given encoding is not a
recognised character encoding.public static java.lang.String decodeUTF(java.lang.String value)
value
- String
to be translated.
String
.public static boolean isErrorStatusCode(int statusCode)
statusCode
- an HTTP response status code
public static final boolean needsDecoding(java.lang.String token)
public static java.lang.String getCookie(java.lang.String cookieName, java.lang.String cookies)
cookieName
- Name of the cookie to search for.cookies
- List of cookies of the form
"name1=value1; name2=value2; ...; nameN=valueN".
public static java.lang.String toHTTPLocale(java.util.Locale locale)
public static java.lang.String setCookie(java.lang.String cookieName, java.lang.String cookieValue, java.lang.String cookies)
cookieName
- Name of the cookie to set.cookieValue
- Value of the cookie to set.cookies
- List of cookies of the form
"name1=value1; name2=value2; ...; nameN=valueN".
public static java.lang.String base64Encode(byte[] bytes)
bytes
- The byte array to encode
public static byte[] base64Decode(java.lang.String string)
string
- The base 64 encoded string to decode
public static java.lang.String encodePathInfo(java.lang.String pathInfo, java.lang.String charset) throws java.io.UnsupportedEncodingException
pathInfo
- The path to be encodedcharset
- The charset to use for encoding
java.io.UnsupportedEncodingException
- if the given encoding is not a
recognised character encoding.public static java.lang.String encodePathInfo(java.lang.String pathInfo) throws java.io.UnsupportedEncodingException
pathInfo
- The path to be encodedcharset
- The charset to use for encoding
java.io.UnsupportedEncodingException
- if the given encoding is not a
recognised character encoding.public static java.lang.String encodeScriptCharacters(java.lang.String url, char[] scriptCharacters, java.lang.String charSet) throws java.io.UnsupportedEncodingException
url
- the url string to be encodedscriptCharacters
- array of characters that should be escaped. If
null, no encoding will be carried out.charSet
- the character set to be used for encoding
java.io.UnsupportedEncodingException
- if the character set is not
recognisedpublic static boolean isText(java.lang.String mimeType)
mimeType
- mime type string to check
public static boolean isXml(java.lang.String mimeType)
mimeType
- mime type string to check
|
Oracle Fusion Middleware Java API Reference for Oracle PDK Java 11g Release 1 (11.1.1) E10691-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |