List of usage examples for org.apache.commons.digester Digester addCallMethod
public void addCallMethod(String pattern, String methodName, int paramCount, Class<?> paramTypes[])
From source file:barrysw19.calculon.opening.OpeningBook.java
public static OpeningBook getDefaultBook() { if (defaultBook != null) { return defaultBook; }/*from w ww. j a va 2 s .c om*/ Digester digester = new Digester(); digester.addObjectCreate("calculon/opening-book", OpeningBook.class); digester.addObjectCreate("calculon/opening-book/moves", OpeningBook.MoveList.class); digester.addCallMethod("calculon/opening-book/moves/move", "addMove", 2, new Class[] { String.class, Integer.class }); digester.addCallParam("calculon/opening-book/moves/move", 0, "pgn"); digester.addCallParam("calculon/opening-book/moves/move", 1, "count"); digester.addCallMethod("calculon/opening-book/moves/position", "setPosition", 1); digester.addCallParam("calculon/opening-book/moves/position", 0); digester.addSetNext("calculon/opening-book/moves", "addMoveList"); try { log.fine("Creating opening book"); defaultBook = (OpeningBook) digester.parse(OpeningBook.class.getResourceAsStream("/calculon.xml")); return defaultBook; } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.threerings.media.tile.tools.xml.UniformTileSetRuleSet.java
@Override public void addRuleInstances(Digester digester) { super.addRuleInstances(digester); digester.addCallMethod(_path + "/width", "setWidth", 0, new Class<?>[] { java.lang.Integer.TYPE }); digester.addCallMethod(_path + "/height", "setHeight", 0, new Class<?>[] { java.lang.Integer.TYPE }); }
From source file:com.dianping.avatar.cache.configuration.CacheItemConfig.java
/** * Parse configuraiton file//www . jav a 2s.co m */ private void init(String file) { try { Digester digester = new Digester(); digester.addCallMethod("dpcache/import", "addImport", 1, new Class[] { String.class }); digester.addCallParam("dpcache/import", 0, "file"); digester.addObjectCreate("dpcache/add", CacheKeyType.class); digester.addSetProperties("dpcache/add", "name", "category"); digester.addSetProperties("dpcache/add", "index", "indexTemplate"); digester.addSetProperties("dpcache/add", "duration", "duration"); digester.addSetProperties("dpcache/add", "indexDesc", "indexParamDescs"); digester.addSetProperties("dpcache/add", "type", "cacheType"); digester.addSetNext("dpcache/add", "addCacheKeyType"); InputStream in = resourceLoader.getResource(file).getInputStream(); digester.push(this); digester.parse(in); in.close(); for (String importFile : importFiles) { CacheItemConfig config = new CacheItemConfig(); config.init(importFile); this.cacheKeyTypes.putAll(config.cacheKeyTypes); } } catch (Exception e) { throw new SystemException("Failed to initialize cache items config file", e); } }
From source file:com.projity.configuration.Configuration.java
private void addGlobalDigesterEvents(Digester dg) { dg.addCallMethod("configuration/constants/int", "setIntConstant", 2, new Class[] { String.class, Integer.class }); dg.addCallParam("configuration/constants/int/name", 0); dg.addCallParam("configuration/constants/int/value", 1); dg.addCallMethod("configuration/constants/String", "setStringConstant", 2, new Class[] { String.class, String.class }); dg.addCallParam("configuration/constants/String/name", 0); dg.addCallParam("configuration/constants/String/value", 1); }
From source file:org.apache.lucene.gdata.server.registry.RegistryBuilder.java
private static void buildFromConfiguration(Digester digester, GDataServerRegistry registry, String schemaURL) throws IOException, SAXException { digester.setValidating(true);/* w ww .j a v a 2s . com*/ digester.setSchema(schemaURL); digester.setErrorHandler(new SimpleSaxErrorHandler()); digester.push(registry); /* * register services */ digester.addObjectCreate("gdata/service", ProvidedServiceConfig.class); digester.addSetProperties("gdata/service"); digester.addSetNext("gdata/service", "registerService"); digester.addBeanPropertySetter("gdata/service/feed-class", "feedType"); digester.addBeanPropertySetter("gdata/service/entry-class", "entryType"); digester.addBeanPropertySetter("gdata/service/extension-profile", "extensionProfileClass"); digester.addBeanPropertySetter("gdata/service/previewStyleSheet", "xsltStylesheet"); addIndexRule(digester); /* * load components and configurations */ digester.addCallMethod("gdata/server-components/component", "registerComponent", 2, new Class[] { Class.class, ComponentConfiguration.class }); digester.addCallParam("gdata/server-components/component/class", 0); digester.addObjectCreate("gdata/server-components/component/configuration", ComponentConfiguration.class); digester.addCallMethod("gdata/server-components/component/configuration/property", "set", 2, new Class[] { String.class, String.class }); digester.addCallParam("gdata/server-components/component/configuration/property", 0, "name"); digester.addCallParam("gdata/server-components/component/configuration/property", 1); //second parameter on registerComponent -- top of the stack (Component configuration) digester.addCallParam("gdata/server-components/component/configuration", 1, 0); digester.parse(RegistryBuilder.class.getResourceAsStream("/gdata-config.xml")); }
From source file:org.apache.lucene.gdata.server.registry.RegistryBuilder.java
private static void addIndexRule(Digester digester) { digester.addObjectCreate("gdata/service/index-schema", IndexSchema.class); digester.addSetNext("gdata/service/index-schema", "setIndexSchema"); digester.addSetProperties("gdata/service/index-schema"); digester.addSetProperties("gdata/service/index-schema/index"); digester.addBeanPropertySetter("gdata/service/index-schema/index/maxMergeDocs"); digester.addBeanPropertySetter("gdata/service/index-schema/index/maxBufferedDocs"); digester.addBeanPropertySetter("gdata/service/index-schema/index/maxFieldLength"); digester.addBeanPropertySetter("gdata/service/index-schema/index/mergeFactor"); digester.addBeanPropertySetter("gdata/service/index-schema/index/indexLocation"); digester.addBeanPropertySetter("gdata/service/index-schema/index/useCompoundFile"); digester.addCallMethod("gdata/service/index-schema/index/defaultAnalyzer", "serviceAnalyzer", 1, new Class[] { Class.class }); //call method on top of the stack addSchemaField digester.addCallMethod("gdata/service/index-schema/field", "addSchemaField", 1, new Class[] { IndexSchemaField.class }); digester.addObjectCreate("gdata/service/index-schema/field", IndexSchemaField.class); //set parameter for method call -- parameter is IndexSchemaField digester.addCallParam("gdata/service/index-schema/field", 0, 0); digester.addSetProperties("gdata/service/index-schema/field"); digester.addBeanPropertySetter("gdata/service/index-schema/field/path"); digester.addBeanPropertySetter("gdata/service/index-schema/field/store", "storeByName"); digester.addBeanPropertySetter("gdata/service/index-schema/field/index", "indexByName"); digester.addBeanPropertySetter("gdata/service/index-schema/field/analyzer", "analyzerClass"); // call method on top of the stack addSchemaField digester.addCallMethod("gdata/service/index-schema/custom", "addSchemaField", 1, new Class[] { IndexSchemaField.class }); digester.addObjectCreate("gdata/service/index-schema/custom", IndexSchemaField.class); //set parameter for method call -- parameter is IndexSchemaField digester.addCallParam("gdata/service/index-schema/custom", 0, 0); digester.addSetProperties("gdata/service/index-schema/custom"); digester.addBeanPropertySetter("gdata/service/index-schema/custom/path"); digester.addBeanPropertySetter("gdata/service/index-schema/custom/store", "storeByName"); digester.addBeanPropertySetter("gdata/service/index-schema/custom/index", "indexByName"); digester.addBeanPropertySetter("gdata/service/index-schema/custom/analyzer", "analyzerClass"); digester.addBeanPropertySetter("gdata/service/index-schema/custom/field-class", "fieldClass"); // digester.addCallMethod("gdata/service/index-schema/custom/field-class","fieldClass",1,new Class[]{Class.class}); // call method on top of the stack addSchemaField digester.addCallMethod("gdata/service/index-schema/mixed", "addSchemaField", 1, new Class[] { IndexSchemaField.class }); digester.addObjectCreate("gdata/service/index-schema/mixed", IndexSchemaField.class); //set parameter for method call -- parameter is IndexSchemaField digester.addCallParam("gdata/service/index-schema/mixed", 0, 0); digester.addSetProperties("gdata/service/index-schema/mixed"); digester.addBeanPropertySetter("gdata/service/index-schema/mixed", "type"); digester.addBeanPropertySetter("gdata/service/index-schema/mixed/path"); digester.addBeanPropertySetter("gdata/service/index-schema/mixed/store", "storeByName"); digester.addBeanPropertySetter("gdata/service/index-schema/mixed/index", "indexByName"); digester.addBeanPropertySetter("gdata/service/index-schema/mixed/contenttype", "typePath"); digester.addBeanPropertySetter("gdata/service/index-schema/mixed/analyzer", "analyzerClass"); }
From source file:org.efaps.maven.run.Plugin.java
/** * * @param _name name of the plugin/*from w w w. j a va 2 s . c o m*/ * @see #name */ private Plugin(final URL _url) throws IOException, SAXException, ParserConfigurationException { System.out.println("read plugin " + _url); Digester digester = new Digester(); digester.setValidating(false); digester.setRules(new ExtendedBaseRules()); // plugin name PluginRule pluginRule = new PluginRule(); digester.addRule("plugin", pluginRule); digester.addCallParam("plugin/goalPrefix", 0); // goal digester.addRule("plugin/mojos/mojo", new GoalRule()); digester.addCallParam("plugin/mojos/mojo/goal", 0); digester.addCallParam("plugin/mojos/mojo/implementation", 1); digester.addCallParam("plugin/mojos/mojo/description", 2); // goal parameter digester.addCallMethod("plugin/mojos/mojo/parameters/parameter", "addParameter", 6, new Class[] { String.class, String.class, String.class, String.class, Boolean.class, Boolean.class }); digester.addCallParam("plugin/mojos/mojo/parameters/parameter/name", 0); digester.addCallParam("plugin/mojos/mojo/parameters/parameter/alias", 1); digester.addCallParam("plugin/mojos/mojo/parameters/parameter/type", 2); digester.addCallParam("plugin/mojos/mojo/parameters/parameter/description", 3); digester.addCallParam("plugin/mojos/mojo/parameters/parameter/required", 4); digester.addCallParam("plugin/mojos/mojo/parameters/parameter/editable", 5); // goal configuration (default values) DefaultValueRule.init(digester); digester.parse(_url.openStream()); this.name = pluginRule.name; }
From source file:org.freecine.filmscan.ScanStripRuleSet.java
@Override public void addRuleInstances(Digester d) { d.addObjectCreate(prefix + "scan", ScanStrip.class); d.addSetProperties(prefix + "scan"); d.addCallMethod(prefix + "scan/perforations/perforation", "addPerforation", 2, new Class[] { Integer.class, Integer.class }); d.addCallParam(prefix + "scan/perforations/perforation", 0, "x"); d.addCallParam(prefix + "scan/perforations/perforation", 1, "y"); }
From source file:org.onebusaway.geocoder.impl.YahooGeocoderImpl.java
private Digester createDigester() { Digester digester = new Digester(); Class<?>[] dType = { Double.class }; digester.addObjectCreate("ResultSet/Result", GeocoderResult.class); digester.addCallMethod("ResultSet/Result/Latitude", "setLatitude", 0, dType); digester.addCallMethod("ResultSet/Result/Longitude", "setLongitude", 0, dType); digester.addCallMethod("ResultSet/Result/Address", "setAddress", 0); digester.addCallMethod("ResultSet/Result/City", "setCity", 0); digester.addCallMethod("ResultSet/Result/State", "setAdministrativeArea", 0); digester.addCallMethod("ResultSet/Result/Zip", "setPostalCode", 0); digester.addCallMethod("ResultSet/Result/Country", "setCountry", 0); digester.addSetNext("ResultSet/Result", "addResult"); return digester; }
From source file:org.photovault.image.ChannelMapRuleSet.java
/** Add rules for the channel-map reule set to digester @param d The digerster to which the rules will be added. *//*from w ww .j a v a2 s .c o m*/ public void addRuleInstances(Digester d) { d.addObjectCreate(pathPrefix + "color-mapping", ChannelMapOperationFactory.class); d.addObjectCreate(pathPrefix + "color-mapping/channel", ColorCurve.class); d.addRule(pathPrefix + "color-mapping/channel", new Rule() { public void begin(String namespace, String name, Attributes attrs) { String channelName = attrs.getValue("name"); ChannelMapOperationFactory f = (ChannelMapOperationFactory) digester.peek(1); ColorCurve c = (ColorCurve) digester.peek(); f.setChannelCurve(channelName, c); } }); d.addCallMethod(pathPrefix + "color-mapping/channel/point", "addPoint", 2, new Class[] { Double.class, Double.class }); d.addCallParam(pathPrefix + "color-mapping/channel/point", 0, "x"); d.addCallParam(pathPrefix + "color-mapping/channel/point", 1, "y"); }