Class TempFileCharacterInput
- java.lang.Object
-
- org.apache.manifoldcf.core.interfaces.PersistentDatabaseObject
-
- org.apache.manifoldcf.core.interfaces.CharacterInput
-
- org.apache.manifoldcf.core.interfaces.TempFileCharacterInput
-
public class TempFileCharacterInput extends CharacterInput
This class represents a temporary file character input stream. Call the "done" method to clean up the file when done. NOTE: The implied flow of this method is to be handed a file that has already been created by some means. The file must be a dedicated temporary file, which can be destroyed when the data has been used. However, this class can also buffer data in memory if the data is not too large (that is, less than a supplied cutoff value).
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String_rcsidprotected static intCHUNK_SIZEprotected static intDEFAULT_MAX_MEM_SIZEprotected java.io.Filefileprotected byte[]inMemoryBuffer-
Fields inherited from class org.apache.manifoldcf.core.interfaces.CharacterInput
charLength, hashValue, stream
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTempFileCharacterInput()TempFileCharacterInput(java.io.File tempFile)Construct from an existing temporary fle.TempFileCharacterInput(java.io.Reader is)Construct from a non-length-delimited reader.TempFileCharacterInput(java.io.Reader is, long length)Construct from a length-delimited reader.TempFileCharacterInput(java.io.Reader is, long length, int maxInMemoryLength)Construct from a length-delimited reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcalculateHashValue()Calculate the datum's hash valueprotected voidcalculateLength()Calculate the datum's length in charactersvoiddiscard()Discard this object permanentlyjava.io.InputStreamgetUtf8Stream()Open a Utf8 stream directly from the backing filelonggetUtf8StreamLength()Get binary UTF8 stream length directlyprotected voidopenStream()Open a reader, for use by a caller, until closeStream is calledCharacterInputtransfer()Transfer to a new object; this causes the current object to become "already discarded"-
Methods inherited from class org.apache.manifoldcf.core.interfaces.CharacterInput
closeStream, doneWithStream, getCharacterLength, getHashValue, getStream, handleIOException
-
-
-
-
Field Detail
-
_rcsid
public static final java.lang.String _rcsid
- See Also:
- Constant Field Values
-
file
protected java.io.File file
-
inMemoryBuffer
protected byte[] inMemoryBuffer
-
CHUNK_SIZE
protected static final int CHUNK_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_MAX_MEM_SIZE
protected static final int DEFAULT_MAX_MEM_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TempFileCharacterInput
public TempFileCharacterInput(java.io.Reader is) throws ManifoldCFException, java.io.IOExceptionConstruct from a non-length-delimited reader.- Parameters:
is- is a reader to transfer from, to the end of the data. This will, as a side effect, also calculate the character length and hash value for the data.- Throws:
ManifoldCFExceptionjava.io.IOException
-
TempFileCharacterInput
public TempFileCharacterInput(java.io.Reader is, long length) throws ManifoldCFException, java.io.IOExceptionConstruct from a length-delimited reader.- Parameters:
is- is a reader to transfer from, to the end of the data. This will, as a side effect, also calculate the character length and hash value for the data.length- is the length limit to transfer, or -1 if no limit- Throws:
ManifoldCFExceptionjava.io.IOException
-
TempFileCharacterInput
public TempFileCharacterInput(java.io.Reader is, long length, int maxInMemoryLength) throws ManifoldCFException, java.io.IOExceptionConstruct from a length-delimited reader.- Parameters:
is- is a reader to transfer from, to the end of the data. This will, as a side effect, also calculate the character length and hash value for the data.length- is the length limit to transfer, or -1 if no limitmaxInMemoryLength- is the maximum size to keep in memory, before using a backing File object. The amount possibly saved in memory will be guaranteed less than this size.- Throws:
ManifoldCFExceptionjava.io.IOException
-
TempFileCharacterInput
public TempFileCharacterInput(java.io.File tempFile)
Construct from an existing temporary fle.- Parameters:
tempFile- is the existing temporary file, encoded in utf-8.
-
TempFileCharacterInput
protected TempFileCharacterInput()
-
-
Method Detail
-
getUtf8Stream
public java.io.InputStream getUtf8Stream() throws ManifoldCFExceptionOpen a Utf8 stream directly from the backing file- Specified by:
getUtf8Streamin classCharacterInput- Throws:
ManifoldCFException
-
getUtf8StreamLength
public long getUtf8StreamLength() throws ManifoldCFExceptionGet binary UTF8 stream length directly- Specified by:
getUtf8StreamLengthin classCharacterInput- Throws:
ManifoldCFException
-
openStream
protected void openStream() throws ManifoldCFExceptionDescription copied from class:CharacterInputOpen a reader, for use by a caller, until closeStream is called- Specified by:
openStreamin classCharacterInput- Throws:
ManifoldCFException
-
transfer
public CharacterInput transfer()
Transfer to a new object; this causes the current object to become "already discarded"- Specified by:
transferin classCharacterInput
-
discard
public void discard() throws ManifoldCFExceptionDescription copied from class:CharacterInputDiscard this object permanently- Overrides:
discardin classCharacterInput- Throws:
ManifoldCFException
-
calculateLength
protected void calculateLength() throws ManifoldCFExceptionCalculate the datum's length in characters- Specified by:
calculateLengthin classCharacterInput- Throws:
ManifoldCFException
-
calculateHashValue
protected void calculateHashValue() throws ManifoldCFExceptionCalculate the datum's hash value- Specified by:
calculateHashValuein classCharacterInput- Throws:
ManifoldCFException
-
-