org.apache.commons.digester3.binder.DigesterLoader Java Examples
The following examples show how to use
org.apache.commons.digester3.binder.DigesterLoader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapParser.java From tankbattle with MIT License | 6 votes |
public static XmlMap getMapFromXml(String name) { try { DigesterLoader loader = DigesterLoader.newLoader(new FromAnnotationsRuleModule() { @Override protected void configureRules() { bindRulesFrom(XmlMap.class); } }); Digester digester = loader.newDigester(); return digester.parse(new FileInputStream(new File(System.getProperty("user" + ".home") + File .separator + ".tankBattle" + File.separator + "custom" + File.separator + name + ".xml"))); } catch (Exception e) { e.printStackTrace(); } return null; }
Example #2
Source File: PluginFile.java From lutece-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Load plugin data from the XML file using Jakarta Commons Digester * * @param strFilename * The XML plugin filename * @throws fr.paris.lutece.portal.service.init.LuteceInitException * If a problem occured during the loading */ public void load( String strFilename ) throws LuteceInitException { // Configure Digester from XML ruleset DigesterLoader digesterLoader = DigesterLoader.newLoader( new FromXmlRulesModule( ) { @Override protected void loadRules( ) { loadXMLRules( getClass( ).getResource( FILE_RULES ) ); } } ); Digester digester = digesterLoader.newDigester( ); // Allow variables in plugin files MultiVariableExpander expander = new MultiVariableExpander( ); expander.addSource( "$", ( (Map) AppPropertiesService.getPropertiesAsMap( ) ) ); Substitutor substitutor = new VariableSubstitutor( expander ); digester.setSubstitutor( substitutor ); // Push empty List onto Digester's Stack digester.push( this ); digester.setValidating( false ); try { InputStream input = new FileInputStream( strFilename ); digester.parse( input ); } catch( IOException | IllegalArgumentException | SAXException e ) { throw new LuteceInitException( "Error loading plugin file : " + strFilename, e ); } }