java.lang.Object
provided.utils.file.impl.FileContents
- All Implemented Interfaces:
Serializable
,IFileContents
A concrete implementation of IFileContents. For convenience and simplicity,
this class defines equality if the names are equal, not the actual contents.
- Author:
- swong
- See Also:
- Serialized Form
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileContents(String name, String filename)
Construct an instance with an associated name and the full filename (i.e.FileContents(String name, String filename, String info)
Construct an instance with an associated name, additional information about the file contents and the full filename (i.e. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Overridden to perform equality based on the name onlybyte[]
getBytes()
The internally stored raw byte streamgetInfo()
Returns any additional information about the file contents.Create an InputStream that sources the file contents.getName()
A name associated with the file, e.g.int
hashCode()
Overridden to return the hashCode() of the name.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor serialization- See Also:
- Constant Field Values
-
name
The name associated with the file contents -
info
The info associated with the file contents -
fileContents
private byte[] fileContentsThe contents of the file in byte array form.
-
-
Constructor Details
-
FileContents
Construct an instance with an associated name and the full filename (i.e. includes sufficient path information) to access the file's contents from the disk. This filename is NOT stored and the FileContent object is independent from where its contents were read. The stored info is set to an empty String.- Parameters:
name
- The name to associate with the file contents, relative to the class that is invoking this constructor.filename
- The filename of the file that sources the contents.
-
FileContents
Construct an instance with an associated name, additional information about the file contents and the full filename (i.e. includes sufficient path information) to access the file's contents from the disk. This filename is NOT stored and the FileContent object is independent from where its contents were read.- Parameters:
name
- The name to associate with the file contents.filename
- The filename of the file that sources the contents.info
- Additional information about the contents
-
-
Method Details
-
getName
Description copied from interface:IFileContents
A name associated with the file, e.g. its filename without the rest of its path. This name is just for reference/identification purposes.- Specified by:
getName
in interfaceIFileContents
- Returns:
- A name to be associated with the contents.
-
getInfo
Description copied from interface:IFileContents
Returns any additional information about the file contents. A typical usage would for an image file, for the info to be "jpg" or "png" to tell what kind of image data was in the contents.- Specified by:
getInfo
in interfaceIFileContents
- Returns:
- The stored info string.
-
getBytes
public byte[] getBytes()Description copied from interface:IFileContents
The internally stored raw byte stream- Specified by:
getBytes
in interfaceIFileContents
- Returns:
- The byte stream of the file
-
getInputStream
Description copied from interface:IFileContents
Create an InputStream that sources the file contents. The use of this stream simulates the reading of the file from the disk but without actually involving any such storage access. This feature would be used by the receiver of this object to load the file contents into something that normally wants to read that data from the disk.- Specified by:
getInputStream
in interfaceIFileContents
- Returns:
- An InputStream
-
equals
Overridden to perform equality based on the name only -
hashCode
public int hashCode()Overridden to return the hashCode() of the name.
-