Exemplo n.º 1
0
  // Implements Reusable.
  public void reset() {
    // Resets all members (alphabetically ordered).
    _attributes.reset();
    _attrPrefixSep = 0;
    _attrQName = null;
    _attrValue = null;
    _attrQName = null;
    _charactersPending = false;
    _encoding = null;
    _entities.reset();
    _eventType = START_DOCUMENT;
    _index = 0;
    _isEmpty = false;
    _location.reset();
    _namespaces.reset();
    _prolog = null;
    _readCount = 0;
    _reader = null;
    _depth = 0;
    _readIndex = 0;
    _seqsIndex = 0;
    _start = 0;
    _startOffset = 0;
    _state = STATE_CHARACTERS;
    _utf8StreamReader.reset();

    // Recycles if factory produced.
    if (_factory != null) _factory.recycle(this);
  }
Exemplo n.º 2
0
  /**
   * Sets the input stream source and encoding for this XML stream reader.
   *
   * @param in the input source.
   * @param encoding the associated encoding.
   */
  public void setInput(InputStream in, String encoding) throws XMLStreamException {
    _encoding = encoding;

    if (_encoding == null) {
      _encoding = detectEncoding(in);
    }

    if (isUTF8(_encoding)) { // Use our fast UTF-8 Reader.
      setInput(_utf8StreamReader.setInput(in));
    } else {
      try {
        setInput(new InputStreamReader(in, encoding));
      } catch (UnsupportedEncodingException e) {
        throw new XMLStreamException(e);
      }
    }
  }