anthill.antnet
Class UrlResource

java.lang.Object
  |
  +--anthill.antnet.UrlResource
All Implemented Interfaces:
java.io.Externalizable, Resource, java.io.Serializable

public class UrlResource
extends java.lang.Object
implements Resource, java.io.Externalizable

An UrlResource is an object containing the URL from which the content of a resource may be downloaded. When a UrlResource is inserted in a Storage object, the storage may perform a local copy of the resource by downloading the contents through the input stream obtained through the getInputStream() method.

See Also:
Serialized Form

Constructor Summary
UrlResource()
          Default constructor for externalization.
 
Method Summary
 java.lang.String getAttribute(java.lang.String name)
          Returns the value associated to the specified attribute name, or null if there is no attribute with that name.
 long getContentLength()
          Return the lenght of the content of the resource, if available; otherwise, it returns -1.
 java.io.InputStream getInputStream()
          Return an input stream to download the contents of the resource.
 java.lang.String getName()
          Returns the string identifier of the object.
 void readExternal(java.io.ObjectInput in)
          Marshals this UrlResource to the specified output stream.
 void writeExternal(java.io.ObjectOutput out)
          Marshals this UrlResource to the specified output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlResource

public UrlResource()
Default constructor for externalization.
Method Detail

getName

public java.lang.String getName()
Returns the string identifier of the object.
Specified by:
getName in interface Resource

getAttribute

public java.lang.String getAttribute(java.lang.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 java.io.InputStream getInputStream()
                                   throws java.io.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;

getContentLength

public long getContentLength()
Return the lenght of the content of the resource, if available; otherwise, it returns -1.
Specified by:
getContentLength in interface Resource

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException
Marshals this UrlResource to the specified output stream.
Specified by:
readExternal in interface java.io.Externalizable

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Marshals this UrlResource to the specified output stream.
Specified by:
writeExternal in interface java.io.Externalizable