anthill.types
Class SimpleURLResource

java.lang.Object
  |
  +--anthill.types.SimpleURLResource
All Implemented Interfaces:
Resource, URLResource

public class SimpleURLResource
extends Object
implements URLResource

Version:
$Revision: 1.2 $
Author:
Alberto Montresor

Constructor Summary
SimpleURLResource(String url, DocumentId id)
          Constructs a new SimpleURLResource identified by the specified stringified URL and by the given document ID.
SimpleURLResource(URL url, DocumentId id)
          Constructs a new SimpleURLResource identified by the specified URL.
 
Method Summary
 boolean equals(Object obj)
          Check whether this SimpleURLResource is equal to the specified object.
 String getAttribute(String name)
          Not supported.
 long getContentLength()
          Returns the lenght of the content of the resource, if available.
 String getFile()
          Returns the file part of this URL.
 InputStream getInputStream()
          Return an input stream to download the contents of the resource.
 Object getKey()
          Returns the document key for this Url resource as the key.
 String getName()
          Returns the string identifier of the object.
 String getURL()
          Returns the stringified url for this Url resource.
 int hashCode()
          Returns a hash code value for the object.
 long size()
          Returns the space needed to store the resource, if available.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleURLResource

public SimpleURLResource(URL url,
                         DocumentId id)
Constructs a new SimpleURLResource identified by the specified URL.

Parameters:
url - url from which the resource may be downloaded
id - the document identifier associated to this resource

SimpleURLResource

public SimpleURLResource(String url,
                         DocumentId id)
Constructs a new SimpleURLResource identified by the specified stringified URL and by the given document ID.

Parameters:
url - url from which the resource may be downloaded
id - the document identifier associated to this resource
Method Detail

getName

public String getName()
Returns the string identifier of the object.

Specified by:
getName in interface Resource

getAttribute

public String getAttribute(String name)
Not supported.

Specified by:
getAttribute in interface Resource
Parameters:
name - the name of the attribute

getInputStream

public InputStream getInputStream()
                           throws IOException
Return an input stream to download the contents of the resource. Depending on the implementation, the contents may be read from the local storage, if the resource has been copied locally; or downloaded remotely, otherwise.

Specified by:
getInputStream in interface Resource
Returns:
an input stream to read the contents of a resource;
IOException

getContentLength

public long getContentLength()
Returns the lenght of the content of the resource, if available. Returns -1 otherwise.

Specified by:
getContentLength in interface Resource
Returns:
the lenght of the content of the resource

size

public long size()
Returns the space needed to store the resource, if available. Returns -1 otherwise.

Specified by:
size in interface Resource

getKey

public Object getKey()
Returns the document key for this Url resource as the key.

Specified by:
getKey in interface Resource

getURL

public String getURL()
Returns the stringified url for this Url resource.

Specified by:
getURL in interface URLResource

getFile

public String getFile()
Returns the file part of this URL.

Specified by:
getFile in interface URLResource

equals

public boolean equals(Object obj)
Check whether this SimpleURLResource is equal to the specified object.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object

toString

public String toString()
Returns a string representation of the object.

Overrides:
toString in class Object