|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.thrift.transport.TTransport
org.apache.thrift.transport.TFileTransport
public class TFileTransport
FileTransport implementation of the TTransport interface. Currently this is a straightforward port of the cpp implementation It may make better sense to provide a basic stream access on top of the framed file format The FileTransport can then be a user of this framed file format with some additional logic for chunking.
Nested Class Summary | |
---|---|
static class |
TFileTransport.chunkState
|
static class |
TFileTransport.Event
|
static class |
TFileTransport.tailPolicy
|
static class |
TFileTransport.truncableBufferedInputStream
|
Field Summary | |
---|---|
protected TSeekableFile |
inputFile_
Underlying file being read |
protected java.io.OutputStream |
outputStream_
Underlying outputStream |
Constructor Summary | |
---|---|
TFileTransport(java.lang.String path,
boolean readOnly)
File Transport ctor |
|
TFileTransport(TSeekableFile inputFile,
boolean readOnly)
File Transport ctor |
Method Summary | |
---|---|
void |
close()
Closes the transport. |
void |
flush()
Flush any pending data out of a transport buffer. |
int |
getCurChunk()
|
int |
getNumChunks()
|
TFileTransport.tailPolicy |
getTailPolicy()
Get File Tailing Policy |
boolean |
isOpen()
open if both input/output open unless readonly |
static void |
main(java.lang.String[] args)
test program |
void |
open()
Diverging from the cpp model and sticking to the TSocket model Files are not opened in ctor - but in explicit open call |
int |
read(byte[] buf,
int off,
int len)
Reads up to len bytes into buffer buf, starting at offset off. |
int |
readAll(byte[] buf,
int off,
int len)
Cloned from TTransport.java:readAll(). |
void |
seekToChunk(int chunk)
|
void |
seekToEnd()
|
TFileTransport.tailPolicy |
setTailPolicy(TFileTransport.tailPolicy policy)
Set file Tailing Policy |
void |
write(byte[] buf,
int off,
int len)
Writes up to len bytes from the buffer. |
Methods inherited from class org.apache.thrift.transport.TTransport |
---|
consumeBuffer, getBuffer, getBufferPosition, getBytesRemainingInBuffer, peek, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected TSeekableFile inputFile_
protected java.io.OutputStream outputStream_
Constructor Detail |
---|
public TFileTransport(java.lang.String path, boolean readOnly) throws java.io.IOException
path
- File path to read and write fromreadOnly
- Whether this is a read-only transport
java.io.IOException
public TFileTransport(TSeekableFile inputFile, boolean readOnly)
inputFile
- open TSeekableFile to read/write fromreadOnly
- Whether this is a read-only transportMethod Detail |
---|
public TFileTransport.tailPolicy getTailPolicy()
public TFileTransport.tailPolicy setTailPolicy(TFileTransport.tailPolicy policy)
policy
- New policy to set
public boolean isOpen()
isOpen
in class TTransport
public void open() throws TTransportException
open
in class TTransport
TTransportException
- if the transport could not be openedpublic void close()
close
in class TTransport
public int readAll(byte[] buf, int off, int len) throws TTransportException
readAll
in class TTransport
buf
- Array to read intooff
- Index to start reading atlen
- Maximum number of bytes to read
TTransportException
- if there was an error reading datapublic int read(byte[] buf, int off, int len) throws TTransportException
read
in class TTransport
buf
- Array to read intooff
- Index to start reading atlen
- Maximum number of bytes to read
TTransportException
- if there was an error reading datapublic int getNumChunks() throws TTransportException
TTransportException
public int getCurChunk() throws TTransportException
TTransportException
public void seekToChunk(int chunk) throws TTransportException
TTransportException
public void seekToEnd() throws TTransportException
TTransportException
public void write(byte[] buf, int off, int len) throws TTransportException
write
in class TTransport
buf
- The output data bufferoff
- The offset to start writing fromlen
- The number of bytes to write
TTransportException
- if there was an error writing datapublic void flush() throws TTransportException
flush
in class TTransport
TTransportException
- if there was an error writing out data.public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |