Java Code Examples for org.apache.commons.digester3.Digester#addSetNext()

The following examples show how to use org.apache.commons.digester3.Digester#addSetNext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TagmeConfig.java    From tagme with Apache License 2.0 6 votes vote down vote up
protected static void setRules(Digester d)
{
	d.addObjectCreate("tagme", Config.class);

	d.addCallMethod("tagme/logConfiguration", "setLoggingFilePath", 0);
	d.addCallMethod("tagme/stopword", "setStopwordDir", 0);
	d.addCallMethod("tagme/repository", "setRepositoryDir", 0);

	d.addCallMethod("tagme/inits/class", "addInit", 0);
	d.addCallMethod("tagme/langs/lang", "addLang", 0);

	d.addObjectCreate("tagme/setting", ParamSetting.class);
	d.addSetNext("tagme/setting", "addSetting", ParamSetting.class.getName());
	d.addCallMethod("tagme/setting", "setName", 1);
	d.addCallParam("tagme/setting", 0, "name");

	d.addCallMethod("tagme/setting/param", "addParam", 2);
	d.addCallParam("tagme/setting/param", 0, "name");
	d.addCallParam("tagme/setting/param", 1, "value");

}
 
Example 2
Source File: FindBugsParser.java    From analysis-model with MIT License 6 votes vote down vote up
/**
 * Pre-parses a file for some information not available from the FindBugs parser. Creates a mapping of FindBugs
 * warnings to messages. A bug is represented by its unique hash code. Also obtains original categories for bug
 * types.
 *
 * @param file
 *         the FindBugs XML file
 *
 * @return the map of warning messages
 * @throws SAXException
 *         if the file contains no valid XML
 * @throws IOException
 *         signals that an I/O exception has occurred.
 */
@VisibleForTesting
List<XmlBugInstance> preParse(final Reader file) throws SAXException, IOException {
    Digester digester = new SecureDigester(FindBugsParser.class);

    String rootXPath = "BugCollection/BugInstance";
    digester.addObjectCreate(rootXPath, XmlBugInstance.class);
    digester.addSetProperties(rootXPath);

    String fileXPath = rootXPath + "/LongMessage";
    digester.addCallMethod(fileXPath, "setMessage", 0);

    digester.addSetNext(rootXPath, "add", Object.class.getName());
    ArrayList<XmlBugInstance> bugs = new ArrayList<>();
    digester.push(bugs);
    digester.parse(file);

    return bugs;
}
 
Example 3
Source File: DupFinderParser.java    From analysis-model with MIT License 6 votes vote down vote up
@Override
protected void configureParser(final Digester digester) {
    String duplicationXPath = "*/DuplicatesReport/Duplicates/Duplicate";
    digester.addObjectCreate(duplicationXPath, Duplicate.class);
    digester.addSetProperties(duplicationXPath, "Cost", "cost");
    digester.addSetNext(duplicationXPath, "add");

    String fragmentXPath = duplicationXPath + "/Fragment";
    digester.addObjectCreate(fragmentXPath, Fragment.class);
    digester.addBeanPropertySetter(fragmentXPath + "/FileName", "fileName");
    digester.addBeanPropertySetter(fragmentXPath + "/Text", "text");
    digester.addSetNext(fragmentXPath, "addFragment", Fragment.class.getName());

    String lineRangeXPath = fragmentXPath + "/LineRange";
    digester.addObjectCreate(lineRangeXPath, Range.class);
    digester.addSetProperties(lineRangeXPath, "Start", "start");
    digester.addSetProperties(lineRangeXPath, "End", "end");
    digester.addSetNext(lineRangeXPath, "setLineRange", Range.class.getName());

    String offsetRangeXPath = fragmentXPath + "/OffsetRange";
    digester.addObjectCreate(offsetRangeXPath, Range.class);
    digester.addSetProperties(offsetRangeXPath, "Start", "start");
    digester.addSetProperties(offsetRangeXPath, "End", "end");
    digester.addSetNext(offsetRangeXPath, "setOffsetRange", Range.class.getName());
}
 
Example 4
Source File: NotificationHubDescription.java    From azure-notificationhubs-java-backend with Apache License 2.0 6 votes vote down vote up
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("*/FcmCredential", FcmCredential.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("*/FcmCredential", "setFcmCredential", FcmCredential.class.getName());
	digester.addSetNext("*/BaiduCredential", "setBaiduCredential", BaiduCredential.class.getName());
}
 
Example 5
Source File: Registration.java    From azure-notificationhubs-java-backend with Apache License 2.0 6 votes vote down vote up
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("*/FcmRegistrationDescription", "addRegistration");
	digester.addSetNext("*/FcmTemplateRegistrationDescription", "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");
}
 
Example 6
Source File: NotificationHubJob.java    From azure-notificationhubs-java-backend with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 7
Source File: RuleSet.java    From formatter-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the rule instances.
 *
 * @param digester
 *            the digester
 * 
 * @see org.apache.commons.digester3.RuleSetBase#addRuleInstances(org.apache.commons.digester3.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_SETTING, "id", "id");
    digester.addSetProperties(PROFILES_PROFILE_SETTING, "value", "value");
}
 
Example 8
Source File: CheckStyleParser.java    From analysis-model with MIT License 5 votes vote down vote up
@Override
public Report parse(final ReaderFactory readerFactory) throws ParsingException {
    Digester digester = new SecureDigester(CheckStyleParser.class);

    String rootXPath = "checkstyle";
    digester.addObjectCreate(rootXPath, CheckStyle.class);
    digester.addSetProperties(rootXPath);

    String fileXPath = "checkstyle/file";
    digester.addObjectCreate(fileXPath, File.class);
    digester.addSetProperties(fileXPath);
    digester.addSetNext(fileXPath, "addFile", File.class.getName());

    String bugXPath = "checkstyle/file/error";
    digester.addObjectCreate(bugXPath, Error.class);
    digester.addSetProperties(bugXPath);
    digester.addSetNext(bugXPath, "addError", Error.class.getName());

    try (Reader reader = readerFactory.create()) {
        CheckStyle checkStyle = digester.parse(reader);
        if (checkStyle == null) {
            throw new ParsingException("Input stream is not a Checkstyle file.");
        }

        return convert(checkStyle);
    }
    catch (IOException | SAXException exception) {
        throw new ParsingException(exception);
    }
}
 
Example 9
Source File: SimianParser.java    From analysis-model with MIT License 5 votes vote down vote up
@Override
protected void configureParser(final Digester digester) {
    String duplicationXPath = "*/simian/check/set";
    digester.addObjectCreate(duplicationXPath, Set.class);
    digester.addSetProperties(duplicationXPath);
    digester.addSetNext(duplicationXPath, "add");

    String fileXPath = duplicationXPath + "/block";
    digester.addObjectCreate(fileXPath, Block.class);
    digester.addSetProperties(fileXPath);
    digester.addSetNext(fileXPath, "addBlock", Block.class.getName());
}
 
Example 10
Source File: CpdParser.java    From analysis-model with MIT License 5 votes vote down vote up
@Override
protected void configureParser(final Digester digester) {
    String duplicationXPath = "*/pmd-cpd/duplication";
    digester.addObjectCreate(duplicationXPath, Duplication.class);
    digester.addSetProperties(duplicationXPath);
    digester.addCallMethod(duplicationXPath + "/codefragment", "setCodeFragment", 0);
    digester.addSetNext(duplicationXPath, "add");

    String fileXPath = duplicationXPath + "/file";
    digester.addObjectCreate(fileXPath, SourceFile.class);
    digester.addSetProperties(fileXPath);
    digester.addSetNext(fileXPath, "addFile", SourceFile.class.getName());
}
 
Example 11
Source File: XmlFactoryConfigurationRuleSet.java    From velocity-tools with Apache License 2.0 5 votes vote down vote up
/**
 * <p>Add the set of Rule instances defined in this RuleSet to the
 * specified <code>Digester</code> instance, associating them with
 * our namespace URI (if any).  This method should only be called
 * by a Digester instance.  These rules assume that an instance of
 * <code>org.apache.velocity.tools.view.ToolboxManager</code> is pushed
 * onto the evaluation stack before parsing begins.</p>
 *
 * @param digester Digester instance to which the new Rule instances
 *        should be added.
 */
public void addRuleInstances(Digester digester)
{
    // create the config objects
    digester.addObjectCreate("tools/property", propertyClass);
    digester.addObjectCreate("tools/*/property", propertyClass);
    digester.addObjectCreate("tools/data", dataClass);
    digester.addObjectCreate("tools/toolbox", toolboxConfigurationClass);
    digester.addObjectCreate("tools/toolbox/tool", toolConfigurationClass);

    // to apply matching attributes to specific setters of config objects
    digester.addSetProperties("tools/property");
    digester.addSetProperties("tools/*/property");
    digester.addSetProperties("tools");
    digester.addSetProperties("tools/data");
    digester.addSetProperties("tools/toolbox");
    digester.addSetProperties("tools/toolbox/tool", "class", "classname");

    // to add all attributes to config via setProperty(name,value)
    digester.addRule("tools", new PropertyAttributeRule());
    digester.addRule("tools/toolbox", new PropertyAttributeRule());
    digester.addRule("tools/toolbox/tool", new PropertyAttributeRule());

    // for config data & properties whose values are in the body of the tag
    digester.addRule("tools/data", new DataValueInBodyRule());
    digester.addRule("tools/*/property", new DataValueInBodyRule());

    // to finish a config and move on to the next
    digester.addSetNext("tools/property", "addProperty");
    digester.addSetNext("tools/*/property", "addProperty");
    digester.addSetNext("tools/data", "addData");
    digester.addSetNext("tools/toolbox", "addToolbox");
    digester.addSetNext("tools/toolbox/tool", "addTool");
}
 
Example 12
Source File: NotificationHubDescription.java    From azure-notificationhubs-java-backend with Apache License 2.0 4 votes vote down vote up
private static void setupCollectionParser(Digester digester){	
	digester.addObjectCreate("*/feed", LinkedList.class);
	setupSingleEntryParser(digester);
	digester.addSetNext("*/entry", "add", NotificationHubDescription.class.getName());
}
 
Example 13
Source File: NotificationHubJob.java    From azure-notificationhubs-java-backend with Apache License 2.0 4 votes vote down vote up
private static void setupCollectionParser(Digester digester){	
	digester.addObjectCreate("*/feed", LinkedList.class);
	setupSingleEntryParser(digester);
	digester.addSetNext("*/entry", "add", NotificationHubJob.class.getName());
}
 
Example 14
Source File: NotificationTelemetry.java    From azure-notificationhubs-java-backend with Apache License 2.0 4 votes vote down vote up
private static void setupParser(Digester digester){
	digester.addObjectCreate("*/NotificationDetails", NotificationTelemetry.class);
	digester.addCallMethod("*/NotificationId", "setNotificationId",1);
	digester.addCallParam("*/NotificationId", 0);
	digester.addCallMethod("*/Location", "setLocation",1);
	digester.addCallParam("*/Location", 0);
	digester.addCallMethod("*/State", "setNotificationStatusFromString",1);
	digester.addCallParam("*/State", 0);
	digester.addCallMethod("*/EnqueueTime", "setEnqueueTimeFromString",1);
	digester.addCallParam("*/EnqueueTime", 0);
	digester.addCallMethod("*/StartTime", "setStartTimeFromString",1);
	digester.addCallParam("*/StartTime", 0);
	digester.addCallMethod("*/EndTime", "setEndTimeFromString",1);
	digester.addCallParam("*/EndTime", 0);
	digester.addCallMethod("*/NotificationBody", "setNotificationBody",1);
	digester.addCallParam("*/NotificationBody", 0);
	digester.addCallMethod("*/TargetPlatforms", "setTargetPlatforms",1);
	digester.addCallParam("*/TargetPlatforms", 0);
	digester.addCallMethod("*/PnsErrorDetailsUri", "setPnsErrorDetailsUri",1);
	digester.addCallParam("*/PnsErrorDetailsUri", 0);
	
	digester.addObjectCreate("*/ApnsOutcomeCounts", HashMap.class);		
	digester.addCallMethod("*/Outcome", "put",2, new Class[]{String.class, Integer.class} );
	digester.addCallParam("*/Name", 0);
	digester.addCallParam("*/Count", 1);
	digester.addSetNext("*/ApnsOutcomeCounts", "setApnsOutcomeCounts", Map.class.getName());
	
	digester.addObjectCreate("*/MpnsOutcomeCounts", HashMap.class);		
	digester.addCallMethod("*/Outcome", "put",2, new Class[]{String.class, Integer.class} );
	digester.addCallParam("*/Name", 0);
	digester.addCallParam("*/Count", 1);
	digester.addSetNext("*/MpnsOutcomeCounts", "setMpnsOutcomeCounts", Map.class.getName());
	
	digester.addObjectCreate("*/WnsOutcomeCounts", HashMap.class);		
	digester.addCallMethod("*/Outcome", "put",2, new Class[]{String.class, Integer.class} );
	digester.addCallParam("*/Name", 0);
	digester.addCallParam("*/Count", 1);
	digester.addSetNext("*/WnsOutcomeCounts", "setWnsOutcomeCounts", Map.class.getName());
	
	digester.addObjectCreate("*/GcmOutcomeCounts", HashMap.class);		
	digester.addCallMethod("*/Outcome", "put",2, new Class[]{String.class, Integer.class} );
	digester.addCallParam("*/Name", 0);
	digester.addCallParam("*/Count", 1);
	digester.addSetNext("*/GcmOutcomeCounts", "setGcmOutcomeCounts", Map.class.getName());
	
	digester.addObjectCreate("*/FcmOutcomeCounts", HashMap.class);		
	digester.addCallMethod("*/Outcome", "put",2, new Class[]{String.class, Integer.class} );
	digester.addCallParam("*/Name", 0);
	digester.addCallParam("*/Count", 1);
	digester.addSetNext("*/FcmOutcomeCounts", "setFcmOutcomeCounts", Map.class.getName());

	digester.addObjectCreate("*/AdmOutcomeCounts", HashMap.class);		
	digester.addCallMethod("*/Outcome", "put",2, new Class[]{String.class, Integer.class} );
	digester.addCallParam("*/Name", 0);
	digester.addCallParam("*/Count", 1);
	digester.addSetNext("*/AdmOutcomeCounts", "setAdmOutcomeCounts", Map.class.getName());

	digester.addObjectCreate("*/BaiduOutcomeCounts", HashMap.class);		
	digester.addCallMethod("*/Outcome", "put",2, new Class[]{String.class, Integer.class} );
	digester.addCallParam("*/Name", 0);
	digester.addCallParam("*/Count", 1);
	digester.addSetNext("*/BaiduOutcomeCounts", "setBaiduOutcomeCounts", Map.class.getName());
}