Java Doc for Util.java in  » Net » SkunkDAV » HTTPClient » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » SkunkDAV » HTTPClient 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   HTTPClient.Util

Util
public class Util (Code)
This class holds various utility methods.
version:
   0.3-2 18/06/1999
author:
   Ronald Tschalär


Field Summary
final static  char[]hex_map
    


Method Summary
final public static  StringassembleHeader(Vector pheader)
     Assembles a Vector of HttpHeaderElements into a full header string.
final static  int[]compile_search(byte[] search)
     Creates an array of distances to speed up the search in findStr(). The returned array should be passed as the second argument to findStr().
Parameters:
  search - the search string (same as the first argument tofindStr()).
final public static  intdefaultPort(String protocol)
     Return the default port used by a given protocol.
final public static  StringdequoteString(String str)
     Replace quoted characters by their unquoted version.
final static  StringescapeUnsafeChars(String path)
     Escape unsafe characters in a path.
final static  intfindSpace(char[] str, int pos)
     returns the position of the first space character in a char array starting a position pos.
final static  intfindStr(byte[] search, int[] cmp, byte[] str, int beg, int end)
     Search for a string.
final public static  HttpHeaderElementgetElement(Vector header, String name)
     Get the HttpHeaderElement with the name name.
final public static  StringgetFragment(String resource)
     Extract the fragment part from an http resource.
final static  HashtablegetList(Hashtable cntxt_list, Object cntxt)
     Helper method for context lists used by modules.
final public static  StringgetParameter(String param, String hdr)
     retrieves the value associated with the parameter param in a given header string.
final public static  StringgetParams(String resource)
     Extract the params part from an http resource.
final public static  StringgetPath(String resource)
     Extract the path from an http resource.

The "resource" part of an HTTP URI can contain a number of parts, some of which are not always of interest.

final public static  StringgetQuery(String resource)
     Extract the query string from an http resource.
final public static  booleanhasToken(String header, String token)
     Determines if the given header contains a certain token.
final public static  StringhttpDate(Date date)
     This returns a string containing the date and time in date formatted according to a subset of RFC-1123.
final static  booleanneedsQuoting(String str)
     Does the string need to be quoted when sent in a header? I.e.
final public static  VectorparseHeader(String header)
     This parses the value part of a header.
final public static  VectorparseHeader(String header, boolean dequote)
     This parses the value part of a header.
final public static  StringquoteString(String str, String qlist)
     Replace given characters by their quoted version.
final static  Object[]resizeArray(Object[] src, int new_size)
    
final static  NVPair[]resizeArray(NVPair[] src, int new_size)
    
final static  AuthorizationInfo[]resizeArray(AuthorizationInfo[] src, int new_size)
    
final static  Cookie[]resizeArray(Cookie[] src, int new_size)
    
final static  String[]resizeArray(String[] src, int new_size)
    
final static  boolean[]resizeArray(boolean[] src, int new_size)
    
final static  byte[]resizeArray(byte[] src, int new_size)
    
final static  char[]resizeArray(char[] src, int new_size)
    
final static  int[]resizeArray(int[] src, int new_size)
    
final public static  booleansameHttpURL(URL url1, URL url2)
     Compares two http urls for equality.
final static  intskipSpace(char[] str, int pos)
     returns the position of the first non-space character in a char array starting a position pos.
final static  intskipToken(char[] str, int pos)
     returns the position of the first non-token character in a char array starting a position pos.
static  String[]splitProperty(String prop)
     Split a property into an array of Strings, using "|" as the separator.

Field Detail
hex_map
final static char[] hex_map(Code)





Method Detail
assembleHeader
final public static String assembleHeader(Vector pheader)(Code)
Assembles a Vector of HttpHeaderElements into a full header string. The individual header elements are seperated by a ", ".
Parameters:
  the - parsed header a string containing the assembled header



compile_search
final static int[] compile_search(byte[] search)(Code)
Creates an array of distances to speed up the search in findStr(). The returned array should be passed as the second argument to findStr().
Parameters:
  search - the search string (same as the first argument tofindStr()). an array of distances (to be passed as the second argument tofindStr()).



defaultPort
final public static int defaultPort(String protocol)(Code)
Return the default port used by a given protocol.
Parameters:
  protocol - the protocol the port number, or 0 if unknown
See Also:   HTTPClient.URI.defaultPort(java.lang.String)



dequoteString
final public static String dequoteString(String str)(Code)
Replace quoted characters by their unquoted version. Quoted characters are characters preceded by a slash. E.g. "\c" would be replaced by "c". This is used in parsing http headers where quoted-characters are allowed in quoted-strings and often used to quote the quote character <">.
Parameters:
  str - the string do dequote the string do with all quoted characters replaced by theirtrue value.



escapeUnsafeChars
final static String escapeUnsafeChars(String path)(Code)
Escape unsafe characters in a path.
Parameters:
  path - the original path the path with all unsafe characters escaped



findSpace
final static int findSpace(char[] str, int pos)(Code)
returns the position of the first space character in a char array starting a position pos.
Parameters:
  str - the char array
Parameters:
  pos - the position to start looking the position of the first space character, or the length ofthe string if not found



findStr
final static int findStr(byte[] search, int[] cmp, byte[] str, int beg, int end)(Code)
Search for a string. Use compile_search() to first generate the second argument. This uses a Knuth-Morris-Pratt like algorithm.
Parameters:
  search - the string to search for.
Parameters:
  cmp - the the array returned by compile_search.
Parameters:
  str - the string in which to look for search.
Parameters:
  beg - the position at which to start the search instr.
Parameters:
  end - the position at which to end the search in str,noninclusive. the position in str where search wasfound, or -1 if not found.



getElement
final public static HttpHeaderElement getElement(Vector header, String name)(Code)
Get the HttpHeaderElement with the name name.
Parameters:
  header - a vector of HttpHeaderElement's, such as is returnedfrom parseHeader()
Parameters:
  name - the name of element to retrieve; matching iscase-insensitive the request element, or null if none found.
See Also:   Util.parseHeader(java.lang.String)



getFragment
final public static String getFragment(String resource)(Code)
Extract the fragment part from an http resource.
Parameters:
  the - resource to split the fragment, or null if there was none
See Also:   Util.getPath



getList
final static Hashtable getList(Hashtable cntxt_list, Object cntxt)(Code)
Helper method for context lists used by modules. Returns the list associated with the context if it exists; otherwise it creates a new list and adds it to the context list.
Parameters:
  cntxt_list - the list of lists indexed by context
Parameters:
  cntxt - the context



getParameter
final public static String getParameter(String param, String hdr) throws ParseException(Code)
retrieves the value associated with the parameter param in a given header string. It parses the header using 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.
See Also:   Util.parseHeader(java.lang.String)
Parameters:
  param - the parameter name
Parameters:
  hdr - the header value the value for this parameter, or null if not found.
exception:
  ParseException - if the above syntax rules are violated.




getParams
final public static String getParams(String resource)(Code)
Extract the params part from an http resource.
Parameters:
  the - resource to split the params, or null if there are none
See Also:   Util.getPath



getPath
final public static String getPath(String resource)(Code)
Extract the path from an http 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-2068):

 resource = [ "/" ] [ path ] [ ";" params ] [ "?" query ] [ "#" fragment ]
 

Parameters:
  the - resource to split the path, including any leading "/"
See Also:   Util.getParams
See Also:   Util.getQuery
See Also:   Util.getFragment



getQuery
final public static String getQuery(String resource)(Code)
Extract the query string from an http resource.
Parameters:
  the - resource to split the query, or null if there was none
See Also:   Util.getPath



hasToken
final public static boolean hasToken(String header, String token) throws ParseException(Code)
Determines if the given header contains a certain token. The header must conform to the rules outlined in parseHeader().
See Also:   Util.parseHeader(java.lang.String)
Parameters:
  header - the header value.
Parameters:
  token - the token to find; the match is case-insensitive. true if the token is present, false otherwise.
exception:
  ParseException - if this is thrown parseHeader().



httpDate
final public static String httpDate(Date date)(Code)
This returns a string containing the date and time in date formatted according to a subset of RFC-1123. The format is defined in the HTTP/1.0 spec (RFC-1945), section 3.3, and the HTTP/1.1 spec (RFC-2068), section 3.3.1. Note that Date.toGMTString() is close, but is missing the weekday and supresses the leading zero if the day is less than the 10th. Instead we use the SimpleDateFormat class.

Some versions of JDK 1.1.x are bugged in that their GMT uses daylight savings time... Therefore we use our own timezone definitions.
Parameters:
  date - the date and time to be converted a string containg the date and time as used in http




needsQuoting
final static boolean needsQuoting(String str)(Code)
Does the string need to be quoted when sent in a header? I.e. does it contain non-token characters?
Parameters:
  str - the string true if it needs quoting (i.e. it contains non-token chars)



parseHeader
final public static Vector parseHeader(String header) throws ParseException(Code)
This parses the value part of a header. All quoted strings are dequoted.
See Also:   Util.parseHeader(java.lang.String,boolean)
Parameters:
  header - the value part of the header. a Vector containing all the elements; each entry is aninstance of HttpHeaderElement.
exception:
  ParseException - if the syntax rules are violated.



parseHeader
final public static Vector parseHeader(String header, boolean dequote) throws ParseException(Code)
This parses the value part of a header. The result is a Vector of HttpHeaderElement's. The syntax the header must conform to is:
 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.
Parameters:
  header - the value part of the header.
Parameters:
  dequote - if true all quoted strings are dequoted. a Vector containing all the elements; each entry is aninstance of HttpHeaderElement.
exception:
  ParseException - if the above syntax rules are violated.
See Also:   HTTPClient.HttpHeaderElement



quoteString
final public static String quoteString(String str, String qlist)(Code)
Replace given characters by their quoted version. Quoted characters are characters preceded by a slash. E.g. "c" would be replaced by "\c". This is used in generating http headers where certain characters need to be quoted, such as the quote character <">.
Parameters:
  str - the string do quote
Parameters:
  qlist - the list of characters to quote the string do with all characters replaced by theirquoted version.



resizeArray
final static Object[] resizeArray(Object[] src, int new_size)(Code)



resizeArray
final static NVPair[] resizeArray(NVPair[] src, int new_size)(Code)



resizeArray
final static AuthorizationInfo[] resizeArray(AuthorizationInfo[] src, int new_size)(Code)



resizeArray
final static Cookie[] resizeArray(Cookie[] src, int new_size)(Code)



resizeArray
final static String[] resizeArray(String[] src, int new_size)(Code)



resizeArray
final static boolean[] resizeArray(boolean[] src, int new_size)(Code)



resizeArray
final static byte[] resizeArray(byte[] src, int new_size)(Code)



resizeArray
final static char[] resizeArray(char[] src, int new_size)(Code)



resizeArray
final static int[] resizeArray(int[] src, int new_size)(Code)



sameHttpURL
final public static boolean sameHttpURL(URL url1, URL url2)(Code)
Compares two http urls for equality. This exists because the method 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).
Parameters:
  url1 - the first url
Parameters:
  url1 - the second url true if url1 and url2 compare equal




skipSpace
final static int skipSpace(char[] str, int pos)(Code)
returns the position of the first non-space character in a char array starting a position pos.
Parameters:
  str - the char array
Parameters:
  pos - the position to start looking the position of the first non-space character



skipToken
final static int skipToken(char[] str, int pos)(Code)
returns the position of the first non-token character in a char array starting a position pos.
Parameters:
  str - the char array
Parameters:
  pos - the position to start looking the position of the first non-token character, or the lengthof the string if not found



splitProperty
static String[] splitProperty(String prop)(Code)
Split a property into an array of Strings, using "|" as the separator.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.