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


Java Digester.parse方法代码示例

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


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

示例1: loadVenusService

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
private void loadVenusService(List<ServiceConfig> serviceConfigList, Map<String, InterceptorMapping> interceptors, Map<String, InterceptorStackConfig> interceptorStacks) {
    for (Resource config : configFiles) {
        RuleSet ruleSet = new FromXmlRuleSet(this.getClass().getResource("venusServerRule.xml"), new DigesterRuleParser());
        Digester digester = new Digester();
        digester.addRuleSet(ruleSet);

        try {
            InputStream is = config.getInputStream();
            Venus venus = (Venus) digester.parse(is);
            serviceConfigList.addAll(venus.getServiceConfigs());
            interceptors.putAll(venus.getInterceptors());
            interceptorStacks.putAll(venus.getInterceptorStatcks());
        } catch (Exception e) {
            throw new ConfigurationException("can not parser xml:" + config.getFilename(), e);
        }
    }
}
 
开发者ID:blusechen,项目名称:venus,代码行数:18,代码来源:XmlFileServiceManager.java

示例2: parseConfig

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
private void parseConfig(String publicId, String entityURL,
    String strutsConfig) {
    // Prepare a Digester for parsing a struts-config.xml file
    Digester digester = new Digester();

    digester.push(config);
    digester.setNamespaceAware(true);
    digester.setValidating(true);
    digester.addRuleSet(new ConfigRuleSet());
    digester.register(publicId,
        this.getClass().getResource(entityURL).toString());

    // Parse the test struts-config.xml file
    try {
        InputStream input =
            this.getClass().getResourceAsStream(strutsConfig);

        assertNotNull("Got an input stream for " + strutsConfig, input);
        digester.parse(input);
        input.close();
    } catch (Throwable t) {
        t.printStackTrace(System.out);
        fail("Parsing threw exception:  " + t);
    }
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:26,代码来源:TestModuleConfig.java

示例3: getWebworkPackages

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
/**
 * Parse file to webwork configuration
 *
 * @param webworkConfigurationFile Webwork configuration file
 * @return Webwork configuration package list
 * @throws IOException IOException
 * @throws SAXException SAXException
 */
@SuppressWarnings("unchecked")
public List<WebworkPackage> getWebworkPackages(File webworkConfigurationFile) throws IOException, SAXException {
	final Digester digester = new Digester();
	digester.addObjectCreate("xwork", ArrayList.class);
	digester.addObjectCreate("xwork/package", WebworkPackage.class);
	digester.addSetProperties("xwork/package", "name", "name");
	digester.addSetProperties("xwork/package", "namespace", "namespace");
	digester.addObjectCreate("xwork/package/action", WebworkAction.class);
	digester.addSetProperties("xwork/package/action", "name", "name");
	digester.addSetProperties("xwork/package/action", "class", "className");
	digester.addSetNext("xwork/package/action", "addAction");
	digester.addSetNext("xwork/package", "add");

	return (List<WebworkPackage>)digester.parse(webworkConfigurationFile);
}
 
开发者ID:unchai,项目名称:maven-precheck-plugin,代码行数:24,代码来源:WebworkConfigurationParser.java

示例4: processSources

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
/**
 * <p>Read xml configuration for source directories into SourceDirectory instances.</p>
 * <p/>
 * <p>package scope so that it could be individually tested</p>
 *
 * @param xml String xml to parse
 * @throws IOException  when an input/output error occurs
 * @throws SAXException when given xml can not be parsed
 */
void processSources(final String xml)
        throws IOException, SAXException {

    final Digester digester = getDigester();

    digester.addObjectCreate(XmlConfiguration.sources, ArrayList.class);
    digester.addObjectCreate(XmlConfiguration.source, SourceDirectory.class);
    digester.addCallMethod(XmlConfiguration.source, "setPath", 0);
    digester.addSetProperties(XmlConfiguration.source, "not-found", "notFound");
    digester.addSetNext(XmlConfiguration.source, "add");

    final StringReader reader = new StringReader(xml);
    Object o = digester.parse(reader);

    if ((o != null) && o instanceof List) {

        final List<SourceDirectory> parsedSources = (ArrayList<SourceDirectory>) o;

        for (final SourceDirectory sourceDirectory : parsedSources) {

            getSources().add(sourceDirectory);
        }
    }
}
 
开发者ID:AndyScherzinger,项目名称:architecturerules,代码行数:34,代码来源:DigesterConfigurationFactory.java

示例5: processRules

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
/**
 * <p>Process XML configuration to read rules elements into <code>Rules</code></p>
 * <p/>
 * <p>package scope so that it could be individually tested</p>
 *
 * @param xml String xml to parse
 * @throws IOException  when an input/output error occurs
 * @throws SAXException when given xml can not be parsed
 */
void processRules(final String xml)
        throws IOException, SAXException {

    final Digester digester = getDigester();

    digester.addObjectCreate(XmlConfiguration.rules, ArrayList.class);
    digester.addObjectCreate(XmlConfiguration.rule, Rule.class);
    digester.addSetProperties(XmlConfiguration.rule, "id", "idString");
    digester.addCallMethod(XmlConfiguration.ruleComment, "setComment", 0);
    digester.addCallMethod(XmlConfiguration.rulePackage, "addPackage", 0);
    digester.addCallMethod(XmlConfiguration.ruleViolation, "addViolation", 0);
    digester.addSetNext(XmlConfiguration.rule, "add");

    final StringReader reader = new StringReader(xml);

    Object o = digester.parse(reader);

    if (o != null) {

        final List<Rule> parsedRules = (ArrayList<Rule>) o;
        getRules().addAll(parsedRules);
    }
}
 
开发者ID:AndyScherzinger,项目名称:architecturerules,代码行数:33,代码来源:DigesterConfigurationFactory.java

示例6: parse

import org.apache.commons.digester.Digester; //导入方法依赖的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

示例7: main

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
public static void main(String[] args) {
  String path = System.getProperty("user.dir") + File.separator  + "etc";
  File file = new File(path, "employee2.xml");
  Digester digester = new Digester();
  digester.addRuleSet(new EmployeeRuleSet());
  try {
    Employee employee = (Employee) digester.parse(file);
    ArrayList offices = employee.getOffices();
    Iterator iterator = offices.iterator();
    System.out.println("-------------------------------------------------");
    while (iterator.hasNext()) {
      Office office = (Office) iterator.next();
      Address address = office.getAddress();
      System.out.println(office.getDescription());
      System.out.println("Address : " + 
        address.getStreetNumber() + " " + address.getStreetName());
      System.out.println("--------------------------------");
    }
    
  }
  catch(Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:25,代码来源:Test03.java

示例8: parseURL

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
private void parseURL(URL u) {
    Digester d = new Digester();
    d.setValidating(false);

    d.push(this);
    d.addObjectCreate("factory/template", HashMap.class);
    d.addRule("factory/template", new AttributeCopyRule());
    d.addSetNext("factory/template", "addFactoryTemplate");

    try {
        d.parse(u.openStream());
    }
    catch (Exception e) {
        throw new ManifestFactoryParseException("Unable to parse " +
                                                builder.getManifestFilename(), e);
    }
}
 
开发者ID:spacewalkproject,项目名称:spacewalk,代码行数:18,代码来源:ManifestFactory.java

示例9: main

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
public static void main(String[] args) {
  String path = System.getProperty("user.dir") + File.separator  + "etc";
  File file = new File(path, "employee1.xml");
  Digester digester = new Digester();
  // add rules
  digester.addObjectCreate("employee", "ex15.pyrmont.digestertest.Employee");
  digester.addSetProperties("employee");    
  digester.addCallMethod("employee", "printName");

  try {
    Employee employee = (Employee) digester.parse(file);
    System.out.println("First name : " + employee.getFirstName());
    System.out.println("Last name : " + employee.getLastName());
  }
  catch(Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:19,代码来源:Test01.java

示例10: load

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
/**
 * Load the contents of our configuration file.
 */
protected void load() {

    // Validate the existence of our configuration file
    File file = new File(pathname);
    if (!file.isAbsolute())
        file = new File(System.getProperty("catalina.base"), pathname);
    if (!file.exists() || !file.canRead()) {
        log("Cannot load configuration file " + file.getAbsolutePath());
        return;
    }

    // Load the contents of our configuration file
    Digester digester = new Digester();
    digester.setValidating(false);
    digester.addRuleSet(new MemoryRuleSet());
    try {
        digester.push(this);
        digester.parse(file);
    } catch (Exception e) {
        log("Error processing configuration file " +
            file.getAbsolutePath(), e);
        return;
    }

}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:29,代码来源:JAASMemoryLoginModule.java

示例11: parseXML

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
public static GoPluginDescriptor parseXML(InputStream pluginXML, String pluginJarFileLocation, File pluginBundleLocation, boolean isBundledPlugin) throws IOException, SAXException {
    Digester digester = initDigester();
    GoPluginDescriptorParser parserForThisXML = new GoPluginDescriptorParser(pluginJarFileLocation, pluginBundleLocation, isBundledPlugin);
    digester.push(parserForThisXML);

    digester.addCallMethod("go-plugin", "createPlugin", 2);
    digester.addCallParam("go-plugin", 0, "id");
    digester.addCallParam("go-plugin", 1, "version");

    digester.addCallMethod("go-plugin/about", "createAbout", 4);
    digester.addCallParam("go-plugin/about/name", 0);
    digester.addCallParam("go-plugin/about/version", 1);
    digester.addCallParam("go-plugin/about/target-go-version", 2);
    digester.addCallParam("go-plugin/about/description", 3);

    digester.addCallMethod("go-plugin/about/vendor", "createVendor", 2);
    digester.addCallParam("go-plugin/about/vendor/name", 0);
    digester.addCallParam("go-plugin/about/vendor/url", 1);

    digester.addCallMethod("go-plugin/about/target-os/value", "addTargetOS", 1);
    digester.addCallParam("go-plugin/about/target-os/value", 0);

    digester.parse(pluginXML);

    return parserForThisXML.descriptor;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:27,代码来源:GoPluginDescriptorParser.java

示例12: get

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
/**
 * Reading the checksum file (xml) from an InputSream and put it in a Map.
 * 
 * @param in
 * @return A Map with the file name as key and the checksum as value.
 */
public static Map<String, String> get(final InputStream in) {
	Digester digester = new Digester();
	digester.setValidating(false);
	digester.addObjectCreate("checksums", HashMap.class);
	digester.addCallMethod("checksums/file", "put", 2);
	digester.addCallParam("checksums/file/name", 0);
	digester.addCallParam("checksums/file/checksum", 1);
	try {
		@SuppressWarnings("unchecked")
		Map<String, String> checksums = (Map<String, String>) digester.parse(in);
		return checksums;
	} catch (Exception e) {
		throw new FatalException("Error while parsing checksums: " + e.getMessage(), e);
	}
}
 
开发者ID:th-schwarz,项目名称:pmcms,代码行数:22,代码来源:ChecksumTool.java

示例13: doPipe

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
@Override
   public PipeRunResult doPipe(Object input, IPipeLineSession session)
	throws PipeRunException {

	//Multi threading: instantiate digester for each request as the digester is NOT thread-safe.
	//TODO: make a pool of digesters
	Digester digester = DigesterLoader.createDigester(rulesURL);

	try {
		ByteArrayInputStream xmlInputStream =
			new ByteArrayInputStream(input.toString().getBytes());

		return new PipeRunResult(getForward(), digester.parse(xmlInputStream));

	} catch (Exception e) {
		throw new PipeRunException(this, getLogPrefix(session)+"exception in digesting", e);
	}
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:19,代码来源:DigesterPipe.java

示例14: getDefaultBook

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
public static OpeningBook getDefaultBook() {
	if(defaultBook != null) {
		return defaultBook;
	}

	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);
	}
}
 
开发者ID:BarrySW19,项目名称:CalculonX,代码行数:27,代码来源:OpeningBook.java

示例15: xmlConfiguration2Object

import org.apache.commons.digester.Digester; //导入方法依赖的package包/类
public void xmlConfiguration2Object()  throws SAXException
   {
       Digester digester = new Digester();
       digester.push(this);        
       digester.addCallMethod("datasources/datasource", "addDataConfigurationSource", 4 );
       digester.addCallParam("datasources/datasource/rutaFotos", 0);
       digester.addCallParam("datasources/datasource/rutaCarpetaFotos", 1);
       digester.addCallParam("datasources/datasource/rutaFotoNoExiste", 2);        
       digester.addCallParam("datasources/datasource/passPhrase", 3); 
try{	
           //java.io.InputStream xmlFile =  getClass().getResourceAsStream("xml/datasource.xml");
           java.io.InputStream xmlFile 
           =  new java.io.FileInputStream(gafetes.util.VariablesAmbiente.getArchivoConfiguracion());        
           digester.parse(xmlFile);
       }catch( java.io.IOException ioex ){
           System.out.println();
       }        
   }
 
开发者ID:developercancun,项目名称:credenjava,代码行数:19,代码来源:SampleDigester.java


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