edu.iu.iv.common.persistence
Class BasicFileResourceDescriptor

java.lang.Object
  |
  +--edu.iu.iv.common.persistence.BasicFileResourceDescriptor
All Implemented Interfaces:
FileResourceDescriptor, ResourceDescriptor

public class BasicFileResourceDescriptor
extends java.lang.Object
implements FileResourceDescriptor

Author:
Team IVC

Constructor Summary
BasicFileResourceDescriptor()
          Creates a file resource descriptor with no compression and file set to null.
BasicFileResourceDescriptor(java.io.File file)
          Creates a file resource descriptor with the specified file and no compression.
BasicFileResourceDescriptor(java.io.File file, boolean fileCompression)
          Creates a file resource descriptor with the specified file and compression.
 
Method Summary
 java.io.File getFile()
          Gets the file represented by this resource descriptor.
 java.lang.String getFileExtension()
          Gets the extension of the file represented by this resource descriptor.
 java.lang.String getFileName()
          Gets the name of the file.
 java.lang.String getFilePath()
          Returns the path to the file.
 boolean isCompressionEnabled()
          Checks to see if the file represented by this resource descriptor is to be compressed or not.
 void setCompression(boolean fileCompression)
          Sets the compression to be enabled or disabled.
 void setFile(java.io.File file)
          Sets the properties of this file based on the File object passed in.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicFileResourceDescriptor

public BasicFileResourceDescriptor()
Creates a file resource descriptor with no compression and file set to null.


BasicFileResourceDescriptor

public BasicFileResourceDescriptor(java.io.File file,
                                   boolean fileCompression)
Creates a file resource descriptor with the specified file and compression.

Parameters:
file - The file to be represented by this descriptor.
fileCompression - true if compression is to be enabled, false otherwise.

BasicFileResourceDescriptor

public BasicFileResourceDescriptor(java.io.File file)
Creates a file resource descriptor with the specified file and no compression.

Parameters:
file - The file to be represented by this descriptor.
Method Detail

setFile

public void setFile(java.io.File file)
Description copied from interface: FileResourceDescriptor
Sets the properties of this file based on the File object passed in.

Specified by:
setFile in interface FileResourceDescriptor
Parameters:
file - The file whose properties this resource descriptor should imbibe.
See Also:
FileResourceDescriptor.setFile(java.io.File)

getFile

public java.io.File getFile()
Description copied from interface: FileResourceDescriptor
Gets the file represented by this resource descriptor.

Specified by:
getFile in interface FileResourceDescriptor
Returns:
The file represented by this file resource descriptor or null if no file has been set.
See Also:
FileResourceDescriptor.getFile()

getFileName

public java.lang.String getFileName()
Description copied from interface: FileResourceDescriptor
Gets the name of the file.

Specified by:
getFileName in interface FileResourceDescriptor
Returns:
The name of the file. if it hasn't been set.
See Also:
FileResourceDescriptor.getFileName()

getFileExtension

public java.lang.String getFileExtension()
Description copied from interface: FileResourceDescriptor
Gets the extension of the file represented by this resource descriptor. The extension of the file must start with a period. Hence a file with the name, "example.mat" would have the extension ".mat".

Specified by:
getFileExtension in interface FileResourceDescriptor
Returns:
The extension of this file.
See Also:
FileResourceDescriptor.getFileExtension()

isCompressionEnabled

public boolean isCompressionEnabled()
Description copied from interface: FileResourceDescriptor
Checks to see if the file represented by this resource descriptor is to be compressed or not.

Specified by:
isCompressionEnabled in interface FileResourceDescriptor
Returns:
true if the file should be compressed after being persisted or decompressed when restored.
See Also:
FileResourceDescriptor.isCompressionEnabled()

setCompression

public void setCompression(boolean fileCompression)
Description copied from interface: FileResourceDescriptor
Sets the compression to be enabled or disabled. Certain file types such as XML files occupy an obnoxious amount of disk space and implementations are encouraged to use compression for these file types. Whether a resource descriptor is to be compressed is or not can be checked using compressionEnabled(). Each persister obviously also needs to check for whether a particular file is compressed or not and respond accordingly as to whether or not it can persist or restore from the resource.

Specified by:
setCompression in interface FileResourceDescriptor
Parameters:
fileCompression - true if the file should be compressed or decompressed. false if the file shouldn't be compressed.
See Also:
FileResourceDescriptor.setCompression(boolean)

getFilePath

public java.lang.String getFilePath()
Description copied from interface: FileResourceDescriptor
Returns the path to the file.

Specified by:
getFilePath in interface FileResourceDescriptor
Returns:
The file path ending with the separator character or null if it hasn't been set.
See Also:
FileResourceDescriptor.getFilePath()