org.hippoecm.hst.servlet.utils
Class BinaryPage

java.lang.Object
  extended by org.hippoecm.hst.servlet.utils.BinaryPage
All Implemented Interfaces:
Serializable

public class BinaryPage
extends Object
implements Serializable

A Serializable representation of a resource from the repository as a html page. The binary page uses the absolute resource path as identifier. The binary data is optionally stored in a byte array. When done so the binary must be able to fit in memory.

See Also:
Serialized Form

Constructor Summary
BinaryPage(String resourcePath)
          Create a new binary page.
 
Method Summary
 boolean containsData()
          Check if the BinaryPage also contains the data next to the meta data.
 boolean equals(Object obj)
           
 long getCreationTime()
          Get the time the binary page cache object was create in milliseconds since epoch.
 String getETag()
          Get the ETag
 String getFileName()
          Get the unencoded file name to be used for Content-Disposition header
 long getLastModified()
          Get the last modified date in milliseconds since epoch.
 long getLength()
          Get the data length which can be used for the Content-Length header or cache checks.
 String getMimeType()
          Get the mime type for the resource.
 long getNextValidityCheckTimeStamp()
          Get the next Validity Check TimeStamp (millis since epoch)
 String getResourcePath()
          Get the absolute path of the repository.
 int getStatus()
          Get the HTTP status for the resource.
 InputStream getStream()
          Get the InputStream to the byte buffer of the data.
 int hashCode()
           
 void loadDataFromStream(InputStream input)
          Read the data from the input stream and close the stream when done.
 void setFileName(String fileName)
          Set the (un-encoded) file name for the Content-Disposition header.
 void setLastModified(long lastModified)
          Set the last modification time in milliseconds since epoch.
 void setLength(long length)
          Set the size of the binary data.
 void setMimeType(String mimeType)
          Set the mime type.
 void setNextValidityCheckTime(long nextValidityCheckTimeStamp)
          Set the next validity check timestamp since epoch.
 void setStatus(int status)
          Set the HTTP status.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BinaryPage

public BinaryPage(String resourcePath)
Create a new binary page. This will just create the page holder. The fields have to be set explicitly after the object creation.

Parameters:
resourcePath - the absolute path of the resource in the repository.
Method Detail

getResourcePath

public String getResourcePath()
Get the absolute path of the repository.

Returns:
the absolute path

getStatus

public int getStatus()
Get the HTTP status for the resource.

Returns:
the HTTP status

getMimeType

public String getMimeType()
Get the mime type for the resource. Could be null.

Returns:
the mime type or null when unknown.

getFileName

public String getFileName()
Get the unencoded file name to be used for Content-Disposition header

Returns:
the file name or null when not set.

getETag

public String getETag()
Get the ETag

Returns:
the ETag

getLastModified

public long getLastModified()
Get the last modified date in milliseconds since epoch.

Returns:
the last modified date or -1 if unknown

getCreationTime

public long getCreationTime()
Get the time the binary page cache object was create in milliseconds since epoch.

Returns:
creation time

getNextValidityCheckTimeStamp

public long getNextValidityCheckTimeStamp()
Get the next Validity Check TimeStamp (millis since epoch)

Returns:
the nextValidityCheckTimeStamp time

getLength

public long getLength()
Get the data length which can be used for the Content-Length header or cache checks.

Returns:
the length of the binary data

containsData

public boolean containsData()
Check if the BinaryPage also contains the data next to the meta data.

Returns:
true if the BinaryPage contains the data as well as the meta data

getStream

public InputStream getStream()
Get the InputStream to the byte buffer of the data.

Returns:
the input stream

loadDataFromStream

public void loadDataFromStream(InputStream input)
                        throws IOException
Read the data from the input stream and close the stream when done.

Parameters:
input - the input stream to read the data from.
Throws:
IOException - when an error occurs while copying. The stream will be closed.

setStatus

public void setStatus(int status)
Set the HTTP status. The status is not checked for validity.

Parameters:
status -

setMimeType

public void setMimeType(String mimeType)
Set the mime type.

Parameters:
mimeType -

setFileName

public void setFileName(String fileName)
Set the (un-encoded) file name for the Content-Disposition header.

Parameters:
mimeType -

setNextValidityCheckTime

public void setNextValidityCheckTime(long nextValidityCheckTimeStamp)
Set the next validity check timestamp since epoch.

Parameters:
nextValidityCheckTimeStamp -

setLastModified

public void setLastModified(long lastModified)
Set the last modification time in milliseconds since epoch.

Parameters:
lastModified -

setLength

public void setLength(long length)
Set the size of the binary data. This method should only be used when the data is not stored in the BinaryData object.

Parameters:
length - the length of the data.

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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


Copyright © 2008-2012 Hippo. All Rights Reserved.