public final class

FileInput

extends Object
implements IInput
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.input.FileInput

Class Overview

An input backed by a file. Entries in zip archives are also supported and must be addressed with a bang, e.g. /some/path/file.zip!a/b/c/data.bin.

Summary

Constants
int SER_FLAG_FULL_PERSISTENCE This flag indicates that the serialization of this object should include a full bytes copy of the underlying file
[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.input.IInput
Public Constructors
FileInput(File file)
FileInput(String path)
Public Methods
boolean canRead()
Determine whether this input is readable.
void close()
Close that input and free all resources used by this object.
SeekableByteChannel getChannel()
Get a seekable read-only channel representing the input.
long getCurrentSize()
Provide the current input size of the input data.
File getFile()
Retrieve the input file.
ByteBuffer getHeader()
Get a read-only, big-endian buffer of the first input bytes.
String getName()
Retrieve the optional input name.
String getOriginalPath()
String getPath()
Retrieve the path to the input file.
String getPathBase()
String getPersistedPath()
Return the path element that would be persisted if this element is serialized.
InputStream getStream()
Get the input stream.
boolean rebase(String base)
Force a new base and reopen the file.
boolean setBase(String base)
Set the base for this input, assuming it is referring to a valid file (i.e.
void setFile(File file)
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.input.IInput

Constants

public static final int SER_FLAG_FULL_PERSISTENCE

This flag indicates that the serialization of this object should include a full bytes copy of the underlying file

Constant Value: 1 (0x00000001)

Public Constructors

public FileInput (File file)

Throws
IOException

public FileInput (String path)

Throws
IOException

Public Methods

public boolean canRead ()

Determine whether this input is readable.

public void close ()

Close that input and free all resources used by this object.

public SeekableByteChannel getChannel ()

Get a seekable read-only channel representing the input. Each call returns a unique channel. Clients should use this method to efficiently read at various locations within the given input.

Returns
  • a unique seekable channel
Throws
IOException

public long getCurrentSize ()

Provide the current input size of the input data.

Returns
  • the size, -1 if the size cannot be calculated or if an error occurred

public File getFile ()

Retrieve the input file.

Returns
  • the input file, null if the input is invalid

public ByteBuffer getHeader ()

Get a read-only, big-endian buffer of the first input bytes. Clients should not attempt to modify or directly access that buffer. The initial position is set to 0. It is recommended that implementations provide at least IDEAL_HEADER_SIZE bytes.

Returns
  • a unique buffer; on error, the returned buffer is null (unlike other methods declared in this interface, this method does not throw IOException)

public String getName ()

Retrieve the optional input name.

public String getOriginalPath ()

public String getPath ()

Retrieve the path to the input file.

public String getPathBase ()

Returns
  • may be null

public String getPersistedPath ()

Return the path element that would be persisted if this element is serialized.

Returns

public InputStream getStream ()

Get the input stream. Each call returns a unique stream. Implementors should offer this method for convenience. The implementor is responsible for closing non-closed streams when close() is called.

Returns
  • a unique input stream
Throws
IOException

public boolean rebase (String base)

Force a new base and reopen the file. The input must not have a base and the current path must not be an absolute path for this method to succeed. (If that is the case, setBase(String) should be used instead.)

Parameters
base the forced new base
Returns
  • success indicator

public boolean setBase (String base)

Set the base for this input, assuming it is referring to a valid file (i.e. getFile() is non-null).

Parameters
base the new base; null to remove any existing base
Returns
  • success indicator

public void setFile (File file)

Throws
IOException

public String toString ()