net.krecan.m2_proxy.resource
Class DefaultResource

java.lang.Object
  extended by net.krecan.m2_proxy.resource.AbstractResource
      extended by net.krecan.m2_proxy.resource.DefaultResource
All Implemented Interfaces:
Resource, ResourceWithInputStream

public class DefaultResource
extends AbstractResource
implements ResourceWithInputStream

Default resource implementantion. Wraps input stream.

Author:
Lukas Krecan

Constructor Summary
DefaultResource(String logicalName, long lastModified, long length, InputStream inputStream)
           
 
Method Summary
 void copyToStream(OutputStream outputStream)
          Copies the resource to the output stream.
 boolean equals(Object obj)
           
 InputStream getInputStream()
           
 long getLastModified()
          Returns last modification date.
 long getLength()
          Returns length of the resource
 int hashCode()
           
 void release()
          Releases all system resources blocked by this resource :-) It HAS to be called after using the resource.
protected  void setInputStream(InputStream inputStream)
           
 void setLastModified(long lastModificationDate)
           
protected  void setLength(long length)
           
 String toString()
           
 
Methods inherited from class net.krecan.m2_proxy.resource.AbstractResource
finalize, getLogicalName, isReleased, setLogicalName, setReleased
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.krecan.m2_proxy.Resource
getLogicalName
 

Constructor Detail

DefaultResource

public DefaultResource(String logicalName,
                       long lastModified,
                       long length,
                       InputStream inputStream)
Method Detail

getLength

public long getLength()
Description copied from interface: Resource
Returns length of the resource

Specified by:
getLength in interface Resource
Returns:

copyToStream

public void copyToStream(OutputStream outputStream)
                  throws IOException
Description copied from interface: Resource
Copies the resource to the output stream. You can call this method only once. It means, you can not recycle a resource. After copying, you have to release the resource.

Specified by:
copyToStream in interface Resource
Throws:
IOException

getInputStream

public InputStream getInputStream()
Specified by:
getInputStream in interface ResourceWithInputStream

setInputStream

protected void setInputStream(InputStream inputStream)

setLength

protected void setLength(long length)

release

public void release()
Description copied from interface: Resource
Releases all system resources blocked by this resource :-) It HAS to be called after using the resource.

Specified by:
release in interface Resource

getLastModified

public long getLastModified()
Description copied from interface: Resource
Returns last modification date.

Specified by:
getLastModified in interface Resource
Returns:

setLastModified

public void setLastModified(long lastModificationDate)

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2006 null. All Rights Reserved.