org.armedbear.lisp
Class Stream

java.lang.Object
  extended by org.armedbear.lisp.Lisp
      extended by org.armedbear.lisp.LispObject
          extended by org.armedbear.lisp.Stream
Direct Known Subclasses:
BroadcastStream, CaseFrobStream, ConcatenatedStream, EchoStream, FileStream, FillPointerOutputStream, SlimeInputStream, SlimeOutputStream, StringInputStream, StringOutputStream, SynonymStream, TwoWayStream

public class Stream
extends LispObject

The stream class A base class for all Lisp built-in streams.


Nested Class Summary
static class Stream.EolStyle
           
 
Field Summary
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
protected  LispObject elementType
           
protected  java.lang.String encoding
           
protected  char eolChar
           
protected  Stream.EolStyle eolStyle
           
protected  LispObject externalFormat
           
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 Stream.EolStyle platformEolStyle
           
protected  java.io.PushbackReader reader
           
 
Fields inherited from class org.armedbear.lisp.Lisp
_AUTOLOAD_VERBOSE_, _BACKQUOTE_COUNT_, _BATCH_MODE_, _BQ_VECTOR_FLAG_, _CL_PACKAGE_, _COMPILE_FILE_ENVIRONMENT_, _COMPILE_FILE_TYPE_, _COMPILE_FILE_ZIP_, _CURRENT_PRINT_LENGTH_, _CURRENT_PRINT_LEVEL_, _DEBUG_, _DISASSEMBLER_, _ENABLE_INLINE_EXPANSION_, _EXPLAIN_, _KEYWORD_PACKAGE_, _LOAD_DEPTH_, _LOAD_STREAM_, _NOINFORM_, _PRINT_FASL_, _PRINT_STRUCTURE_, _REQUIRE_STACK_FRAME_, _SAFETY_, _SAVED_BACKTRACE_, _SLOT_UNBOUND_, _SOURCE_, _SOURCE_POSITION_, _SPACE_, _SPEED_, _TRACED_NAMES_, _WARN_ON_REDEFINITION_, ARRAY_DIMENSION_MAX, CALL_REGISTERS_LIMIT, CALL_REGISTERS_MAX, CHAR_MAX, cold, COMPILE_FILE_TYPE, debug, EOF, FUNCTION_NAME, initialized, interrupted, NIL, NULL_VALUE, PACKAGE_CL, PACKAGE_CL_USER, PACKAGE_EXT, PACKAGE_JAVA, PACKAGE_JVM, PACKAGE_KEYWORD, PACKAGE_LOOP, PACKAGE_MOP, PACKAGE_PROF, PACKAGE_SYS, PACKAGE_TPL, profiling, REMEMBER, sampleNow, sampling, STANDARD_READTABLE, T, TRAP_OVERFLOW, TRAP_UNDERFLOW, UNBOUND_VALUE, UNSIGNED_BYTE_16, UNSIGNED_BYTE_32, UNSIGNED_BYTE_32_MAX_VALUE, UNSIGNED_BYTE_8
 
Constructor Summary
protected Stream()
           
  Stream(java.io.InputStream inputStream, LispObject elementType)
           
  Stream(java.io.InputStream inputStream, LispObject elementType, boolean interactive)
           
  Stream(java.io.InputStream inputStream, LispObject elementType, LispObject format)
           
  Stream(java.io.OutputStream outputStream, LispObject elementType)
           
  Stream(java.io.OutputStream outputStream, LispObject elementType, boolean interactive)
           
  Stream(java.io.OutputStream outputStream, LispObject elementType, LispObject format)
           
 
Method Summary
protected  boolean _charReady()
          Returns a boolean indicating input readily available
 void _clearInput()
          Reads all input from the underlying stream, until _charReady() indicates no more input to be available
 void _close()
          Closes the stream and underlying streams
 void _finishOutput()
          Flushes any buffered output in the (underlying) stream
protected  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 stream
protected  int _readChar()
          Reads a character off an underlying stream
protected  boolean _setFilePosition(LispObject arg)
          Sets the file position based on a position designator passed in arg
protected  void _unreadChar(int n)
          Puts a character back into the (underlying) stream
 void _writeByte(int n)
          Writes an 8-bit byte off the underlying stream
 void _writeChar(char c)
          Writes a character into the underlying stream, updating charPos while doing so
 void _writeChars(char[] chars, int start, int end)
          Writes a series of characters in the underlying stream, updating charPos while doing so
 void _writeLine(java.lang.String s)
          Writes a string to the underlying stream, appending a new line and updating charPos while doing so
 void _writeString(java.lang.String s)
          Writes a string to the underlying stream, updating charPos while doing so
 LispObject classOf()
           
 LispObject clearInput()
           
 LispObject close(LispObject abort)
           
 LispObject faslRead(boolean eofError, LispObject eofValue, boolean recursive, LispThread thread)
           
 LispObject faslReadArray(int rank)
           
 LispObject faslReadComplex()
           
 LispObject faslReadPathname()
           
 LispObject faslReadRadix(int radix)
           
 LispObject faslReadStructure()
           
 LispObject fileLength()
           
 LispObject fileStringLength(LispObject arg)
           
 LispObject finishOutput()
           
 LispObject freshLine()
           
 int getCharPos()
           
 LispObject getElementType()
           
 java.lang.String getEncoding()
           
 LispObject getExternalFormat()
           
 LispObject getFilePosition()
           
 int getLineNumber()
           
 int getOffset()
           
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)
           
 LispObject readArray(int rank)
           
 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()
           
 LispObject readDelimitedList(char delimiter)
           
 LispObject readDispatchChar(char dispChar, boolean useFaslReadtable)
           
 LispObject readLine(boolean eofError, LispObject eofValue)
           
 LispObject readList(boolean requireProperList, boolean useFaslReadtable)
           
 LispObject readPathname()
           
 LispObject readPreservingWhitespace(boolean eofError, LispObject eofValue, boolean recursive, LispThread thread)
           
 LispObject readRadix(int radix)
           
 LispObject readStructure()
           
 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()
           
 java.lang.String toString()
           
 LispObject typeOf()
           
 LispObject typep(LispObject typeSpecifier)
           
 LispObject unreadChar(LispCharacter c)
           
 
Methods inherited from class org.armedbear.lisp.LispObject
ABS, add, add, aref_long, aref, AREF, AREF, 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, equalp, evenp, EVENP, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, floatp, FLOATP, floatValue, getBooleanValue, getCallCount, getDescription, getDocumentation, getFixnumSlotValue, getInstance, getParts, getPropertyList, getSlotValue_0, getSlotValue_1, getSlotValue_2, getSlotValue_3, getSlotValue, getSlotValueAsBoolean, getStringChars, getStringValue, getSymbolFunction, getSymbolFunctionOrDie, getSymbolValue, incr, incrementCallCount, 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, 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, psxhash, psxhash, push, rationalp, RATIONALP, realp, REALP, reverse, RPLACA, RPLACD, SCHAR, setCallCount, setCar, setCdr, setDocumentation, setPropertyList, setSlotValue_0, setSlotValue_1, setSlotValue_2, setSlotValue_3, setSlotValue, setSlotValue, SIMPLE_STRING_P, SLOT_VALUE, STRING, stringp, STRINGP, subtract, subtract, SVREF, svset, sxhash, SYMBOLP, truncate, unreadableString, unreadableString, VECTOR_PUSH_EXTEND, VECTOR_PUSH_EXTEND, vectorp, VECTORP, vectorPushExtend, writeToString, zerop, ZEROP
 
Methods inherited from class org.armedbear.lisp.Lisp
assq, bindArg, checkArray, checkBinaryInputStream, checkBounds, checkCharacter, checkCharacterInputStream, checkCharacterOutputStream, checkEnvironment, checkFunction, checkList, checkPackage, checkReadtable, checkStream, checkSymbol, checkVector, coerceJavaByteToLispObject, coerceLispObjectToJavaByte, coerceToFunction, coerceToPackage, coerceToPathname, currentReadtable, designator_readtable, error, error, eval, eval, evalCall, exit, exportConstant, exportSpecial, format, funcall, gensym, gensym, get, get, getCurrentPackage, getf, getStandardInput, getStandardOutput, getTerminalIO, getUpgradedArrayElementType, handleInterrupt, inSynonymOf, intern, internConstant, internInPackage, internKeyword, internSpecial, isValidSetfFunctionName, javaString, list, list1, list2, list3, list4, list5, list6, list7, list8, list9, loadCompiledFunction, loadTimeValue, macroexpand_1, macroexpand, makeCompiledClosure, memq, memql, mix, mod, multipleValueCall1, multipleValueList, number, number, number, progn, progvBindVars, put, putf, readObjectFromString, recall, remprop, resetIO, resetIO, safeWriteToString, setInterrupted, type_error, writeByte
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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
Constructor Detail

Stream

protected Stream()

Stream

public Stream(java.io.InputStream inputStream,
              LispObject elementType)

Stream

public Stream(java.io.InputStream inputStream,
              LispObject elementType,
              LispObject format)

Stream

public Stream(java.io.InputStream inputStream,
              LispObject elementType,
              boolean interactive)

Stream

public Stream(java.io.OutputStream outputStream,
              LispObject elementType)

Stream

public Stream(java.io.OutputStream outputStream,
              LispObject elementType,
              LispObject format)

Stream

public Stream(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()
                      throws ConditionThrowable
Throws:
ConditionThrowable

isOutputStream

public boolean isOutputStream()
                       throws ConditionThrowable
Throws:
ConditionThrowable

isCharacterInputStream

public boolean isCharacterInputStream()
                               throws ConditionThrowable
Throws:
ConditionThrowable

isBinaryInputStream

public boolean isBinaryInputStream()
                            throws ConditionThrowable
Throws:
ConditionThrowable

isCharacterOutputStream

public boolean isCharacterOutputStream()
                                throws ConditionThrowable
Throws:
ConditionThrowable

isBinaryOutputStream

public boolean isBinaryOutputStream()
                             throws ConditionThrowable
Throws:
ConditionThrowable

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)

isOpen

public boolean isOpen()

setOpen

public void setOpen(boolean b)

typeOf

public LispObject typeOf()
Overrides:
typeOf in class LispObject

classOf

public LispObject classOf()
Overrides:
classOf in class LispObject

typep

public LispObject typep(LispObject typeSpecifier)
                 throws ConditionThrowable
Overrides:
typep in class LispObject
Throws:
ConditionThrowable

getElementType

public LispObject getElementType()
                          throws ConditionThrowable
Throws:
ConditionThrowable

getOffset

public int getOffset()

getLineNumber

public final 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)
                throws ConditionThrowable
Throws:
ConditionThrowable

readPreservingWhitespace

public LispObject readPreservingWhitespace(boolean eofError,
                                           LispObject eofValue,
                                           boolean recursive,
                                           LispThread thread)
                                    throws ConditionThrowable
Throws:
ConditionThrowable

faslRead

public LispObject faslRead(boolean eofError,
                           LispObject eofValue,
                           boolean recursive,
                           LispThread thread)
                    throws ConditionThrowable
Throws:
ConditionThrowable

readPathname

public LispObject readPathname()
                        throws ConditionThrowable
Throws:
ConditionThrowable

faslReadPathname

public LispObject faslReadPathname()
                            throws ConditionThrowable
Throws:
ConditionThrowable

readSymbol

public LispObject readSymbol()
                      throws ConditionThrowable
Throws:
ConditionThrowable

readSymbol

public LispObject readSymbol(Readtable rt)
                      throws ConditionThrowable
Throws:
ConditionThrowable

readStructure

public LispObject readStructure()
                         throws ConditionThrowable
Throws:
ConditionThrowable

faslReadStructure

public LispObject faslReadStructure()
                             throws ConditionThrowable
Throws:
ConditionThrowable

readList

public LispObject readList(boolean requireProperList,
                           boolean useFaslReadtable)
                    throws ConditionThrowable
Throws:
ConditionThrowable

readDispatchChar

public LispObject readDispatchChar(char dispChar,
                                   boolean useFaslReadtable)
                            throws ConditionThrowable
Throws:
ConditionThrowable

readCharacterLiteral

public LispObject readCharacterLiteral(Readtable rt,
                                       LispThread thread)
                                throws ConditionThrowable
Throws:
ConditionThrowable

skipBalancedComment

public void skipBalancedComment()
                         throws ConditionThrowable
Throws:
ConditionThrowable

readArray

public LispObject readArray(int rank)
                     throws ConditionThrowable
Throws:
ConditionThrowable

faslReadArray

public LispObject faslReadArray(int rank)
                         throws ConditionThrowable
Throws:
ConditionThrowable

readComplex

public LispObject readComplex()
                       throws ConditionThrowable
Throws:
ConditionThrowable

faslReadComplex

public LispObject faslReadComplex()
                           throws ConditionThrowable
Throws:
ConditionThrowable

invert

public static final java.lang.String invert(java.lang.String s,
                                            java.util.BitSet flags)

readRadix

public LispObject readRadix(int radix)
                     throws ConditionThrowable
Throws:
ConditionThrowable

faslReadRadix

public LispObject faslReadRadix(int radix)
                         throws ConditionThrowable
Throws:
ConditionThrowable

readDelimitedList

public LispObject readDelimitedList(char delimiter)
                             throws ConditionThrowable
Throws:
ConditionThrowable

readLine

public LispObject readLine(boolean eofError,
                           LispObject eofValue)
                    throws ConditionThrowable
Throws:
ConditionThrowable

readChar

public LispObject readChar()
                    throws ConditionThrowable
Throws:
ConditionThrowable

readChar

public LispObject readChar(boolean eofError,
                           LispObject eofValue)
                    throws ConditionThrowable
Throws:
ConditionThrowable

readCharNoHang

public LispObject readCharNoHang(boolean eofError,
                                 LispObject eofValue)
                          throws ConditionThrowable
Throws:
ConditionThrowable

unreadChar

public LispObject unreadChar(LispCharacter c)
                      throws ConditionThrowable
Throws:
ConditionThrowable

finishOutput

public LispObject finishOutput()
                        throws ConditionThrowable
Throws:
ConditionThrowable

clearInput

public LispObject clearInput()
                      throws ConditionThrowable
Throws:
ConditionThrowable

getFilePosition

public LispObject getFilePosition()
                           throws ConditionThrowable
Throws:
ConditionThrowable

setFilePosition

public LispObject setFilePosition(LispObject arg)
                           throws ConditionThrowable
Throws:
ConditionThrowable

close

public LispObject close(LispObject abort)
                 throws ConditionThrowable
Throws:
ConditionThrowable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

readByte

public LispObject readByte(boolean eofError,
                           LispObject eofValue)
                    throws ConditionThrowable
Throws:
ConditionThrowable

terpri

public LispObject terpri()
                  throws ConditionThrowable
Throws:
ConditionThrowable

freshLine

public LispObject freshLine()
                     throws ConditionThrowable
Throws:
ConditionThrowable

print

public void print(char c)
           throws ConditionThrowable
Throws:
ConditionThrowable

prin1

public void prin1(LispObject obj)
           throws ConditionThrowable
Throws:
ConditionThrowable

listen

public LispObject listen()
                  throws ConditionThrowable
Throws:
ConditionThrowable

fileLength

public LispObject fileLength()
                      throws ConditionThrowable
Throws:
ConditionThrowable

fileStringLength

public LispObject fileStringLength(LispObject arg)
                            throws ConditionThrowable
Throws:
ConditionThrowable

_readChar

protected int _readChar()
                 throws ConditionThrowable
Reads a character off an underlying stream

Returns:
a character, or -1 at end-of-file
Throws:
ConditionThrowable

_unreadChar

protected void _unreadChar(int n)
                    throws ConditionThrowable
Puts a character back into the (underlying) stream

Parameters:
n -
Throws:
ConditionThrowable

_charReady

protected boolean _charReady()
                      throws ConditionThrowable
Returns a boolean indicating input readily available

Returns:
true if a character is available
Throws:
ConditionThrowable

_writeChar

public void _writeChar(char c)
                throws ConditionThrowable
Writes a character into the underlying stream, updating charPos while doing so

Parameters:
c -
Throws:
ConditionThrowable

_writeChars

public void _writeChars(char[] chars,
                        int start,
                        int end)
                 throws ConditionThrowable
Writes a series of characters in the underlying stream, updating charPos while doing so

Parameters:
chars -
start -
end -
Throws:
ConditionThrowable

_writeString

public void _writeString(java.lang.String s)
                  throws ConditionThrowable
Writes a string to the underlying stream, updating charPos while doing so

Parameters:
s -
Throws:
ConditionThrowable

_writeLine

public void _writeLine(java.lang.String s)
                throws ConditionThrowable
Writes a string to the underlying stream, appending a new line and updating charPos while doing so

Parameters:
s -
Throws:
ConditionThrowable

_readByte

public int _readByte()
              throws ConditionThrowable
Reads an 8-bit byte off the underlying stream

Returns:
Throws:
ConditionThrowable

_writeByte

public void _writeByte(int n)
                throws ConditionThrowable
Writes an 8-bit byte off the underlying stream

Parameters:
n -
Throws:
ConditionThrowable

_finishOutput

public void _finishOutput()
                   throws ConditionThrowable
Flushes any buffered output in the (underlying) stream

Throws:
ConditionThrowable

_clearInput

public void _clearInput()
                 throws ConditionThrowable
Reads all input from the underlying stream, until _charReady() indicates no more input to be available

Throws:
ConditionThrowable

_getFilePosition

protected long _getFilePosition()
                         throws ConditionThrowable
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
Throws:
ConditionThrowable

_setFilePosition

protected boolean _setFilePosition(LispObject arg)
                            throws ConditionThrowable
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
Throws:
ConditionThrowable

_close

public void _close()
            throws ConditionThrowable
Closes the stream and underlying streams

Throws:
ConditionThrowable

printStackTrace

public void printStackTrace(java.lang.Throwable t)
                     throws ConditionThrowable
Throws:
ConditionThrowable

streamNotInputStream

protected LispObject streamNotInputStream()
                                   throws ConditionThrowable
Throws:
ConditionThrowable

streamNotCharacterInputStream

protected LispObject streamNotCharacterInputStream()
                                            throws ConditionThrowable
Throws:
ConditionThrowable

streamNotOutputStream

protected LispObject streamNotOutputStream()
                                    throws ConditionThrowable
Throws:
ConditionThrowable

streamNotBinaryOutputStream

protected LispObject streamNotBinaryOutputStream()
                                          throws ConditionThrowable
Throws:
ConditionThrowable

streamNotCharacterOutputStream

protected LispObject streamNotCharacterOutputStream()
                                             throws ConditionThrowable
Throws:
ConditionThrowable