|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectHTTPClient.Util
This class holds various utility methods.
| Field Summary | |
(package private) static char[] |
hex_map
|
| Method Summary | |
static String |
assembleHeader(Vector pheader)
Assembles a Vector of HttpHeaderElements into a full header string. |
(package private) static int[] |
compile_search(byte[] search)
Creates an array of distances to speed up the search in findStr(). |
static int |
defaultPort(String protocol)
Deprecated. use URI.defaultPort() instead |
static String |
dequoteString(String str)
Replace quoted characters by their unquoted version. |
(package private) static String |
escapeUnsafeChars(String path)
Escape unsafe characters in a path. |
(package private) static int |
findSpace(char[] str,
int pos)
returns the position of the first space character in a char array starting a position pos. |
(package private) static int |
findStr(byte[] search,
int[] cmp,
byte[] str,
int beg,
int end)
Search for a string. |
static HttpHeaderElement |
getElement(Vector header,
String name)
Get the HttpHeaderElement with the name name. |
static String |
getFragment(String resource)
Extract the fragment part from an http resource. |
(package private) static Hashtable |
getList(Hashtable cntxt_list,
Object cntxt)
Helper method for context lists used by modules. |
static String |
getParameter(String param,
String hdr)
retrieves the value associated with the parameter param in a given header string. |
static String |
getParams(String resource)
Extract the params part from an http resource. |
static String |
getPath(String resource)
Extract the path from an http resource. |
static String |
getQuery(String resource)
Extract the query string from an http resource. |
static boolean |
hasToken(String header,
String token)
Determines if the given header contains a certain token. |
static String |
httpDate(Date date)
This returns a string containing the date and time in date formatted according to a subset of RFC-1123. |
(package private) static boolean |
needsQuoting(String str)
Does the string need to be quoted when sent in a header? I.e. |
static Vector |
parseHeader(String header)
This parses the value part of a header. |
static Vector |
parseHeader(String header,
boolean dequote)
This parses the value part of a header. |
(package private) static Date |
parseHttpDate(String dstr)
Parse the http date string. |
static String |
quoteString(String str,
String qlist)
Replace given characters by their quoted version. |
(package private) static AuthorizationInfo[] |
resizeArray(AuthorizationInfo[] src,
int new_size)
|
(package private) static boolean[] |
resizeArray(boolean[] src,
int new_size)
|
(package private) static byte[] |
resizeArray(byte[] src,
int new_size)
|
(package private) static char[] |
resizeArray(char[] src,
int new_size)
|
(package private) static Cookie[] |
resizeArray(Cookie[] src,
int new_size)
|
(package private) static int[] |
resizeArray(int[] src,
int new_size)
|
(package private) static NVPair[] |
resizeArray(NVPair[] src,
int new_size)
|
(package private) static Object[] |
resizeArray(Object[] src,
int new_size)
|
(package private) static String[] |
resizeArray(String[] src,
int new_size)
|
static boolean |
sameHttpURL(URL url1,
URL url2)
Compares two http urls for equality. |
(package private) static int |
skipSpace(char[] str,
int pos)
returns the position of the first non-space character in a char array starting a position pos. |
(package private) static int |
skipToken(char[] str,
int pos)
returns the position of the first non-token character in a char array starting a position pos. |
(package private) static String[] |
splitProperty(String prop)
Split a property into an array of Strings, using "|" as the separator. |
static boolean |
wildcardMatch(String pattern,
String name)
Match pattern against name, where pattern may contain wildcards ('*'). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
static final char[] hex_map
| Method Detail |
static final Object[] resizeArray(Object[] src,
int new_size)
static final NVPair[] resizeArray(NVPair[] src,
int new_size)
static final AuthorizationInfo[] resizeArray(AuthorizationInfo[] src,
int new_size)
static final Cookie[] resizeArray(Cookie[] src,
int new_size)
static final String[] resizeArray(String[] src,
int new_size)
static final boolean[] resizeArray(boolean[] src,
int new_size)
static final byte[] resizeArray(byte[] src,
int new_size)
static final char[] resizeArray(char[] src,
int new_size)
static final int[] resizeArray(int[] src,
int new_size)
static String[] splitProperty(String prop)
static final Hashtable getList(Hashtable cntxt_list,
Object cntxt)
cntxt_list - the list of lists indexed by contextcntxt - the contextstatic final int[] compile_search(byte[] search)
search - the search string (same as the first argument to
findStr()).
static final int findStr(byte[] search,
int[] cmp,
byte[] str,
int beg,
int end)
search - the string to search for.cmp - the the array returned by compile_search.str - the string in which to look for search.beg - the position at which to start the search in
str.end - the position at which to end the search in str,
noninclusive.
public static final String dequoteString(String str)
str - the string do dequote
public static final String quoteString(String str,
String qlist)
str - the string do quoteqlist - the list of characters to quote
public static final Vector parseHeader(String header)
throws ParseException
header - the value part of the header.
ParseException - if the syntax rules are violated.parseHeader(java.lang.String, boolean)
public static final Vector parseHeader(String header,
boolean dequote)
throws ParseException
header = [ element ] *( "," [ element ] )
element = name [ "=" [ value ] ] *( ";" [ param ] )
param = name [ "=" [ value ] ]
name = token
value = ( token | quoted-string )
token = 1*<any char except "=", ",", ";", <"> and
white space>
quoted-string = <"> *( text | quoted-char ) <">
text = any char except <">
quoted-char = "\" char
Any amount of white space is allowed between any part of the header,
element or param and is ignored. A missing value in any element or
param will be stored as the empty string; if the "=" is also missing
null will be stored instead.
header - the value part of the header.dequote - if true all quoted strings are dequoted.
ParseException - if the above syntax rules are violated.HttpHeaderElement
public static final boolean hasToken(String header,
String token)
throws ParseException
header - the header value.token - the token to find; the match is case-insensitive.
ParseException - if this is thrown parseHeader().parseHeader(java.lang.String)
public static final HttpHeaderElement getElement(Vector header,
String name)
header - a vector of HttpHeaderElement's, such as is returned
from parseHeader()name - the name of element to retrieve; matching is
case-insensitive
parseHeader(java.lang.String)
public static final String getParameter(String param,
String hdr)
throws ParseException
parseHeader() and then searches the first element for the
given parameter. This is used especially in headers like
'Content-type' and 'Content-Disposition'.
quoted characters ("\x") in a quoted string are dequoted.
param - the parameter namehdr - the header value
ParseException - if the above syntax rules are violated.parseHeader(java.lang.String)public static final String assembleHeader(Vector pheader)
static final int skipSpace(char[] str,
int pos)
str - the char arraypos - the position to start looking
static final int findSpace(char[] str,
int pos)
str - the char arraypos - the position to start looking
static final int skipToken(char[] str,
int pos)
str - the char arraypos - the position to start looking
static final boolean needsQuoting(String str)
str - the string
public static final boolean sameHttpURL(URL url1,
URL url2)
java.net.URL.sameFile() is broken (an explicit port 80
doesn't compare equal to an implicit port, and it doesn't take
escapes into account).
Two http urls are considered equal if they have the same protocol (case-insensitive match), the same host (case-insensitive), the same port and the same file (after decoding escaped characters).
url1 - the first url
public static final int defaultPort(String protocol)
protocol - the protocol
URI.defaultPort(java.lang.String)static final Date parseHttpDate(String dstr)
dstr - the date string to parse
public static final String httpDate(Date date)
Some versions of JDK 1.1.x are bugged in that their GMT uses daylight savings time... Therefore we use our own timezone definitions.
date - the date and time to be converted
static final String escapeUnsafeChars(String path)
path - the original path
public static final String getPath(String resource)
The "resource" part of an HTTP URI can contain a number of parts, some of which are not always of interest. These methods here will extract the various parts, assuming the following syntanx (taken from RFC-2616):
resource = [ "/" ] [ path ] [ ";" params ] [ "?" query ] [ "#" fragment ]
getParams(java.lang.String),
getQuery(java.lang.String),
getFragment(java.lang.String)public static final String getParams(String resource)
getPath(java.lang.String)public static final String getQuery(String resource)
getPath(java.lang.String)public static final String getFragment(String resource)
getPath(java.lang.String)
public static final boolean wildcardMatch(String pattern,
String name)
pattern - the pattern to match; may contain '*' which match
any number (0 or more) of any character (think file
globbing)name - the name to match against the pattern
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||