com.ctc.wstx.io
Class BaseInputSource

java.lang.Object
  extended bycom.ctc.wstx.io.WstxInputSource
      extended bycom.ctc.wstx.io.BaseInputSource
Direct Known Subclasses:
CharArraySource, ReaderSource

public abstract class BaseInputSource
extends WstxInputSource

Abstract base class that implements shared functionality that all current WstxInputSource implementations Woodstox includes need.


Field Summary
protected  char[] mBuffer
          Input buffer this input source uses, if any.
protected  int mInputLen
          Length of the buffer, if buffer used
 
Fields inherited from class com.ctc.wstx.io.WstxInputSource
mParent
 
Constructor Summary
protected BaseInputSource(WstxInputSource parent, java.lang.String fromEntity, java.lang.String publicId, java.lang.String systemId, java.net.URL src)
           
 
Method Summary
abstract  void close()
           
abstract  int getInputBufferLength()
           
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)
           
 java.lang.String getPublicId()
           
 java.net.URL getSource()
           
 java.lang.String getSystemId()
           
abstract  void initInputLocation(WstxInputData reader)
          Method called by Reader when current input has changed to come from this input 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
getParent, hasRecursion, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mBuffer

protected char[] mBuffer
Input buffer this input source uses, if any.


mInputLen

protected int mInputLen
Length of the buffer, if buffer used

Constructor Detail

BaseInputSource

protected BaseInputSource(WstxInputSource parent,
                          java.lang.String fromEntity,
                          java.lang.String publicId,
                          java.lang.String systemId,
                          java.net.URL src)
Method Detail

getInputBufferLength

public abstract int getInputBufferLength()
Specified by:
getInputBufferLength in class WstxInputSource
Returns:
Length of suggested input buffer (if source needs one); used for passing default buffer size down the input source line.

getSource

public java.net.URL getSource()
Specified by:
getSource in class WstxInputSource

getPublicId

public java.lang.String getPublicId()
Specified by:
getPublicId in class WstxInputSource

getSystemId

public java.lang.String getSystemId()
Specified by:
getSystemId in class WstxInputSource

initInputLocation

public abstract void initInputLocation(WstxInputData reader)
Description copied from class: WstxInputSource
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.

Specified by:
initInputLocation in class WstxInputSource

readInto

public abstract int readInto(WstxInputData reader)
                      throws java.io.IOException
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 class WstxInputSource
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:
java.io.IOException

readMore

public abstract boolean readMore(WstxInputData reader,
                                 int minAmount)
                          throws java.io.IOException
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 class WstxInputSource
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:
java.io.IOException

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 class WstxInputSource

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 class WstxInputSource

close

public abstract void close()
                    throws java.io.IOException
Specified by:
close in class WstxInputSource
Throws:
java.io.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 class WstxInputSource

getLocation

public final WstxInputLocation getLocation(long total,
                                           int row,
                                           int col)
Specified by:
getLocation in class WstxInputSource