org.niocchi.core
Class Resource

java.lang.Object
  extended by org.niocchi.core.Resource
Direct Known Subclasses:
DiskResource, MemoryResource

public abstract class Resource
extends java.lang.Object


Field Summary
static int UNKNOWN_HTTP_STATUS
           
 
Constructor Summary
Resource()
           
 
Method Summary
 int getBodyLength()
          Return the message body length.
 java.lang.String getContentEncoding()
          Returns the content encoding, if any.
 java.lang.String getContentMimeSubType()
          Returns the MIME subtype part of the content type.
 java.lang.String getContentMimeType()
          Returns the MIME type part of the content type.
 java.lang.String getContentType()
          Returns the content type.
 java.lang.String getHeader(java.lang.String name_)
          Returns the value associated to a specific HTTP header.
 java.lang.String[] getHeaderNames()
          Returns an array with the HTTP header names.
 int getHTTPStatus()
          Returns the HTTP status.
 int getRawDataSize()
          Returns the size of the data in the response, before processing it.
 java.lang.String headersToString()
          Utility function to display the headers
 boolean isCompressed()
          Return true is the body has been received compressed.
 boolean isValid()
          If the crawled content need to be checked by the URLPool for validity, subclasses can implement this method.
abstract  void save(java.lang.String path_)
          Save this resource to a file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_HTTP_STATUS

public static final int UNKNOWN_HTTP_STATUS
See Also:
Constant Field Values
Constructor Detail

Resource

public Resource()
Method Detail

getBodyLength

public int getBodyLength()
Return the message body length.

Returns:
the message body length.

isValid

public boolean isValid()
If the crawled content need to be checked by the URLPool for validity, subclasses can implement this method. For instance, is jpeg pictures are expected, this method should check the format and returns true only when the picture is in this format.

Returns:
always true.

getHTTPStatus

public int getHTTPStatus()
Returns the HTTP status.

Returns:
the HTTP status.

getHeaderNames

public java.lang.String[] getHeaderNames()
Returns an array with the HTTP header names.

Returns:
an array of the HTTP header names.

getHeader

public java.lang.String getHeader(java.lang.String name_)
Returns the value associated to a specific HTTP header.

Parameters:
name_ - the name of the HTTP header.
Returns:
the associated value.

getContentType

public java.lang.String getContentType()
Returns the content type.


getContentMimeType

public java.lang.String getContentMimeType()
Returns the MIME type part of the content type.


getContentMimeSubType

public java.lang.String getContentMimeSubType()
Returns the MIME subtype part of the content type.


getContentEncoding

public java.lang.String getContentEncoding()
Returns the content encoding, if any. It could be gzip or deflate

Returns:
the content encoding, null if no encoding was found in the HTTP headers.

getRawDataSize

public int getRawDataSize()
Returns the size of the data in the response, before processing it. This size usually is not the same of the given by getBytes().length because this size is before removing not important caracters and decompressing the data


headersToString

public java.lang.String headersToString()
Utility function to display the headers


isCompressed

public boolean isCompressed()
Return true is the body has been received compressed.

Returns:

save

public abstract void save(java.lang.String path_)
                   throws java.io.FileNotFoundException,
                          java.io.IOException
Save this resource to a file.

Parameters:
path_ - the path to save the resource.
Throws:
java.io.FileNotFoundException
java.io.IOException