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


Java Digester.push方法代码示例

本文整理汇总了Java中org.apache.commons.digester3.Digester.push方法的典型用法代码示例。如果您正苦于以下问题:Java Digester.push方法的具体用法?Java Digester.push怎么用?Java Digester.push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.digester3.Digester的用法示例。


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

示例1: testLoadRules

import org.apache.commons.digester3.Digester; //导入方法依赖的package包/类
/**
 * JAVADOC Method Level Comments
 *
 * @throws Exception JAVADOC.
 */
@Test
public void testLoadRules()
    throws Exception {
    Resource rulesResource = new InputStreamResource(new ByteArrayInputStream(
                SIMPLE_RULES.getBytes()));
    DigesterRulesModule module = new DigesterRulesModule(rulesResource);
    DigesterLoader loader = DigesterLoader.newLoader(module);
    Digester digester = loader.newDigester();

    digester.push(new Container());

    Container cont = digester.parse(new StringReader(SIMPLE_DATA));

    assertNotNull("Container is null", cont);
    assertNotNull("startState is null", cont.getStartState());
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:22,代码来源:DigesterRulesModuleTest.java

示例2: build

import org.apache.commons.digester3.Digester; //导入方法依赖的package包/类
/**
 * Builds a Vocabulary from the supplied input stream
 *
 * @param is For the XML
 * @return The extension
 * @throws SAXException
 * @throws IOException
 * @throws ParserConfigurationException
 */
public Vocabulary build(InputStream is) throws IOException, SAXException, ParserConfigurationException {
  Digester digester = new Digester(saxf.newSAXParser());
  digester.setNamespaceAware(true);
  digester.setXIncludeAware(false);
  digester.setRuleNamespaceURI(VOCABULARY_NAMESPACE);

  Vocabulary tv = new Vocabulary();
  digester.push(tv);

  // build the thesaurus
  digester.addCallMethod("*/thesaurus", "setTitle", 1);
  digester.addRule("*/thesaurus", new CallParamNoNSRule(0, "title"));

  digester.addCallMethod("*/thesaurus", "setDescription", 1);
  digester.addRule("*/thesaurus", new CallParamNoNSRule(0, "description"));

  digester.addCallMethod("*/thesaurus", "setLink", 1);
  digester.addRule("*/thesaurus", new CallParamNoNSRule(0, "relation"));

  digester.addCallMethod("*/thesaurus", "setUri", 1);
  digester.addRule("*/thesaurus", new CallParamNoNSRule(0, "URI"));

  // build the concept
  digester.addObjectCreate("*/concept", VocabularyConcept.class);

  digester.addCallMethod("*/concept", "setLink", 1);
  digester.addRule("*/concept", new CallParamNoNSRule(0, "relation"));

  digester.addCallMethod("*/concept", "setDescription", 1);
  digester.addRule("*/concept", new CallParamNoNSRule(0, "description"));

  digester.addCallMethod("*/concept", "setUri", 1);
  digester.addRule("*/concept", new CallParamNoNSRule(0, "URI"));

  digester.addCallMethod("*/concept", "setIdentifier", 1);
  digester.addRule("*/concept", new CallParamNoNSRule(0, "identifier"));

  // build the terms
  digester.addObjectCreate("*/preferred/term", VocabularyTerm.class);
  VocabularyTerm t = new VocabularyTerm();

  digester.addCallMethod("*/preferred/term", "setLang", 1);
  digester.addRule("*/preferred/term", new CallParamNoNSRule(0, "lang"));

  digester.addCallMethod("*/preferred/term", "setTitle", 1);
  digester.addRule("*/preferred/term", new CallParamNoNSRule(0, "title"));

  digester.addSetNext("*/preferred/term", "addPreferredTerm");

  // build alternative terms
  digester.addObjectCreate("*/alternative/term", VocabularyTerm.class);
  VocabularyTerm talt = new VocabularyTerm();

  digester.addCallMethod("*/alternative/term", "setLang", 1);
  digester.addRule("*/alternative/term", new CallParamNoNSRule(0, "lang"));

  digester.addCallMethod("*/alternative/term", "setTitle", 1);
  digester.addRule("*/alternative/term", new CallParamNoNSRule(0, "title"));

  digester.addSetNext("*/alternative/term", "addAlternativeTerm");

  // add concept
  digester.addSetNext("*/concept", "addConcept");

  digester.parse(is);
  return tv;
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:77,代码来源:VocabularyFactory.java

示例3: build

import org.apache.commons.digester3.Digester; //导入方法依赖的package包/类
/**
 * Builds an extension from the supplied input stream
 *
 * @param is For the XML
 * @return The extension
 * @throws SAXException
 * @throws IOException
 * @throws ParserConfigurationException
 */
public Extension build(InputStream is, URL url, boolean dev) throws IOException, SAXException, ParserConfigurationException {

  // in order to deal with arbitrary namespace prefixes we need to parse namespace aware!
  Digester digester = new Digester(saxf.newSAXParser());
  digester.setRuleNamespaceURI(EXTENSION_NAMESPACE);

  Extension e = new Extension(url, dev);
  digester.push(e);

  digester.addCallMethod("*/extension", "setTitle", 1);
  digester.addRule("*/extension", new CallParamNoNSRule(0, "title"));

  digester.addCallMethod("*/extension", "setName", 1);
  digester.addCallParam("*/extension", 0, "name");

  digester.addCallMethod("*/extension", "setNamespace", 1);
  digester.addCallParam("*/extension", 0, "namespace");

  digester.addCallMethod("*/extension", "setRowType", 1);
  digester.addCallParam("*/extension", 0, "rowType");

  digester.addCallMethod("*/extension", "setLink", 1);
  digester.addRule("*/extension", new CallParamNoNSRule(0, "relation"));

  digester.addCallMethod("*/extension", "setDescription", 1);
  digester.addRule("*/extension", new CallParamNoNSRule(0, "description"));

  digester.addCallMethod("*/extension", "setSubject", 1);
  digester.addRule("*/extension", new CallParamNoNSRule(0, "subject"));

  // build the properties
  digester.addObjectCreate("*/property", ExtensionProperty.class);

  digester.addCallMethod("*/property", "setQualname", 1);
  digester.addCallParam("*/property", 0, "qualName");

  digester.addCallMethod("*/property", "setName", 1);
  digester.addCallParam("*/property", 0, "name");

  digester.addCallMethod("*/property", "setNamespace", 1);
  digester.addCallParam("*/property", 0, "namespace");

  digester.addCallMethod("*/property", "setGroup", 1);
  digester.addCallParam("*/property", 0, "group");

  digester.addCallMethod("*/property", "setType", 1);
  digester.addCallParam("*/property", 0, "type");

  digester.addCallMethod("*/property", "setRequired", 1);
  digester.addCallParam("*/property", 0, "required");

  digester.addCallMethod("*/property", "setLink", 1);
  digester.addRule("*/property", new CallParamNoNSRule(0, "relation"));

  digester.addCallMethod("*/property", "setDescription", 1);
  digester.addRule("*/property", new CallParamNoNSRule(0, "description"));

  digester.addCallMethod("*/property", "setExamples", 1);
  digester.addCallParam("*/property", 0, "examples");

  digester.addCallMethod("*/property", "setColumnLength", 1);
  digester.addCallParam("*/property", 0, "columnLength");

  // This is a special rule that will use the url2ThesaurusMap
  // to set the Vocabulary based on the attribute "thesaurus"
  digester.addRule("*/property", thesaurusRule);

  digester.addSetNext("*/property", "addProperty");

  digester.parse(is);
  return e;
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:82,代码来源:ExtensionFactory.java


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