@Test public void testDoneParsing() throws Exception { XMLAttributesImpl attrs = new XMLAttributesImpl(); attrs.addAttribute( new QName( null, "language", null, URI ), ATTR_TYPE, LANG_VALUE ); attrs.addAttribute( new QName( null, "script", null, URI ), ATTR_TYPE, SCRIPT_VALUE ); attrs.addAttribute( new QName( null, "shutdown-script", null, URI ), ATTR_TYPE, SHUTDOWN_SCRIPT_VALUE ); AttributesProxy fAttributesProxy = new AttributesProxy( attrs ); handler.init( rootXmlReadHandler, URI, TAG_NAME ); ConfigReadHandler confHandler = (ConfigReadHandler) handler.getHandlerForChild( URI, "config", null ); confHandler.init( rootXmlReadHandler, URI, TAG_NAME ); confHandler.startParsing( fAttributesProxy ); PropertyReadHandler queryHandler = (PropertyReadHandler) handler.getHandlerForChild( URI, "query", null ); queryHandler.init( rootXmlReadHandler, URI, TAG_NAME ); XMLAttributesImpl queryAttrs = new XMLAttributesImpl(); queryAttrs.addAttribute( new QName( null, "name", null, URI ), ATTR_TYPE, QUERY_NAME ); AttributesProxy queryAttrsProxy = new AttributesProxy( queryAttrs ); queryHandler.startElement( URI, TAG_NAME, queryAttrsProxy ); char[] chars = new char[] { 'b' }; queryHandler.characters( chars, 0, chars.length ); queryHandler.endElement( URI, TAG_NAME ); handler.doneParsing(); assertThat( handler.getDataFactory(), is( notNullValue() ) ); assertThat( handler.getDataFactory(), is( instanceOf( ScriptableDataFactory.class ) ) ); ScriptableDataFactory sdf = (ScriptableDataFactory) handler.getDataFactory(); assertThat( sdf.getLanguage(), is( equalTo( LANG_VALUE ) ) ); assertThat( sdf.getScript(), is( equalTo( SCRIPT_VALUE ) ) ); assertThat( sdf.getShutdownScript(), is( equalTo( SHUTDOWN_SCRIPT_VALUE ) ) ); assertThat( sdf.getQuery( QUERY_NAME ), is( equalTo( "b" ) ) ); assertThat( handler.getObject(), is( instanceOf( ScriptableDataFactory.class ) ) ); assertThat( (ScriptableDataFactory) handler.getObject(), is( equalTo( sdf ) ) ); }
protected void doneParsing() throws SAXException { final ScriptableDataFactory srdf = new ScriptableDataFactory(); if ( configReadHandler == null ) { throw new ParseException( "Required element 'config' is missing.", getLocator() ); } srdf.setLanguage( configReadHandler.getLanguage() ); if ( !StringUtils.isEmpty( configReadHandler.getScript() ) ) { srdf.setScript( configReadHandler.getScript() ); } if ( !StringUtils.isEmpty( configReadHandler.getShutdownScript() ) ) { srdf.setShutdownScript( configReadHandler.getShutdownScript() ); } for ( int i = 0; i < queries.size(); i++ ) { final PropertyReadHandler handler = queries.get( i ); srdf.setQuery( handler.getName(), handler.getResult() ); } dataFactory = srdf; }
ScriptableDataSourceReadHandler extends AbstractXmlReadHandler implements DataFactoryReadHandler { protected void doneParsing() throws SAXException { final ScriptableDataFactory srdf = new ScriptableDataFactory(); if ( configReadHandler == null ) { throw new ParseException( "Required element 'config' is missing.", getLocator() ); } srdf.setLanguage( configReadHandler.getLanguage() ); if ( !StringUtils.isEmpty( configReadHandler.getScript() ) ) { srdf.setScript( configReadHandler.getScript() ); } if ( !StringUtils.isEmpty( configReadHandler.getShutdownScript() ) ) { srdf.setShutdownScript( configReadHandler.getShutdownScript() ); } for ( int i = 0; i < queries.size(); i++ ) { final PropertyReadHandler handler = queries.get( i ); srdf.setQuery( handler.getName(), handler.getResult() ); } dataFactory = srdf; } }
ScriptableDataSourceReadHandler extends AbstractXmlReadHandler implements DataFactoryReadHandler { protected void doneParsing() throws SAXException { final ScriptableDataFactory srdf = new ScriptableDataFactory(); if ( configReadHandler == null ) { throw new ParseException( "Required element 'config' is missing.", getLocator() ); } srdf.setLanguage( configReadHandler.getLanguage() ); if ( !StringUtils.isEmpty( configReadHandler.getScript() ) ) { srdf.setScript( configReadHandler.getScript() ); } if ( !StringUtils.isEmpty( configReadHandler.getShutdownScript() ) ) { srdf.setShutdownScript( configReadHandler.getShutdownScript() ); } for ( int i = 0; i < queries.size(); i++ ) { final PropertyReadHandler handler = queries.get( i ); srdf.setQuery( handler.getName(), handler.getResult() ); } dataFactory = srdf; } ScriptableDataSourceReadHandler(); }
ScriptableDataSourceReadHandler extends AbstractXmlReadHandler implements DataFactoryReadHandler { protected void doneParsing() throws SAXException { final ScriptableDataFactory srdf = new ScriptableDataFactory(); if ( configReadHandler == null ) { throw new ParseException( "Required element 'config' is missing.", getLocator() ); } srdf.setLanguage( configReadHandler.getLanguage() ); if ( !StringUtils.isEmpty( configReadHandler.getScript() ) ) { srdf.setScript( configReadHandler.getScript() ); } if ( !StringUtils.isEmpty( configReadHandler.getShutdownScript() ) ) { srdf.setShutdownScript( configReadHandler.getShutdownScript() ); } for ( int i = 0; i < queries.size(); i++ ) { final PropertyReadHandler handler = queries.get( i ); srdf.setQuery( handler.getName(), handler.getResult() ); } dataFactory = srdf; } ScriptableDataSourceReadHandler(); Object getObject(); DataFactory getDataFactory(); }
ScriptableDataSourceReadHandler extends AbstractXmlReadHandler implements DataFactoryReadHandler { protected void doneParsing() throws SAXException { final ScriptableDataFactory srdf = new ScriptableDataFactory(); if ( configReadHandler == null ) { throw new ParseException( "Required element 'config' is missing.", getLocator() ); } srdf.setLanguage( configReadHandler.getLanguage() ); if ( !StringUtils.isEmpty( configReadHandler.getScript() ) ) { srdf.setScript( configReadHandler.getScript() ); } if ( !StringUtils.isEmpty( configReadHandler.getShutdownScript() ) ) { srdf.setShutdownScript( configReadHandler.getShutdownScript() ); } for ( int i = 0; i < queries.size(); i++ ) { final PropertyReadHandler handler = queries.get( i ); srdf.setQuery( handler.getName(), handler.getResult() ); } dataFactory = srdf; } ScriptableDataSourceReadHandler(); Object getObject(); DataFactory getDataFactory();  }