|
Oracle UIX API Reference Release 2.1.22.0.0 B12196-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.cabo.share.url.EncoderUtils
Utility functions for encoding URLs for output. This class contains three classes of encoding functions:
The major difference between these types of functions is what characters they will encode.
Category 1 (entire URLs) will perform correct NLS encodings, but cannot encode '%', '&' '=', '?', '#', and '+', as all of these characters have very specific meanings in an URL. In the case of '%' and '+' note that this means UIX will never double-encode an URL.
Category 2 (parameters for UIX) will encode only '%', '+', '&', and '#'. Note that it does not perform NLS encodings, or any disallowed URL characters (like the space character), as it relies on the UIX rendering layer to handle these where it can be performed more efficiently. Also, note that '+' and '%' are encoded, so this function should not be used on parameters that have already been URL encoded.
Finally, Category 3 (parameters for final output) encodes all characters except for '-', '_', '.', and '/'. There is no need to call these functions if you'll be using UIX (or Marlin beans) to render the URL.
EncoderUtils also includes support for manually decoding strings. This is generally not necessary, as Servlets are generally responsible for decoding parameters themselves, but developers working around buggy servlet engines may find this useful, as will developers writing their own HTTP code.
Constructor Summary | |
EncoderUtils()
|
Method Summary | |
static void |
appendUIXQueryParameter(java.lang.StringBuffer buffer,
java.lang.String text)
Partially encodes a query parameter. |
static java.lang.String |
decodeString(java.lang.String text,
java.lang.String encoding)
URL-decodes a string. |
static java.lang.String |
encodeString(java.lang.String text,
java.lang.String encoding)
Fully encodes a string - all characters with special meanings in an URL will be '%' encoded. |
static java.lang.String |
encodeUIXQueryParameter(java.lang.String text)
Partially encodes a query parameter. |
static java.lang.String |
encodeURL(java.lang.String text,
java.lang.String queryEncoding,
boolean useISOForBody)
Encodes a string into URL-encoded format. |
static void |
writeQueryParameters(java.io.Writer out,
java.lang.String text,
java.lang.String encoding,
int start)
Writes a query parameter. |
static void |
writeURL(java.io.Writer out,
java.lang.String text,
java.lang.String queryEncoding,
boolean useISOForBody)
Writes a string into URL-encoded format out to a Writer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EncoderUtils()
Method Detail |
public static java.lang.String encodeURL(java.lang.String text, java.lang.String queryEncoding, boolean useISOForBody) throws java.io.UnsupportedEncodingException
writeURL(java.io.Writer, java.lang.String, java.lang.String, boolean)
method.
text
- the unencoded (or partially encoded) StringqueryEncoding
- the character set encoding for after the first
question markuseISOForBody
- if false, text before the first question
mark will be encoded with UTF-8; if true, encoded with ISO-8859-1.public static void writeURL(java.io.Writer out, java.lang.String text, java.lang.String queryEncoding, boolean useISOForBody) throws java.io.IOException, java.io.UnsupportedEncodingException
All characters before the start of the query string will be encoded using either UTF-8 or ISO-8859-1. The former is the ideal standard, as it allows any Unicode character to be used in the path. However, many web servers assume ISO-8859-1 instead, hence the option.
Characters after the start of the query string will be encoded using a client-defined encoding. You'll need to use the encoding that the server will expect. (HTML forms will generate query strings using the character encoding that the HTML itself was generated in.)
All characters will be encoded as needed for URLs, with the exception of the percent symbol ("%"). Because this is the character itself used for escaping, attempting to escape this character would cause this code to double-escape some strings. It also may be necessary to pre-escape some characters. In particular, a question mark ("?") is considered the start of the query string.
out
- a Writer for the outputtext
- the unencoded (or partially encoded) StringqueryEncoding
- the character set encoding for after the first
question markuseISOForBody
- if false, text before the first question
mark will be encoded with UTF-8; if true, encoded with ISO-8859-1.public static void writeQueryParameters(java.io.Writer out, java.lang.String text, java.lang.String encoding, int start) throws java.io.IOException, java.io.UnsupportedEncodingException
public static java.lang.String encodeUIXQueryParameter(java.lang.String text)
public static void appendUIXQueryParameter(java.lang.StringBuffer buffer, java.lang.String text)
public static java.lang.String encodeString(java.lang.String text, java.lang.String encoding) throws java.io.UnsupportedEncodingException
public static java.lang.String decodeString(java.lang.String text, java.lang.String encoding) throws java.io.UnsupportedEncodingException
CaboHttpUtils.decodeRequestParameter()
has already
been called, and this function is being passed the result
of that function. That is: if the string does not
contain any '%' characters, the string will be returned unmodified.
text
- the original textencoding
- the character encoding to assumeCaboHttpUtils.decodeRequestParameter(java.lang.String, java.lang.String, byte[])
|
Oracle UIX API Reference Release 2.1.22.0.0 B12196-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |