|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.httpclient.URIUtil
General purpose methods for encoding URI's, as described in RFC 2396.
This class provides a number of methods useful for encoding and
decoding the "%HH" format, as used in various HTTP related
formats such as URIs and the URLEncoder
and
java.net.URLDecoder
classes.
As well this class provides some useful methods for dealing with URLs
Constructor Summary | |
URIUtil()
|
Method Summary | |
static java.lang.String |
decode(byte[] bytes)
Unescape the given byte array by first converting all '%', 'H', 'H' sequences into the byte 0xHH, and then converting the bytes into characters using the default encoding. |
static java.lang.String |
decode(byte[] bytes,
boolean plusIsSpace)
Unescape the given byte array by first converting all '%', 'H', 'H' sequences into the byte 0xHH, and then converting the bytes into characters using the default encoding. |
static java.lang.String |
decode(byte[] bytes,
int off,
int len)
Unescape a fragment of the given byte array, by first converting all '%', 'H', 'H' sequences into the byte 0xHH, and then converting the bytes into characters using the default encoding. |
static java.lang.String |
decode(byte[] bytes,
int off,
int len,
boolean plusIsSpace)
Unescape a fragment of the given byte array, by first converting all '%', 'H', 'H' sequences into the byte 0xHH, and then converting the bytes into characters using the default encoding. |
static java.lang.String |
decode(byte[] bytes,
int off,
int len,
java.lang.String enc)
Unescape a fragment of the given byte array by first converting all '%', 'H', 'H' sequences into the byte 0xHH, and then converting the bytes into characters using the specified encoding. |
static java.lang.String |
decode(byte[] bytes,
int off,
int len,
java.lang.String enc,
boolean plusIsSpace)
Unescape a fragment of the given byte array by first converting all '%', 'H', 'H' sequences into the byte 0xHH, and then converting the bytes into characters using the specified encoding. |
static java.lang.String |
decode(byte[] bytes,
java.lang.String enc)
Unescape the given byte array by first converting all '%', 'H', 'H' sequences into the byte 0xHH, and then converting the bytes into characters using the default encoding. |
static java.lang.String |
decode(byte[] bytes,
java.lang.String enc,
boolean plusIsSpace)
Unescape the given byte array by first converting all '%', 'H', 'H' sequences into the byte 0xHH, and then converting the bytes into characters using the default encoding. |
static java.lang.String |
decode(java.lang.String str)
Unescape the given String , converting all %HH
sequences into the UTF-8 character 0xHH. |
static java.lang.String |
decode(java.lang.String str,
boolean plusIsSpace)
Unescape the given String , converting all %HH
sequences into the UTF-8 character 0xHH. |
static java.lang.String |
encode(byte[] bytes,
java.util.BitSet safe)
Escape the given byte array by first converting all bytes not in the given set of "safe" bytes to the sequence '%', 'H', 'H' (where HH is the hex value of the byte), and then converting the bytes into characters using the default encoding. |
static java.lang.String |
encode(byte[] bytes,
java.util.BitSet safe,
boolean spaceAsPlus)
Escape the given byte array by first converting all bytes not in the given set of "safe" bytes to the sequence '%', 'H', 'H' (where HH is the hex value of the byte), and then converting the bytes into characters using the default encoding. |
static java.lang.String |
encode(byte[] bytes,
int off,
int len,
java.util.BitSet safe)
Escape a fragment of the given byte array by first converting all bytes not in the given set of "safe" bytes to the sequence '%', 'H', 'H' (where HH is the hex value of the byte), and then converting the bytes into characters using the default encoding. |
static java.lang.String |
encode(byte[] bytes,
int off,
int len,
java.util.BitSet safe,
boolean spaceAsPlus)
Escape a fragment of the given byte array by first converting all bytes not in the given set of "safe" bytes to the sequence '%', 'H', 'H' (where HH is the hex value of the byte), and then converting the bytes into characters using the default encoding. |
static java.lang.String |
encode(java.lang.String str)
Escape the given String by replacing
all characters not in the default
set of safe characters (unreserved() )
into the sequence %HH (where HH is the hex
value of the character in the default encoding). |
static java.lang.String |
encode(java.lang.String str,
java.util.BitSet safe)
Escape the given String by replacing
all characters not in the given
set of safe characters into the sequence
%HH (where HH is the hex value of the
character in the default encoding). |
static java.lang.String |
encode(java.lang.String str,
java.util.BitSet safe,
boolean spaceAsPlus)
Escape the given String by replacing
all characters not in the given
set of safe characters into the sequence
%HH (where HH is the hex value of the
character in the default encoding). |
static java.lang.String |
encode(java.lang.String str,
java.util.BitSet safe,
java.lang.String enc)
Escape the given String , first converting
the String to bytes using the specified
encoding, then replacing all bytes not in the given
set of safe bytes into the sequence %HH (where HH is
the hex value of the byte). |
static java.lang.String |
encode(java.lang.String str,
java.util.BitSet safe,
java.lang.String enc,
boolean spaceAsPlus)
Escape the given String , first converting
the String to bytes using the specified
encoding, then replacing all bytes not in the given
set of safe bytes into the sequence %HH (where HH is
the hex value of the byte). |
static java.lang.String |
encode(java.lang.String str,
boolean spaceAsPlus)
Escape the given String by replacing
all characters not in the default
set of safe characters (unreserved() )
into the sequence %HH (where HH is the hex
value of the character in the default encoding). |
static java.lang.String |
getPath(java.lang.String url)
Returns the path portion of the given URL. |
static java.lang.String |
getQueryString(java.lang.String url)
Returns the query string for the given URL. |
static java.util.BitSet |
pathSafe()
|
static java.util.BitSet |
queryStringValueSafe()
|
static java.util.BitSet |
unreserved()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public URIUtil()
Method Detail |
public static final java.lang.String decode(java.lang.String str)
String
, converting all %HH
sequences into the UTF-8 character 0xHH.str
- the escaped String
java.lang.IllegalArgumentException
- if a '%'
character is not followed by a
valid 2-digit hexadecimal numberpublic static final java.lang.String decode(java.lang.String str, boolean plusIsSpace)
String
, converting all %HH
sequences into the UTF-8 character 0xHH.
When plusIsSpace is true, '+' will
be converted into ' ' (space),
as is used in the
str
- the escaped String
java.lang.IllegalArgumentException
- if a '%'
character is not followed by a
valid 2-digit hexadecimal numberpublic static final java.lang.String decode(byte[] bytes)
bytes
- the escaped byte array, which
may be changed by this
calljava.lang.IllegalArgumentException
- if a '%'
byte is not followed by a valid
2-digit hexadecimal number (as bytes)public static final java.lang.String decode(byte[] bytes, boolean plusIsSpace)
When plusIsSpace is true, '+' will
be converted into ' ' (space),
as is used in the
bytes
- the escaped byte array, which
may be changed by this
calljava.lang.IllegalArgumentException
- if a '%'
byte is not followed by a valid
2-digit hexadecimal number (as bytes)public static final java.lang.String decode(byte[] bytes, int off, int len)
bytes
- the escaped byte array, which
may be changed by this
calloff
- the index of the first byte to convertlen
- the number of unescaped bytes to convertjava.lang.IllegalArgumentException
- if a '%'
byte is not followed by a valid
2-digit hexadecimal number (as bytes)public static final java.lang.String decode(byte[] bytes, int off, int len, boolean plusIsSpace)
When plusIsSpace is true, '+' will
be converted into ' ' (space),
as is used in the
bytes
- the escaped byte array, which
may be changed by this
calloff
- the index of the first byte to convertlen
- the number of unescaped bytes to convertjava.lang.IllegalArgumentException
- if a '%'
byte is not followed by a valid
2-digit hexadecimal number (as bytes)public static final java.lang.String decode(byte[] bytes, java.lang.String enc) throws java.io.UnsupportedEncodingException
bytes
- the escaped byte array, which
may be changed by this
callenc
- the encoding to usejava.lang.IllegalArgumentException
- if a '%'
byte is not followed by a valid
2-digit hexadecimal number (as bytes)public static final java.lang.String decode(byte[] bytes, java.lang.String enc, boolean plusIsSpace) throws java.io.UnsupportedEncodingException
When plusIsSpace is true, '+' will
be converted into ' ' (space),
as is used in the
bytes
- the escaped byte array, which
may be changed by this
callenc
- the encoding to usejava.lang.IllegalArgumentException
- if a '%'
byte is not followed by a valid
2-digit hexadecimal number (as bytes)public static final java.lang.String decode(byte[] bytes, int off, int len, java.lang.String enc) throws java.io.UnsupportedEncodingException
bytes
- the escaped byte arrayoff
- the index of the first byte to convertlen
- the number of escaped bytes to convertenc
- the encoding to usejava.lang.IllegalArgumentException
- if a '%'
character is not followed by a
valid 2-digit hexadecimal numberpublic static final java.lang.String decode(byte[] bytes, int off, int len, java.lang.String enc, boolean plusIsSpace) throws java.io.UnsupportedEncodingException
When plusIsSpace is true, a
'+' byte will be converted into ' ',
as is used in the
bytes
- the escaped byte arrayoff
- the index of the first byte to convertlen
- the number of escaped bytes to convertenc
- the encoding to usejava.lang.IllegalArgumentException
- if a '%'
character is not followed by a
valid 2-digit hexadecimal numberpublic static final java.lang.String encode(java.lang.String str)
String
by replacing
all characters not in the default
set of safe characters (unreserved()
)
into the sequence %HH (where HH is the hex
value of the character in the default encoding).str
- The unescaped stringpublic static final java.lang.String encode(java.lang.String str, boolean spaceAsPlus)
String
by replacing
all characters not in the default
set of safe characters (unreserved()
)
into the sequence %HH (where HH is the hex
value of the character in the default encoding).
When spaceAsPlus is true and ' '
needs to be encoded (i.e., it is not a safe byte),
then it will be converted to '+',
as is used in the
str
- The unescaped stringpublic static final java.lang.String encode(java.lang.String str, java.util.BitSet safe)
String
by replacing
all characters not in the given
set of safe characters into the sequence
%HH (where HH is the hex value of the
character in the default encoding).str
- The unescaped stringsafe
- The set of "safe" characters (not to be escaped)public static final java.lang.String encode(java.lang.String str, java.util.BitSet safe, boolean spaceAsPlus)
String
by replacing
all characters not in the given
set of safe characters into the sequence
%HH (where HH is the hex value of the
character in the default encoding).
When spaceAsPlus is true and ' '
needs to be encoded (i.e., it is not a safe byte),
then it will be converted to '+',
as is used in the
str
- The unescaped stringsafe
- The set of "safe" characters (not to be escaped)public static final java.lang.String encode(byte[] bytes, java.util.BitSet safe)
bytes
- the unescaped bytessafe
- the set of "safe" bytes (not to be escaped)public static final java.lang.String encode(byte[] bytes, java.util.BitSet safe, boolean spaceAsPlus)
When spaceAsPlus is true and ' '
needs to be encoded (i.e., it is not a safe byte),
then it will be converted to '+',
as is used in the
bytes
- the unescaped bytessafe
- the set of "safe" bytes (not to be escaped)public static final java.lang.String encode(byte[] bytes, int off, int len, java.util.BitSet safe)
bytes
- The unescaped bytesoff
- the index of the first byte to convertlen
- the number of unescaped bytes to convertsafe
- The set of "safe" bytes (not to be escaped)public static final java.lang.String encode(byte[] bytes, int off, int len, java.util.BitSet safe, boolean spaceAsPlus)
When spaceAsPlus is true and ' '
needs to be encoded (i.e., it is not a safe byte),
then it will be converted to '+',
as is used in the
bytes
- The unescaped bytesoff
- the index of the first byte to convertlen
- the number of unescaped bytes to convertsafe
- The set of "safe" bytes (not to be escaped)public static final java.lang.String encode(java.lang.String str, java.util.BitSet safe, java.lang.String enc)
String
, first converting
the String
to bytes using the specified
encoding, then replacing all bytes not in the given
set of safe bytes into the sequence %HH (where HH is
the hex value of the byte).str
- the unescaped stringsafe
- the set of "safe" characters (not to be escaped)enc
- the encoding to usepublic static final java.lang.String encode(java.lang.String str, java.util.BitSet safe, java.lang.String enc, boolean spaceAsPlus)
String
, first converting
the String
to bytes using the specified
encoding, then replacing all bytes not in the given
set of safe bytes into the sequence %HH (where HH is
the hex value of the byte).
When spaceAsPlus is true and ' '
needs to be encoded (i.e., it is not a safe byte),
then it will be converted to '+',
as is used in the
str
- the unescaped stringsafe
- the set of "safe" characters (not to be escaped)enc
- the encoding to usepublic static final java.lang.String getPath(java.lang.String url)
url
- - the URLpublic static final java.lang.String getQueryString(java.lang.String url)
url
- - the URLpublic static final java.util.BitSet unreserved()
public static final java.util.BitSet pathSafe()
public static final java.util.BitSet queryStringValueSafe()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |