Package com.pnfsoftware.jeb.core.input
Class FileInput
java.lang.Object
com.pnfsoftware.jeb.core.input.FileInput
- All Implemented Interfaces:
IInput
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThis flag indicates that the serialization of this object should include a full bytes copy of the underlying fileFields inherited from interface com.pnfsoftware.jeb.core.input.IInput
IDEAL_HEADER_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRead()Determine whether this input is readable.voidclose()Close that input and free all resources used by this object.Get a seekable read-only channel representing the input.longProvide the current input size of the input data.getFile()Retrieve the input file.Get a read-only, big-endian buffer of the first input bytes.getName()Retrieve the optional input name.getPath()Retrieve the path to the input file.Return the path element that would be persisted if this element is serialized.Get the input stream.booleanForce a new base and reopen the file.booleanSet the base for this input, assuming it is referring to a valid file (i.e.voidtoString()
-
Field Details
-
SER_FLAG_FULL_PERSISTENCE
public static final int SER_FLAG_FULL_PERSISTENCEThis flag indicates that the serialization of this object should include a full bytes copy of the underlying file- See Also:
-
-
Constructor Details
-
FileInput
- Throws:
IOException
-
FileInput
- Throws:
IOException
-
FileInput
- Throws:
IOException
-
FileInput
- Throws:
IOException
-
FileInput
- Throws:
IOException
-
FileInput
- Throws:
IOException
-
-
Method Details
-
getName
Description copied from interface:IInputRetrieve the optional input name. -
getFile
Retrieve the input file.- Returns:
- the input file, null if the input is invalid
-
getPath
Retrieve the path to the input file.- Returns:
-
getPersistedPath
Return the path element that would be persisted if this element is serialized.- Returns:
- may be null; may differ from
getPath()
-
getPathBase
- Returns:
- may be null
-
rebase
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
-
setBase
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
-
setFile
- Throws:
IOException
-
canRead
public boolean canRead()Description copied from interface:IInputDetermine whether this input is readable. -
close
public void close()Description copied from interface:IInputClose that input and free all resources used by this object. -
getCurrentSize
public long getCurrentSize()Description copied from interface:IInputProvide the current input size of the input data.- Specified by:
getCurrentSizein interfaceIInput- Returns:
- the size, -1 if the size cannot be calculated or if an error occurred
-
getHeader
Description copied from interface:IInputGet 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 leastIInput.IDEAL_HEADER_SIZEbytes.- Specified by:
getHeaderin interfaceIInput- Returns:
- a unique buffer; on error, the returned buffer is null (unlike other methods declared
in this interface, this method does not throw
IOException)
-
getChannel
Description copied from interface:IInputGet 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.- Specified by:
getChannelin interfaceIInput- Returns:
- a unique seekable channel
- Throws:
IOException- on IO error
-
getStream
Description copied from interface:IInputGet 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 whenIInput.close()is called.- Specified by:
getStreamin interfaceIInput- Returns:
- a unique input stream
- Throws:
IOException- on IO error
-
toString
-