Package org.armedbear.lisp
Class Stream
- java.lang.Object
-
- org.armedbear.lisp.LispObject
-
- org.armedbear.lisp.StructureObject
-
- org.armedbear.lisp.Stream
-
- Direct Known Subclasses:
BroadcastStream
,ByteArrayInputStream
,ByteArrayOutputStream
,CaseFrobStream
,ConcatenatedStream
,EchoStream
,FileStream
,FillPointerOutputStream
,GrayStream
,JarStream
,SlimeInputStream
,SlimeOutputStream
,StringInputStream
,StringOutputStream
,SynonymStream
,TwoWayStream
,URLStream
public class Stream extends StructureObject
The stream class A base class for all Lisp built-in streams.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Stream.EolStyle
static class
Stream.ReadtableAccessor
Class to abstract readtable access Many of the functions below (used to) exist in 2 variants.
-
Field Summary
Fields Modifier and Type Field Description static Primitive
AVAILABLE_ENCODINGS
protected int
charPos
The number of characters on the current line of output Used to determine whether additional line feeds are required when calling FRESH-LINEstatic Stream.ReadtableAccessor
currentReadtable
pre-instantiated readtable accessor for the *readtable*.protected LispObject
elementType
protected java.lang.String
encoding
protected char
eolChar
protected Stream.EolStyle
eolStyle
protected LispObject
externalFormat
static Stream.ReadtableAccessor
faslReadtable
pre-instantiated readtable accessor for the fasl readtable.protected boolean
isBinaryStream
protected boolean
isCharacterStream
protected boolean
isInputStream
protected boolean
isOutputStream
protected static Symbol
keywordDefault
protected char
lastChar
protected int
lineNumber
protected int
offset
static Primitive
OUT_SYNONYM_OF
static Stream.EolStyle
platformEolStyle
protected java.io.PushbackReader
reader
static Primitive
SET_STREAM_EXTERNAL_FORMAT
static Primitive
STREAM_EXTERNAL_FORMAT
-
Constructor Summary
Constructors Modifier Constructor Description protected
Stream(Symbol structureClass)
Stream(Symbol structureClass, java.io.InputStream stream)
Stream(Symbol structureClass, java.io.InputStream inputStream, LispObject elementType)
Stream(Symbol structureClass, java.io.InputStream inputStream, LispObject elementType, boolean interactive)
Stream(Symbol structureClass, java.io.InputStream inputStream, LispObject elementType, LispObject format)
Stream(Symbol structureClass, java.io.OutputStream stream)
Stream(Symbol structureClass, java.io.OutputStream outputStream, LispObject elementType)
Stream(Symbol structureClass, java.io.OutputStream outputStream, LispObject elementType, boolean interactive)
Stream(Symbol structureClass, java.io.OutputStream outputStream, LispObject elementType, LispObject format)
Stream(Symbol structureClass, java.io.Reader r)
Stream(Symbol structureClass, java.io.Writer w)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_byteReady()
protected boolean
_charReady()
Returns a boolean indicating input readily availablevoid
_clearInput()
Reads all input from the underlying stream, until _charReady() indicates no more input to be availablevoid
_close()
Closes the stream and underlying streamsvoid
_finishOutput()
Flushes any buffered output in the (underlying) streamprotected long
_getFilePosition()
Returns a (non-negative) file position integer or a negative value if the position cannot be determined.int
_readByte()
Reads an 8-bit byte off the underlying streamprotected int
_readChar()
Reads a character off an underlying streamprotected boolean
_setFilePosition(LispObject arg)
Sets the file position based on a position designator passed in argprotected void
_unreadChar(int n)
Puts a character back into the (underlying) streamvoid
_writeByte(int n)
Writes an 8-bit byte off the underlying streamvoid
_writeChar(char c)
Writes a character into the underlying stream, updating charPos while doing sovoid
_writeChars(char[] chars, int start, int end)
Writes a series of characters in the underlying stream, updating charPos while doing sovoid
_writeLine(java.lang.String s)
Writes a string to the underlying stream, appending a new line and updating charPos while doing sovoid
_writeString(java.lang.String s)
Writes a string to the underlying stream, updating charPos while doing sostatic java.util.List<Symbol>
availableEncodings()
LispObject
classOf()
LispObject
clearInput()
LispObject
close(LispObject abort)
LispObject
fileLength()
LispObject
fileStringLength(LispObject arg)
LispObject
finishOutput()
LispObject
freshLine()
Emit a newline unless at character position zero Return T if newline was emitted, NIL otherwiseint
getCharPos()
LispObject
getElementType()
java.lang.String
getEncoding()
LispObject
getExternalFormat()
LispObject
getFilePosition()
int
getLineNumber()
int
getOffset()
java.io.InputStream
getWrappedInputStream()
java.io.OutputStream
getWrappedOutputStream()
java.io.PushbackReader
getWrappedReader()
java.io.Writer
getWrappedWriter()
protected void
initAsBinaryInputStream(java.io.InputStream in)
protected void
initAsBinaryOutputStream(java.io.OutputStream out)
protected void
initAsCharacterInputStream(java.io.Reader reader)
protected void
initAsCharacterOutputStream(java.io.Writer writer)
static java.lang.String
invert(java.lang.String s, java.util.BitSet flags)
boolean
isBinaryInputStream()
boolean
isBinaryOutputStream()
boolean
isCharacterInputStream()
boolean
isCharacterOutputStream()
boolean
isInputStream()
boolean
isInteractive()
boolean
isOpen()
boolean
isOutputStream()
LispObject
listen()
void
prin1(LispObject obj)
void
print(char c)
void
printStackTrace(java.lang.Throwable t)
LispObject
read(boolean eofError, LispObject eofValue, boolean recursive, LispThread thread, Stream.ReadtableAccessor rta)
LispObject
readArray(int rank, Stream.ReadtableAccessor rta)
LispObject
readByte(boolean eofError, LispObject eofValue)
LispObject
readChar()
LispObject
readChar(boolean eofError, LispObject eofValue)
LispObject
readCharacterLiteral(Readtable rt, LispThread thread)
LispObject
readCharNoHang(boolean eofError, LispObject eofValue)
LispObject
readComplex(Stream.ReadtableAccessor rta)
LispObject
readDelimitedList(char delimiter)
LispObject
readDispatchChar(char dispChar, Stream.ReadtableAccessor rta)
LispObject
readLine(boolean eofError, LispObject eofValue)
LispObject
readList(boolean requireProperList, Stream.ReadtableAccessor rta)
LispObject
readPathname(Stream.ReadtableAccessor rta)
LispObject
readPreservingWhitespace(boolean eofError, LispObject eofValue, boolean recursive, LispThread thread, Stream.ReadtableAccessor rta)
LispObject
readRadix(int radix, Stream.ReadtableAccessor rta)
LispObject
readSharpDot(char c, int n, Stream.ReadtableAccessor rta)
LispObject
readSharpLeftParen(char c, int n, Stream.ReadtableAccessor rta)
LispObject
readSharpStar(char ignored, int n, Stream.ReadtableAccessor rta)
LispObject
readString(char terminator, Stream.ReadtableAccessor rta)
LispObject
readStructure(Stream.ReadtableAccessor rta)
LispObject
readSymbol()
LispObject
readSymbol(Readtable rt)
void
setCharPos(int n)
void
setExternalFormat(LispObject format)
LispObject
setFilePosition(LispObject arg)
void
setInteractive(boolean b)
void
setOpen(boolean b)
protected void
setWriter(java.io.Writer writer)
void
skipBalancedComment()
protected LispObject
streamNotBinaryOutputStream()
protected LispObject
streamNotCharacterInputStream()
protected LispObject
streamNotCharacterOutputStream()
protected LispObject
streamNotInputStream()
protected LispObject
streamNotOutputStream()
LispObject
terpri()
LispObject
typeOf()
LispObject
typep(LispObject typeSpecifier)
LispObject
unreadChar(LispCharacter c)
-
Methods inherited from class org.armedbear.lisp.StructureObject
equalp, getFixnumSlotValue, getParts, getSlotIndex, getSlotValue, getSlotValue_0, getSlotValue_1, getSlotValue_2, getSlotValue_3, getSlotValueAsBoolean, printObject, psxhash, psxhash, setSlotValue, setSlotValue, setSlotValue_0, setSlotValue_1, setSlotValue_2, setSlotValue_3, SLOT_VALUE
-
Methods inherited from class org.armedbear.lisp.LispObject
ABS, add, add, aref, AREF, AREF, aref_long, aset, aset, aset, ash, ash, atom, ATOM, caddr, cadr, car, cddr, cdr, CHAR, characterp, CHARACTERP, chars, COMPLEXP, constantp, CONSTANTP, copyToArray, decr, DENOMINATOR, dispatch, divideBy, doubleValue, elt, endp, ENDP, EQ, eql, eql, eql, EQL, equal, equal, EQUAL, equalp, evenp, EVENP, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, floatp, FLOATP, floatValue, getBooleanValue, getCallCount, getDescription, getDocumentation, getHotCount, getInstance, getPropertyList, getStringChars, getStringValue, getSymbolFunction, getSymbolFunctionOrDie, getSymbolSetfFunction, getSymbolSetfFunctionOrDie, getSymbolValue, incr, incrementCallCount, incrementHotCount, integerp, INTEGERP, intValue, IS_E, IS_GE, IS_GT, IS_LE, IS_LT, IS_NE, isEqualTo, isEqualTo, isGreaterThan, isGreaterThan, isGreaterThanOrEqualTo, isGreaterThanOrEqualTo, isLessThan, isLessThan, isLessThanOrEqualTo, isLessThanOrEqualTo, isNotEqualTo, isNotEqualTo, isSpecialOperator, isSpecialVariable, javaInstance, javaInstance, LDB, length, LENGTH, listp, LISTP, lockableInstance, LOGAND, LOGAND, LOGIOR, LOGIOR, LOGNOT, LOGXOR, LOGXOR, longValue, minusp, MINUSP, MOD, MOD, multiplyBy, multiplyBy, negate, noFillPointer, NOT, nreverse, NTH, NTH, nthcdr, numberp, NUMBERP, NUMERATOR, oddp, ODDP, plusp, PLUSP, princToString, push, rationalp, RATIONALP, realp, REALP, resolve, reverse, RPLACA, RPLACD, SCHAR, setCallCount, setCar, setCdr, setDocumentation, setHotCount, setPropertyList, SIMPLE_STRING_P, STRING, stringp, STRINGP, subtract, subtract, SVREF, svset, sxhash, SYMBOLP, truncate, unreadableString, unreadableString, VECTOR_PUSH_EXTEND, VECTOR_PUSH_EXTEND, vectorp, VECTORP, vectorPushExtend, zerop, ZEROP
-
-
-
-
Field Detail
-
elementType
protected LispObject elementType
-
isInputStream
protected boolean isInputStream
-
isOutputStream
protected boolean isOutputStream
-
isCharacterStream
protected boolean isCharacterStream
-
isBinaryStream
protected boolean isBinaryStream
-
reader
protected java.io.PushbackReader reader
-
offset
protected int offset
-
lineNumber
protected int lineNumber
-
charPos
protected int charPos
The number of characters on the current line of output Used to determine whether additional line feeds are required when calling FRESH-LINE
-
keywordDefault
protected static final Symbol keywordDefault
-
platformEolStyle
public static final Stream.EolStyle platformEolStyle
-
eolStyle
protected Stream.EolStyle eolStyle
-
eolChar
protected char eolChar
-
externalFormat
protected LispObject externalFormat
-
encoding
protected java.lang.String encoding
-
lastChar
protected char lastChar
-
STREAM_EXTERNAL_FORMAT
public static final Primitive STREAM_EXTERNAL_FORMAT
-
SET_STREAM_EXTERNAL_FORMAT
public static final Primitive SET_STREAM_EXTERNAL_FORMAT
-
AVAILABLE_ENCODINGS
public static final Primitive AVAILABLE_ENCODINGS
-
currentReadtable
public static Stream.ReadtableAccessor currentReadtable
pre-instantiated readtable accessor for the *readtable*.
-
faslReadtable
public static Stream.ReadtableAccessor faslReadtable
pre-instantiated readtable accessor for the fasl readtable.
-
OUT_SYNONYM_OF
public static final Primitive OUT_SYNONYM_OF
-
-
Constructor Detail
-
Stream
protected Stream(Symbol structureClass)
-
Stream
public Stream(Symbol structureClass, java.io.InputStream stream)
-
Stream
public Stream(Symbol structureClass, java.io.Reader r)
-
Stream
public Stream(Symbol structureClass, java.io.OutputStream stream)
-
Stream
public Stream(Symbol structureClass, java.io.Writer w)
-
Stream
public Stream(Symbol structureClass, java.io.InputStream inputStream, LispObject elementType)
-
Stream
public Stream(Symbol structureClass, java.io.InputStream inputStream, LispObject elementType, LispObject format)
-
Stream
public Stream(Symbol structureClass, java.io.InputStream inputStream, LispObject elementType, boolean interactive)
-
Stream
public Stream(Symbol structureClass, java.io.OutputStream outputStream, LispObject elementType)
-
Stream
public Stream(Symbol structureClass, java.io.OutputStream outputStream, LispObject elementType, LispObject format)
-
Stream
public Stream(Symbol structureClass, java.io.OutputStream outputStream, LispObject elementType, boolean interactive)
-
-
Method Detail
-
initAsCharacterInputStream
protected void initAsCharacterInputStream(java.io.Reader reader)
-
initAsBinaryInputStream
protected void initAsBinaryInputStream(java.io.InputStream in)
-
initAsCharacterOutputStream
protected void initAsCharacterOutputStream(java.io.Writer writer)
-
initAsBinaryOutputStream
protected void initAsBinaryOutputStream(java.io.OutputStream out)
-
isInputStream
public boolean isInputStream()
-
isOutputStream
public boolean isOutputStream()
-
isCharacterInputStream
public boolean isCharacterInputStream()
-
isBinaryInputStream
public boolean isBinaryInputStream()
-
isCharacterOutputStream
public boolean isCharacterOutputStream()
-
isBinaryOutputStream
public boolean isBinaryOutputStream()
-
isInteractive
public boolean isInteractive()
-
setInteractive
public void setInteractive(boolean b)
-
getExternalFormat
public LispObject getExternalFormat()
-
getEncoding
public java.lang.String getEncoding()
-
setExternalFormat
public void setExternalFormat(LispObject format)
-
availableEncodings
public static java.util.List<Symbol> availableEncodings()
-
isOpen
public boolean isOpen()
-
setOpen
public void setOpen(boolean b)
-
typeOf
public LispObject typeOf()
- Overrides:
typeOf
in classStructureObject
-
classOf
public LispObject classOf()
- Overrides:
classOf
in classStructureObject
-
typep
public LispObject typep(LispObject typeSpecifier)
- Overrides:
typep
in classStructureObject
-
getElementType
public LispObject getElementType()
-
getOffset
public int getOffset()
-
getLineNumber
public int getLineNumber()
-
setWriter
protected void setWriter(java.io.Writer writer)
-
getCharPos
public int getCharPos()
-
setCharPos
public void setCharPos(int n)
-
read
public LispObject read(boolean eofError, LispObject eofValue, boolean recursive, LispThread thread, Stream.ReadtableAccessor rta)
-
readPreservingWhitespace
public LispObject readPreservingWhitespace(boolean eofError, LispObject eofValue, boolean recursive, LispThread thread, Stream.ReadtableAccessor rta)
-
readPathname
public LispObject readPathname(Stream.ReadtableAccessor rta)
-
readSymbol
public LispObject readSymbol()
-
readSymbol
public LispObject readSymbol(Readtable rt)
-
readStructure
public LispObject readStructure(Stream.ReadtableAccessor rta)
-
readString
public LispObject readString(char terminator, Stream.ReadtableAccessor rta)
-
readList
public LispObject readList(boolean requireProperList, Stream.ReadtableAccessor rta)
-
readDispatchChar
public LispObject readDispatchChar(char dispChar, Stream.ReadtableAccessor rta)
-
readSharpLeftParen
public LispObject readSharpLeftParen(char c, int n, Stream.ReadtableAccessor rta)
-
readSharpStar
public LispObject readSharpStar(char ignored, int n, Stream.ReadtableAccessor rta)
-
readSharpDot
public LispObject readSharpDot(char c, int n, Stream.ReadtableAccessor rta)
-
readCharacterLiteral
public LispObject readCharacterLiteral(Readtable rt, LispThread thread)
-
skipBalancedComment
public void skipBalancedComment()
-
readArray
public LispObject readArray(int rank, Stream.ReadtableAccessor rta)
-
readComplex
public LispObject readComplex(Stream.ReadtableAccessor rta)
-
invert
public static final java.lang.String invert(java.lang.String s, java.util.BitSet flags)
-
readRadix
public LispObject readRadix(int radix, Stream.ReadtableAccessor rta)
-
readDelimitedList
public LispObject readDelimitedList(char delimiter)
-
readLine
public LispObject readLine(boolean eofError, LispObject eofValue)
-
readChar
public LispObject readChar()
-
readChar
public LispObject readChar(boolean eofError, LispObject eofValue)
-
readCharNoHang
public LispObject readCharNoHang(boolean eofError, LispObject eofValue)
-
unreadChar
public LispObject unreadChar(LispCharacter c)
-
finishOutput
public LispObject finishOutput()
-
clearInput
public LispObject clearInput()
-
getFilePosition
public LispObject getFilePosition()
-
setFilePosition
public LispObject setFilePosition(LispObject arg)
-
close
public LispObject close(LispObject abort)
-
readByte
public LispObject readByte(boolean eofError, LispObject eofValue)
-
terpri
public LispObject terpri()
-
freshLine
public LispObject freshLine()
Emit a newline unless at character position zero Return T if newline was emitted, NIL otherwise
-
print
public void print(char c)
-
prin1
public void prin1(LispObject obj)
-
listen
public LispObject listen()
-
fileLength
public LispObject fileLength()
-
fileStringLength
public LispObject fileStringLength(LispObject arg)
-
_readChar
protected int _readChar() throws java.io.IOException
Reads a character off an underlying stream- Returns:
- a character, or -1 at end-of-file
- Throws:
java.io.IOException
-
_unreadChar
protected void _unreadChar(int n) throws java.io.IOException
Puts a character back into the (underlying) stream- Parameters:
n
-- Throws:
java.io.IOException
-
_charReady
protected boolean _charReady() throws java.io.IOException
Returns a boolean indicating input readily available- Returns:
- true if a character is available
- Throws:
java.io.IOException
-
_byteReady
protected boolean _byteReady() throws java.io.IOException
- Throws:
java.io.IOException
-
_writeChar
public void _writeChar(char c)
Writes a character into the underlying stream, updating charPos while doing so- Parameters:
c
-
-
_writeChars
public void _writeChars(char[] chars, int start, int end)
Writes a series of characters in the underlying stream, updating charPos while doing so- Parameters:
chars
-start
-end
-
-
_writeString
public void _writeString(java.lang.String s)
Writes a string to the underlying stream, updating charPos while doing so- Parameters:
s
-
-
_writeLine
public void _writeLine(java.lang.String s)
Writes a string to the underlying stream, appending a new line and updating charPos while doing so- Parameters:
s
-
-
_readByte
public int _readByte()
Reads an 8-bit byte off the underlying stream- Returns:
-
_writeByte
public void _writeByte(int n)
Writes an 8-bit byte off the underlying stream- Parameters:
n
-
-
_finishOutput
public void _finishOutput()
Flushes any buffered output in the (underlying) stream
-
_clearInput
public void _clearInput()
Reads all input from the underlying stream, until _charReady() indicates no more input to be available
-
_getFilePosition
protected long _getFilePosition()
Returns a (non-negative) file position integer or a negative value if the position cannot be determined.- Returns:
- non-negative value as a position spec
-
_setFilePosition
protected boolean _setFilePosition(LispObject arg)
Sets the file position based on a position designator passed in arg- Parameters:
arg
- File position specifier as described in the CLHS- Returns:
- true on success, false on failure
-
_close
public void _close()
Closes the stream and underlying streams
-
printStackTrace
public void printStackTrace(java.lang.Throwable t)
-
streamNotInputStream
protected LispObject streamNotInputStream()
-
streamNotCharacterInputStream
protected LispObject streamNotCharacterInputStream()
-
streamNotOutputStream
protected LispObject streamNotOutputStream()
-
streamNotBinaryOutputStream
protected LispObject streamNotBinaryOutputStream()
-
streamNotCharacterOutputStream
protected LispObject streamNotCharacterOutputStream()
-
getWrappedInputStream
public java.io.InputStream getWrappedInputStream()
-
getWrappedOutputStream
public java.io.OutputStream getWrappedOutputStream()
-
getWrappedWriter
public java.io.Writer getWrappedWriter()
-
getWrappedReader
public java.io.PushbackReader getWrappedReader()
-
-