public class RemoteStream extends Stream
Modifier and Type | Class and Description |
---|---|
private static class |
RemoteStream.ContextContainer
Simple container that stores and returns a context-local instance of
the global work area.
|
private static class |
RemoteStream.WorkArea
Stores global data relating to the state of the current context.
|
Stream.PrintMode
Modifier and Type | Field and Description |
---|---|
private boolean |
cacheIsIn
Control caching of IsIn flag.
|
private boolean |
cacheIsOut
Control caching of IsOut flag.
|
private int |
id
The stream id on the remote node.
|
private boolean |
savedIsIn
Cached IsIn flag.
|
private boolean |
savedIsOut
Cached IsOut flag.
|
private int |
sz
The locally cached page size.
|
private boolean |
term
Mark terminal stream.
|
private static RemoteStream.ContextContainer |
work
Stores context-local state variables.
|
binary, convert, CR, DELIM, doneIn, doneOut, EOF, increment, LF, MODE_EXPORT, MODE_PUT_CONTROL, MODE_PUT_NORMAL, MODE_PUT_UNFORMATTED, NEWLINE, NEWLINE_LEN, PAGED_DEFAULT, PIPE_BROKEN_MESSAGE, SET_PAGED_DEFAULT, sourceCp, targetCp
Constructor and Description |
---|
RemoteStream(int id)
Create an instance to represent a specific remote stream.
|
RemoteStream(int id,
boolean term)
Create an instance to represent a specific remote stream.
|
Modifier and Type | Method and Description |
---|---|
void |
advancePage()
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.
|
void |
assign(Stream s)
Assigns the internal stream reference to the given reference.
|
long |
available()
The number of bytes available to be immediately read without blocking.
|
protected void |
cleanup(boolean in,
boolean out)
Perform common close preprocessing for all streams.
|
void |
close()
Closes the stream and releases OS resources associated with it.
|
void |
closeIn()
Closes the input stream and releases OS resources associated with it.
|
void |
closeOut()
Closes the output stream and releases OS resources associated with it.
|
void |
endOutput(boolean appendNewLine)
Write the current output buffer to the stream.
|
void |
flush()
Flushes the stream.
|
int |
getId()
Get the stream's remote id.
|
long |
getLen()
The length of the stream in bytes.
|
integer |
getNextLineNum()
Gets the current page's next logical line number.
|
long |
getPos()
The 0-based offset into the stream at which the next read or write will
occur.
|
boolean |
isIn()
State of the input side of the stream.
|
boolean |
isOut()
State of the output side of the stream.
|
boolean |
isTerm()
Check if given instance is bound to terminal.
|
(package private) boolean |
needsPageBreak()
Detects when a page break is needed.
|
int |
peekCh()
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 |
putWorker(FieldEntry[] data,
int mode,
char delim)
Output a list of fields to the stream.
|
(package private) int |
rawGetNextLineNum()
Gets the current page's next line number.
|
(package private) int |
rawGetPageNum()
Gets the current page number.
|
(package private) int |
rawGetPageSize()
Gets the current page size in lines.
|
(package private) void |
rawIncrementNextLineNum()
Increments the current page's next line number.
|
(package private) void |
rawIncrementPageNum()
Increments the current page number.
|
(package private) void |
rawResetNextLineNum()
Resets the current page's next line number to 1.
|
(package private) void |
rawSetPageSize(int sz)
Sets the current page size in lines.
|
int |
readCh()
Read a character from the current read position in the stream.
|
byte[] |
readChunk(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()
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()
Sets the stream into binary mode which disables character translations
during
Stream.readChar() . |
void |
setConvert(boolean convert)
Sets the stream's character conversion mode.
|
void |
setConvertSource(java.lang.String cp)
Sets the stream's source codepage and activates character conversion mode.
|
void |
setConvertTarget(java.lang.String cp)
Sets the stream's target codepage and activates character conversion mode.
|
void |
setFont(int num)
Sets the stream font number.
|
void |
setLandscape()
Set stream display mode to landscape
|
void |
setLen(long len)
Truncates or extends the stream to the specified length if this stream
supports such an operation.
|
void |
setPortrait()
Set stream display mode to portrait
|
void |
setPos(long pos)
Moves the current read/write position to the specified absolute 0-based
offset.
|
void |
setUnbuffered()
Makes the stream UNBUFFERED.
|
void |
setUnnamed(boolean unnamed)
Set the unnamed status for this stream.
|
void |
write(byte[] data)
Write the given byte array to the output stream.
|
void |
write(byte[] data,
int off,
int len)
Write the specified range of bytes from the given byte array to the output stream.
|
void |
write(java.lang.String data)
Write the given string to the output stream.
|
void |
writeByte(byte b)
Write the given byte to the output stream.
|
void |
writeCh(char ch)
Write the given character to the output stream.
|
afterWrite, assignDatum, deleted, deregisterFooter, deregisterHeader, endOutput, export, finished, flushControlled, flushData, forcePageBreak, forcePageBreak, generateStringFormat, getAvailableLines, getControl, getConvert, getDelimiter, getDisplayMode, getEcho, getEffectivePageSize, getLength, getName, getPageNum, getPageSize, getPendingRowCount, getPosition, getPulseOnClose, getUnformatted, hasPageHeadersFooters, indexOfNewLine, isContiguous, isFreshPage, isSilent, isSuppressFormFeed, isUnbuffered, isUnnamed, isValid, iterate, needsHeadersOutput, needsPageBreak, processFooters, processHeaders, processHeadersInt, processHeadersUncond, protectReads, protectWrites, pulseOutput, put, putControl, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putField, putLineEnd, putLineEnd, putNull, putNull, putSpace, putSpace, putUnformatted, rawNextLineNum, rawPageSize, readBlock, readChar, readChar, readField, readField, readField, readField, readFieldWorker, readLine, readLineCleanup, registerAdvanceListener, registerCloseListener, registerFlushListener, registerFooter, registerHeader, registerPageBreakListener, resetCurrentLine, retry, setAppend, setContiguous, setControl, setConvertSource, setConvertTarget, setDelimiter, setDelimiter, setEcho, setFont, setName, setPageSize, setPageSize, setPageSize, setPendingRowCount, setPosition, setPosition, setPulseOnClose, setUnformatted, skipField, skipLoneHyphenInput, startOutput, writeBlock, writeControlled, writeControlledSpecial, writeField, writeField, writeField, writeField, writeField
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initFailure
private int id
private int sz
private static RemoteStream.ContextContainer work
private boolean term
private boolean cacheIsOut
private boolean cacheIsIn
private boolean savedIsOut
private boolean savedIsIn
public RemoteStream(int id)
id
- Specifies the stream on which this operation is to execute.public RemoteStream(int id, boolean term)
id
- Specifies the stream on which this operation is to execute.term
- If true
then stream ID belongs to terminal
stream.public boolean isTerm()
public boolean isIn()
public boolean isOut()
public int getId()
public long available() throws java.io.IOException
public long getPos() throws java.lang.UnsupportedOperationException, java.io.IOException
public void setPos(long pos) throws java.lang.UnsupportedOperationException, java.io.IOException
public long getLen() throws java.lang.UnsupportedOperationException, java.io.IOException
public void setLen(long len) throws java.lang.UnsupportedOperationException, java.io.IOException
public void setBinary()
Stream.readChar()
. It is important to note that field and line
reading (import
, set
, update
prompt-for
and import unformatted
) are
unaffected by this setting (this is based on Progress testcases).public void writeCh(char ch) throws java.io.IOException
public void writeByte(byte b) throws java.io.IOException
public void write(java.lang.String data) throws java.io.IOException
public void write(byte[] data) throws java.io.IOException
public void write(byte[] data, int off, int len) throws java.io.IOException
write
in class Stream
data
- The data to be written.off
- Starting offset in data from which to read bytes to be written. Must be
non-negative and < data.length
.len
- Length of data to be written. Must be non-negative and <= (data.length
- offset)
.java.io.IOException
- If an I/O error occurs.public int peekCh()
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.
public int readCh()
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.
public java.lang.String readLn() 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.public byte[] readChunk(int len) throws java.io.IOException
EOF
, whichever
comes first. The EOF
character is not returned.readChunk
in class Stream
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.public void closeIn()
public void closeOut()
public void close()
assign(com.goldencode.p2j.util.Stream)
is used to "re-open" the stream. This is safe to
call when no stream is open (it will do nothing in that case).public void assign(Stream s) throws java.lang.UnsupportedOperationException
public void advancePage() throws ErrorConditionException
advancePage
in class Stream
ErrorConditionException
public void putWorker(FieldEntry[] data, int mode, char delim) throws ErrorConditionException
putWorker
in class Stream
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.public void setUnnamed(boolean unnamed)
setUnnamed
in class Stream
unnamed
- true
if this is an unnamed stream.public void setUnbuffered()
setUnbuffered
in class Stream
public void setConvert(boolean convert)
setConvert
in class Stream
convert
- The new character conversion mode. true
to
enable character conversion, false
to disable
conversion.public void setConvertSource(java.lang.String cp)
setConvertSource
in class Stream
cp
- The source codepage for character conversion mode.public void setConvertTarget(java.lang.String cp)
setConvertTarget
in class Stream
cp
- The target codepage for character conversion mode.public void setFont(int num)
public void setLandscape()
setLandscape
in class Stream
public void setPortrait()
setPortrait
in class Stream
public void endOutput(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.
endOutput
in class Stream
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.protected void cleanup(boolean in, boolean out) throws java.io.IOException
boolean needsPageBreak()
needsPageBreak
in class Stream
true
if a page break should be output.int rawGetPageSize()
rawGetPageSize
in class Stream
void rawSetPageSize(int sz)
rawSetPageSize
in class Stream
sz
- The number of lines per page.int rawGetPageNum()
rawGetPageNum
in class Stream
void rawIncrementPageNum()
rawIncrementPageNum
in class Stream
int rawGetNextLineNum()
rawGetNextLineNum
in class Stream
public integer getNextLineNum()
getNextLineNum
in class Stream
void rawIncrementNextLineNum()
rawIncrementNextLineNum
in class Stream
void rawResetNextLineNum()
rawResetNextLineNum
in class Stream