public AssemblyData parse ( InputStream inputStream ) throws GrokParseException { try ( InputStream schema = FileUtils . getResourceAsStream ( GROK_SCHEMA ) ) { final GrokHandler handler = new GrokHandler ( ) ; final SAXParser saxParser = XmlUtils . buildSecureSaxParser ( schema ) ; final XMLReader xmlReader = saxParser . getXMLReader ( ) ; xmlReader . setErrorHandler ( new GrokErrorHandler ( ) ) ; xmlReader . setContentHandler ( handler ) ; try ( Reader reader = new InputStreamReader ( inputStream , StandardCharsets . UTF_8 ) ) { final InputSource in = new InputSource ( reader ) ; xmlReader . parse ( in ) ; return handler . getAssemblyData ( ) ; } } catch ( ParserConfigurationException | FileNotFoundException ex ) { LOGGER . debug ( "" , ex ) ; throw new GrokParseException ( ex ) ; } catch ( SAXException ex ) { if ( ex . getMessage ( ) . contains ( "Cannot find the declaration of element 'assembly'." ) ) { throw new GrokParseException ( "Malformed grok xml?" , ex ) ; } else { LOGGER . debug ( "" , ex ) ; throw new GrokParseException ( ex ) ; } } catch ( IOException ex ) { LOGGER . debug ( "" , ex ) ; throw new GrokParseException ( ex ) ; } }
Parses the given XML stream and returns the contained assembly data .