Java Doc for HttpTool.java in  » Web-Crawler » JoBo » net » matuschek » http » 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 » Web Crawler » JoBo » net.matuschek.http 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.matuschek.http.HttpTool

HttpTool
public class HttpTool (Code)
Class for retrieving documents from HTTP servers.

The main purpose of this class is to retrieve a document from an HTTP server.

For many purposes the Java URLInputStream is good for this, but if you want to have full control over the HTTP headers (both request and response headers), HttpTool is the answer.

Also it defines a callback interface to inform a client about the state of the current download operation.

It is possible to abort a download after getting the HTTP response headers from the server (e.g. if a document of this Content-Type is useless for your application or the document is to big or whatever you like)

HttpTool is reusuable. You should initializes it once and use it for every download operation.


author:
   Daniel Matuschek
version:
   $Id: HttpTool.java,v 1.28 2004/03/26 20:28:44 matuschd Exp $

Inner Class :protected class DocAndConnection

Field Summary
final static  byteCR
    
final static  StringHTTP_VERSION
    
final static  byteLF
    
final public static  intSTATUS_CONNECTED
    
final public static  intSTATUS_CONNECTING
    
final public static  intSTATUS_DENIEDBYRULE
    
final public static  intSTATUS_DONE
    
final public static  intSTATUS_RETRIEVING
    
static  SimpleDateFormatdf
    

Constructor Summary
public  HttpTool()
     Initializes HttpTool with a new CookieManager (that will not contain any cookie).

Method Summary
public  voidclearCookies()
    
public  voidfinish()
     Insiders BugFix This method finishes the MemoryCleanupManager.
public  StringgetAgentName()
    
public  intgetBandwidth()
     Get the value of bandwidth.
public  HttpToolCallbackgetCallback()
    
public  CookieManagergetCookieManager()
    
public  DownloadRuleSetgetDownloadRuleSet()
    
public  booleangetEnableCookies()
    
public  DategetIfModifiedSince()
    
public  NTLMAuthorizationgetNtlmAuthorization()
    
public  StringgetProxy()
    
public  intgetTimeout()
    
public  intgetUpdateInterval()
    
protected  StringlineString(byte[] b)
     convert an array of bytes to a String.
public  HttpDocretrieveDocument(URL u, int method, String parameters)
     Retrieves a document from the given URL.
protected  DocAndConnectionretrieveDocumentInternal(URL u, int method, String parameters, HttpConnection httpConn, String ntlmAuthorizationInfo)
     Same like method without parameter httpConnection, but this method uses the passed connection.
public  voidsetAgentName(String name)
    
public  voidsetBandwidth(int bandwidth)
     Set the value of bandwidth.
public  voidsetCallback(HttpToolCallback callback)
     Sets a callback object If set this object will be used to inform about the current status of the download.
public  voidsetCookieManager(CookieManager cm)
    
public  voidsetDownloadRuleSet(DownloadRuleSet rules)
     Sets the DownloadRules for this object
A download rule uses the HTTP return headers to decide if the download should be finished.
public  voidsetEnableCookies(boolean enable)
    
public  voidsetFromAddress(String fromAddress)
     Sets the content From: HTTP header
Parameters:
  fromAdress - an email adress (e.g.
public  voidsetIfModifiedSince(Date modifyDate)
     Set the value of the "If-Modified-Since" header Usually, this is null and HttpTool will retrieve every document.
public  voidsetNtlmAuthorization(NTLMAuthorization ntlmAuthorization)
    
public  voidsetProxy(String proxyDescr)
    
public  voidsetReferer(String referer)
    
public  voidsetTimeout(int timeout)
     Sets the timeout for getting data.
public  voidsetUpdateInterval(int updateInterval)
     Sets the callback update interval This setting is used if a callback object is defined.
protected  booleanuseProxy()
    

Field Detail
CR
final static byte CR(Code)
Carriage return



HTTP_VERSION
final static String HTTP_VERSION(Code)
used HTTP version



LF
final static byte LF(Code)
Line feed



STATUS_CONNECTED
final public static int STATUS_CONNECTED(Code)
HTTP connection was established, but no data where retrieved



STATUS_CONNECTING
final public static int STATUS_CONNECTING(Code)
HTTP connection will be established



STATUS_DENIEDBYRULE
final public static int STATUS_DENIEDBYRULE(Code)
download could not be finished because a DownloadRule denied it



STATUS_DONE
final public static int STATUS_DONE(Code)
download finished



STATUS_RETRIEVING
final public static int STATUS_RETRIEVING(Code)
data will be retrieved now



df
static SimpleDateFormat df(Code)
The DateFormat instance will be used to format If-Modified-Since requests




Constructor Detail
HttpTool
public HttpTool()(Code)
Initializes HttpTool with a new CookieManager (that will not contain any cookie). Enables logging




Method Detail
clearCookies
public void clearCookies()(Code)
Delete all cookies



finish
public void finish()(Code)
Insiders BugFix This method finishes the MemoryCleanupManager.



getAgentName
public String getAgentName()(Code)
Gets the current setting of the User-Agent HTTP header the User-Agent name



getBandwidth
public int getBandwidth()(Code)
Get the value of bandwidth. value of bandwidth.



getCallback
public HttpToolCallback getCallback()(Code)
Gets the current callback object the defined HttpToolCallback object



getCookieManager
public CookieManager getCookieManager()(Code)
Gets the CookieManager used by this HttpTool the CookieManager that will be used by this HttpTool



getDownloadRuleSet
public DownloadRuleSet getDownloadRuleSet()(Code)
Gets the DownloadRules for this object a DownloadRuleSet



getEnableCookies
public boolean getEnableCookies()(Code)
Get the status of the cookie engine true, if HTTP cookies are enabled, false otherwise



getIfModifiedSince
public Date getIfModifiedSince()(Code)
Returns the date used for the "If-Modified-Since" header a Date object if the "If-Modified-Since" header is set,null otherwise



getNtlmAuthorization
public NTLMAuthorization getNtlmAuthorization()(Code)



getProxy
public String getProxy()(Code)
Gets a textual representation of the current proxy settings return the proxy settings in the format host:port



getTimeout
public int getTimeout()(Code)
Gets the timeout for getting data in seconds the value of sockerTimeout
See Also:   HttpTool.setTimeout(int)



getUpdateInterval
public int getUpdateInterval()(Code)
Gets the current update interval the update interval in bytes
See Also:   HttpTool.setUpdateInterval(int)



lineString
protected String lineString(byte[] b)(Code)
convert an array of bytes to a String. if the last byte is an CR it will be ignored



retrieveDocument
public HttpDoc retrieveDocument(URL u, int method, String parameters) throws HttpException(Code)
Retrieves a document from the given URL. If Cookies are enabled it will use the CookieManager to set Cookies it got from former retrieveDocument operations.
Parameters:
  u - the URL to retrieve (only http:// supported yet)
Parameters:
  method - HttpConstants.GET for a GET request, HttpConstants.POSTfor a POST request
Parameters:
  parameters - additional parameters. Will be added to the URL ifthis is a GET request, posted if it is a POST request a HttpDoc if a document was retrieved, null otherwise
See Also:   HttpConstants



retrieveDocumentInternal
protected DocAndConnection retrieveDocumentInternal(URL u, int method, String parameters, HttpConnection httpConn, String ntlmAuthorizationInfo) throws HttpException(Code)
Same like method without parameter httpConnection, but this method uses the passed connection.
Parameters:
  u -
Parameters:
  method -
Parameters:
  parameters -
Parameters:
  httpConnection - (Use this connection) DocAndConnection
throws:
  HttpException -



setAgentName
public void setAgentName(String name)(Code)
Sets the User-Agent: HTTP header
Parameters:
  name - name of the user agent (may contain spaces)



setBandwidth
public void setBandwidth(int bandwidth)(Code)
Set the value of bandwidth.
Parameters:
  bandwith - Value to assign to bandwidth.



setCallback
public void setCallback(HttpToolCallback callback)(Code)
Sets a callback object If set this object will be used to inform about the current status of the download. HttpTool will call methods of this object while retrieving a document.
Parameters:
  callback - a callback object
See Also:   HttpToolCallback



setCookieManager
public void setCookieManager(CookieManager cm)(Code)
Sets the CookieManager for this HttpTool By default a MemoryCookieManager will be used, but you can use this method to use your own CookieManager implementation
Parameters:
  cm - an object that implements the CookieManager interface



setDownloadRuleSet
public void setDownloadRuleSet(DownloadRuleSet rules)(Code)
Sets the DownloadRules for this object
A download rule uses the HTTP return headers to decide if the download should be finished.
Parameters:
  rule - a DownloadRule



setEnableCookies
public void setEnableCookies(boolean enable)(Code)
Enable/disable cookies
Parameters:
  enable - if true, HTTP cookies will be enabled, if falseHttpTool will not use cookies



setFromAddress
public void setFromAddress(String fromAddress)(Code)
Sets the content From: HTTP header
Parameters:
  fromAdress - an email adress (e.g. some@where.com)



setIfModifiedSince
public void setIfModifiedSince(Date modifyDate)(Code)
Set the value of the "If-Modified-Since" header Usually, this is null and HttpTool will retrieve every document. Setting this to a date will retrieve only documents that were modified since this time



setNtlmAuthorization
public void setNtlmAuthorization(NTLMAuthorization ntlmAuthorization)(Code)



setProxy
public void setProxy(String proxyDescr) throws HttpException(Code)
sets a proxy to use
Parameters:
  proxyDescr - the Proxy definition in the format host:port



setReferer
public void setReferer(String referer)(Code)
Sets the Referer: HTTP header
Parameters:
  referer - value for the Referer header



setTimeout
public void setTimeout(int timeout)(Code)
Sets the timeout for getting data. If HttpTool can't read data from a remote web server after this number of seconds it will stop the download of the current file
Parameters:
  timeout - Timeout in seconds



setUpdateInterval
public void setUpdateInterval(int updateInterval)(Code)
Sets the callback update interval This setting is used if a callback object is defined. Then after reading this number of bytes, the method setHttpToolDocCurrentSize will be called. You should not set this to a value smaller then 1000 unless your bandwidth is very small, because it will slow down downloads.
Parameters:
  updateInterval - update interval in bytes
See Also:   HttpToolCallbackInterface.setHttpToolDocCurrentSize(int)



useProxy
protected boolean useProxy()(Code)
should I use a proxy ? true if a proxy was configured, false otherwise



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.