antsim.impl
Class RandomResource

java.lang.Object
  |
  +--antsim.impl.RandomResource
All Implemented Interfaces:
Resource

public class RandomResource
extends Object
implements Resource

A RandomResource is characterized only by its name, which is a string obtained from a long value generated randomly.

Version:
$Revision: 1.2 $
Author:
Alberto Montresor

Constructor Summary
RandomResource()
          Construct a resource with a random name
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one
 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()
          Return the lenght of the content of the resource, if available; otherwise, it returns -1.
 InputStream getInputStream()
          Return an input stream to download the contents of the resource.
 Object getKey()
          Returns the key identifier of the object.
 String getName()
          Returns the string identifier of the object.
 long size()
          Return the space required to store the resource object.
 String toString()
          Return a string representing this resource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RandomResource

public RandomResource()
Construct a resource with a random name

Method Detail

getKey

public Object getKey()
Returns the key identifier of the object.

Specified by:
getKey in interface Resource

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.

Implementation note: in this simple implementation, this feature is not present; exception UnsupportedOperationException is raised.

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

getInputStream

public InputStream getInputStream()
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.

Implementation note: in this simple implementation, this feature is not present; exception UnsupportedOperationException is raised.

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.

Implementation note: in this simple implementation, this feature is not present; exception UnsupportedOperationException is raised.

Specified by:
getContentLength in interface Resource

size

public long size()
Description copied from interface: Resource
Return the space required to store the resource object.

Specified by:
size in interface Resource

toString

public String toString()
Return a string representing this resource

Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one

Overrides:
equals in class Object