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


Java Digester类代码示例

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


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

示例1: parse

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
/**
 * <p>Parse the XML document at the specified URL using the configured
 * <code>RuleSet</code>, registering catalogs with nested chains and
 * commands as they are encountered.  Use this method <strong>only</strong>
 * if you have included one or more <code>factory</code> elements in your
 * configuration resource.</p>
 *
 * @param <K> the type of keys maintained by the context associated with this command
 * @param <V> the type of mapped values
 * @param <C> Type of the context associated with this command
 * @param url <code>URL</code> of the XML document to be parsed
 * @return a CatalogFactory instance parsed from the given location
 * @exception ChainConfigurationException if a parsing error occurs
 */
public <K extends String, V extends Object, C extends Map<K, V>> CatalogFactory<K, V, C> parse(URL url) {
    // Prepare our Digester instance
    Digester digester = getDigester();
    digester.clear();

    // Parse the configuration document
    try {
        digester.parse(url);
    } catch (Exception e) {
        String msg = String.format(
                "Error parsing digester configuration at url: %s",
                url);
        throw new ChainConfigurationException(msg, e);
    }
    // FIXME get rid of singleton pattern and create a new instance here
    return CatalogFactoryBase.getInstance();
}
 
开发者ID:Dotosoft,项目名称:dot4command-core,代码行数:32,代码来源:XmlConfigParser.java

示例2: describe4Digester

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
public static Digester describe4Digester(Digester digester, String base) throws Exception{
		String mybase = base;
        digester.addBeanPropertySetter( mybase+"/baseclass", "baseclass" );
        digester.addBeanPropertySetter( mybase+"/kind", "kind" );
        digester.addBeanPropertySetter( mybase+"/tag", "tag" );
        digester.addBeanPropertySetter( mybase+"/name", "name" );
        digester.addBeanPropertySetter( mybase+"/description", "description" );
        digester.addBeanPropertySetter( mybase+"/help", "help" );
		String tmp = mybase + "/entries/entry";
        digester.addObjectCreate( tmp , Entry.class );
        Entry.describe4Digester(digester, tmp);
        digester.addSetNext( tmp, "addEntry" );
        // Properties
		tmp = mybase + "/properties/property";
        digester.addObjectCreate( tmp , PropertyEntry.class );
        PropertyEntry.describe4Digester(digester, tmp);
        digester.addSetNext( tmp, "addProperty" );
        
        return digester;
}
 
开发者ID:PRTG,项目名称:JMXMiniProbe,代码行数:21,代码来源:Profile.java

示例3: createListNoAttribute

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
/**
 * JAVADOC Method Level Comments
 *
 * @throws Exception JAVADOC.
 */
@Test(expected = IllegalArgumentException.class)
public void createListNoAttribute()
    throws Exception {
    ListWrapper wrapper = new ListWrapper();
    Digester digester = mock(Digester.class);

    when(digester.peek()).thenReturn(wrapper);

    Attributes attributes = mock(Attributes.class);

    when(attributes.getValue("name")).thenReturn(null);

    CreateListFactory factory = new CreateListFactory();

    factory.setDigester(digester);
    factory.createObject(attributes);
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:23,代码来源:CreateListFactoryTest.java

示例4: createListNoPropertyWithName

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
/**
 * JAVADOC Method Level Comments
 *
 * @throws Exception JAVADOC.
 */
@Test(expected = IllegalArgumentException.class)
public void createListNoPropertyWithName()
    throws Exception {
    ListWrapper wrapper = new ListWrapper();
    Digester digester = mock(Digester.class);

    when(digester.peek()).thenReturn(wrapper);

    Attributes attributes = mock(Attributes.class);

    when(attributes.getValue("name")).thenReturn("rabbitch");

    CreateListFactory factory = new CreateListFactory();

    factory.setDigester(digester);
    factory.createObject(attributes);
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:23,代码来源:CreateListFactoryTest.java

示例5: 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

示例6: loadProfile

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
public static Profiles loadProfile(ProbeContext context, File inputFile){
		Profiles retVal = null;
		if(inputFile.exists()){
			System.out.println("Loading profile from["+inputFile.getAbsolutePath()+"]");
		    try {
		        Digester digester = getDigester();
		        retVal = (Profiles)digester.parse( inputFile );
		      } catch( Exception exc ) {
		        exc.printStackTrace();
		      }
		} else {
//			Logger.getRootLogger().debug("File does not exist["+inputFile.getAbsolutePath()+"]");
			System.out.println("File does not exist["+inputFile.getAbsolutePath()+"]");
		}
	    return retVal;
	}
 
开发者ID:PRTG,项目名称:JMXMiniProbe,代码行数:17,代码来源:ProfileFactory.java

示例7: describe4Digester

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
public static Digester describe4Digester(Digester digester, String base) throws Exception{
	String mybase = base;
       digester.addBeanPropertySetter( mybase+"/object", "object" );
       digester.addBeanPropertySetter( mybase+"/description", "description" );
       digester.addBeanPropertySetter( mybase+"/shortdescription", "shortDescription" );
       digester.addBeanPropertySetter( mybase+"/displayvalue", "displayValue" );
       digester.addBeanPropertySetter( mybase+"/comment", "comment" );
	String tmp = mybase + "/attributes/attribute";
	digester.addObjectCreate( tmp, StringAttribute.class );
       Attribute.describe4Digester(digester, tmp);
       digester.addSetNext( tmp, "addAttribute" );
       // Properties
	tmp = mybase + "/properties/property";
       digester.addObjectCreate( tmp , PropertyEntry.class );
       PropertyEntry.describe4Digester(digester, tmp);
       digester.addSetNext( tmp, "addProperty" );

       return digester;
}
 
开发者ID:PRTG,项目名称:JMXMiniProbe,代码行数:20,代码来源:Entry.java

示例8: setupSingleEntryParser

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
private static void setupSingleEntryParser(Digester digester){
	digester.addObjectCreate("*/entry", NotificationHubDescription.class);
	digester.addCallMethod("*/entry/title","setPath",1);
	digester.addCallParam("*/entry/title",0);
	digester.addObjectCreate("*/ApnsCredential", ApnsCredential.class);
	digester.addObjectCreate("*/AdmCredential", AdmCredential.class);
	digester.addObjectCreate("*/WnsCredential", WindowsCredential.class);
	digester.addObjectCreate("*/MpnsCredential", MpnsCredential.class);
	digester.addObjectCreate("*/GcmCredential", GcmCredential.class);
	digester.addObjectCreate("*/BaiduCredential", BaiduCredential.class);
	PnsCredential.setupDigister(digester);
	digester.addSetNext("*/ApnsCredential", "setApnsCredential", ApnsCredential.class.getName());
	digester.addSetNext("*/AdmCredential", "setAdmCredential", AdmCredential.class.getName());
	digester.addSetNext("*/WnsCredential", "setWindowsCredential", WindowsCredential.class.getName());
	digester.addSetNext("*/MpnsCredential", "setMpnsCredential", MpnsCredential.class.getName());
	digester.addSetNext("*/GcmCredential", "setGcmCredential", GcmCredential.class.getName());
	digester.addSetNext("*/BaiduCredential", "setBaiduCredential", BaiduCredential.class.getName());
}
 
开发者ID:Azure,项目名称:azure-notificationhubs-java-backend,代码行数:19,代码来源:NotificationHubDescription.java

示例9: addCollectionRules

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
private static void addCollectionRules(Digester digester) {
	digester.addObjectCreate("feed", CollectionResult.class);
	digester.addSetNext("*/RegistrationDescription", "addRegistration");
	digester.addSetNext("*/WindowsRegistrationDescription", "addRegistration");
	digester.addSetNext("*/WindowsTemplateRegistrationDescription", "addRegistration");
	digester.addSetNext("*/AppleRegistrationDescription", "addRegistration");
	digester.addSetNext("*/AppleTemplateRegistrationDescription", "addRegistration");
	digester.addSetNext("*/GcmRegistrationDescription", "addRegistration");
	digester.addSetNext("*/GcmTemplateRegistrationDescription", "addRegistration");
	digester.addSetNext("*/MpnsRegistrationDescription", "addRegistration");
	digester.addSetNext("*/MpnsTemplateRegistrationDescription", "addRegistration");
	digester.addSetNext("*/AdmRegistrationDescription", "addRegistration");
	digester.addSetNext("*/AdmTemplateRegistrationDescription", "addRegistration");
	digester.addSetNext("*/BaiduRegistrationDescription", "addRegistration");
	digester.addSetNext("*/BaiduTemplateRegistrationDescription", "addRegistration");
}
 
开发者ID:Azure,项目名称:azure-notificationhubs-java-backend,代码行数:17,代码来源:Registration.java

示例10: setupSingleEntryParser

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
private static void setupSingleEntryParser(Digester digester){
	digester.addObjectCreate("*/entry", NotificationHubJob.class);
	digester.addCallMethod("*/JobId", "setJobId",1);
	digester.addCallParam("*/JobId", 0);
	digester.addCallMethod("*/Progress", "setProgressFromString",1);
	digester.addCallParam("*/Progress", 0);
	digester.addCallMethod("*/Type", "setJobTypeFromString",1);
	digester.addCallParam("*/Type", 0);
	digester.addCallMethod("*/Status", "setJobStatusFromString",1);
	digester.addCallParam("*/Status", 0);
	digester.addCallMethod("*/OutputContainerUri", "setOutputContainerUri",1);
	digester.addCallParam("*/OutputContainerUri", 0);
	digester.addCallMethod("*/ImportFileUri", "setImportFileUri",1);
	digester.addCallParam("*/ImportFileUri", 0);
	digester.addCallMethod("*/Failure", "setFailure",1);
	digester.addCallParam("*/Failure", 0);
	digester.addCallMethod("*/CreatedAt", "setCreatedAtFromString",1);
	digester.addCallParam("*/CreatedAt", 0);
	digester.addCallMethod("*/UpdatedAt", "setUpdatedAtFromString",1);
	digester.addCallParam("*/UpdatedAt", 0);		
	digester.addObjectCreate("*/OutputProperties", HashMap.class);
	digester.addCallMethod("*/d3p1:KeyValueOfstringstring", "put",2);
	digester.addCallParam("*/d3p1:Key", 0);
	digester.addCallParam("*/d3p1:Value", 1);
	digester.addSetNext("*/OutputProperties", "setOutputProperties", Map.class.getName());
}
 
开发者ID:Azure,项目名称:azure-notificationhubs-java-backend,代码行数:27,代码来源:NotificationHubJob.java

示例11: addRuleInstances

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
/**
 * @see
 * org.apache.commons.digester.RuleSetBase#addRuleInstances(org.apache.commons.digester.Digester)
 */
@Override
public void addRuleInstances(Digester digester) {
    digester.addObjectCreate("profiles", Profiles.class);
    digester.addObjectCreate("profiles/profile", Profile.class);
    digester.addObjectCreate("profiles/profile/setting", Setting.class);

    digester.addSetNext("profiles/profile", "addProfile");
    digester.addSetNext("profiles/profile/setting", "addSetting");

    digester.addSetProperties("profiles/profile", "kind", "kind");
    digester.addSetProperties("profiles/profile", "name", "name");
    digester.addSetProperties("profiles/profile", "version", "version");
    digester.addSetProperties("profiles/profile/setting", "id", "id");
    digester.addSetProperties("profiles/profile/setting", "value", "value");
}
 
开发者ID:markiewb,项目名称:eclipsecodeformatter_for_netbeans,代码行数:20,代码来源:RuleSet.java

示例12: read

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
/**
 * Read from the
 * <code>input</code> and return it's configuration settings as a
 * {@link Map}.
 *
 * @param 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 SAXException
 * @throws IOException
 * @throws ConfigReadException
 */
public List<Profile> read(File normalizedFile) throws IOException, SAXException, ConfigReadException {
    Digester digester = new Digester();
    digester.addRuleSet(new RuleSet());
    Object result = null;
    InputStream configInput = FileUtil.toFileObject(normalizedFile).getInputStream();
    try {
        result = digester.parse(configInput);
    } finally {
        try {
            configInput.close();
        } catch (IOException e) {
        }
    }
    if (result == null && !(result instanceof Profiles)) {
        throw new ConfigReadException("No profiles found in config file");
    }
    Profiles profiles = (Profiles) result;
    return profiles.getProfiles();
}
 
开发者ID:markiewb,项目名称:eclipsecodeformatter_for_netbeans,代码行数:33,代码来源:ConfigReader.java

示例13: read

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
/**
 * Parses XML config of QSAdmin Plugin
 */
public static QSAdminPluginConfig read(File input) throws Exception {
	Digester digester = new Digester();
    digester.setValidating(false);

	String mainTag = "qsadmin-plugin";
	
	digester.addObjectCreate(mainTag, QSAdminPluginConfig.class);
	digester.addBeanPropertySetter(mainTag+"/name", "name");
	digester.addBeanPropertySetter(mainTag+"/desc", "desc");
	digester.addBeanPropertySetter(mainTag+"/type", "type");
	digester.addBeanPropertySetter(mainTag+"/main-class", "mainClass");
	digester.addBeanPropertySetter(mainTag+"/active", "active");
	

	logger.fine("Loading Plugin config from xml file : " + input.getAbsolutePath());
	QSAdminPluginConfig psc = (QSAdminPluginConfig) digester.parse(input);
	return psc;
}
 
开发者ID:QuickServerLab,项目名称:QuickServer-Main,代码行数:22,代码来源:PluginConfigReader.java

示例14: getDigester

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
/**
 * <p>Return the <code>Digester</code> instance to be used for
 * parsing, creating one if necessary.</p>
 * @return A Digester instance.
 */
public Digester getDigester() {
    Digester digester = new Digester();
    RuleSet ruleSet = getRuleSet();
    digester.setNamespaceAware(ruleSet.getNamespaceURI() != null);
    digester.setUseContextClassLoader(getUseContextClassLoader());
    digester.setValidating(false);
    digester.addRuleSet(ruleSet);
    return digester;
}
 
开发者ID:Dotosoft,项目名称:dot4command-core,代码行数:15,代码来源:XmlConfigParser.java

示例15: addChainRules

import org.apache.commons.digester3.Digester; //导入依赖的package包/类
private void addChainRules(Digester digester) {
    digester.addObjectCreate("*/" + getChainElement(),
            getChainClass(),
            getClassAttribute());
    digester.addSetProperties("*/" + getChainElement());
    digester.addRule("*/" + getChainElement(),
            new ConfigRegisterRule(nameAttribute));
}
 
开发者ID:Dotosoft,项目名称:dot4command-core,代码行数:9,代码来源:ConfigRuleSet.java


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