public interface LowLevelStream
Modifier and Type | Method and Description |
---|---|
void |
advancePage(int id)
Inserts a page break if the stream is paged and if the next write
position is not on the first line of a new page.
|
long |
available(int id)
The number of bytes available to be immediately read without blocking.
|
void |
close(int id)
Closes the stream and releases OS resources associated with it.
|
void |
closeIn(int id)
Closes the input stream and releases OS resources associated with it.
|
void |
closeOut(int id)
Closes the output stream and releases OS resources associated with it.
|
void |
endOutput(int id,
boolean appendNewLine)
Write the current output buffer to the stream.
|
void |
flush(int id)
Flushes the stream.
|
long |
getLen(int id)
The length of the stream in bytes.
|
int |
getNextLineNum(int id)
Gets the current page's next logical line number.
|
long |
getPos(int id)
The 0-based offset into the stream at which the next read or write will
occur.
|
boolean |
isIn(int id)
State of the input side of the stream.
|
boolean |
isOut(int id)
State of the output side of the stream.
|
boolean |
needsPageBreak(int id)
Detects when a page break is needed.
|
int |
peekCh(int id)
Peeks at the character from the current read position in the stream (reads a character from
the current read position in the stream without incrementing stream read position.
|
void |
processCleanup(int id,
boolean in,
boolean out)
Perform common close preprocessing for all streams.
|
void |
putWorker(int id,
FieldEntry[] data,
int mode,
char delim)
Output a list of fields to the stream.
|
int |
rawGetNextLineNum(int id)
Gets the current page's next line number.
|
int |
rawGetPageNum(int id)
Gets the current page number.
|
int |
rawGetPageSize(int id)
Gets the current page size in lines.
|
void |
rawIncrementNextLineNum(int id)
Increments the current page's next line number.
|
void |
rawIncrementPageNum(int id)
Increments the current page number.
|
void |
rawResetNextLineNum(int id)
Resets the current page's next line number to 1.
|
void |
rawSetPageSize(int id,
int sz)
Sets the current page size in lines.
|
int |
readCh(int id)
Read a character from the current read position in the stream.
|
byte[] |
readChunk(int id,
int len)
Read a chunk of bytes from the current read position in the stream to the
offset calculated by given length or to the
EOF , whichever
comes first. |
java.lang.String |
readLn(int id)
Read all characters from the current read position in the stream to the
next line separator (as determined by the
File.separator
or to the EOF . |
void |
setBinary(int id)
Sets the stream into binary mode which disables character translations during I/O
operations.
|
void |
setConvert(int id,
boolean convert)
Sets the stream's character conversion mode.
|
void |
setConvertSource(int id,
java.lang.String cp)
Sets the stream's source codepage and activates character conversion mode.
|
void |
setConvertTarget(int id,
java.lang.String cp)
Sets the stream's target codepage and activates character conversion mode.
|
void |
setLen(int id,
long len)
Truncates or extends the stream to the specified length if this stream
supports such an operation.
|
void |
setPos(int id,
long pos)
Moves the current read/write position to the specified absolute 0-based
offset.
|
void |
setUnbuffered(int id)
Set the specified stream UNBUFFERED.
|
void |
setUnnamed(int id,
boolean unnamed)
Set the unnamed status for the specified stream.
|
void |
write(int id,
byte[] data)
Write the given byte array to the output stream.
|
void |
write(int id,
java.lang.String data)
Write the given string to the output stream.
|
void |
writeByte(int id,
byte b)
Write the given byte to the output stream.
|
void |
writeCh(int id,
char ch)
Write the given character to the output stream.
|
long available(int id) throws java.io.IOException
id
- Specifies the stream on which this operation is to execute.java.io.IOException
- if an I/O error occurs.long getPos(int id) throws java.lang.UnsupportedOperationException, java.io.IOException
id
- Specifies the stream on which this operation is to execute.java.lang.UnsupportedOperationException
- If the requested operation is not supported.java.io.IOException
- If an I/O error occurs.void setPos(int id, long pos) throws java.lang.UnsupportedOperationException, java.io.IOException
id
- Specifies the stream on which this operation is to execute.pos
- The new read/write position in the stream.java.lang.UnsupportedOperationException
- If the requested operation is not supported.java.io.IOException
- If an I/O error occurs.long getLen(int id) throws java.lang.UnsupportedOperationException, java.io.IOException
id
- Specifies the stream on which this operation is to execute.java.lang.UnsupportedOperationException
- If the requested operation is not supported.java.io.IOException
- If an I/O error occurs.void setLen(int id, long len) throws java.lang.UnsupportedOperationException, java.io.IOException
id
- Specifies the stream on which this operation is to execute.len
- The new length of the file.java.lang.UnsupportedOperationException
- If the requested operation is not supported.java.io.IOException
- If an I/O error occurs.void writeCh(int id, char ch) throws java.io.IOException
id
- Specifies the stream on which this operation is to execute.ch
- The character to be written.java.io.IOException
- If an I/O error occurs.void writeByte(int id, byte b) throws java.io.IOException
id
- Specifies the stream on which this operation is to execute.b
- The byte to be written.java.io.IOException
- If an I/O error occurs.void write(int id, java.lang.String data) throws java.io.IOException
id
- Specifies the stream on which this operation is to execute.data
- The data to be written.java.io.IOException
- If an I/O error occurs.void write(int id, byte[] data) throws java.io.IOException
id
- Specifies the stream on which this operation is to execute.data
- The data to be written.java.io.IOException
- If an I/O error occurs.int peekCh(int id)
peekCh()
and readCh()
will return the same value).
The underlying stream subclass determines the content of the result. Byte oriented streams such as pipes or files will return a byte while streams that generate keystrokes or characters may return a DBCS or Unicode character.
id
- Specifies the stream on which this operation is to execute.EOF
.int readCh(int id)
The underlying stream subclass determines the content of the result. Byte oriented streams such as pipes or files will return a byte while streams that generate keystrokes or characters may return a DBCS or Unicode character.
id
- Specifies the stream on which this operation is to execute.EOF
.java.lang.String readLn(int id) throws java.io.EOFException, java.io.IOException, java.lang.InterruptedException
File.separator
or to the EOF
. Any line separator character(s) and the
EOF
character are not returned.id
- Specifies the stream on which this operation is to execute.java.io.IOException
- If an I/O error occurs.java.io.EOFException
- If this input stream reaches the end before reading all the
bytes.java.lang.InterruptedException
- If any thread interrupted the current thread before or while
the current thread was waiting for a notification.byte[] readChunk(int id, int len) throws java.io.IOException
EOF
, whichever
comes first. The EOF
character is not returned.id
- Specifies the stream on which this operation is to execute.len
- The number of bytes to read.null
if there
is nothing to read (the EOF
has been reached). The
length of the returned array will be the smaller of the
len
parameter or the actual bytes left before the
EOF
.java.io.IOException
- If an I/O error occurs.void closeIn(int id)
id
- Specifies the stream on which this operation is to execute.void closeOut(int id)
id
- Specifies the stream on which this operation is to execute.boolean isIn(int id)
id
- Specifies the stream on which this operation is to execute.true
if the input side of the stream is active.boolean isOut(int id)
id
- Specifies the stream on which this operation is to execute.true
if the output side of the stream is active.void close(int id)
assign
is used to "re-open" the stream. This is safe to
call when no stream is open (it will do nothing in that case).id
- Specifies the stream on which this operation is to execute.void advancePage(int id) throws ErrorConditionException
id
- Specifies the stream on which this operation is to execute.ErrorConditionException
- On any error during I/O.void flush(int id)
id
- Specifies the stream on which this operation is to execute.boolean needsPageBreak(int id)
id
- Specifies the stream on which this operation is to execute.true
if a page break should be output.int rawGetPageSize(int id)
id
- Specifies the stream on which this operation is to execute.void rawSetPageSize(int id, int sz)
id
- Specifies the stream on which this operation is to execute.sz
- The number of lines per page.int rawGetPageNum(int id)
id
- Specifies the stream on which this operation is to execute.void rawIncrementPageNum(int id)
id
- Specifies the stream on which this operation is to execute.int rawGetNextLineNum(int id)
id
- Specifies the stream on which this operation is to execute.int getNextLineNum(int id)
id
- Specifies the stream on which this operation is to execute.void rawIncrementNextLineNum(int id)
id
- Specifies the stream on which this operation is to execute.void rawResetNextLineNum(int id)
id
- Specifies the stream on which this operation is to execute.void processCleanup(int id, boolean in, boolean out) throws java.io.IOException
id
- Specifies the stream on which this operation is to execute.in
- true
if this was triggered during a call to
closeIn(int)
or close(int)
. Input resources are
to be cleaned up.out
- true
if this was triggered during a call to
closeOut(int)
or close(int)
. Output resources are
to be cleaned up.java.io.IOException
- On any error during I/O.void endOutput(int id, boolean appendNewLine) throws ErrorConditionException, StopConditionException
Stream.putField(int)
, Stream.putSpace()
,
Stream.putLineEnd()
and Stream.writeField(int)
methods to the
stream. This method also resets the current delimiter to the default.
This method does nothing if the stream is in control
mode.
id
- Specifies the stream on which this operation is to execute.appendNewLine
- Automatically add new line at the end of output.ErrorConditionException
- On any error during I/O.StopConditionException
- If any interruption occurs during I/O processing.void putWorker(int id, FieldEntry[] data, int mode, char delim) throws ErrorConditionException
id
- Specifies the stream on which this operation is to execute.data
- The list of fields to be output.mode
- MODE_PUT_NORMAL
, MODE_PUT_CONTROL
,
MODE_PUT_UNFORMATTED
or MODE_EXPORT
.delim
- The delimiter to use in EXPORT mode.ErrorConditionException
- On any error during I/O.void setUnnamed(int id, boolean unnamed)
id
- Specifies the stream on which this operation is to execute.unnamed
- true
if it is an unnamed stream.void setUnbuffered(int id)
id
- Specifies the stream on which this operation is to execute.void setConvert(int id, boolean convert)
id
- Specifies the stream on which this operation is to execute.convert
- The new character conversion mode. true
to
enable character conversion, false
to disable
conversion.void setConvertSource(int id, java.lang.String cp)
id
- Specifies the stream on which this operation is to execute.cp
- The source codepage for character conversion mode.void setConvertTarget(int id, java.lang.String cp)
id
- Specifies the stream on which this operation is to execute.cp
- The target codepage for character conversion mode.void setBinary(int id)
import
,
set
, update
prompt-for
and import
unformatted
) are unaffected by this setting (this is based on Progress testcases).id
- Specifies the stream on which this operation is to execute.