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 classStream.EolStylestatic classStream.ReadtableAccessorClass to abstract readtable access Many of the functions below (used to) exist in 2 variants.
-
Field Summary
Fields Modifier and Type Field Description static PrimitiveAVAILABLE_ENCODINGSprotected intcharPosThe number of characters on the current line of output Used to determine whether additional line feeds are required when calling FRESH-LINEstatic Stream.ReadtableAccessorcurrentReadtablepre-instantiated readtable accessor for the *readtable*.protected LispObjectelementTypeprotected java.lang.Stringencodingprotected chareolCharprotected Stream.EolStyleeolStyleprotected LispObjectexternalFormatstatic Stream.ReadtableAccessorfaslReadtablepre-instantiated readtable accessor for the fasl readtable.protected booleanisBinaryStreamprotected booleanisCharacterStreamprotected booleanisInputStreamprotected booleanisOutputStreamprotected static SymbolkeywordDefaultprotected charlastCharprotected intlineNumberprotected intoffsetstatic PrimitiveOUT_SYNONYM_OFstatic Stream.EolStyleplatformEolStyleprotected java.io.PushbackReaderreaderstatic PrimitiveSET_STREAM_EXTERNAL_FORMATstatic PrimitiveSTREAM_EXTERNAL_FORMAT
-
Constructor Summary
Constructors Modifier Constructor Description protectedStream(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()LispObjectclassOf()LispObjectclearInput()LispObjectclose(LispObject abort)LispObjectfileLength()LispObjectfileStringLength(LispObject arg)LispObjectfinishOutput()LispObjectfreshLine()Emit a newline unless at character position zero Return T if newline was emitted, NIL otherwiseintgetCharPos()LispObjectgetElementType()java.lang.StringgetEncoding()LispObjectgetExternalFormat()LispObjectgetFilePosition()intgetLineNumber()intgetOffset()java.io.InputStreamgetWrappedInputStream()java.io.OutputStreamgetWrappedOutputStream()java.io.PushbackReadergetWrappedReader()java.io.WritergetWrappedWriter()protected voidinitAsBinaryInputStream(java.io.InputStream in)protected voidinitAsBinaryOutputStream(java.io.OutputStream out)protected voidinitAsCharacterInputStream(java.io.Reader reader)protected voidinitAsCharacterOutputStream(java.io.Writer writer)static java.lang.Stringinvert(java.lang.String s, java.util.BitSet flags)booleanisBinaryInputStream()booleanisBinaryOutputStream()booleanisCharacterInputStream()booleanisCharacterOutputStream()booleanisInputStream()booleanisInteractive()booleanisOpen()booleanisOutputStream()LispObjectlisten()voidprin1(LispObject obj)voidprint(char c)voidprintStackTrace(java.lang.Throwable t)LispObjectread(boolean eofError, LispObject eofValue, boolean recursive, LispThread thread, Stream.ReadtableAccessor rta)LispObjectreadArray(int rank, Stream.ReadtableAccessor rta)LispObjectreadByte(boolean eofError, LispObject eofValue)LispObjectreadChar()LispObjectreadChar(boolean eofError, LispObject eofValue)LispObjectreadCharacterLiteral(Readtable rt, LispThread thread)LispObjectreadCharNoHang(boolean eofError, LispObject eofValue)LispObjectreadComplex(Stream.ReadtableAccessor rta)LispObjectreadDelimitedList(char delimiter)LispObjectreadDispatchChar(char dispChar, Stream.ReadtableAccessor rta)LispObjectreadLine(boolean eofError, LispObject eofValue)LispObjectreadList(boolean requireProperList, Stream.ReadtableAccessor rta)LispObjectreadPathname(Stream.ReadtableAccessor rta)LispObjectreadPreservingWhitespace(boolean eofError, LispObject eofValue, boolean recursive, LispThread thread, Stream.ReadtableAccessor rta)LispObjectreadRadix(int radix, Stream.ReadtableAccessor rta)LispObjectreadSharpDot(char c, int n, Stream.ReadtableAccessor rta)LispObjectreadSharpLeftParen(char c, int n, Stream.ReadtableAccessor rta)LispObjectreadSharpStar(char ignored, int n, Stream.ReadtableAccessor rta)LispObjectreadString(char terminator, Stream.ReadtableAccessor rta)LispObjectreadStructure(Stream.ReadtableAccessor rta)LispObjectreadSymbol()LispObjectreadSymbol(Readtable rt)voidsetCharPos(int n)voidsetExternalFormat(LispObject format)LispObjectsetFilePosition(LispObject arg)voidsetInteractive(boolean b)voidsetOpen(boolean b)protected voidsetWriter(java.io.Writer writer)voidskipBalancedComment()protected LispObjectstreamNotBinaryOutputStream()protected LispObjectstreamNotCharacterInputStream()protected LispObjectstreamNotCharacterOutputStream()protected LispObjectstreamNotInputStream()protected LispObjectstreamNotOutputStream()LispObjectterpri()LispObjecttypeOf()LispObjecttypep(LispObject typeSpecifier)LispObjectunreadChar(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:
typeOfin classStructureObject
-
classOf
public LispObject classOf()
- Overrides:
classOfin classStructureObject
-
typep
public LispObject typep(LispObject typeSpecifier)
- Overrides:
typepin 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.IOExceptionReads 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.IOExceptionPuts a character back into the (underlying) stream- Parameters:
n-- Throws:
java.io.IOException
-
_charReady
protected boolean _charReady() throws java.io.IOExceptionReturns 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()
-
-