Package com.ctc.wstx.io
Class BaseInputSource
- java.lang.Object
-
- com.ctc.wstx.io.WstxInputSource
-
- com.ctc.wstx.io.BaseInputSource
-
- Direct Known Subclasses:
CharArraySource
,ReaderSource
public abstract class BaseInputSource extends WstxInputSource
Abstract base class that implements shared functionality that all currentWstxInputSource
implementations Woodstox includes need.
-
-
Field Summary
Fields Modifier and Type Field Description protected char[]
mBuffer
Input buffer this input source uses, if any.protected int
mInputLast
Length of the buffer, if buffer used-
Fields inherited from class com.ctc.wstx.io.WstxInputSource
mEntityDepth, mFromEntity, mParent, mScopeId
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseInputSource(WstxInputSource parent, String fromEntity, String publicId, SystemId systemId)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
close()
Method reader calls for this input source when it has encountered EOF.protected abstract void
doInitInputLocation(WstxInputData reader)
abstract boolean
fromInternalEntity()
protected WstxInputLocation
getLocation()
This method only gets called by the 'child' input source (for example, contents of an expanded entity), to get the enclosing context location.WstxInputLocation
getLocation(long total, int row, int col)
String
getPublicId()
URL
getSource()
String
getSystemId()
void
overrideSource(URL src)
Method that can be called to override originally defined source.abstract int
readInto(WstxInputData reader)
Method called to read at least one more char from input source, and update input data appropriately.abstract 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
restoreContext(WstxInputData reader)
Method Reader calls when this input source is resumed as the current source.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).-
Methods inherited from class com.ctc.wstx.io.WstxInputSource
closeCompletely, getEntityDepth, getEntityId, getParent, getScopeId, initInputLocation, isOrIsExpandedFrom, toString
-
-
-
-
Constructor Detail
-
BaseInputSource
protected BaseInputSource(WstxInputSource parent, String fromEntity, String publicId, SystemId systemId)
-
-
Method Detail
-
overrideSource
public void overrideSource(URL src)
Description copied from class:WstxInputSource
Method that can be called to override originally defined source.- Specified by:
overrideSource
in classWstxInputSource
- Parameters:
src
- New base URL to set; may be null.
-
fromInternalEntity
public abstract boolean fromInternalEntity()
- Specified by:
fromInternalEntity
in classWstxInputSource
- 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)
-
getSource
public URL getSource() throws IOException
- Specified by:
getSource
in classWstxInputSource
- Throws:
IOException
-
getPublicId
public String getPublicId()
- Specified by:
getPublicId
in classWstxInputSource
-
getSystemId
public String getSystemId()
- Specified by:
getSystemId
in classWstxInputSource
-
doInitInputLocation
protected abstract void doInitInputLocation(WstxInputData reader)
- Specified by:
doInitInputLocation
in classWstxInputSource
-
readInto
public abstract int readInto(WstxInputData reader) throws IOException, XMLStreamException
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 classWstxInputSource
- 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
public abstract boolean readMore(WstxInputData reader, int minAmount) throws IOException, XMLStreamException
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 classWstxInputSource
- 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
-
saveContext
public void saveContext(WstxInputData reader)
Description copied from class:WstxInputSource
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.- Specified by:
saveContext
in classWstxInputSource
-
restoreContext
public void restoreContext(WstxInputData reader)
Description copied from class:WstxInputSource
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.- Specified by:
restoreContext
in classWstxInputSource
-
close
public abstract void close() throws IOException
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 classWstxInputSource
- Throws:
IOException
-
getLocation
protected final WstxInputLocation getLocation()
This method only gets called by the 'child' input source (for example, contents of an expanded entity), to get the enclosing context location.- Specified by:
getLocation
in classWstxInputSource
-
getLocation
public final WstxInputLocation getLocation(long total, int row, int col)
- Specified by:
getLocation
in classWstxInputSource
-
-