当前位置: 首页>>代码示例>>Java>>正文


Java Rule类代码示例

本文整理汇总了Java中org.apache.commons.digester.Rule的典型用法代码示例。如果您正苦于以下问题:Java Rule类的具体用法?Java Rule怎么用?Java Rule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Rule类属于org.apache.commons.digester包,在下文中一共展示了Rule类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.apache.commons.digester.Rule; //导入依赖的package包/类
public void parse() {
  String path = System.getProperty("user.dir") + File.separator  + "etc";
  File file = new File(path, "MyDocument-1.xml");

  Digester digester = new Digester();
  try {
    Rule rule = new MyRule();
    digester.addRule("book", rule);
    //digester.addRule("a/b", rule);
    digester.parse(file);
  }
  catch(Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:16,代码来源:UseDigesterExample.java

示例2: addRuleInstances

import org.apache.commons.digester.Rule; //导入依赖的package包/类
public void addRuleInstances(Digester digester) {
    final String ruleClassName = Rule.class.getName();
    digester.addFactoryCreate("*/bean-property-setter-byAttrname-rule", new BeanPropertySetterRuleFactory());
    digester.addRule("*/bean-property-setter-byAttrname-rule", new PatternRule("pattern"));
    digester.addSetNext("*/bean-property-setter-byAttrname-rule", "add", ruleClassName);

    digester.addFactoryCreate("*/object-create-rule-with-init", new ObjectCreateRuleFactoryWithInit());
    digester.addRule("*/object-create-rule-with-init", new PatternRule("pattern"));
    digester.addSetNext("*/object-create-rule-with-init", "add", ruleClassName);

    super.addRuleInstances(digester);
}
 
开发者ID:blusechen,项目名称:venus,代码行数:13,代码来源:DigesterRuleParser.java

示例3: createObject

import org.apache.commons.digester.Rule; //导入依赖的package包/类
public Object createObject(Attributes attributes) throws Exception {
    Rule beanPropertySetterRule = null;
    String propertyname = attributes.getValue("propertyname");
    String attrname = attributes.getValue("attrname");
    if (propertyname == null && attrname == null) {
        // call the setter method corresponding to the element name.
        beanPropertySetterRule = new BeanPropertySetterRule();
    } else {
        beanPropertySetterRule = new BeanPropertySetterRule(propertyname, attrname);
    }

    return beanPropertySetterRule;
}
 
开发者ID:blusechen,项目名称:venus,代码行数:14,代码来源:BeanPropertySetterRuleFactory.java

示例4: addOldArgRules

import org.apache.commons.digester.Rule; //导入依赖的package包/类
/**
 * Create a <code>Rule</code> to handle <code>arg0-arg3</code>
 * elements. This will allow validation.xml files that use the
 * versions of the DTD prior to Validator 1.2.0 to continue
 * working.
 */
private void addOldArgRules(Digester digester) {

    // Create a new rule to process args elements
    Rule rule = new Rule() {
        @Override
        public void begin(String namespace, String name,
                           Attributes attributes) throws Exception {
            // Create the Arg
            Arg arg = new Arg();
            arg.setKey(attributes.getValue("key"));
            arg.setName(attributes.getValue("name"));
            if ("false".equalsIgnoreCase(attributes.getValue("resource"))) {
                arg.setResource(false);
            }
            try {
                final int length = "arg".length(); // skip the arg prefix
                arg.setPosition(Integer.parseInt(name.substring(length)));
            } catch (Exception ex) {
                getLog().error("Error parsing Arg position: "
                           + name + " " + arg + " " + ex);
            }

            // Add the arg to the parent field
            ((Field)getDigester().peek(0)).addArg(arg);
        }
    };

    // Add the rule for each of the arg elements
    digester.addRule(ARGS_PATTERN + "0", rule);
    digester.addRule(ARGS_PATTERN + "1", rule);
    digester.addRule(ARGS_PATTERN + "2", rule);
    digester.addRule(ARGS_PATTERN + "3", rule);

}
 
开发者ID:ManfredTremmel,项目名称:gwt-commons-validator,代码行数:41,代码来源:ValidatorResources.java

示例5: setDigesterRules

import org.apache.commons.digester.Rule; //导入依赖的package包/类
public void setDigesterRules(Digester d) {
	Rule attributeChecker=new AttributeCheckingRule();

	d.addFactoryCreate("*/monitoring",new CreationFactory());
	d.addSetProperties("*/monitoring");
	d.addSetTop("*/monitoring","register");
	d.addRule("*/monitoring", attributeChecker);

	d.addRule("*/monitoring/destinations",new DestinationCleanup());

	d.addObjectCreate("*/destination","className",IMonitorAdapter.class);
	d.addSetProperties("*/destination");
	d.addSetTop("*/destination","register");
	d.addRule("*/destination", attributeChecker);

	d.addObjectCreate("*/destination/sender","className",ISender.class);
	d.addSetProperties("*/destination/sender");
	d.addSetNext("*/destination/sender","setSender");
	d.addRule("*/destination/sender", attributeChecker);

	d.addObjectCreate("*/monitor",Monitor.class);
	d.addSetProperties("*/monitor");
	d.addSetTop("*/monitor","register");
	d.addRule("*/monitor", attributeChecker);

	d.addObjectCreate("*/alarm",Trigger.class);
	d.addSetProperties("*/alarm");
	d.addSetNext("*/alarm","registerAlarm");
	d.addRule("*/alarm", attributeChecker);

	d.addCallMethod("*/alarm/events/event", "addEventCode", 0);


	d.addObjectCreate("*/clearing",Trigger.class);
	d.addSetProperties("*/clearing");
	d.addSetNext("*/clearing","registerClearing");
	d.addRule("*/clearing", attributeChecker);

	d.addCallMethod("*/clearing/events/event", "addEventCode", 0);

	d.addObjectCreate("*/trigger",Trigger.class);
	d.addSetProperties("*/trigger");
	d.addSetNext("*/trigger","registerTrigger");
	d.addRule("*/trigger", attributeChecker);

	d.addCallMethod("*/trigger/events/event", "addEventCode", 0);

	d.addObjectCreate("*/adapterfilter",AdapterFilter.class);
	d.addSetProperties("*/adapterfilter");
	d.addSetNext("*/adapterfilter","registerAdapterFilter");
	d.addRule("*/adapterfilter", attributeChecker);

	d.addSetNext("*/adapterfilter/sources","setFilteringToLowerLevelObjects");
	d.addCallMethod("*/adapterfilter/sources/source", "registerSubOject", 0);

}
 
开发者ID:ibissource,项目名称:iaf,代码行数:57,代码来源:MonitorManager.java

示例6: getDigester

import org.apache.commons.digester.Rule; //导入依赖的package包/类
public Digester getDigester(Configuration configuration) throws SAXNotSupportedException, SAXNotRecognizedException {
	Digester digester = new Digester();
	digester.setUseContextClassLoader(true);
	digester.push(configuration);

	URL digesterRulesURL = ClassUtils.getResourceURL(this, getDigesterRules());
	FromXmlRuleSet ruleSet = new FromXmlRuleSet(digesterRulesURL);
	digester.addRuleSet(ruleSet);

	Rule attributeChecker = new AttributeCheckingRule();
	digester.addRule("*/jmsRealms", attributeChecker);
	digester.addRule("*/jmsRealm", attributeChecker);
	digester.addRule("*/sapSystem", attributeChecker);
	digester.addRule("*/adapter", attributeChecker);
	digester.addRule("*/pipeline", attributeChecker);
	digester.addRule("*/errorMessageFormatter", attributeChecker);
	digester.addRule("*/receiver", attributeChecker);
	digester.addRule("*/sender", attributeChecker);
	digester.addRule("*/listener", attributeChecker);
	digester.addRule("*/postboxSender", attributeChecker);
	digester.addRule("*/postboxListener", attributeChecker);
	digester.addRule("*/errorSender", attributeChecker);
	digester.addRule("*/messageLog", attributeChecker);
	digester.addRule("*/inProcessStorage", attributeChecker);
	digester.addRule("*/errorStorage", attributeChecker);
	digester.addRule("*/pipe", attributeChecker);
	digester.addRule("*/readerFactory", attributeChecker);
	digester.addRule("*/manager", attributeChecker);
	digester.addRule("*/manager/flow", attributeChecker);
	digester.addRule("*/recordHandler", attributeChecker);
	digester.addRule("*/resultHandler", attributeChecker);
	digester.addRule("*/forward", attributeChecker);
	digester.addRule("*/child", attributeChecker);
	digester.addRule("*/param", attributeChecker);
	digester.addRule("*/pipeline/exits/exit", attributeChecker);
	digester.addRule("*/scheduler/job", attributeChecker);
	digester.addRule("*/locker", attributeChecker);
	digester.addRule("*/directoryCleaner", attributeChecker);
	digester.addRule("*/statistics", attributeChecker);
	digester.addRule("*/handler", attributeChecker);
	digester.addRule("*/cache", attributeChecker);
	digester.addRule("*/inputValidator", attributeChecker);
	digester.addRule("*/outputValidator", attributeChecker);
	digester.addRule("*/inputWrapper", attributeChecker);
	digester.addRule("*/outputWrapper", attributeChecker);
	if (MonitorManager.getInstance().isEnabled()) {
		MonitorManager.getInstance().setDigesterRules(digester);
	}

	boolean validation = AppConstants.getInstance().getBoolean(CONFIGURATION_VALIDATION_KEY, false);
	if (validation) {
		digester.setValidating(true);
		digester.setNamespaceAware(true);
		digester.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
		digester.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", "AdapterFramework.xsd");
		XmlErrorHandler xeh = new XmlErrorHandler();
		digester.setErrorHandler(xeh);
	}

	return digester;
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:62,代码来源:ConfigurationDigester.java

示例7: add

import org.apache.commons.digester.Rule; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void add(String pattern, Rule rule)
{
    super.add(_caseSensitive ? pattern : pattern.toLowerCase(), rule);
}
 
开发者ID:flex-rental-solutions,项目名称:apache-ddlutils,代码行数:8,代码来源:DigesterRules.java


注:本文中的org.apache.commons.digester.Rule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。