javax.rad.io
Class RemoteFileHandle

java.lang.Object
  extended by javax.rad.io.RemoteFileHandle
All Implemented Interfaces:
Serializable, IFileHandle

public class RemoteFileHandle
extends Object
implements IFileHandle, Serializable

RemoteFileHandle handles data that is stored in the ObjectCache. Supported Objects are java.io.File, java.net.URL, javax.rad.io.IFileHandle and byte[]. The Bean standard guarantees with the properties "fileName" and "objectCacheKey" that it can be transported with a connection. The Creator of the ObjectCacheHandle has to guarantee that the data is available under the given key. For compatibility reasons is the ObjectCacheHandle also Serializable.

See Also:
Serialized Form

Field Summary
static String OBJECT_CACHE_KEY
          Placeholder for the ObjectCache key.
 
Constructor Summary
RemoteFileHandle()
          Constructs a new FileHandle.
RemoteFileHandle(File pContent)
          Constructs a new FileHandle with the given file as content.
RemoteFileHandle(String pFileName)
          Constructs a new FileHandle.
RemoteFileHandle(String pFileName, InputStream pContent)
          Constructs a new FileHandle.
RemoteFileHandle(String pFileName, Object pObjectCacheKey)
          Constructs a new FileHandle.
RemoteFileHandle(String pFileName, Object pObjectCacheKey, InputStream pContent)
          Constructs a new FileHandle.
RemoteFileHandle(String pFileName, Object pObjectCacheKey, URL pContent)
          Constructs a new FileHandle.
RemoteFileHandle(String pFileName, URL pContent)
          Constructs a new FileHandle.
 
Method Summary
static Object createObjectCacheKey()
          Gets the access key for the object.
protected  void finalize()
          
 String getDownloadURL()
          Gets the download URL with filled in key.
static String getDownloadURL(Object pObjectCacheKey)
          Creates the download URL with filled in key.
static String getDownloadURLSpec()
          Gets the download URL, that specifies where to get the content from server.
 String getFileName()
          Gets the file name of this file handle.
 InputStream getInputStream()
          Gets the InputStream of this file handle.
 long getLength()
          Gets the length of the InputStream in bytes
 Object getObjectCacheKey()
          Gets the ObjectCache key.
 OutputStream getOutputStream()
          Resets the content to zero, and gets an OutputStresm to write the content.
 long getTimeout()
          Gets the ObjectCache key.
 void setContent(byte[] pContent)
          Sets a new content with a byte array.
 void setContent(File pContent)
          Sets a new content with a File.
 void setContent(InputStream pContent)
          Sets a new content with a InputStream.
 void setContent(URL pContent)
          Sets a new content with a URL.
static void setDownloadURLSpec(String pDownloadURLSpec)
          Sets the download URL, that specifies where to get the content from server.
 void setFileName(String pFileName)
          Sets the file name of this file handle.
 void setObjectCacheKey(Object pObjectCacheKey)
          Sets the ObjectCache key.
 void setTimeout(long pTimeout)
          Sets the ObjectCache key.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OBJECT_CACHE_KEY

public static final String OBJECT_CACHE_KEY
Placeholder for the ObjectCache key.

See Also:
Constant Field Values
Constructor Detail

RemoteFileHandle

public RemoteFileHandle()
Constructs a new FileHandle.


RemoteFileHandle

public RemoteFileHandle(String pFileName)
Constructs a new FileHandle.

Parameters:
pFileName - the file name.

RemoteFileHandle

public RemoteFileHandle(String pFileName,
                        Object pObjectCacheKey)
Constructs a new FileHandle.

Parameters:
pFileName - the filename.
pObjectCacheKey - the ObjectCache key.

RemoteFileHandle

public RemoteFileHandle(String pFileName,
                        URL pContent)
Constructs a new FileHandle.

Parameters:
pFileName - the filename.
pContent - the content.

RemoteFileHandle

public RemoteFileHandle(String pFileName,
                        Object pObjectCacheKey,
                        URL pContent)
Constructs a new FileHandle.

Parameters:
pFileName - the filename.
pObjectCacheKey - the ObjectCache key.
pContent - the content.

RemoteFileHandle

public RemoteFileHandle(String pFileName,
                        InputStream pContent)
                 throws IOException
Constructs a new FileHandle.

Parameters:
pFileName - the filename.
pContent - the content.
Throws:
IOException - if an IOException occurs.

RemoteFileHandle

public RemoteFileHandle(String pFileName,
                        Object pObjectCacheKey,
                        InputStream pContent)
                 throws IOException
Constructs a new FileHandle.

Parameters:
pFileName - the filename.
pObjectCacheKey - the ObjectCache key.
pContent - the content.
Throws:
IOException - if an IOException occurs.

RemoteFileHandle

public RemoteFileHandle(File pContent)
Constructs a new FileHandle with the given file as content.

Parameters:
pContent - the content.
Method Detail

getFileName

public String getFileName()
Gets the file name of this file handle.

Specified by:
getFileName in interface IFileHandle
Returns:
the file name of this file handle.

getInputStream

public InputStream getInputStream()
                           throws IOException
Gets the InputStream of this file handle.

Specified by:
getInputStream in interface IFileHandle
Returns:
the InputStream of this file handle.
Throws:
IOException - if an exception occurs.

getLength

public long getLength()
               throws IOException
Gets the length of the InputStream in bytes. -1 is returned if getInputStream is null.

Specified by:
getLength in interface IFileHandle
Returns:
the length of the InputStream in bytes.
Throws:
IOException - if an exception occurs.

getDownloadURLSpec

public static String getDownloadURLSpec()
Gets the download URL, that specifies where to get the content from server. If the URL contains OBJECT_CACHE_KEY the ObjectCache key is filled in at that place, else is the key concatenated to the end.

Returns:
the download URL, that specifies where to get the content from server.

setDownloadURLSpec

public static void setDownloadURLSpec(String pDownloadURLSpec)
Sets the download URL, that specifies where to get the content from server. If the URL contains a OBJECT_CACHE_KEY the ObjectCache key is filled in at that place, else is the key concatinated to the end.

Parameters:
pDownloadURLSpec - the download URL, that specifies where to get the content from server.

getDownloadURL

public static String getDownloadURL(Object pObjectCacheKey)
                             throws MalformedURLException
Creates the download URL with filled in key.

Parameters:
pObjectCacheKey - the ObjectCache key.
Returns:
the download URL with filled in key.
Throws:
MalformedURLException - if the download url is a malformed.

getDownloadURL

public String getDownloadURL()
                      throws MalformedURLException
Gets the download URL with filled in key.

Returns:
the download URL with filled in key.
Throws:
MalformedURLException - if the download url is a malformed.

createObjectCacheKey

public static Object createObjectCacheKey()
Gets the access key for the object.

Returns:
the access key for the object

setFileName

public void setFileName(String pFileName)
Sets the file name of this file handle.

Parameters:
pFileName - the file name of this file handle.

getObjectCacheKey

public Object getObjectCacheKey()
Gets the ObjectCache key.

Returns:
the ObjectCache key.

setObjectCacheKey

public void setObjectCacheKey(Object pObjectCacheKey)
Sets the ObjectCache key.

Parameters:
pObjectCacheKey - the ObjectCache key.

getTimeout

public long getTimeout()
Gets the ObjectCache key.

Returns:
the ObjectCache key.

setTimeout

public void setTimeout(long pTimeout)
Sets the ObjectCache key.

Parameters:
pTimeout - the ObjectCache key.

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Resets the content to zero, and gets an OutputStresm to write the content. The content is stored temporary with the configured timeout.

Returns:
an OutputStresm to write the content.
Throws:
IOException - if an IOException occurs.

setContent

public void setContent(byte[] pContent)
                throws IOException
Sets a new content with a byte array. The content is stored temporary with the configured timeout.

Parameters:
pContent - the new content.
Throws:
IOException - if an IOException occurs.

setContent

public void setContent(InputStream pContent)
                throws IOException
Sets a new content with a InputStream. The content is stored temporary with the configured timeout.

Parameters:
pContent - the new content.
Throws:
IOException - if an IOException occurs.

setContent

public void setContent(File pContent)
Sets a new content with a File. The content is stored temporary with the configured timeout.

Parameters:
pContent - the new content.

setContent

public void setContent(URL pContent)
Sets a new content with a URL. The content is stored temporary with the configured timeout.

Parameters:
pContent - the new content.

finalize

protected void finalize()
                 throws Throwable

Overrides:
finalize in class Object
Throws:
Throwable


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.