jxtaimpl.storage
Class AnthillResource

java.lang.Object
  |
  +--jxtaimpl.storage.AnthillResource
All Implemented Interfaces:
Resource, Serializable

public class AnthillResource
extends Object
implements Resource, Serializable

This class represents a resource in the Anthill network

Author:
Francesco Russo (frusso@cs.unibo.it)
See Also:
Serialized Form

Constructor Summary
AnthillResource(Content cont, String species, URL pipeId, String pipeName, String pipeType)
          This is the default constructor.
 
Method Summary
 String getAttribute(String name)
          Returns the value associated to the specified attribute name, or null if there is no attribute with that name.
protected  Content getContent()
          This protected method can be invoked in order to obtain the Content instance associated with an AnthillResource.
 long getContentLength()
          Return the lenght of the content of the resource, if available; otherwise, it returns -1.
 InputStream getInputStream()
          This method returns an InputStream created starting from the Content this resource refers to.
 Object getKey()
          Returns the key identifier of the object.
 String getName()
          Returns the string identifier of the object.
 URL getPipeId()
          This method returns the ID of the pipe for downloading the resource
 String getPipeName()
          This method returns the name of the pipe for downloading the resource
 String getPipeType()
          This method returns the type of the pipe for downloading the resource
 String getResourceName()
          This method returns the logical name of the resource.
 String getSpecies()
          This method gets the ant species of the ant that obtained this resource
 long size()
          Return the space required to store the resource object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnthillResource

public AnthillResource(Content cont,
                       String species,
                       URL pipeId,
                       String pipeName,
                       String pipeType)
This is the default constructor. It needs a Content instance, and the set of information rapresenting the input pipe from which a resource can be downloaded

Parameters:
cont - The Content instance associate with the resource
species - The ant species of the ant requiring this resource
pipeId - This is the JXTA pipeID of the local jxtaimpl.DownloadService input-pipe waiting for download requests to come
pipeName - The pipe's logical name
pipeType - The pipe's type (point-to-point, propagate, secure)
Method Detail

getKey

public Object getKey()
Returns the key identifier of the object. Actually this key idendifier is a net.jxta.share.ContentId instance.

Specified by:
getKey in interface Resource

getName

public String getName()
Returns the string identifier of the object. Actually this string idendifier is a net.jxta.share.ContentId instance converted to String.

Specified by:
getName in interface Resource

getResourceName

public String getResourceName()
This method returns the logical name of the resource. In order to obtain its ID, please refer to the getKey and getName methods.


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. The attributes this implementation refers to are the elements found in a generic ContentAdvertisement, since an AnthillResource is based on the net.jxta.share.Content class. Reflection API is used for discovering getter methods in the ContentAdvertisement class matching with the "name" input parameter.

Specified by:
getAttribute in interface Resource
Parameters:
name - the name of the attribute (ContentAdvertisement xml-element)

getInputStream

public InputStream getInputStream()
                           throws IOException
This method returns an InputStream created starting from the Content this resource refers to. This method has to be invoke only locally.

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

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

size

public long size()
Return the space required to store the resource object.

Specified by:
size in interface Resource

getContent

protected Content getContent()
This protected method can be invoked in order to obtain the Content instance associated with an AnthillResource.


getSpecies

public String getSpecies()
This method gets the ant species of the ant that obtained this resource


getPipeId

public URL getPipeId()
This method returns the ID of the pipe for downloading the resource


getPipeName

public String getPipeName()
This method returns the name of the pipe for downloading the resource


getPipeType

public String getPipeType()
This method returns the type of the pipe for downloading the resource