| java.lang.Object tcl.lang.TclOutputStream
TclOutputStream | class TclOutputStream (Code) | | |
Method Summary | |
int | checkFlush(ChannelBuffer buf, boolean newlineFlag) CheckFlush -> checkFlush
Helper function for writeBytes() and writeChars(). | void | close() Tcl_Close -> close
Closes a channel.
Closes the channel if this is the last reference.
close removes the channel as far as the user is concerned.
However, it may continue to exist for a while longer if it has
a background flush scheduled. | protected int | closeChannel(Interp interp, int errorCode) CloseChannel -> closeChannel
Utility procedure to close a channel and free associated resources.
If the channel was stacked, then the it will copy the necessary
elements of the NEXT channel into the TOP channel, in essence
unstacking the channel. | int | doWriteChars(char[] src, int srcOff, int srcLen) DoWriteChars -> doWriteChars
Takes a sequence of characters and converts them for output
using the channel's current encoding, may queue the buffer for
output if it gets full, and also remembers whether the current
buffer is ready e.g. | void | flush() Tcl_Flush -> flush
Flushes output data on a channel. | int | flushChannel(Interp interp, boolean calledFromAsyncFlush) FlushChannel -> flushChannel
This function flushes as much of the queued output as is possible
now. | int | getNumBufferedBytes() Tcl_OutputBuffered -> getNumBufferedBytes
Return the number of bytes that are current buffered. | boolean | isBlocked() | void | seekCheckBuferReady() seekCheckBuferReady
This method is used by the seek command to check
the channel for buffered output and mark the
buffer as ready to flush if found. | void | setBlocking(boolean inBlocking) | void | setBufferSize(int inBufSize) | void | setBuffering(int inBuffering) | void | setEncoding(String inEncoding) | void | setEofChar(char inEofChar) | void | setSync(boolean canSync) Set the sync flag for a channel so that a
sync will be invoked in addition to a flush. | void | setTranslation(int inTranslation) | boolean | translateEOL(Object dstArray, int dstStart, Object srcArray, int srcStart, IntPtr dstLenPtr, IntPtr srcLenPtr) TranslateOutputEOL -> translateEOL
Helper function for writeBytes() and writeChars(). | int | unicodeToExternal(char[] src, int srcOff, int srcLen, byte[] dst, int dstOff, int dstLen, IntPtr srcReadPtr, IntPtr dstWrotePtr, IntPtr dstCharsPtr) Tcl_UtfToExternal -> unicodeToExternal
Convert a source buffer from unicode characters to a specified encoding.
FIXME: Add doc for return values
src, Source characters. | void | updateInterest() UpdateInterest -> updateInterest
Arrange for the notifier to call us back at appropriate times
based on the current state of the channel. | int | writeBytes(byte[] srcArray, int srcOff, int srcLen) WriteBytes -> writeBytes
Write a sequence of bytes into an output buffer, may queue the
buffer for output if it gets full, and also remembers whether the
current buffer is ready e.g. | int | writeChars(char[] srcArray, int srcOff, int srcLen) WriteChars -> writeChars
Convert chars to the channel's external encoding and
write the produced bytes into an output buffer, may queue the
buffer for output if it gets full, and also remembers whether the
current buffer is ready e.g. | int | writeObj(TclObject obj) Tcl_WriteObj -> writeObj
Takes the Tcl object and queues its contents for output. |
bgFlushScheduled | protected boolean bgFlushScheduled(Code) | | |
blocked | protected boolean blocked(Code) | | Blocked
|
blocking | protected boolean blocking(Code) | | Blocking
|
bufSize | protected int bufSize(Code) | | Buffer size in bytes
|
bufferReady | protected boolean bufferReady(Code) | | Used to track buffer state, these are bit flags stored
in the flags filed in the C impl.
|
buffering | protected int buffering(Code) | | Buffering
|
canSync | protected boolean canSync(Code) | | This flag is true when the OutputStream is from
a file on disk that should be sync()'ed after
a flush. A sync should not be used for non-file
streams.
|
closed | protected boolean closed(Code) | | |
cse | protected CharsetEncoder cse(Code) | | Charset encoder object. A null value means
that no conversions have been done yet.
|
encoding | protected String encoding(Code) | | Name of Java encoding for this Channel.
A null value means use no encoding (binary).
|
encodingEnd | boolean encodingEnd(Code) | | |
encodingStart | boolean encodingStart(Code) | | |
encodingState | Object encodingState(Code) | | Flags used to track encoding states.
The encodingState member of called outputEncodingState
in the C ChannelState type. The encodingStart and encodingEnd
members combined are called outputEncodingFlags
and have the bit values TCL_ENCODING_END and TCL_ENCODING_START.
|
outQueueHead | ChannelBuffer outQueueHead(Code) | | First and last buffers in the output queue and
the current buffer being filled.
|
outputStage | protected char[] outputStage(Code) | | Staging area used to store chars before conversion into
buffered bytes.
|
refCount | protected int refCount(Code) | | FIXME: add desc
|
translation | protected int translation(Code) | | Translation mode for end-of-line character
|
unreportedError | protected int unreportedError(Code) | | Posix error code of deferred error.
|
TclOutputStream | TclOutputStream(OutputStream inOutput)(Code) | | Constructor for Tcl input stream class. We require
a byte stream source at init time, the stram can't
be changed after the TclInputStream is created.
|
checkFlush | int checkFlush(ChannelBuffer buf, boolean newlineFlag) throws IOException(Code) | | CheckFlush -> checkFlush
Helper function for writeBytes() and writeChars(). If the
channel buffer is ready to be flushed, flush it.
The return value is -1 if there was a problem flushing the
channel buffer, or 0 otherwise.
The buffer will be recycled if it is flushed.
Parameters: buf - Channel buffer to possibly flush. Parameters: newlineFlag - True if a the channel buffercontains a newline. |
close | void close() throws IOException(Code) | | Tcl_Close -> close
Closes a channel.
Closes the channel if this is the last reference.
close removes the channel as far as the user is concerned.
However, it may continue to exist for a while longer if it has
a background flush scheduled. The device itself is eventually
closed and the channel record removed, in closeChannel.
|
closeChannel | protected int closeChannel(Interp interp, int errorCode) throws IOException(Code) | | CloseChannel -> closeChannel
Utility procedure to close a channel and free associated resources.
If the channel was stacked, then the it will copy the necessary
elements of the NEXT channel into the TOP channel, in essence
unstacking the channel. The NEXT channel will then be freed.
If the channel was not stacked, then we will free all the bits
for the TOP channel, including the data structure itself.
Returns 1 if the channel was stacked, 0 otherwise.
|
doWriteChars | int doWriteChars(char[] src, int srcOff, int srcLen)(Code) | | DoWriteChars -> doWriteChars
Takes a sequence of characters and converts them for output
using the channel's current encoding, may queue the buffer for
output if it gets full, and also remembers whether the current
buffer is ready e.g. if it contains a newline and we are in
line buffering mode. Compensates stacking, i.e. will redirect the
data from the specified channel to the topmost channel in a stack.
The number of bytes written or -1 in case of error. If -1,
Tcl_GetErrno will return the error code.
May buffer up output and may cause output to be produced on the
channel.
Parameters: src - Chars to write. Parameters: srfOff - First index in src array. Parameters: srfLen - Number of chars to write. |
flush | void flush() throws IOException(Code) | | Tcl_Flush -> flush
Flushes output data on a channel.
|
flushChannel | int flushChannel(Interp interp, boolean calledFromAsyncFlush) throws IOException(Code) | | FlushChannel -> flushChannel
This function flushes as much of the queued output as is possible
now. If calledFromAsyncFlush is true, it is being called in an
event handler to flush channel output asynchronously.
Return 0 if successful, else the error code that was returned by the
channel type operation.
May produce output on a channel. May block indefinitely if the
channel is synchronous. May schedule an async flush on the channel.
May recycle memory for buffers in the output queue.
Parameters: interp - Interp object. Parameters: calledFromAsyncFlush - True if called from an asynchronousflush callback. |
getNumBufferedBytes | int getNumBufferedBytes()(Code) | | Tcl_OutputBuffered -> getNumBufferedBytes
Return the number of bytes that are current buffered.
|
isBlocked | boolean isBlocked()(Code) | | |
seekCheckBuferReady | void seekCheckBuferReady()(Code) | | seekCheckBuferReady
This method is used by the seek command to check
the channel for buffered output and mark the
buffer as ready to flush if found.
|
setBlocking | void setBlocking(boolean inBlocking)(Code) | | |
setBufferSize | void setBufferSize(int inBufSize)(Code) | | |
setBuffering | void setBuffering(int inBuffering)(Code) | | |
setEofChar | void setEofChar(char inEofChar)(Code) | | |
setSync | void setSync(boolean canSync)(Code) | | Set the sync flag for a channel so that a
sync will be invoked in addition to a flush.
|
setTranslation | void setTranslation(int inTranslation)(Code) | | |
translateEOL | boolean translateEOL(Object dstArray, int dstStart, Object srcArray, int srcStart, IntPtr dstLenPtr, IntPtr srcLenPtr)(Code) | | TranslateOutputEOL -> translateEOL
Helper function for writeBytes() and writeChars(). Converts the
'\n' characters in the source buffer into the appropriate EOL
form specified by the output translation mode.
EOL translation stops either when the source buffer is empty
or the output buffer is full.
When converting to CRLF mode and there is only 1 byte left in
the output buffer, this routine stores the '\r' in the last
byte and then stores the '\n' in the byte just past the end of the
buffer. The caller is responsible for passing in a buffer that
is large enough to hold the extra byte.
Results:
The return value is 1 if a '\n' was translated from the source
buffer, or 0 otherwise -- this can be used by the caller to
decide to flush a line-based channel even though the channel
buffer is not full.
dstLenPtr.i is filled with how many bytes of the output buffer
were used. As mentioned above, this can be one more that
the output buffer's specified length if a CRLF was stored.
srcLenPtr.i is filled with how many bytes of the source buffer
were consumed.
It may be obvious, but bears mentioning that when converting
in CRLF mode (which requires two bytes of storage in the output
buffer), the number of bytes consumed from the source buffer
will be less than the number of bytes stored in the output buffer.
dstArray, Output buffer to fill with translated bytes or chars. dstStart, First unused index in the dst output array. srcArray, Input buffer that holds the bytes or chars to translate srcStart, Index of first available byte in src array. dstLenPtr, On entry, the maximum length of outputbuffer in bytes or chars. On exit, the number ofbytes or chars actually used in output buffer. srcLenPtr, On entry, the length of source buffer.On exit, the number of bytes or chars read fromthe source buffer. |
unicodeToExternal | int unicodeToExternal(char[] src, int srcOff, int srcLen, byte[] dst, int dstOff, int dstLen, IntPtr srcReadPtr, IntPtr dstWrotePtr, IntPtr dstCharsPtr)(Code) | | Tcl_UtfToExternal -> unicodeToExternal
Convert a source buffer from unicode characters to a specified encoding.
FIXME: Add doc for return values
src, Source characters. srcOff, First index in src input array. srcLen, Number of characters in src buffer. dst, Array to store encoded bytes in. dstOff, First available index in dst array. dstLen, Length of dst array. srcReadPtr, Filled with the number of characters fromthe source string that were converted.This may be less than the original sourcelength if there was a problem convertingsome source characters. dstWrotePtr, Filled with the number of bytes that werestored in the output buffer as a result ofthe conversion dstCharsPtr, Filled with the number of characters thatcorrespond to the bytes stored in theoutput buffer. |
updateInterest | void updateInterest()(Code) | | UpdateInterest -> updateInterest
Arrange for the notifier to call us back at appropriate times
based on the current state of the channel.
|
writeBytes | int writeBytes(byte[] srcArray, int srcOff, int srcLen) throws IOException(Code) | | WriteBytes -> writeBytes
Write a sequence of bytes into an output buffer, may queue the
buffer for output if it gets full, and also remembers whether the
current buffer is ready e.g. if it contains a newline and we are in
line buffering mode.
The number of bytes written or -1 in case of error. If -1,
Tcl_GetErrno will return the error code.
May buffer up output and may cause output to be produced on the
channel.
Parameters: src - Bytes to write. Parameters: srfOff - First index in src array. Parameters: srfLen - Number of bytes to write. |
writeChars | int writeChars(char[] srcArray, int srcOff, int srcLen) throws IOException(Code) | | WriteChars -> writeChars
Convert chars to the channel's external encoding and
write the produced bytes into an output buffer, may queue the
buffer for output if it gets full, and also remembers whether the
current buffer is ready e.g. if it contains a newline and we are in
line buffering mode.
The number of bytes written or -1 in case of error. If -1,
Tcl_GetErrno will return the error code.
May buffer up output and may cause output to be produced on the
channel.
Parameters: src - Chars to write. Parameters: srfOff - First index in src array. Parameters: srfLen - Number of chars to write. |
writeObj | int writeObj(TclObject obj) throws IOException(Code) | | Tcl_WriteObj -> writeObj
Takes the Tcl object and queues its contents for output. If the
encoding of the channel is NULL, takes the byte-array representation
of the object and queues those bytes for output. Otherwise, takes
the characters in the UTF-8 (string) representation of the object
and converts them for output using the channel's current encoding.
May flush internal buffers to output if one becomes full or is ready
for some other reason, e.g. if it contains a newline and the channel
is in line buffering mode.
The number of bytes written or -1 in case of error. If -1,
Tcl_GetErrno will return the error code.
May buffer up output and may cause output to be produced on the
channel.
Parameters: obj - The object to write. |
|
|