public Config build ( ) throws ConfigException { if ( properties != null ) { Config config = new Config ( "properties" ) ; config . setProperties ( properties ) ; return config ; } try { Loader loader = new Loader ( ) ; SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; SAXParser parser = factory . newSAXParser ( ) ; XMLReader reader = parser . getXMLReader ( ) ; reader . setContentHandler ( loader ) ; reader . parse ( new InputSource ( xmlStream ) ) ; return loader . getConfig ( ) ; } catch ( Exception e ) { throw new ConfigException ( e ) ; } }
Build configuration object . Configuration object is not reusable so this factory creates a new instance for every call .