javax.rad.io
Class FileHandle

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

public class FileHandle
extends Object
implements IFileHandle, 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(File pContent)
          Constructs a new FileHandle.
FileHandle(String pAbsolutePath)
          Constructs a new FileHandle.
FileHandle(String pFileName, byte[] pContent)
          Constructs a new memory file handle.
FileHandle(String pFileName, InputStream pContent)
          Constructs a new memory file handle.
 
Method Summary
 File getFile()
          Gets the file that was set as content.
 String getFileName()
          Gets the file name of this file handle.
 byte[] getGZIPContent()
          Gets the gzipped content.
 InputStream getInputStream()
          Gets the InputStream of this file handle.
 long getLength()
          Gets the length of the InputStream in bytes
 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(File pContent)
          Sets a new content with a File.
 void setContent(InputStream pContent)
          Sets a new content with a InputStream.
 void setFileName(String pFileName)
          Sets the file name of this file handle.
 void setGZIPContent(byte[] pGZIPContent)
          Sets the gzipped content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileHandle

public FileHandle()
Constructs a new FileHandle.


FileHandle

public FileHandle(String pAbsolutePath)
Constructs a new FileHandle.

Parameters:
pAbsolutePath - the absolute path of the file.

FileHandle

public FileHandle(String pFileName,
                  byte[] pContent)
           throws IOException
Constructs a new memory file handle.

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

FileHandle

public FileHandle(String pFileName,
                  InputStream pContent)
           throws IOException
Constructs a new memory file handle.

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

FileHandle

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

Parameters:
pContent - the content.
Throws:
IOException - if an IOException occurs.
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.

setFileName

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

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

getFile

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

Returns:
the file that was set as content.

getGZIPContent

public byte[] getGZIPContent()
                      throws IOException
Gets the gzipped content.

Returns:
the gzipped content.
Throws:
IOException - if an IOException occurs.

setGZIPContent

public void setGZIPContent(byte[] pGZIPContent)
                    throws IOException
Sets the gzipped content.

Parameters:
pGZIPContent - the gzipped content.
Throws:
IOException - if an IOException occurs.

getOutputStream

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

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.

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.

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

setContent

public void setContent(File pContent)
                throws IOException
Sets a new content with a File.

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


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.