public static String requireSingleAttribute ( final XMLStreamReader reader , final String attributeName ) throws XMLStreamException { final int count = reader . getAttributeCount ( ) ; if ( count == 0 ) { throw missingRequired ( reader , Collections . singleton ( attributeName ) ) ; } requireNoNamespaceAttribute ( reader , 0 ) ; if ( ! attributeName . equals ( reader . getAttributeLocalName ( 0 ) ) ) { throw unexpectedAttribute ( reader , 0 ) ; } if ( count > 1 ) { throw unexpectedAttribute ( reader , 1 ) ; } return reader . getAttributeValue ( 0 ) ; }
Require that the current element have only a single attribute with the given name .