Top Description Fields Constructors Methods
com.ctc.wstx.io

public Class ReaderSource

extends BaseInputSource
Class Inheritance
Known Direct Subclasses
com.ctc.wstx.io.BranchingReaderSource
Imports
java.io.IOException, .Reader, javax.xml.stream.XMLStreamException, com.ctc.wstx.api.ReaderConfig, com.ctc.wstx.exc.WstxException

Input source that reads input via a Reader.

Field Summary

Modifier and TypeField and Description
pack-priv final ReaderConfig
pack-priv final boolean
mDoRealClose

If true, will close the underlying Reader when this source is closed; if false will leave it open.

pack-priv int
pack-priv int
pack-priv int
protected Reader
mReader

Underlying Reader to read character data from

Inherited from com.ctc.wstx.io.BaseInputSource:
mBuffermInputLastmParentLocationmPublicIdmSavedInputProcessedmSavedInputPtrmSavedInputRowmSavedInputRowStartmSystemId

Constructor Summary

AccessConstructor and Description
public
ReaderSource(ReaderConfig cfg, WstxInputSource parent, String fromEntity, String pubId, SystemId sysId, Reader r, boolean realClose)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract com.ctc.wstx.io.BaseInputSource.close.

Method reader calls for this input source when it has encountered EOF.

private void
closeAndRecycle(boolean fullClose)

public void
closeCompletely()

Implements abstract com.ctc.wstx.io.WstxInputSource.closeCompletely.

Method reader MAY call to force full closing of the underlying input stream(s)/reader(s).

protected void
doInitInputLocation(WstxInputData reader)

Implements abstract com.ctc.wstx.io.BaseInputSource.doInitInputLocation.

Input location is easy to set, as we'll start from the beginning of a File.

public boolean
fromInternalEntity()

Implements abstract com.ctc.wstx.io.BaseInputSource.fromInternalEntity.

This is a hard-coded assumption, for now this source is only created from external entities

public int
readInto(WstxInputData reader)

Implements abstract com.ctc.wstx.io.BaseInputSource.readInto.

Method called to read at least one more char from input source, and update input data appropriately.

public boolean
readMore(WstxInputData reader, int minAmount)

Implements abstract com.ctc.wstx.io.BaseInputSource.readMore.

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.

public void
setInputOffsets(int proc, int row, int rowStart)

Method called to change the default offsets this source has.

Inherited from com.ctc.wstx.io.BaseInputSource:
getLocationgetLocationgetPublicIdgetSourcegetSystemIdoverrideSourcerestoreContextsaveContext

Field Detail

mConfigback to summary
pack-priv final ReaderConfig mConfig
mDoRealCloseback to summary
pack-priv final boolean mDoRealClose

If true, will close the underlying Reader when this source is closed; if false will leave it open.

mInputProcessedback to summary
pack-priv int mInputProcessed
mInputRowback to summary
pack-priv int mInputRow
mInputRowStartback to summary
pack-priv int mInputRowStart
mReaderback to summary
protected Reader mReader

Underlying Reader to read character data from

Constructor Detail

ReaderSourceback to summary
public ReaderSource(ReaderConfig cfg, WstxInputSource parent, String fromEntity, String pubId, SystemId sysId, Reader r, boolean realClose)

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract com.ctc.wstx.io.BaseInputSource.close.

Doc from com.ctc.wstx.io.WstxInputSource.close.

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

Annotations
@Override
closeAndRecycleback to summary
private void closeAndRecycle(boolean fullClose) throws IOException
closeCompletelyback to summary
public void closeCompletely() throws IOException

Implements abstract com.ctc.wstx.io.WstxInputSource.closeCompletely.

Doc from com.ctc.wstx.io.WstxInputSource.closeCompletely.

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).

Annotations
@Override
doInitInputLocationback to summary
protected void doInitInputLocation(WstxInputData reader)

Implements abstract com.ctc.wstx.io.BaseInputSource.doInitInputLocation.

Input location is easy to set, as we'll start from the beginning of a File.

Annotations
@Override
fromInternalEntityback to summary
public boolean fromInternalEntity()

Implements abstract com.ctc.wstx.io.BaseInputSource.fromInternalEntity.

This is a hard-coded assumption, for now this source is only created from external entities

Returns:boolean

Doc from com.ctc.wstx.io.WstxInputSource.fromInternalEntity.

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)

Annotations
@Override
readIntoback to summary
public int readInto(WstxInputData reader) throws IOException, XMLStreamException

Implements abstract com.ctc.wstx.io.BaseInputSource.readInto.

Doc from com.ctc.wstx.io.WstxInputSource.readInto.

Method called to read at least one more char from input source, and update input data appropriately.

Returns:int

Number of characters read from the input source (at least 1), if it had any input; -1 if input source has no more input.

Annotations
@Override
readMoreback to summary
public boolean readMore(WstxInputData reader, int minAmount) throws IOException, XMLStreamException

Implements abstract com.ctc.wstx.io.BaseInputSource.readMore.

Doc from com.ctc.wstx.io.WstxInputSource.readMore.

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).

Returns:boolean

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.

Annotations
@Override
setInputOffsetsback to summary
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).