javax.rad.io
Class FileHandle

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

public class FileHandle
extends java.lang.Object
implements IFileHandle, java.io.Serializable

FileHandle handles data in memory or in the file system. The Bean standard guarantees with the properties "fileName" and "gZIPContent" that it can be transported with a connection. For compatibility reasons is the FileHandle also Serializable.

See Also:
Serialized Form

Constructor Summary
FileHandle()
          Constructs a new FileHandle.
FileHandle(java.io.File pContent)
          Constructs a new FileHandle.
FileHandle(java.lang.String pAbsolutePath)
          Constructs a new FileHandle.
FileHandle(java.lang.String pFileName, byte[] pContent)
          Constructs a new file handle with the content from a byte[].
FileHandle(java.lang.String pFileName, java.io.InputStream pContent)
          Constructs a file handle with the content form an InputStream.
 
Method Summary
protected  void finalize()
          
 java.lang.Object getContentDefinition()
          Gets the content (definition).
 java.io.File getFile()
          Gets the file that was set as content.
 java.lang.String getFileName()
          Gets the file name of this file handle.
 java.io.InputStream getInputStream()
          Gets the InputStream of this file handle.
 long getLength()
          Gets the length of the InputStream in bytes
 java.io.OutputStream getOutputStream()
          Resets the content to zero, and gets an OutputStresm to write the content.
 void setContent(byte[] pContent)
          Sets a new content with a byte array.
 void setContent(java.io.File pContent)
          Sets a new content with a File.
 void setContent(java.io.InputStream pContent)
          Sets a new content with an InputStream.
 void setContentDefinition(java.lang.Object pDefinition)
          Sets the content (definition).
 void setFileName(java.lang.String pFileName)
          Sets the file name of this file handle.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileHandle

public FileHandle()
Constructs a new FileHandle.


FileHandle

public FileHandle(java.lang.String pAbsolutePath)
Constructs a new FileHandle.

Parameters:
pAbsolutePath - the absolute path of the file.

FileHandle

public FileHandle(java.lang.String pFileName,
                  byte[] pContent)
           throws java.io.IOException
Constructs a new file handle with the content from a byte[].

Parameters:
pFileName - the file name.
pContent - the content.
Throws:
java.io.IOException - if an IOException occurs.

FileHandle

public FileHandle(java.lang.String pFileName,
                  java.io.InputStream pContent)
           throws java.io.IOException
Constructs a file handle with the content form an InputStream.

Parameters:
pFileName - the file name.
pContent - the content.
Throws:
java.io.IOException - if an IOException occurs.

FileHandle

public FileHandle(java.io.File pContent)
           throws java.io.IOException
Constructs a new FileHandle.

Parameters:
pContent - the content.
Throws:
java.io.IOException - if an IOException occurs.
Method Detail

getFileName

public java.lang.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 java.io.InputStream getInputStream()
                                   throws java.io.IOException
Gets the InputStream of this file handle.

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

getLength

public long getLength()
               throws java.io.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:
java.io.IOException - if an exception occurs.

finalize

protected void finalize()
                 throws java.lang.Throwable

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

setFileName

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

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

getFile

public java.io.File getFile()
Gets the file that was set as content.

Returns:
the file that was set as content.

getContentDefinition

public java.lang.Object getContentDefinition()
                                      throws java.io.IOException
Gets the content (definition). The content is dynamic and can be an IFileHandle or an GZIP compressed byte[]. It depends on the current state, whether the file was used only locally or sent to a remote server. This method is primarily for serialization support.

Returns:
the content (definition)
Throws:
java.io.IOException - if accessing content failed

setContentDefinition

public void setContentDefinition(java.lang.Object pDefinition)
                          throws java.io.IOException
Sets the content (definition).

Parameters:
pDefinition - an IFileHandle or a GZIP compressed byte[].
Throws:
java.io.IOException - if accessing content failed
See Also:
getContentDefinition()

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Resets the content to zero, and gets an OutputStresm to write the content.

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

setContent

public void setContent(byte[] pContent)
                throws java.io.IOException
Sets a new content with a byte array.

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

setContent

public void setContent(java.io.InputStream pContent)
                throws java.io.IOException
Sets a new content with an InputStream.

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

setContent

public void setContent(java.io.File pContent)
Sets a new content with a File.

Parameters:
pContent - the new content.


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.