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

public abstract Class WstxInputSource

extends Object
Class Inheritance
Known Direct Subclasses
com.ctc.wstx.io.BaseInputSource
Imports
java.io.IOException, java.net.URL, javax.xml.stream.XMLStreamException

Interface that defines API actual parsers (stream readers) can use to read input from various input sources. Needed to abstract out details of getting input from primary input files, secondary (potentially cached) referenced documents, and from parsed entities, as well as for allowing hierarchic location information for error reporting.

Field Summary

Modifier and TypeField and Description
protected int
mEntityDepth

Number of parent entities that have been expanded to get to this input source; 0 for root-level input that is not generated via entity expansion.

protected final String
mFromEntity

Name/id of the entity that was expanded to produce this input source; null if not entity-originated.

protected final WstxInputSource
mParent

Parent in input source stack

protected int
mScopeId

Scope of the reader when this entity was initially expanded.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public abstract void
close()

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

public abstract void
closeCompletely()

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

protected abstract void
public abstract boolean

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)
fromInternalEntity
()

public int
public String
protected abstract WstxInputLocation
getLocation()

Method usually called to get a parent location for another input source.

public abstract WstxInputLocation
getLocation(long total, int row, int col)

public final WstxInputSource
public abstract String
public int
public abstract URL
public abstract String
public final void
initInputLocation(WstxInputData
Reader whose data structures are to be used for returning data read
reader
,
int currScopeId, int entityDepth)

Method called by Reader when current input has changed to come from this input source.

public boolean
isOrIsExpandedFrom(String entityId)

Method that checks if this input source expanded from the specified entity id, directly or by ancestor.

public abstract void
overrideSource(URL
New base URL to set; may be null.
url
)

Method that can be called to override originally defined source.

public abstract int

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.
readInto
(WstxInputData reader)

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

public abstract boolean

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

public abstract void
restoreContext(WstxInputData reader)

Method Reader calls when this input source is resumed as the current source.

public abstract void
saveContext(WstxInputData reader)

Method Reader calls when this input source is being stored, when a nested input source gets used instead (due to entity expansion).

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

mEntityDepthback to summary
protected int mEntityDepth

Number of parent entities that have been expanded to get to this input source; 0 for root-level input that is not generated via entity expansion.

mFromEntityback to summary
protected final String mFromEntity

Name/id of the entity that was expanded to produce this input source; null if not entity-originated. Used for catching recursive expansions of entities.

mParentback to summary
protected final WstxInputSource mParent

Parent in input source stack

mScopeIdback to summary
protected int mScopeId

Scope of the reader when this entity was initially expanded. Snapshot that will generally be used by the reader to match scoping limitations, such as proper nesting entity expansion with respect to element and declaration nesting.

Constructor Detail

WstxInputSourceback to summary
protected WstxInputSource(WstxInputSource parent, String fromEntity)

Method Detail

closeback to summary
public abstract void close() throws IOException

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

closeCompletelyback to summary
public abstract void closeCompletely() throws IOException

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

doInitInputLocationback to summary
protected abstract void doInitInputLocation(WstxInputData reader)
fromInternalEntityback to summary
public abstract boolean fromInternalEntity()
Returns:boolean

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)

getEntityDepthback to summary
public int getEntityDepth()
getEntityIdback to summary
public String getEntityId()
getLocationback to summary
protected abstract WstxInputLocation getLocation()

Method usually called to get a parent location for another input source. Works since at this point context (line, row, chars) information has already been saved to this object.

getLocationback to summary
public abstract WstxInputLocation getLocation(long total, int row, int col)
getParentback to summary
public final WstxInputSource getParent()
getPublicIdback to summary
public abstract String getPublicId()
getScopeIdback to summary
public int getScopeId()
getSourceback to summary
public abstract URL getSource() throws IOException
getSystemIdback to summary
public abstract String getSystemId()
initInputLocationback to summary
public final void initInputLocation(WstxInputData reader, int currScopeId, int entityDepth)

Method called by Reader when current input has changed to come from this input source. Should reset/initialize input location information Reader keeps, for error messages to work ok.

Parameters
reader:WstxInputData

Reader whose data structures are to be used for returning data read

isOrIsExpandedFromback to summary
public boolean isOrIsExpandedFrom(String entityId)

Method that checks if this input source expanded from the specified entity id, directly or by ancestor.

Note that entity ids are expected to have been interned (using whatever uniqueness mechanism used), and thus can be simply identity checked.

overrideSourceback to summary
public abstract void overrideSource(URL url)

Method that can be called to override originally defined source.

Parameters
url:URL

New base URL to set; may be null.

Since
4.0
readIntoback to summary
public abstract int readInto(WstxInputData reader) throws IOException, XMLStreamException

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.

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

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.

restoreContextback to summary
public abstract void restoreContext(WstxInputData reader)

Method Reader calls when this input source is resumed as the current source. Needs to update Reader's input location data used for error messages etc.

saveContextback to summary
public abstract void saveContext(WstxInputData reader)

Method Reader calls when this input source is being stored, when a nested input source gets used instead (due to entity expansion). Needs to get location info from Reader and store it in this Object.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override