List of usage examples for org.apache.commons.digester Digester addRule
public void addRule(String pattern, Rule rule)
Register a new Rule matching the specified pattern.
From source file:net.sourceforge.jcctray.model.DashboardXmlParser.java
private static Digester createDigester() { Digester digester = new Digester(); digester.addRule("Projects", new ObjectCreateRule(DashBoardProjects.class)); digester.addRule("Projects/Project", new ObjectCreateRule(DashBoardProject.class)); digester.addRule("Projects/Project", new SetPropertiesRule()); digester.addRule("Projects/Project", new SetNextRule("add")); return digester; }
From source file:com.pureinfo.srmcenter.datasync.client.SyncClientHelper.java
public static Map getSrmSrmcMapping(String _sFileName) throws PureException { Digester digester = new Digester(); digester.addObjectCreate("sync-data", HashMap.class); digester.addRule("sync-data/property", new Rule() { public void begin(String _sNamespace, String _sName, Attributes _attributes) throws Exception { Map mapping = (Map) digester.peek(); SyncMapping sync = new SyncMapping(); sync.setSRM(_attributes.getValue("srm")); sync.setSRMC(_attributes.getValue("srmc")); String sType = _attributes.getValue("type"); if (sType == null) sync.setType(0);/*from www . ja v a 2 s . co m*/ else sync.setType(Integer.parseInt(sType)); mapping.put(sync.getSRMC(), sync); } }); try { return (Map) digester.parse(_sFileName); } catch (Exception ex) { throw new PureException(PureException.UNKNOWN, "", ex); } }
From source file:com.threerings.miso.tools.xml.SparseMisoSceneRuleSet.java
/** * Adds a set of rules to <code>dig</code> to create an Object info from the element at * base/type/object and calls <code>methodName</code> on the object on dig's stack. */// w ww. j a va 2s.c om public static void addObjectExtractor(Digester dig, String type, String base, String methodName) { String prefix = base + "/" + type + "/object"; dig.addObjectCreate(prefix, ObjectInfo.class); dig.addRule(prefix, new SetPropertyFieldsRule()); dig.addSetNext(prefix, methodName, ObjectInfo.class.getName()); }
From source file:net.sourceforge.jcctray.utils.ObjectPersister.java
public static CruiseRegistry loadCruiseRegistry(String fileName) throws IOException, SAXException { Digester digester = new Digester(); FileReader fileReader = new FileReader(fileName); digester.addRule("cruiseregistry", new ObjectCreateRule(CruiseRegistry.class)); digester.addRule("cruiseregistry/cruiseImpls/cruiseImpl", new CallMethodRule("addCruiseImpl", 0, new Class[] { Class.class })); CruiseRegistry result = (CruiseRegistry) digester.parse(fileReader); fileReader.close();// w w w .ja v a 2 s . com return result; }
From source file:net.sourceforge.jcctray.utils.ObjectPersister.java
public static JCCTraySettings loadJCCTraySettings(String fileName) throws IOException, SAXException { Digester digester = new Digester(); FileReader fileReader = new FileReader(fileName); digester.addRule("cctraysettings", new ObjectCreateRule(JCCTraySettings.class)); digester.addRule("cctraysettings/hosts/host", new ObjectCreateRule(Host.class)); digester.addRule("cctraysettings/hosts/host", new SetPropertiesRule()); digester.addRule("cctraysettings/hosts/host", new SetNextRule("addHost")); digester.addRule("cctraysettings/hosts/host/projects/project", new ObjectCreateRule(DashBoardProject.class)); digester.addRule("cctraysettings/hosts/host/projects/project", new SetPropertiesRule()); digester.addRule("cctraysettings/hosts/host/projects/project", new SetNextRule("addConfiguredProject")); digester.addRule("cctraysettings/settings/entry", new ObjectCreateRule(NameValuePair.class)); digester.addRule("cctraysettings/settings/entry", new SetPropertiesRule()); digester.addRule("cctraysettings/settings/entry", new SetNextRule("set")); JCCTraySettings result = (JCCTraySettings) digester.parse(fileReader); fileReader.close();//from w w w .j ava2 s. c om return result; }
From source file:com.acciente.induction.init.config.xmlconfigloader.DigesterFactory.java
public static Digester getDigester(Config oConfig, ResourceLoader oResourceLoader) { Digester oDigester = createBasicDigester(oConfig); // include config rules oDigester.addRule(XML.Config_IncludeConfig.PATTERN, new IncludeConfigRule(oConfig, oResourceLoader)); return oDigester; }
From source file:net.sf.jasperreports.customvisualization.xml.CVDigester.java
protected static void addEvaluationPropertiesRules(Digester digester, String pattern) { digester.addSetProperties(pattern,/*from ww w . ja v a2 s . co m*/ // properties to be ignored by this rule new String[] { JRXmlConstants.ATTRIBUTE_evaluationTime, CVXmlFactory.ATTRIBUTE_onErrorType }, new String[0]); digester.addRule(pattern, new XmlConstantPropertyRule(JRXmlConstants.ATTRIBUTE_evaluationTime, "evaluationTimeValue", EvaluationTimeEnum.values())); digester.addRule(pattern, new XmlConstantPropertyRule(CVXmlFactory.ATTRIBUTE_onErrorType, OnErrorTypeEnum.values())); }
From source file:net.sf.jasperreports.components.sort.SortComponentDigester.java
public static void addSortComponentRules(Digester digester) { String componentNamespace = digester.getRuleNamespaceURI(); String sortComponentPattern = "*/componentElement/sort"; digester.addObjectCreate(sortComponentPattern, SortComponent.class.getName()); digester.addSetProperties(sortComponentPattern, new String[] { SortComponent.PROPERTY_EVALUATION_TIME, }, new String[0]); digester.addRule(sortComponentPattern, new XmlConstantPropertyRule(SortComponent.PROPERTY_EVALUATION_TIME, EvaluationTimeEnum.values())); digester.addFactoryCreate(sortComponentPattern + "/symbol", SortComponentSymbolFactory.class.getName()); digester.setRuleNamespaceURI(JRXmlConstants.JASPERREPORTS_NAMESPACE); digester.addFactoryCreate(sortComponentPattern + "/symbol/font", SortComponentSymbolFontFactory.class.getName()); digester.addSetNext(sortComponentPattern + "/symbol/font", "setSymbolFont", JRFont.class.getName()); digester.setRuleNamespaceURI(componentNamespace); }
From source file:com.change_vision.astah.extension.plugin.cplusreverse.reverser.DoxygenXmlParser.java
/** * /*from ww w . j a va2 s . co m*/ * @param file * : target file * @return the Compounddef * @throws IOException * @throws SAXException */ public static CompoundDef parserCompounddefXML(File file) throws IOException, SAXException { // init digester for parser class.xml or interface.xml... Digester digester = new DoxygenDigester(); digester.setValidating(false); // create the Compounddef digester.addRule("doxygen/compounddef", new ObjectCreateAfterLanguageRule(CompoundDef.class)); digester.addSetProperties("doxygen/compounddef", "id", "compounddefId"); digester.addSetProperties("doxygen/compounddef", "prot", "compounddefVisible"); digester.addSetProperties("doxygen/compounddef", "kind", "compounddefKind"); digester.addBeanPropertySetter("doxygen/compounddef/compoundname", "compoundName"); // crreate the TempleParam digester.addRule("doxygen/compounddef/templateparamlist/param", new ObjectCreateAfterLanguageRule(TempleParam.class)); digester.addBeanPropertySetter("doxygen/compounddef/templateparamlist/param/type", "type"); digester.addBeanPropertySetter("doxygen/compounddef/templateparamlist/param/declname", "declname"); digester.addBeanPropertySetter("doxygen/compounddef/templateparamlist/param/defname", "defname"); digester.addBeanPropertySetter("doxygen/compounddef/templateparamlist/param/defval", "defval"); digester.addRule("doxygen/compounddef/templateparamlist/param/defval/ref", new ObjectCreateAfterLanguageRule(Ref.class)); digester.addSetProperties("doxygen/compounddef/templateparamlist/param/defval/ref", "refid", "refid"); digester.addSetProperties("doxygen/compounddef/templateparamlist/param/defval/ref", "refid", "kindref"); digester.addBeanPropertySetter("doxygen/compounddef/templateparamlist/param/defval/ref", "value"); digester.addSetNext("doxygen/compounddef/templateparamlist/param/defval/ref", "setDefaultValue"); digester.addSetNext("doxygen/compounddef/templateparamlist/param", "addTemplateParam"); // create the BaseCompounddefref digester.addRule("doxygen/compounddef/basecompoundref", new ObjectCreateAfterLanguageRule(BaseCompoundDefRef.class)); digester.addSetProperties("doxygen/compounddef/basecompoundref", "refid", "refid"); digester.addSetProperties("doxygen/compounddef/basecompoundref", "prot", "prot"); digester.addSetProperties("doxygen/compounddef/basecompoundref", "virt", "virt"); digester.addBeanPropertySetter("doxygen/compounddef/basecompoundref", "value"); digester.addSetNext("doxygen/compounddef/basecompoundref", "addBasecompoundList"); // create the Derivedcompoundref digester.addRule("doxygen/compounddef/derivedcompoundref", new ObjectCreateAfterLanguageRule(DerivedCompoundRef.class)); digester.addSetProperties("doxygen/compounddef/derivedcompoundref", "refid", "refid"); digester.addSetProperties("doxygen/compounddef/derivedcompoundref", "prot", "prot"); digester.addSetProperties("doxygen/compounddef/derivedcompoundref", "virt", "virt"); digester.addBeanPropertySetter("doxygen/compounddef/derivedcompoundref", "value"); digester.addSetNext("doxygen/compounddef/derivedcompoundref", "addDerivedcompoundList"); // create the InnerClass digester.addRule("doxygen/compounddef/innerclass", new ObjectCreateAfterLanguageRule(InnerClass.class)); digester.addSetProperties("doxygen/compounddef/innerclass", "refid", "refid"); digester.addSetProperties("doxygen/compounddef/innerclass", "prot", "prot"); digester.addSetNext("doxygen/compounddef/innerclass", "addInnerclass"); // create the Innernamespace digester.addRule("doxygen/compounddef/innernamespace", new ObjectCreateAfterLanguageRule(InnerNameSpace.class)); digester.addSetProperties("doxygen/compounddef/innernamespace", "refid", "refid"); digester.addSetNext("doxygen/compounddef/innernamespace", "addInnernamespace"); digester.addSetProperties("doxygen/compounddef/location", "file", "locationFile"); digester.addSetProperties("doxygen/compounddef/location", "line", "locationLine"); digester.addSetProperties("doxygen/compounddef/location", "bodyfile", "locationBodyFile"); digester.addSetProperties("doxygen/compounddef/location", "bodystart", "locationBodyStart"); digester.addSetProperties("doxygen/compounddef/location", "bodyend", "locationBodyEnd"); // digester.addBeanPropertySetter("doxygen/compounddef/briefdescription/para", "briefdescriptionPara"); digester.addBeanPropertySetter("doxygen/compounddef/detaileddescription/para", "detaileddescriptionPara"); // create the Section digester.addRule("doxygen/compounddef/sectiondef", new ObjectCreateAfterLanguageRule(Section.class)); digester.addSetProperties("doxygen/compounddef/sectiondef", "kind", "kind"); digester.addSetNext("doxygen/compounddef/sectiondef", "addSection"); // create the Member digester.addRule("doxygen/compounddef/sectiondef/memberdef", new ObjectCreateAfterLanguageRule(Member.class)); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "kind", "kind"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "id", "id"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "prot", "prot"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "const", "constBoolean"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "static", "staticBoolean"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "gettable", "gettable"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "settable", "settable"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "virt", "virt"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "explicit", "explicit"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "inline", "inline"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef", "mutable", "mutable"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/type", "type"); digester.addRule("doxygen/compounddef/sectiondef/memberdef/type/ref", new ObjectCreateAfterLanguageRule(Ref.class)); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef/type/ref", "refid", "refid"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef/type/ref", "refid", "kindref"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/type/ref", "value"); digester.addSetNext("doxygen/compounddef/sectiondef/memberdef/type/ref", "addTypeRef"); // resolve special initializer digester.addRule("doxygen/compounddef/sectiondef/memberdef/initializer", new InitBeanPropertySetterRule()); digester.addRule("doxygen/compounddef/sectiondef/memberdef/enumvalue", new ObjectCreateAfterLanguageRule(EnumValue.class)); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/enumvalue/name", "name"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/enumvalue/initializer", "initializer"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/enumvalue/briefdescription", "briefdescription"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/enumvalue/detaileddescription", "detaileddescription"); digester.addSetNext("doxygen/compounddef/sectiondef/memberdef/enumvalue", "addEnum"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/name", "name"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/argsstring", "argsstring"); // create the Param digester.addRule("doxygen/compounddef/sectiondef/memberdef/param", new ObjectCreateAfterLanguageRule(Param.class)); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/param/type", "type"); digester.addRule("doxygen/compounddef/sectiondef/memberdef/param/type/ref", new ObjectCreateAfterLanguageRule(Ref.class)); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef/param/type/ref", "refid", "refid"); digester.addSetProperties("doxygen/compounddef/sectiondef/memberdef/param/type/ref", "refid", "kindref"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/param/type/ref", "value"); digester.addSetNext("doxygen/compounddef/sectiondef/memberdef/param/type/ref", "addTypeRef"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/param/declname", "declname"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/param/defname", "defname"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/param/array", "array"); digester.addSetNext("doxygen/compounddef/sectiondef/memberdef/param", "addMemberParam"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/briefdescription/para", "briefdescriptionPara"); digester.addBeanPropertySetter("doxygen/compounddef/sectiondef/memberdef/detaileddescription/para", "detaileddescriptionPara"); digester.addSetNext("doxygen/compounddef/sectiondef/memberdef", "addMember"); logger.debug("file:{}", file); return (CompoundDef) digester.parse(file); }
From source file:net.sf.jasperreports.components.iconlabel.IconLabelComponentDigester.java
public static void addIconLabelComponentRules(Digester digester) { String componentNamespace = digester.getRuleNamespaceURI(); String iconLabelComponentPattern = "*/componentElement/iconLabel"; digester.addFactoryCreate(iconLabelComponentPattern, IconLabelComponentFactory.class.getName()); digester.addSetProperties(iconLabelComponentPattern, new String[] { IconLabelComponent.PROPERTY_ICON_POSITION, IconLabelComponent.PROPERTY_LABEL_FILL, IconLabelComponent.PROPERTY_HORIZONTAL_ALIGNMENT, IconLabelComponent.PROPERTY_VERTICAL_ALIGNMENT }, new String[0]); digester.addRule(iconLabelComponentPattern, new XmlConstantPropertyRule(IconLabelComponent.PROPERTY_ICON_POSITION, IconPositionEnum.values())); digester.addRule(iconLabelComponentPattern, new XmlConstantPropertyRule(IconLabelComponent.PROPERTY_LABEL_FILL, ContainerFillEnum.values())); digester.addRule(iconLabelComponentPattern, new XmlConstantPropertyRule(IconLabelComponent.PROPERTY_HORIZONTAL_ALIGNMENT, "horizontalImageAlign", HorizontalImageAlignEnum.values())); digester.addRule(iconLabelComponentPattern, new XmlConstantPropertyRule(IconLabelComponent.PROPERTY_VERTICAL_ALIGNMENT, "verticalImageAlign", VerticalImageAlignEnum.values())); digester.setRuleNamespaceURI(JRXmlConstants.JASPERREPORTS_NAMESPACE); digester.addFactoryCreate(iconLabelComponentPattern + "/label/textField", LabelTextFieldFactory.class.getName()); digester.addFactoryCreate(iconLabelComponentPattern + "/icon/textField", IconTextFieldFactory.class.getName()); digester.setRuleNamespaceURI(componentNamespace); }