Package com.ctc.wstx.io
Class ReaderSource
java.lang.Object
com.ctc.wstx.io.WstxInputSource
com.ctc.wstx.io.BaseInputSource
com.ctc.wstx.io.ReaderSource
- Direct Known Subclasses:
BranchingReaderSource
Input source that reads input via a Reader.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final ReaderConfig
(package private) final boolean
If true, will close the underlying Reader when this source is closed; if false will leave it open.(package private) int
(package private) int
(package private) int
protected Reader
Underlying Reader to read character data fromFields inherited from class com.ctc.wstx.io.BaseInputSource
mBuffer, mInputLast, mParentLocation, mPublicId, mSavedInputProcessed, mSavedInputPtr, mSavedInputRow, mSavedInputRowStart, mSystemId
Fields inherited from class com.ctc.wstx.io.WstxInputSource
mEntityDepth, mFromEntity, mParent, mScopeId
-
Constructor Summary
ConstructorsConstructorDescriptionReaderSource
(ReaderConfig cfg, WstxInputSource parent, String fromEntity, String pubId, SystemId sysId, Reader r, boolean realClose) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Method reader calls for this input source when it has encountered EOF.private void
closeAndRecycle
(boolean fullClose) void
Method reader MAY call to force full closing of the underlying input stream(s)/reader(s).protected void
doInitInputLocation
(WstxInputData reader) Input location is easy to set, as we'll start from the beginning of a File.boolean
This is a hard-coded assumption, for now this source is only created from external entitiesint
readInto
(WstxInputData reader) Method called to read at least one more char from input source, and update input data appropriately.boolean
readMore
(WstxInputData reader, int minAmount) Method called by reader when it has to have at least specified number of consequtive input characters in its buffer, and it currently does not have.void
setInputOffsets
(int proc, int row, int rowStart) Method called to change the default offsets this source has.Methods inherited from class com.ctc.wstx.io.BaseInputSource
getLocation, getLocation, getPublicId, getSource, getSystemId, overrideSource, restoreContext, saveContext
Methods inherited from class com.ctc.wstx.io.WstxInputSource
getEntityDepth, getEntityId, getParent, getScopeId, initInputLocation, isOrIsExpandedFrom, toString
-
Field Details
-
mConfig
-
mReader
Underlying Reader to read character data from -
mDoRealClose
final boolean mDoRealCloseIf true, will close the underlying Reader when this source is closed; if false will leave it open. -
mInputProcessed
int mInputProcessed -
mInputRow
int mInputRow -
mInputRowStart
int mInputRowStart
-
-
Constructor Details
-
ReaderSource
public ReaderSource(ReaderConfig cfg, WstxInputSource parent, String fromEntity, String pubId, SystemId sysId, Reader r, boolean realClose)
-
-
Method Details
-
setInputOffsets
public void setInputOffsets(int proc, int row, int rowStart) Method called to change the default offsets this source has. Generally done when the underlying Reader had been partially read earlier (like reading the xml declaration before starting real parsing). -
doInitInputLocation
Input location is easy to set, as we'll start from the beginning of a File.- Specified by:
doInitInputLocation
in classBaseInputSource
-
fromInternalEntity
public boolean fromInternalEntity()This is a hard-coded assumption, for now this source is only created from external entities- Specified by:
fromInternalEntity
in classBaseInputSource
- Returns:
- True, if this input source was directly expanded from an internal entity (general, parsed); false if not (from external entity, DTD ext. subset, main document)
-
readInto
Description copied from class:WstxInputSource
Method called to read at least one more char from input source, and update input data appropriately.- Specified by:
readInto
in classBaseInputSource
- Returns:
- Number of characters read from the input source (at least 1), if it had any input; -1 if input source has no more input.
- Throws:
IOException
XMLStreamException
-
readMore
Description copied from class:WstxInputSource
Method called by reader when it has to have at least specified number of consequtive input characters in its buffer, and it currently does not have. If so, it asks input source to do whatever it has to do to try to get more data, if possible (including moving stuff in input buffer if necessary and possible).- Specified by:
readMore
in classBaseInputSource
- Returns:
- True if input source was able to provide specific number of characters or more; false if not. In latter case, source is free to return zero or more characters any way.
- Throws:
IOException
XMLStreamException
-
close
Description copied from class:WstxInputSource
Method reader calls for this input source when it has encountered EOF. This may or may not close the underlying stream/reader; what happens depends on configuration- Specified by:
close
in classBaseInputSource
- Throws:
IOException
-
closeCompletely
Description copied from class:WstxInputSource
Method reader MAY call to force full closing of the underlying input stream(s)/reader(s). No checks are done regarding configuration, but input source object is to deal gracefully with multiple calls (ie. it's not an error for reader to call this more than once).- Specified by:
closeCompletely
in classWstxInputSource
- Throws:
IOException
-
closeAndRecycle
- Throws:
IOException
-