code: @Override
      public final void declaration() throws IllegalStateException, IOException {
  
          // Check state
          if (_state != XMLEventListenerStates.BEFORE_XML_DECLARATION) {
              throw new IllegalStateException("getState() == " + _state);
          }
  
          // Temporarily set the state to ERROR_STATE. Unless an exception is
          // thrown in the write methods, it will be reset to a valid state.
          _state = XMLEventListenerStates.ERROR_STATE;
  
          // Write the output
          _encoder.declaration(_out, _quotationMark);
  
          // Change the state
          _state = XMLEventListenerStates.BEFORE_DTD_DECLARATION;
  
          // State has changed, check
          checkInvariants();
      }
docs: Writes the XML declaration. This method always prints the name of the
  encoding. The case of the encoding is as it was specified during
  initialization (or re-initialization).
  <p />
  If the encoding is set to <code>"ISO-8859-1"</code>, then this method will produce the
  following output: <blockquote><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;</code>
  </blockquote>
  
  @throws IllegalStateException if <code>getState() != {@link #BEFORE_XML_DECLARATION}</code>.
  @throws IOException           if an I/O error occurs; this will set the state to {@link #ERROR_STATE}.