public class DirStream extends Stream
Stream
class implementation for the INPUT FROM OS-DIR
Progress statement.
The stream will be initialized with the content of the os-dir parameter each line containing info in this format:
<FILE_NAME> <FILE_PATH> <FILE_TYPE>
The file type is optional and will not be shown if NO-ATTR-LIST
parameter is given to OS-DIR.
The implemented file type statuses are:
PRIMARY TYPES
SECONDARY (ADDITIVE) TYPES
One of the main types will always appear, and can also be accompanied by one or more of the secondary types.
OsDirStream is an Input only Stream therefore some Stream operations will not be supported.
Stream.PrintMode
Modifier and Type | Field and Description |
---|---|
private static CharsetConverter |
cc
Optimized character set conversion helper.
|
private static java.lang.String |
fileSep
OS file separator
|
private static java.io.InputStream |
in
The Input stream used to store OS-Dir data
|
static java.lang.String |
NEWLINE
Newline separator
|
private static java.lang.String |
override
Charset name to use for encoding or
null for default. |
private static java.lang.String |
UNSUPPORTED
Error message for unsupported operation
|
binary, convert, CR, DELIM, doneIn, doneOut, EOF, increment, LF, MODE_EXPORT, MODE_PUT_CONTROL, MODE_PUT_NORMAL, MODE_PUT_UNFORMATTED, NEWLINE_LEN, PAGED_DEFAULT, PIPE_BROKEN_MESSAGE, SET_PAGED_DEFAULT, sourceCp, targetCp
Constructor and Description |
---|
DirStream(java.lang.String dir,
boolean noAttrList)
Constructor for the
OsDirStream |
Modifier and Type | Method and Description |
---|---|
private void |
addOsDirLine(java.io.File file,
java.lang.StringBuilder sb,
boolean noAttrList)
Utility methods that takes a
File input and appends to the
given StringBuilder parameter:
The file name. |
void |
assign(Stream stream)
Assigns the internal stream reference to the given reference.
|
long |
available()
The number of bytes available to be immediately read without blocking.
|
void |
close()
Close the input side of the stream and release OS resources.
|
void |
closeIn()
Closes the input stream and releases OS resources associated with it.
|
void |
closeOut()
This just redirects to @{link #close} since this stream type cannot be
an output stream.
|
long |
getLen()
The length of the stream in bytes.
|
private java.lang.String |
getPathName(java.io.File file)
Utility method that gets the absolute path name from a
File
which may be given with a relative path. |
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.
|
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.
|
private int |
read()
Worker to read a character and hide any charset conversion that may or
may not be needed.
|
int |
readCh()
Read a character from the current read position in the stream.
|
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 |
setLen(long len)
Truncates or extends the stream to the specified length if this stream
supports such an operation.
|
void |
setPos(long pos)
Moves the current read/write position to the specified absolute 0-based
offset.
|
void |
write(byte[] data)
Write 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.
|
advancePage, afterWrite, cleanup, deleted, deregisterFooter, deregisterHeader, endOutput, endOutput, export, finished, flush, flushControlled, flushData, forcePageBreak, forcePageBreak, generateStringFormat, getAvailableLines, getControl, getConvert, getDelimiter, getDisplayMode, getEcho, getEffectivePageSize, getLength, getName, getNextLineNum, getPageNum, getPageSize, getPendingRowCount, getPosition, getUnformatted, hasPageHeadersFooters, indexOfNewLine, isContiguous, isFreshPage, isSilent, isSuppressFormFeed, isTerm, isUnbuffered, isUnnamed, isValid, iterate, needsHeadersOutput, needsPageBreak, 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, putWorker, rawGetNextLineNum, rawGetPageNum, rawGetPageSize, rawIncrementNextLineNum, rawIncrementPageNum, rawNextLineNum, rawPageSize, rawResetNextLineNum, rawSetPageSize, readBlock, readChar, readChar, readChunk, readField, readField, readField, readField, readFieldWorker, readLine, readLineCleanup, registerAdvanceListener, registerCloseListener, registerFlushListener, registerFooter, registerHeader, registerPageBreakListener, resetCurrentLine, retry, setAppend, setBinary, setContiguous, setControl, setConvert, setConvertSource, setConvertSource, setConvertTarget, setConvertTarget, setDelimiter, setDelimiter, setEcho, setLandscape, setName, setPageSize, setPageSize, setPageSize, setPendingRowCount, setPortrait, setPosition, setPosition, setUnbuffered, setUnformatted, setUnnamed, skipField, skipLoneHyphenInput, startOutput, writeBlock, writeControlled, writeControlledSpecial, writeField, writeField, writeField, writeField, writeField
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initFailure
private static java.io.InputStream in
private static final java.lang.String UNSUPPORTED
public static final java.lang.String NEWLINE
private static final java.lang.String override
null
for default.private static final CharsetConverter cc
private static final java.lang.String fileSep
public DirStream(java.lang.String dir, boolean noAttrList)
OsDirStream
The OsDirStream will be initialized for each content of the given directory including itself(.) and the upper directory (..) with a line containing:
dir
- The directory name for which OS-DIR statement is appliednoAttrList
- This indicates if type index will no be output to stream. If
true
the index will not be output to the stream,
if false
it will be outputpublic 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
This does not work for "streams" that require sequential access.
public long getLen() throws java.lang.UnsupportedOperationException, java.io.IOException
public void setLen(long len) throws java.lang.UnsupportedOperationException, java.io.IOException
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 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.readLn
in class Stream
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.public void closeIn()
public void closeOut()
public void close()
public boolean isIn()
public boolean isOut()
public void assign(Stream stream) throws java.lang.UnsupportedOperationException
private int read() throws java.io.IOException
java.io.IOException
private void addOsDirLine(java.io.File file, java.lang.StringBuilder sb, boolean noAttrList)
File
input and appends to the
given StringBuilder
parameter:
The file type is obtained by calling FileChecker.getFileType() which will execute native code to get OS specific file type.
file
- The File
for which the line information will be
appended to the StringBuilder variable
.sb
- The StringBuilder
variable to which the information
will be appended.noAttrList
- This indicates if type index will no be output to stream. If
true
the index will not be output to the stream,
if false
it will be outputprivate java.lang.String getPathName(java.io.File file)
File
which may be given with a relative path. If current "." and upper ".."
directory are included they will be added to the found path be added to
the canonical path.file
- The File
for which we want to return the absolute
path.