edu.isi.stella
Class InputStream

java.lang.Object
  extended by edu.isi.stella.Stella_Object
      extended by edu.isi.stella.StandardObject
          extended by edu.isi.stella.Stream
              extended by edu.isi.stella.InputStream
Direct Known Subclasses:
InputFileStream, InputStringStream

public class InputStream
extends Stream


Field Summary
 Keyword bufferingScheme
          One of :CHARACTER, :LINE or :BLOCK indicating what kind of input buffer we are reading from.
 OutputStream echoStream
           
 java.io.PushbackInputStream nativeStream
           
 TokenizerStreamState tokenizerState
           
 
Fields inherited from class edu.isi.stella.Stream
state
 
Constructor Summary
InputStream()
           
 
Method Summary
static Stella_Object accessInputStreamSlotValue(InputStream self, Symbol slotname, Stella_Object value, boolean setvalueP)
           
static CharacterIterator characters(InputStream stream)
           
static boolean consumeWhitespace(InputStream stream)
           
static void copyStreamToStream(InputStream in, OutputStream out)
          Copy in verbatimely to out.
static boolean eatNextCharacterIfWhitespace(InputStream stream)
           
 void free()
          Default method.
static LineIterator lines(InputStream stream)
           
static NativeLineIterator nativeLines(InputStream stream)
           
static java.lang.String nativeReadLine(InputStream inputstream)
          Read one line from inputstream using the native language readline algorithm and return the result.
static InputStream newInputStream()
           
 Surrogate primaryType()
          Returns the primary type of self.
static char readCharacter(InputStream inputstream, java.lang.Object[] MV_returnarray)
          Read one character from inputstream and return the result.
static char readCharacterFromTokenizerBuffer(InputStream stream, java.lang.Object[] MV_returnarray)
           
static boolean readIntoTokenizerBuffer(InputStream stream, TokenizerStreamState state, int currenttokenstart)
           
static java.lang.String readLine(InputStream stream)
          Read one line from stream and return the result.
static java.lang.String readLine2(InputStream stream, java.lang.Object[] MV_returnarray)
          Read one line from stream and return the result and a keyword that indicates the terminator for that line ending: CCR CLF CCRLF or CEOF.
static java.lang.String readLineFromTokenizerBuffer(InputStream stream)
           
static Stella_Object readSExpression(InputStream stream, java.lang.Object[] MV_returnarray)
          Read one STELLA s-expression from stream and return the result.
static Stella_Object readXmlExpression(InputStream stream, Stella_Object startTag, java.lang.Object[] MV_returnarray)
          Read one balanced XML expression from stream and return its s-expression representation (see xmlTokenListToSExpression).
static SExpressionIterator sExpressions(InputStream stream)
           
 java.lang.String streamToString()
          Read all of the input from stream and return it as a string.
static void substituteTemplateVariablesToStream(InputStream templatestream, OutputStream outputstream, KeyValueList variables)
           
static boolean terminateInputStreamP(InputStream self)
           
static StellaToken tokenizeSExpression(InputStream stream, StellaToken tokenlist)
           
static TokenizerToken tokenizeXmlExpression(InputStream stream, TokenizerToken tokenlist, java.lang.String regiontagname, boolean skiptoregionP, java.lang.Object[] MV_returnarray)
           
static XmlExpressionIterator xmlExpressions(InputStream stream, Stella_Object regiontag)
          Return an XML-expression-iterator (which see) reading from stream.
 
Methods inherited from class edu.isi.stella.Stream
accessStreamSlotValue, closeStream
 
Methods inherited from class edu.isi.stella.StandardObject
arrayTypeSpecifierP, baseTypeToTypeSpec, cantOverwriteActiveCollectionSlot, compatibleParameterTypesP, computeAnchoredTypeSpec, computeRelativeTypeSpec, conformingTypeSpecP, copyWrappedLiteral, cppNonPointerTypeP, cppReferenceTypeP, cppReferencizeType, cppTranslateAndPointerizeTypeSpec, cppTranslateAndReferencizeTypeSpec, cppTranslateTypeSpec, cppTypeWithoutInteriorPointersP, dropSlotValue, extractParameterType, extractRequiredArgumentValues, getSlot, hashCode_, idlTranslateTypeSpec, inverseSlotDemon, javaLiteralP, javaNativeLiteralWrapperNames, javaSpecialSetterName, javaTranslateArrayOfTypeSpec, javaTranslateTypeSpec, javaTranslateTypeSpecForFunction, javaTranslateTypeSpecHelper, javaYieldClassObjectArrayExpression, javaYieldClassObjectExpression, javaYieldFullyQualifiedTypeName, javaYieldTranslatedClassAndMethodNames, listifyTypeSpec, lookupClTypeFromStellaType, objectEqlP, putSlotValue, readSlotValue, runConstructorDemons, runDestructorDemons, runSlotDemons, runSlotGuardDemonsP, standardObjectP, subTypeSpecOfP, twoArgumentLeastCommonSupertype, typeSpecToBaseType, typeSpecToClass, typeToWalkedNullValueTree, validateTypeSpecifier, voidP, walkTypeSpecIsNativeTypeP, writeSlotValue, yieldTypeSpecTree
 
Methods inherited from class edu.isi.stella.Stella_Object
_, accessInContext, addPropertyValue, amPm, anchoredTypeSpecifierP, andOrNotTreeP, applyCoercionMethod, atomicExpressionP, bindToSurrogateP, booleanP, bootstrapIsaP, bquotify, cast, characterP, chooseSortPredicate, clConditionalizeTypeDeclarationTree, clTranslateAtomicTree, clTranslateATree, clTranslateBooleanTest, clTranslatePlainBooleanTest, clTranslateVerbatimBodySymbols, clYieldTypedExpressionTree, coerceATree, coerceEvaluatedTree, coerceMvTree, coerceOptionValue, coerceToBoolean, coerceToFloat, coerceToHashSet, coerceToModule, coerceToModuleName, coerceToString, coerceToSymbol, coerceToXmlElement, coerceValueToBoolean, coerceValueToFloat, coerceValueToString, coerceValueToType, coercibleP, collectFeatureList, collectKeyValueList, commonLispSymbolP, computeExpressionType, consify, consifyListsAndIterators, consP, consTreeMatchP, convertToLiteral, copyConsTree, cppArgumentIsStreamP, cppBinaryOperatorP, cppBlockP, cppMaybeOutputStatementWithParentheses, cppOperatorP, cppOutputAtomicExpression, cppOutputLiteral, cppOutputOneActualParameter, cppOutputStatement, cppOutputTypedEntity, cppPrognifyStatement, cppPrognP, cppStatementToList, cppStreamIsStandardOutputP, cpptrans, cppTranslateAtomicTree, cppTranslateATree, cppTranslatedArrayTypeP, csValueP, dateDivider, dateTimeDivider, day, dealWithAmPm, dealWithEra, dealWithNoonMidn, decrementReferenceCount, defaultOptionHandler, defineSystem, defmodule, deletedP, describe, describeObject, describeTersely, destructureMethodNameTree, deUglifyParseTree, either, eqlP, eqlToBooleanP, eqlToCharacterP, eqlToFloatP, eqlToIntegerP, eqlToLongIntegerP, eqlToStringP, equalConsTreesP, equalHashCode, equalP, era, estimatedEvaluationCost, evaluate, evaluateArgumentTree, evaluateAtomicTree, evaluateCommand, expandBquoteTree, filterModuleP, floatP, get, getObject, getProperty, hashlist, hashMemoizedArguments, helpBquotify, helpClTranslateATree, helpCoerceATree, helpLptrans, helpPrintOutline, helpTransformBooleanProceduralExpression, helpWalkATree, homeModule, hour, idlOutputAtomicExpression, idlOutputLiteral, idlOutputStatement, idlTranslateAtomicTree, idlTranslateATree, illegalTreeP, implodePathname, incrementallyTranslate, incrementReferenceCount, inlineUnwrapBoolean, inlineWrapBoolean, inModule, integerP, isaP, javaBinaryOperatorP, javaBlockP, javaEndOfLineTokenP, javaHelpOutputPrintStream, javaMaybeOutputStatementWithParentheses, javaOperatorP, javaOutputLiteral, javaOutputStatement, javaPrognP, javaStreamIsStandardOutputP, javaSymbolCaseP, javaTranslateAtomicTree, javaTranslateATree, javaTranslateWithNativeWrapper, jptrans, keywordP, legalTokenizerFromStateP, legalTokenizerStateP, legalTokenizerToStateP, literalEqlP, logLevelLE, longIntegerP, lptrans, makeEvaluatableBquoteTree, makeFileNameFromRelativePath, makeMemoizedValueEntry, makeMemoizedValueEntryn, matchConsTree, methodSlotP, minute, month, nameToString, nilP, noonMidn, numberWrapperToFloat, objectEqualP, objectHashCode, one, oneI, onlyIf, parametricTypeSpecifierP, parseArrayDimensionsSpec, parseOptions, parseTokenizerCharacterSpec, parseTokenizerStateModifiers, permanentCopy, permanentify, permanentifyForm, po, prettyPrintLiteral, primaryClass, printObject, printOutline, printStellaCode, printStellaDefinition, printUndefinedSuperClasses, proceduralExpressionP, ptrans, publicSlots, registerRecycledItem, runOptionHandlerP, safeEqualHashCode, safeHashCode, safePrimaryType, safeYieldTypeSpecifier, searchConsTreeP, searchConsTreeWithFilterP, searchForObject, secondp, setProperty, sideEffectFreeExpressionP, simplifyBquoteTree, specialp, stella_Increment, stellaClassP, stellaCollectionP, stellaNeedToCompileP, stellaNeedToTranslateP, stellaObjectP, stellify, storageSlotP, stringifyInModule, stringP, substituteConsTree, substituteOnce, surrogateP, surrogatify, sweep, symbolCaseP, symbolP, sysTree, targetLanguageType, taxonomyIsaP, timeDivider, timeMultiply, tokenizerIncludeSpecP, tokenizerToStateAlias, tokenizerToStateName, toString, traceIf, traceKeywordP, transientifyForm, transientObjectP, transientSymbolP, translateWalkedTree, treeSize, treeToTrees, trueOptionP, tryToEvaluate, typeP, typify, unmake, unregisterRecycledItem, updateInContext, valuesTreeP, variableExpressionP, verbatimStringP, verbatimTreeP, vetOptions, vrletExpressionP, walkAtomicTree, walkATree, walkCollectionTree, walkDontCallMeTree, walkedExpressionExpression, walkedExpressionType, walkExpressionTree, walkMvExpressionTree, walkMvTree, walkStatement, walkTopLevelExpression, walkWithoutTypeTree, warnAboutUnknownSourceType, weekday, withinContext, withinModule, withinWorld, withStellaTokenizer, withSystemDefinition, withTokenizer, wrapperP, wrapWhereTest, xmlAttributeP, xmlBaseAttributeP, xmlCdataFormP, xmlCdataP, xmlDeclarationFormP, xmlDeclarationP, xmlDoctypeFormP, xmlElementFormP, xmlElementP, xmlGlobalAttributeP, xmlLocalAttributeP, xmlnsAttributeP, xmlProcessingInstructionFormP, xmlProcessingInstructionP, xmlTagCase, year, yieldCondTest, yieldCondTestOrTests, yieldHardcodedCaseSymbolIdOrIds, yieldInCursorClausesForArgumentList, yieldInCursorClausesForGeneralCollection, yieldInCursorClausesForVector, yieldTypeSpecifier, zone, zoneMinute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nativeStream

public java.io.PushbackInputStream nativeStream

echoStream

public OutputStream echoStream

tokenizerState

public TokenizerStreamState tokenizerState

bufferingScheme

public Keyword bufferingScheme
One of :CHARACTER, :LINE or :BLOCK indicating what kind of input buffer we are reading from. This determines what read function to use for tokenization.

Constructor Detail

InputStream

public InputStream()
Method Detail

newInputStream

public static InputStream newInputStream()

substituteTemplateVariablesToStream

public static void substituteTemplateVariablesToStream(InputStream templatestream,
                                                       OutputStream outputstream,
                                                       KeyValueList variables)

xmlExpressions

public static XmlExpressionIterator xmlExpressions(InputStream stream,
                                                   Stella_Object regiontag)
Return an XML-expression-iterator (which see) reading from stream. regiontag can be used to define delimited regions from which expressions should be considered. Use s-expression representation to specify regiontag, e.g., '(KIF (:version "1.0"))'. The tag can be an XML element object, a symbol, a string or a cons. If the tag is a cons the first element can also be (name namespace) pair.

Parameters:
stream -
regiontag -
Returns:
XmlExpressionIterator

readXmlExpression

public static Stella_Object readXmlExpression(InputStream stream,
                                              Stella_Object startTag,
                                              java.lang.Object[] MV_returnarray)
Read one balanced XML expression from stream and return its s-expression representation (see xmlTokenListToSExpression). If startTagName is non-null, skip all tags until a start tag matching startTag is encountered. XML namespaces are ignored for outside of the start tag. Use s-expression representation to specify startTag, e.g., '(KIF (:version "1.0"))'. The tag can be an XML element object, a symbol, a string or a cons. If the tag is a cons the first element can also be (name namespace) pair.

Return true as the second value on EOF.

CHANGE WARNING: It is anticipated that this function will change to a) Properly take XML namespaces into account and b) require XML element objects instead of strings as the second argument. This change will not be backwards-compatible.

Parameters:
stream -
startTag -
MV_returnarray -
Returns:
Stella_Object

tokenizeXmlExpression

public static TokenizerToken tokenizeXmlExpression(InputStream stream,
                                                   TokenizerToken tokenlist,
                                                   java.lang.String regiontagname,
                                                   boolean skiptoregionP,
                                                   java.lang.Object[] MV_returnarray)

streamToString

public java.lang.String streamToString()
Read all of the input from stream and return it as a string.

Returns:
String

readCharacter

public static char readCharacter(InputStream inputstream,
                                 java.lang.Object[] MV_returnarray)
Read one character from inputstream and return the result. Return true as the second value on EOF.

Parameters:
inputstream -
MV_returnarray -
Returns:
char

readLine2

public static java.lang.String readLine2(InputStream stream,
                                         java.lang.Object[] MV_returnarray)
Read one line from stream and return the result and a keyword that indicates the terminator for that line ending: CCR CLF CCRLF or CEOF. This is not platform-dependent and differs from readLine by returning a second value. It may hang when used on interactive streams such as terminal or network streams with only CR line endings. It should only be used on file or string input streams.

Parameters:
stream -
MV_returnarray -
Returns:
String

readLine

public static java.lang.String readLine(InputStream stream)
Read one line from stream and return the result. This differs from nativeReadLine in that it is not platform-dependent. It recognizes any of the three common line ending formats: CR, LF, CR-LF in any combination. It is not as fast as nativeReadLine, however.

Parameters:
stream -
Returns:
String

nativeReadLine

public static java.lang.String nativeReadLine(InputStream inputstream)
Read one line from inputstream using the native language readline algorithm and return the result. On EOF return null

Parameters:
inputstream -
Returns:
String

consumeWhitespace

public static boolean consumeWhitespace(InputStream stream)

eatNextCharacterIfWhitespace

public static boolean eatNextCharacterIfWhitespace(InputStream stream)

readSExpression

public static Stella_Object readSExpression(InputStream stream,
                                            java.lang.Object[] MV_returnarray)
Read one STELLA s-expression from stream and return the result. Return true as the second value on EOF.

Parameters:
stream -
MV_returnarray -
Returns:
Stella_Object

tokenizeSExpression

public static StellaToken tokenizeSExpression(InputStream stream,
                                              StellaToken tokenlist)

readLineFromTokenizerBuffer

public static java.lang.String readLineFromTokenizerBuffer(InputStream stream)

readCharacterFromTokenizerBuffer

public static char readCharacterFromTokenizerBuffer(InputStream stream,
                                                    java.lang.Object[] MV_returnarray)

readIntoTokenizerBuffer

public static boolean readIntoTokenizerBuffer(InputStream stream,
                                              TokenizerStreamState state,
                                              int currenttokenstart)

copyStreamToStream

public static void copyStreamToStream(InputStream in,
                                      OutputStream out)
Copy in verbatimely to out. Does the right thing for binary data.

Parameters:
in -
out -

characters

public static CharacterIterator characters(InputStream stream)

lines

public static LineIterator lines(InputStream stream)

nativeLines

public static NativeLineIterator nativeLines(InputStream stream)

sExpressions

public static SExpressionIterator sExpressions(InputStream stream)

terminateInputStreamP

public static boolean terminateInputStreamP(InputStream self)

accessInputStreamSlotValue

public static Stella_Object accessInputStreamSlotValue(InputStream self,
                                                       Symbol slotname,
                                                       Stella_Object value,
                                                       boolean setvalueP)

primaryType

public Surrogate primaryType()
Description copied from class: Stella_Object
Returns the primary type of self. Gets defined automatically for every non-abstract subclass of OBJECT.

Overrides:
primaryType in class Stella_Object
Returns:
Surrogate

free

public void free()
Description copied from class: Stella_Object
Default method. Deallocate storage for self.

Overrides:
free in class Stella_Object