Example #1
0
 /** Reloads data buffer. */
 private void reloadBuffer() throws XMLStreamException {
   if (_reader == null) throw new XMLStreamException("Input not specified");
   _location._column += _readIndex;
   _location._charactersRead += _readIndex;
   _readIndex = 0;
   try {
     _readCount = _reader.read(_readBuffer, 0, _readBuffer.length);
     if ((_readCount <= 0) && ((_depth != 0) || (_state != STATE_CHARACTERS)))
       throw new XMLUnexpectedEndOfDocumentException("Unexpected end of document", _location);
   } catch (IOException e) {
     throw new XMLStreamException(e);
   }
   while ((_index + _readCount) >= _data.length) { // Potential overflow.
     increaseDataBuffer();
   }
 }
Example #2
0
 /**
  * Handles end of line as per XML Spec. 2.11
  *
  * @param c the potential end of line character.
  * @return the replacement character for end of line.
  */
 private char handleEndOfLine(char c) throws XMLStreamException {
   if (c == 0xD) { // Replaces #xD with #xA
     // Unless next char is #xA, then skip,
     // #xD#xA will be replaced by #xA
     if (_readIndex >= _readCount) reloadBuffer();
     if ((_readIndex < _readCount) && (_readBuffer[_readIndex] == 0xA)) {
       _readIndex++; // Skips 0xD
       _location._totalCharsRead++;
     }
     c = (char) 0xA;
   }
   if (c == 0xA) {
     _location._line++;
     _location._column = -_readIndex; // column = 0
   } else if (c == 0x0) {
     throw new XMLStreamException("Illegal XML character U+0000", _location);
   }
   return c;
 }