Examples of CallMethodRule


Examples of org.apache.commons.digester.CallMethodRule

                targetOffset = Integer.parseInt(targetOffsetStr);
            }

            if (attributes.getValue("paramcount") == null) {
                // call against empty method
                callMethodRule = new CallMethodRule(targetOffset, methodName);
           
            } else {
                int paramCount = Integer.parseInt(attributes.getValue("paramcount"));
               
                String paramTypesAttr = attributes.getValue("paramtypes");
                if (paramTypesAttr == null || paramTypesAttr.length() == 0) {
                    callMethodRule = new CallMethodRule(targetOffset, methodName, paramCount);
                } else {
                    String[] paramTypes = getParamTypes(paramTypesAttr);
                    callMethodRule = new CallMethodRule(
                        targetOffset, methodName, paramCount, paramTypes);
                }
            }
            return callMethodRule;
        }
View Full Code Here

Examples of org.apache.commons.digester.CallMethodRule

        expander.addSource("$", mutableSource);
        digester.setSubstitutor(new VariableSubstitutor(expander));

        int useRootObj = -1;
        Class<?>[] callerArgTypes = new Class[] {String.class, String.class};
        CallMethodRule caller = new CallMethodRule(useRootObj, "addProperty",
            callerArgTypes.length, callerArgTypes);
        digester.addRule("root/property", caller);
        digester.addCallParam("root/property", 0, "name");
        digester.addCallParam("root/property", 1, "value");
View Full Code Here

Examples of org.apache.commons.digester.CallMethodRule

       
        d.addObjectCreate("*/metrics/metric", CprMetricResult.class);
        d.addSetProperties("*/metrics/metric/result");
        d.addBeanPropertySetter("*/metrics/metric/state");
       
        CallMethodRule metricRule = new CallMethodRule(1, "addMetric", 2);
        d.addRule("*/metrics/metric", metricRule);
        d.addCallParam("*/metrics/metric", 0 , "name");
        d.addCallParam("*/metrics/metric", 1, true);  
       
       
//            <metric id="121" name="valueSetMatch_1">
//            <result state="ok">true</result>
//            </metric>

       
        CallMethodRule r = new CallMethodRule(1, "addProperty", 2);
        d.addRule("*/set/property", r);
        d.addCallParam("*/set/property", 0 , "name");
        d.addCallParam("*/set/property",1,true);

       
View Full Code Here

Examples of org.apache.commons.digester.CallMethodRule

   
            addCreateUpload(digester, "*/experiment/results/result", null, DigitalObject.class);
            addCreateUpload(digester, "*/result/xcdlDescription", "setXcdlDescription", XcdlDescription.class);
   
            // call function addUpload of ExperimentWrapper
            CallMethodRule r = new CallMethodRule(1, "addResult", 2)//method with two params
            // every time  */experiment/uploads/upload  is encountered
            digester.addRule("*/experiment/results/result", r);
            // use attribute "key" as first param
            digester.addCallParam("*/experiment/results/result", 0 , "key");
            // and the object on stack (DigitalObject) as the second
            digester.addCallParam("*/experiment/results/result",1,true);
   
    //        addCreateUpload(digester, "*/experiment/xcdlDescriptions/xcdlDescription", null, XcdlDescription.class);
    //        // call function addXcdlDescription of ExperimentWrapper
    //        r = new CallMethodRule(1, "addXcdlDescription", 2);  //method with two params
    //        // every time  */experiment/xcdlDescriptions/xcdlDescription  is encountered
    //        digester.addRule("*/experiment/xcdlDescriptions/xcdlDescription", r);
    //        // use attribute "key" as first param
    //        digester.addCallParam("*/experiment/xcdlDescriptions/xcdlDescription", 0 , "key");
    //        // and the object on stack (DigitalObject) as the second
    //        digester.addCallParam("*/experiment/xcdlDescriptions/xcdlDescription",1,true);
   
           
            digester.addObjectCreate("*/experiment/detailedInfos/detailedInfo", DetailedExperimentInfo.class);
            digester.addSetProperties("*/experiment/detailedInfos/detailedInfo");
            digester.addBeanPropertySetter("*/experiment/detailedInfos/detailedInfo/programOutput");
            digester.addBeanPropertySetter("*/experiment/detailedInfos/detailedInfo/cpr");
           
            // call function "addDetailedInfo" of ExperimentWrapper
            r = new CallMethodRule(1, "addDetailedInfo", 2)//method with two params
            // every time  */experiment/detailedInfos/detailedInfo is encountered
            digester.addRule("*/experiment/detailedInfos/detailedInfo", r);
            // use attribute "key" as first param
            digester.addCallParam("*/experiment/detailedInfos/detailedInfo", 0 , "key");
            // and the object on stack as second parameter
            digester.addCallParam("*/experiment/detailedInfos/detailedInfo",1,true);
   
            // read contained measurements:
            digester.addObjectCreate("*/detailedInfo/measurements/measurement", Measurement.class);
            digester.addSetNext("*/detailedInfo/measurements/measurement", "put");
            // values are defined with wild-cards, and therefore set automatically       
            digester.addObjectCreate("*/measurement/property", MeasurableProperty.class);
            digester.addSetProperties("*/measurement/property");
            digester.addSetNext("*/measurement/property", "setProperty");
            // scales are defined with wild-cards, and therefore set automatically
           
            /*
             * for each value type a set of rules
             * because of FreeStringValue we need to store the value as XML-element
             * instead of an attribute
             * naming them "ResultValues" wasn't nice too
             */
            addCreateValue(digester, BooleanValue.class, "setValue");
            addCreateValue(digester, FloatRangeValue.class, "setValue");
            addCreateValue(digester, IntegerValue.class, "setValue");
            addCreateValue(digester, IntRangeValue.class, "setValue");
            addCreateValue(digester, OrdinalValue.class, "setValue");
            addCreateValue(digester, PositiveFloatValue.class, "setValue");
            addCreateValue(digester, PositiveIntegerValue.class, "setValue");
            addCreateValue(digester, YanValue.class, "setValue");
            addCreateValue(digester, FreeStringValue.class, "setValue");
   
           
            // go no go decision
            digester.addObjectCreate("*/plan/decision", Decision.class);
            digester.addSetProperties("*/plan/decision");
            digester.addSetNext("*/plan/decision", "setDecision");
   
            digester.addCallMethod("*/plan/decision/actionNeeded", "setActionNeeded", 0);
            digester.addCallMethod("*/plan/decision/reason", "setReason", 0);
   
            digester.addFactoryCreate("*/plan/decision/goDecision", GoDecisionFactory.class);
            digester.addSetNext("*/plan/decision/goDecision", "setDecision");
   
   
            // evaluation
            digester.addObjectCreate("*/plan/evaluation", Evaluation.class);
            digester.addSetProperties("*/plan/evaluation");
            digester.addSetNext("*/plan/evaluation", "setEvaluation");
   
            digester.addCallMethod("*/plan/evaluation/comment", "setComment", 0);
   
            // importance weighting
            digester.addObjectCreate("*/plan/importanceWeighting", ImportanceWeighting.class);
            digester.addSetProperties("*/plan/importanceWeighting");
            digester.addSetNext("*/plan/importanceWeighting", "setImportanceWeighting");
   
            digester.addCallMethod("*/plan/importanceWeighting/comment", "setComment", 0);
   
            // recommendation
            digester.addObjectCreate("*/plan/recommendation", RecommendationWrapper.class);
            digester.addSetProperties("*/plan/recommendation");
            digester.addSetNext("*/plan/recommendation", "setRecommendation");
   
            digester.addCallMethod("*/plan/recommendation/reasoning", "setReasoning", 0);
            digester.addCallMethod("*/plan/recommendation/effects", "setEffects", 0);
   
            // transformation
            digester.addObjectCreate("*/plan/transformation", Transformation.class);
            digester.addSetProperties("*/plan/transformation");
            digester.addSetNext("*/plan/transformation", "setTransformation");
   
            digester.addCallMethod("*/plan/transformation/comment", "setComment", 0);
   
   
            // Tree
            /* Some rules for tree parsing are necessary for importing templates too,
             * that's why they are added by this static method. */
            ProjectImporter.addTreeParsingRulesToDigester(digester);
   
            digester.addObjectCreate("*/leaf/evaluation", HashMap.class);
            digester.addSetNext("*/leaf/evaluation", "setValueMap");
            /*
             *  The valueMap has an entry for each (considered) alternative ...
             *  and for each alternative there is a list of values, one per SampleObject.
             *  Note: The digester uses a stack, therefore the rule to put the list of values to the valueMap
             *  must be added after the rule for adding the values to the list.
             */
   
            /*
             * 2. and for each alternative there is a list of values, one per SampleObject
             */
            digester.addObjectCreate("*/leaf/evaluation/alternative", Values.class);
            digester.addCallMethod("*/leaf/evaluation/alternative/comment", "setComment", 0);
   
            /*
             *  for each result-type a set of rules
             *  they are added to the valueMap by the rules above
             */
            addCreateResultValue(digester, BooleanValue.class);
            addCreateResultValue(digester, FloatValue.class);
            addCreateResultValue(digester, FloatRangeValue.class);
            addCreateResultValue(digester, IntegerValue.class);
            addCreateResultValue(digester, IntRangeValue.class);
            addCreateResultValue(digester, OrdinalValue.class);
            addCreateResultValue(digester, PositiveFloatValue.class);
            addCreateResultValue(digester, PositiveIntegerValue.class);
            addCreateResultValue(digester, YanValue.class);
            addCreateResultValue(digester, FreeStringValue.class);
   
            /*
             * 1. The valueMap has an entry for each (considered) alternative ...
             */
            // call put of the ValueMap (HashMap)
            r = new CallMethodRule(1, "put", 2);
            digester.addRule("*/leaf/evaluation/alternative", r);
            digester.addCallParam("*/leaf/evaluation/alternative", 0 , "key");
            digester.addCallParam("*/leaf/evaluation/alternative",1,true);
           
    //        digester.addObjectCreate("*/plan/executablePlan/planWorkflow", ExecutablePlanContentWrapper.class);
    //        digester.addSetProperties("*/plan/executablePlan/planWorkflow");
    //        digester.addSetNext("*/plan/executablePlan/planWorkflow", "setRecommendation");
   
            // Executable plan definition
            digester.addObjectCreate("*/plan/executablePlan", ExecutablePlanDefinition.class);
            digester.addSetProperties("*/plan/executablePlan");
            digester.addSetNext("*/plan/executablePlan", "setExecutablePlanDefinition");
           
            //
            // Import Planets executable plan if present
            //
            try {
                // object-create rules are called at the beginning element-tags, in the same order as defined
                // first create the wrapper
                digester.addObjectCreate("*/plan/executablePlan/planWorkflow", NodeContentWrapper.class);
                // then an element for workflowConf
                digester.addRule("*/plan/executablePlan/planWorkflow/workflowConf", new NodeCreateRule());
               
                // CallMethod and SetNext rules are called at closing element-tags, (last in - first out!)
               
                CallMethodRule rr = new CallMethodRule(1, "setNodeContent", 2);
                digester.addRule("*/plan/executablePlan/planWorkflow/workflowConf", rr);
                // right below the wrapper is an instance of ExecutablePlanDefinition 
                digester.addCallParam("*/plan/executablePlan/planWorkflow/workflowConf", 0 , 1);
                // provide the name of the setter method
                digester.addObjectParam("*/plan/executablePlan/planWorkflow/workflowConf", 1, "setExecutablePlan");
   
                // the generated node is not accessible as CallParam (why?!?), but available for addSetNext
                digester.addSetNext("*/plan/executablePlan/planWorkflow/workflowConf", "setNode");

            } catch (ParserConfigurationException e) {
                PlatoLogger.getLogger(this.getClass()).error(e.getMessage(),e);
            }

            //
            // Import EPrints executable plan if present
            //
            try {
               
                digester.addObjectCreate("*/plan/executablePlan/eprintsPlan", NodeContentWrapper.class);
                // then an element for workflowConf
                digester.addRule("*/plan/executablePlan/eprintsPlan", new NodeCreateRule());
               
                CallMethodRule rr2 = new CallMethodRule(1, "setNodeContentEPrintsPlan", 2);
                digester.addRule("*/plan/executablePlan/eprintsPlan", rr2);
                // right below the wrapper is an instance of ExecutablePlanDefinition 
                digester.addCallParam("*/plan/executablePlan/eprintsPlan", 0 , 1);
                // provide the name of the setter method
                digester.addObjectParam("*/plan/executablePlan/eprintsPlan", 1, "setEprintsExecutablePlan");
View Full Code Here

Examples of org.apache.commons.digester.CallMethodRule

                LinkedHashMap.class);
        digester.addSetNext("*/ordinalTransformer/mappings", "setMapping");
        digester.addFactoryCreate("*/mappings/mapping",
                OrdinalTransformerMappingFactory.class);

        digester.addRule("*/mappings/mapping", new CallMethodRule(1, "put", 2)); // method
                                                                                 // with
                                                                                 // two
                                                                                 // params
        digester.addCallParam("*/mappings/mapping", 0, "ordinal"); // use
                                                                   // attribute
View Full Code Here

Examples of org.apache.commons.digester3.CallMethodRule

        expander.addSource( "$", mutableSource );
        digester.setSubstitutor( new VariableSubstitutor( expander ) );

        int useRootObj = -1;
        Class<?>[] callerArgTypes = new Class[] { String.class, String.class };
        CallMethodRule caller = new CallMethodRule( useRootObj, "addProperty", callerArgTypes.length, callerArgTypes );
        digester.addRule( "root/property", caller );
        digester.addCallParam( "root/property", 0, "name" );
        digester.addCallParam( "root/property", 1, "value" );

        digester.addObjectCreate( "root/bean", SimpleTestBean.class );
View Full Code Here

Examples of org.apache.commons.digester3.CallMethodRule

        expander.addSource( "$", mutableSource );
        digester.setSubstitutor( new VariableSubstitutor( expander ) );

        int useRootObj = -1;
        Class<?>[] callerArgTypes = new Class[] { String.class, String.class };
        CallMethodRule caller = new CallMethodRule( useRootObj, "addProperty", callerArgTypes.length, callerArgTypes );
        digester.addRule( "root/property", caller );
        digester.addCallParam( "root/property", 0, "name" );
        digester.addCallParam( "root/property", 1, "value" );

        digester.addObjectCreate( "root/bean", SimpleTestBean.class );
View Full Code Here

Examples of org.apache.commons.digester3.CallMethodRule

     * {@inheritDoc}
     */
    @Override
    protected CallMethodRule createRule()
    {
        CallMethodRule callMethodRule = new CallMethodRule( targetOffset, methodName, paramCount, paramTypes );
        callMethodRule.setUseExactMatch( useExactMatch );
        return callMethodRule;
    }
View Full Code Here

Examples of org.apache.commons.digester3.CallMethodRule

        PlanParser.addCreateUpload(digester, "*/experiment/results/result", null, DigitalObject.class);
        PlanParser.addCreateUpload(digester, "*/result/xcdlDescription", "setXcdlDescription", XcdlDescription.class);

        // call function addUpload of ExperimentWrapper
        CallMethodRule r = new CallMethodRule(1, "addResult", 2); // method
                                                                  // with
                                                                  // two
                                                                  // params
        // every time */experiment/uploads/upload is encountered
        digester.addRule("*/experiment/results/result", r);
        // use attribute "key" as first param
        digester.addCallParam("*/experiment/results/result", 0, "key");
        // and the object on stack (DigitalObject) as the second
        digester.addCallParam("*/experiment/results/result", 1, true);

        // addCreateUpload(digester,
        // "*/experiment/xcdlDescriptions/xcdlDescription", null,
        // XcdlDescription.class);
        // // call function addXcdlDescription of ExperimentWrapper
        // r = new CallMethodRule(1, "addXcdlDescription", 2); //method with
        // two
        // params
        // // every time */experiment/xcdlDescriptions/xcdlDescription is
        // encountered
        // digester.addRule("*/experiment/xcdlDescriptions/xcdlDescription",
        // r);
        // // use attribute "key" as first param
        // digester.addCallParam("*/experiment/xcdlDescriptions/xcdlDescription",
        // 0 , "key");http://fue.onb.ac.at/abo/data
        // // and the object on stack (DigitalObject) as the second
        // digester.addCallParam("*/experiment/xcdlDescriptions/xcdlDescription",1,true);

        digester.addObjectCreate("*/experiment/detailedInfos/detailedInfo", DetailedExperimentInfo.class);
        digester.addSetProperties("*/experiment/detailedInfos/detailedInfo");
        digester.addBeanPropertySetter("*/experiment/detailedInfos/detailedInfo/programOutput");
        digester.addBeanPropertySetter("*/experiment/detailedInfos/detailedInfo/cpr");

        // call function "addDetailedInfo" of ExperimentWrapper
        r = new CallMethodRule(1, "addDetailedInfo", 2); // method with two
                                                         // params
        // every time */experiment/detailedInfos/detailedInfo is encountered
        digester.addRule("*/experiment/detailedInfos/detailedInfo", r);
        // use attribute "key" as first param
        digester.addCallParam("*/experiment/detailedInfos/detailedInfo", 0, "key");
        // and the object on stack as second parameter
        digester.addCallParam("*/experiment/detailedInfos/detailedInfo", 1, true);

        // read contained measurements:
        digester.addObjectCreate("*/detailedInfo/measurements/measurement", Measurement.class);
        digester.addSetProperties("*/detailedInfo/measurements/measurement");
        digester.addSetNext("*/detailedInfo/measurements/measurement", "put");
        // values are defined with wild-cards, and therefore set
        // automatically

        /*
         * for each value type a set of rules because of FreeStringValue we need
         * to store the value as XML-element instead of an attribute naming them
         * "ResultValues" wasn't nice too
         */
        PlanParser.addCreateValue(digester, BooleanValue.class, "setValue");
        PlanParser.addCreateValue(digester, FloatRangeValue.class, "setValue");
        PlanParser.addCreateValue(digester, IntegerValue.class, "setValue");
        PlanParser.addCreateValue(digester, IntRangeValue.class, "setValue");
        PlanParser.addCreateValue(digester, OrdinalValue.class, "setValue");
        PlanParser.addCreateValue(digester, PositiveFloatValue.class, "setValue");
        PlanParser.addCreateValue(digester, PositiveIntegerValue.class, "setValue");
        PlanParser.addCreateValue(digester, YanValue.class, "setValue");
        PlanParser.addCreateValue(digester, FreeStringValue.class, "setValue");

        // go no go decision
        digester.addObjectCreate("*/plan/decision", Decision.class);
        digester.addSetProperties("*/plan/decision");
        digester.addSetNext("*/plan/decision", "setDecision");

        digester.addCallMethod("*/plan/decision/actionNeeded", "setActionNeeded", 0);
        digester.addCallMethod("*/plan/decision/reason", "setReason", 0);

        digester.addFactoryCreate("*/plan/decision/goDecision", GoDecisionFactory.class);
        digester.addSetNext("*/plan/decision/goDecision", "setDecision");

        // evaluation
        digester.addObjectCreate("*/plan/evaluation", Evaluation.class);
        digester.addSetProperties("*/plan/evaluation");
        digester.addSetNext("*/plan/evaluation", "setEvaluation");

        digester.addCallMethod("*/plan/evaluation/comment", "setComment", 0);

        // importance weighting
        digester.addObjectCreate("*/plan/importanceWeighting", ImportanceWeighting.class);
        digester.addSetProperties("*/plan/importanceWeighting");
        digester.addSetNext("*/plan/importanceWeighting", "setImportanceWeighting");

        digester.addCallMethod("*/plan/importanceWeighting/comment", "setComment", 0);

        // recommendation
        digester.addObjectCreate("*/plan/recommendation", RecommendationWrapper.class);
        digester.addSetProperties("*/plan/recommendation");
        digester.addSetNext("*/plan/recommendation", "setRecommendation");

        digester.addCallMethod("*/plan/recommendation/reasoning", "setReasoning", 0);
        digester.addCallMethod("*/plan/recommendation/effects", "setEffects", 0);

        // transformation
        digester.addObjectCreate("*/plan/transformation", Transformation.class);
        digester.addSetProperties("*/plan/transformation");
        digester.addSetNext("*/plan/transformation", "setTransformation");

        digester.addCallMethod("*/plan/transformation/comment", "setComment", 0);

        // Tree
        /*
         * Some rules for tree parsing are necessary for importing templates
         * too, that's why they are added by this static method.
         */
        PlanParser.addTreeParsingRulesToDigester(digester);

        digester.addObjectCreate("*/leaf/evaluation", HashMap.class);
        digester.addSetNext("*/leaf/evaluation", "setValueMap");
        /*
         * The valueMap has an entry for each (considered) alternative ... and
         * for each alternative there is a list of values, one per SampleObject.
         * Note: The digester uses a stack, therefore the rule to put the list
         * of values to the valueMap must be added after the rule for adding the
         * values to the list.
         */

        /*
         * 2. and for each alternative there is a list of values, one per
         * SampleObject
         */
        digester.addObjectCreate("*/leaf/evaluation/alternative", Values.class);
        digester.addCallMethod("*/leaf/evaluation/alternative/comment", "setComment", 0);

        /*
         * for each result-type a set of rules they are added to the valueMap by
         * the rules above
         */
        PlanParser.addCreateResultValue(digester, BooleanValue.class);
        PlanParser.addCreateResultValue(digester, FloatValue.class);
        PlanParser.addCreateResultValue(digester, FloatRangeValue.class);
        PlanParser.addCreateResultValue(digester, IntegerValue.class);
        PlanParser.addCreateResultValue(digester, IntRangeValue.class);
        PlanParser.addCreateResultValue(digester, OrdinalValue.class);
        PlanParser.addCreateResultValue(digester, PositiveFloatValue.class);
        PlanParser.addCreateResultValue(digester, PositiveIntegerValue.class);
        PlanParser.addCreateResultValue(digester, YanValue.class);
        PlanParser.addCreateResultValue(digester, FreeStringValue.class);

        /*
         * 1. The valueMap has an entry for each (considered) alternative ...
         */
        // call put of the ValueMap (HashMap)
        r = new CallMethodRule(1, "put", 2);
        digester.addRule("*/leaf/evaluation/alternative", r);
        digester.addCallParam("*/leaf/evaluation/alternative", 0, "key");
        digester.addCallParam("*/leaf/evaluation/alternative", 1, true);

        // digester.addObjectCreate("*/plan/executablePlan/planWorkflow",
 
View Full Code Here

Examples of org.apache.commons.digester3.CallMethodRule

        digester.addObjectCreate("*/ordinalTransformer/mappings", LinkedHashMap.class);
        digester.addSetNext("*/ordinalTransformer/mappings", "setMapping");
        digester.addFactoryCreate("*/mappings/mapping", OrdinalTransformerMappingFactory.class);

        digester.addRule("*/mappings/mapping", new CallMethodRule(1, "put", 2)); // method
                                                                                 // with
                                                                                 // two
                                                                                 // params
        digester.addCallParam("*/mappings/mapping", 0, "ordinal"); // use
                                                                   // attribute
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.