public static MtasConfiguration readConfiguration(InputStream reader)
      throws IOException {
    MtasConfiguration currentConfig = null;
    // parse xml
    XMLInputFactory factory = XMLInputFactory.newInstance();
    try {
      XMLStreamReader streamReader = factory.createXMLStreamReader(reader);
      QName qname;
      try {
        int event = streamReader.getEventType();
        while (true) {
          switch (event) {
          case XMLStreamConstants.START_DOCUMENT:
            if (!streamReader.getCharacterEncodingScheme().equals("UTF-8")) {
              throw new IOException("XML not UTF-8 encoded");
            }
            break;
          case XMLStreamConstants.END_DOCUMENT:
          case XMLStreamConstants.SPACE:
            break;
          case XMLStreamConstants.START_ELEMENT:
            // get data
            qname = streamReader.getName();
            if (currentConfig == null) {
              if (qname.getLocalPart().equals("mtas")) {
                currentConfig = new MtasConfiguration();
              } else {
                throw new IOException("no Mtas Configuration");
              }
            } else {
              MtasConfiguration parentConfig = currentConfig;
              currentConfig = new MtasConfiguration();
              parentConfig.children.add(currentConfig);
              currentConfig.parent = parentConfig;
              currentConfig.name = qname.getLocalPart();
              for (int i = 0; i < streamReader.getAttributeCount(); i++) {
                currentConfig.attributes.put(
                    streamReader.getAttributeLocalName(i),
                    streamReader.getAttributeValue(i));
              }
            }
            break;
          case XMLStreamConstants.END_ELEMENT:
            if (currentConfig.parent == null) {
              return currentConfig;
            } else {
              currentConfig = currentConfig.parent;
            }
            break;
          case XMLStreamConstants.CHARACTERS:
            break;
          }
          if (!streamReader.hasNext()) {
            break;
          }
          event = streamReader.next();
        }
      } finally {
        streamReader.close();
      }
    } catch (XMLStreamException e) {
      log.debug(e);
    }
    return null;
  }
public static MtasConfiguration readConfiguration ( InputStream reader ) throws IOException { MtasConfiguration currentConfig = null ; XMLInputFactory factory = XMLInputFactory . newInstance ( ) ; try { XMLStreamReader streamReader = factory . createXMLStreamReader ( reader ) ; QName qname ; try { int event = streamReader . getEventType ( ) ; while ( true ) { switch ( event ) { case XMLStreamConstants . START_DOCUMENT : if ( ! streamReader . getCharacterEncodingScheme ( ) . equals ( "UTF-8" ) ) { throw new IOException ( "XML not UTF-8 encoded" ) ; } break ; case XMLStreamConstants . END_DOCUMENT : case XMLStreamConstants . SPACE : break ; case XMLStreamConstants . START_ELEMENT : qname = streamReader . getName ( ) ; if ( currentConfig == null ) { if ( qname . getLocalPart ( ) . equals ( "mtas" ) ) { currentConfig = new MtasConfiguration ( ) ; } else { throw new IOException ( "no Mtas Configuration" ) ; } } else { MtasConfiguration parentConfig = currentConfig ; currentConfig = new MtasConfiguration ( ) ; parentConfig . children . add ( currentConfig ) ; currentConfig . parent = parentConfig ; currentConfig . name = qname . getLocalPart ( ) ; for ( int i = 0 ; i < streamReader . getAttributeCount ( ) ; i ++ ) { currentConfig . attributes . put ( streamReader . getAttributeLocalName ( i ) , streamReader . getAttributeValue ( i ) ) ; } } break ; case XMLStreamConstants . END_ELEMENT : if ( currentConfig . parent == null ) { return currentConfig ; } else { currentConfig = currentConfig . parent ; } break ; case XMLStreamConstants . CHARACTERS : break ; } if ( ! streamReader . hasNext ( ) ) { break ; } event = streamReader . next ( ) ; } } finally { streamReader . close ( ) ; } } catch ( XMLStreamException e ) { log . debug ( e ) ; } return null ; }
Read configuration.

@param reader
the reader
@return the mtas configuration
@throws IOException
Signals that an I/O exception has occurred.