anthill.types
Class URLResourceImpl

java.lang.Object
  |
  +--anthill.types.URLResourceImpl
All Implemented Interfaces:
Externalizable, Resource, Serializable

public class URLResourceImpl
extends Object
implements Resource, Externalizable

Version:
$Revision: 1.2 $
Author:
Alberto Montresor
See Also:
Serialized Form

Constructor Summary
URLResourceImpl()
          Default constructor for externalization.
URLResourceImpl(String url, DocumentId id)
          Constructs a new URLResourceImpl identified by the specified stringified URL and by the given document ID.
URLResourceImpl(URL url, DocumentId id)
          Constructs a new URLResourceImpl identified by the specified URL.
 
Method Summary
 boolean equals(Object obj)
          Check whether this URLResourceImpl is equal to the specified object.
 String getAttribute(String name)
          Returns the value associated to the specified attribute name, or null if there is no attribute with that name.
 long getContentLength()
          Returns the lenght of the content of the resource, if available.
 String getFile(String url)
          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.
 void readExternal(ObjectInput in)
          Marshals this URLResourceImpl to the specified output stream.
 long size()
          Returns the space needed to store the resource, if available.
 String toString()
          Returns a string representation of the object.
 void writeExternal(ObjectOutput out)
          Marshals this URLResourceImpl to the specified output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URLResourceImpl

public URLResourceImpl()
Default constructor for externalization.


URLResourceImpl

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

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

URLResourceImpl

public URLResourceImpl(String url,
                       DocumentId id)
Constructs a new URLResourceImpl 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)
Returns the value associated to the specified attribute name, or null if there is no attribute with that name.

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.


getFile

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


equals

public boolean equals(Object obj)
Check whether this URLResourceImpl 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

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Marshals this URLResourceImpl to the specified output stream.

Specified by:
readExternal in interface Externalizable
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Marshals this URLResourceImpl to the specified output stream.

Specified by:
writeExternal in interface Externalizable
IOException