List of usage examples for org.apache.commons.digester3 Digester Digester
public Digester()
From source file:net.sf.mcf2pdf.mcfglobals.McfProductCatalogue.java
public static McfProductCatalogue read(InputStream in, CatalogueVersion version) throws IOException, SAXException { if (version == CatalogueVersion.V6) { return readV6(in); }//from w ww.j a v a 2 s.com // PRE_V6 Digester digester = new Digester(); digester.addObjectCreate("fotobookdefinitions", McfProductCatalogueImpl.class); digester.addObjectCreate("fotobookdefinitions/album", McfAlbumTypeImpl.class); DigesterUtil.addSetProperties(digester, "fotobookdefinitions/album", getAlbumSpecialAttributes()); DigesterUtil.addSetProperties(digester, "fotobookdefinitions/album/usablesize", getUsableSizeAttributes()); digester.addCallMethod("fotobookdefinitions/album/spines/spine", "addSpine", 2, new String[] { Integer.class.getName(), Integer.class.getName() }); digester.addCallParam("fotobookdefinitions/album/spines/spine", 0, "pages"); digester.addCallParam("fotobookdefinitions/album/spines/spine", 1, "width"); digester.addSetNext("fotobookdefinitions/album", "addAlbumType"); return digester.parse(in); }
From source file:com.mathworks.xzheng.tika.DigesterXMLDocument.java
public DigesterXMLDocument() { dig = new Digester(); dig.setValidating(false);//from w w w . j av a2s . co m dig.addObjectCreate("address-book", DigesterXMLDocument.class); // #1 dig.addObjectCreate("address-book/contact", Contact.class); // #2 dig.addSetProperties("address-book/contact", "type", "type"); // #3 dig.addCallMethod("address-book/contact/name", // #4 "setName", 0); // #4 dig.addCallMethod("address-book/contact/address", "setAddress", 0); dig.addCallMethod("address-book/contact/city", "setCity", 0); dig.addCallMethod("address-book/contact/province", "setProvince", 0); dig.addCallMethod("address-book/contact/postalcode", "setPostalcode", 0); dig.addCallMethod("address-book/contact/country", "setCountry", 0); dig.addCallMethod("address-book/contact/telephone", "setTelephone", 0); dig.addSetNext("address-book/contact", "populateDocument"); // #5 }
From source file:net.sf.mcf2pdf.mcfglobals.McfProductCatalogue.java
private static McfProductCatalogue readV6(InputStream in) throws IOException, SAXException { Digester digester = new Digester(); digester.addObjectCreate("description", McfProductCatalogueImpl.class); digester.addObjectCreate("description/product", McfAlbumTypeImpl.class); DigesterUtil.addSetProperties(digester, "description/product", getAlbumSpecialAttributes()); DigesterUtil.addSetProperties(digester, "description/product/usablesize", getUsableSizeAttributes()); digester.addCallMethod("description/product/spines/spine", "addSpine", 2, new String[] { Integer.class.getName(), Integer.class.getName() }); digester.addCallParam("description/product/spines/spine", 0, "pages"); digester.addCallParam("description/product/spines/spine", 1, "width"); digester.addSetNext("description/product", "addAlbumType"); return digester.parse(in); }
From source file:br.univali.celine.lms.config.LMSConfig.java
private static void doBuildConfig(String path) throws Exception { Digester d = new Digester(); d.setUseContextClassLoader(true);//ww w .ja va 2s . c om d.push(config); d.addCallMethod("*/courses-folder", "setCoursesFolder", 0); // d.addCallMethod("*/login-page", "setLoginPage", 0); d.addCallMethod("*/registerCourseOnImport", "setRegisterCourseOnImport", 0); d.addCallMethod("*/registerUserOnInsertCourse", "setRegisterUserOnInsert", 0); d.addCallMethod("*/error-page", "setErrorPage", 0); d.addCallMethod("*/lmsIntegration", "setLMSIntegration", 0); d.addObjectCreate("*/database-source/rdb", RDBDAO.class); d.addSetNestedProperties("*/database-source/rdb"); d.addSetNext("*/database-source/rdb", "setDAO"); d.addObjectCreate("*/database-source/xml", XMLDAO.class); d.addCallMethod("*/database-source/xml", "setFileName", 0); d.addSetNext("*/database-source/xml", "setDAO"); d.addObjectCreate("*/database-source/bean", "", "class"); // devido a um bug da versao 3.3 tive que fazer esse workaround !!! //d.addObjectCreate("*/database-source/bean", "class", DAO.class); d.addSetNext("*/database-source/bean", "setDAO"); d.addRule("*/database-source/bean/bean-attribute", new BeanSetterAttribute()); String fileName = path + "/celine-config.xml"; java.io.File srcfile = new java.io.File(fileName); d.parse(srcfile); if (config.dao == null) throw new Exception("DAO is not defined at celine-config.xml"); config.dao.initialize(); }
From source file:architecture.ee.web.navigator.XmlMenuHolder.java
protected Digester initDigester() { Digester digester = new Digester(); digester.setClassLoader(Thread.currentThread().getContextClassLoader()); digester.push(this); // 1/*w w w . ja v a2 s. co m*/ digester.addObjectCreate("MenuConfig/Menus/Menu", "architecture.ee.web.navigator.MenuComponent", "type"); digester.addSetProperties("MenuConfig/Menus/Menu"); digester.addSetNext("MenuConfig/Menus/Menu", "addMenu"); // 2 digester.addObjectCreate("MenuConfig/Menus/Menu/Item", "architecture.ee.web.navigator.MenuComponent", "type"); digester.addSetProperties("MenuConfig/Menus/Menu/Item"); digester.addSetNext("MenuConfig/Menus/Menu/Item", "addMenuComponent", "architecture.ee.web.navigator.MenuComponent"); // 3 digester.addObjectCreate("MenuConfig/Menus/Menu/Item/Item", "architecture.ee.web.navigator.MenuComponent", "type"); digester.addSetProperties("MenuConfig/Menus/Menu/Item/Item"); digester.addSetNext("MenuConfig/Menus/Menu/Item/Item", "addMenuComponent", "architecture.ee.web.navigator.MenuComponent"); // 4 digester.addObjectCreate("MenuConfig/Menus/Menu/Item/Item/Item", "architecture.ee.web.navigator.MenuComponent", "type"); digester.addSetProperties("MenuConfig/Menus/Menu/Item/Item/Item"); digester.addSetNext("MenuConfig/Menus/Menu/Item/Item/Item", "addMenuComponent", "architecture.ee.web.navigator.MenuComponent"); // 5 digester.addObjectCreate("MenuConfig/Menus/Menu/Item/Item/Item/Item", "architecture.ee.web.navigator.MenuComponent", "type"); digester.addSetProperties("MenuConfig/Menus/Menu/Item/Item/Item/Item"); digester.addSetNext("MenuConfig/Menus/Menu/Item/Item/Item/Item", "addMenuComponent", "architecture.ee.web.navigator.MenuComponent"); // 6 digester.addObjectCreate("MenuConfig/Menus/Menu/Item/Item/Item/Item/Item", "architecture.ee.web.navigator.MenuComponent", "type"); digester.addSetProperties("MenuConfig/Menus/Menu/Item/Item/Item/Item/Item"); digester.addSetNext("MenuConfig/Menus/Menu/Item/Item/Item/Item/Item", "addMenuComponent", "architecture.ee.web.navigator.MenuComponent"); // 7 digester.addObjectCreate("MenuConfig/Menus/Menu/Item/Item/Item/Item/Item/Item", "architecture.ee.web.navigator.MenuComponent", "type"); digester.addSetProperties("MenuConfig/Menus/Menu/Item/Item/Item/Item/Item/Item"); digester.addSetNext("MenuConfig/Menus/Menu/Item/Item/Item/Item/Item/Item", "addMenuComponent", "architecture.ee.web.navigator.MenuComponent"); /** digester.addObjectCreate("MenuConfig/Displayers/Displayer", "net.sf.navigator.displayer.MenuDisplayerMapping", "mapping"); digester.addSetProperties("MenuConfig/Displayers/Displayer"); digester.addSetNext("MenuConfig/Displayers/Displayer", "addMenuDisplayerMapping", "net.sf.navigator.displayer.MenuDisplayerMapping"); digester.addSetProperty("MenuConfig/Displayers/Displayer/SetProperty", "property", "value"); */ return digester; }
From source file:com.w20e.socrates.workflow.ProcessorFactory.java
/** * Creates a new <code>ProcessorFactory</code> instance, and define rules * for digester./*from w w w .j a v a2 s. c o m*/ * * @param proc * the processor to use as root object. May be null, in which * case a new Processor will be created. */ public ProcessorFactory(final ProcessorImpl proc) { final ActionFactory actionFactory = new ActionFactory(); final MappingFactory mappingFactory = new MappingFactory(); this.dig = new Digester(); if (proc == null) { this.dig.addObjectCreate("workflow", ProcessorImpl.class); } else { this.dig.push(proc); } this.dig.addFactoryCreate("workflow/actions/action", actionFactory); this.dig.addFactoryCreate("workflow/mappings/mapping", mappingFactory); this.dig.addFactoryCreate("workflow/initial", actionFactory); this.dig.addObjectCreate("workflow/finals", Vector.class); this.dig.addFactoryCreate("workflow/finals/final", actionFactory); this.dig.addSetNext("workflow/mappings/mapping", "addMapping"); this.dig.addSetNext("workflow/initial", "setInitial"); this.dig.addSetNext("workflow/finals/final", "add"); this.dig.addSetNext("workflow/finals", "setFinals"); this.dig.addCallMethod("workflow/actions/action/property", "setProperty", 2); this.dig.addCallParam("workflow/actions/action/property", 0, "name"); this.dig.addCallParam("workflow/actions/action/property", 1, "value"); }
From source file:net.revelc.code.formatter.model.ConfigReader.java
/** * Read from the <code>input</code> and return it's configuration settings * as a {@link Map}./* w w w . j av a 2s.c om*/ * * @param input the input * @return return {@link Map} with all the configurations read from the * config file, or throws an exception if there's a problem reading * the input, e.g.: invalid XML. * @throws IOException Signals that an I/O exception has occurred. * @throws SAXException the SAX exception * @throws ConfigReadException the config read exception */ public Map<String, String> read(InputStream input) throws IOException, SAXException, ConfigReadException { Digester digester = new Digester(); digester.addRuleSet(new RuleSet()); Object result = digester.parse(input); if (result == null || !(result instanceof Profiles)) { throw new ConfigReadException("No profiles found in config file"); } Profiles profiles = (Profiles) result; List<Map<String, String>> list = profiles.getProfiles(); if (list.isEmpty()) { throw new ConfigReadException("No profile in config file of kind: " + Profiles.PROFILE_KIND); } return list.get(0); }
From source file:net.sf.mcf2pdf.mcfelements.FotobookBuilder.java
/** * Reads the given MCF input file and creates an MCF DOM reflecting the * relevant parts of the content.//from ww w . j av a 2s. co m * * @param file MCF input file. * * @return A Fotobook object reflecting the contents of the file. * * @throws IOException If any I/O related problem occurs reading the file. * @throws SAXException If any XML related problem occurs reading the file. */ public McfFotobook readFotobook(File file) throws IOException, SAXException { Digester digester = new Digester(); configurator.configureDigester(digester, file); McfFotobook fb = digester.parse(file); // try to set file on it try { BeanUtils.setProperty(fb, "file", file); } catch (Exception e) { // ignore - digester configurator will (hopefully) do it anyhow } // if this is thrown, your McfFotobook implementation has no setFile(), // and your configurator has also not set it. if (!file.equals(fb.getFile())) throw new IllegalStateException( "File could not be set on photobook. Please check used DigesterConfigurator."); return fb; }
From source file:com.relativitas.maven.plugins.formatter.ConfigReader.java
/** * Read from the <code>input</code> and return it's configuration settings * as a {@link Map}.// w w w. ja v a 2 s .c om * * @param input the input * @return return {@link Map} with all the configurations read from the * config file, or throws an exception if there's a problem reading * the input, e.g.: invalid XML. * @throws IOException Signals that an I/O exception has occurred. * @throws SAXException the SAX exception * @throws ConfigReadException the config read exception */ public Map<String, String> read(InputStream input) throws IOException, SAXException, ConfigReadException { Digester digester = new Digester(); digester.addRuleSet(new RuleSet()); Object result = digester.parse(input); if (result == null && !(result instanceof Profiles)) { throw new ConfigReadException("No profiles found in config file"); } Profiles profiles = (Profiles) result; List<Map<String, String>> list = profiles.getProfiles(); if (list.size() == 0) { throw new ConfigReadException("No profile in config file of kind: " + Profiles.PROFILE_KIND); } return (Map<String, String>) list.get(0); }
From source file:com.w20e.socrates.factories.XMLQuestionnaireFactory.java
/** * Create a new Digester for the instance. This should ALWAYS happen for * each parse... Seriously!//from w w w. j a v a2 s .c om * * @return the digester */ private Digester createInstanceDigester() { Digester dig = new Digester(); NodeFactory nodeFactory = new NodeFactory(); PropertiesFactory propsFactory = new PropertiesFactory(); ExpressionFactory exprFactory = new ExpressionFactory(); SurveyFactory surveyFactory = new SurveyFactory(); dig.addFactoryCreate("survey", surveyFactory); dig.addSetProperties("survey"); // dig.addRule("*/var", nodeCreateRule); // dig.addCallParam( "*/var", 0, "name"); // dig.addCallParam( "*/var", 1); dig.addFactoryCreate("*/var", nodeFactory); dig.addCallMethod("*/var", "setValue", 1); dig.addCallParam("*/var", 0); dig.addSetNext("*/var", "addNode", "com.w20e.socrates.model.NodeImpl"); // dig.addObjectCreate("*/vargroup", Node.class); // dig.addSetNext("*/var", "addNode"); dig.addFactoryCreate("*/model/properties", propsFactory); dig.addSetNext("*/model/properties", "addProperties", "com.w20e.socrates.model.ItemPropertiesImpl"); dig.addCallMethod("*/model/properties/bind", "addBind", 1); dig.addCallParam("*/model/properties/bind", 0); Rule exprRule = new ExpressionCreateRule(exprFactory); dig.addRule("*/properties/required", exprRule); dig.addCallMethod("*/properties/required", "setExpr", 1); dig.addCallParam("*/properties/required", 0); dig.addRule("*/properties/relevant", exprRule); dig.addCallMethod("*/properties/relevant", "setExpr", 1); dig.addCallParam("*/properties/relevant", 0); dig.addRule("*/properties/readonly", exprRule); dig.addCallMethod("*/properties/readonly", "setExpr", 1); dig.addCallParam("*/properties/readonly", 0); dig.addRule("*/properties/calculate", exprRule); dig.addCallMethod("*/properties/calculate", "setExpr", 1); dig.addCallParam("*/properties/calculate", 0); dig.addRule("*/properties/constraint", exprRule); dig.addCallMethod("*/properties/constraint", "setExpr", 1); dig.addCallParam("*/properties/constraint", 0); dig.addRule("*/properties/datatype", exprRule); dig.addCallMethod("*/properties/datatype", "setExpr", 1); dig.addCallParam("*/properties/datatype", 0); dig.addRule("*/properties/default", exprRule); dig.addCallMethod("*/properties/default", "setExpr", 1); dig.addCallParam("*/properties/default", 0); return dig; }