Package gri.tasks

Examples of gri.tasks.ParameterDef


      return outputs;
    }
   
    public TaskDef getTaskDef() {
      TaskDef taskDef = new TaskDef();
      taskDef.addInput(new ParameterDef("x", Types.INTEGER));
      taskDef.addInput(new ParameterDef("y", Types.INTEGER));
      taskDef.addOutput(new ParameterDef("result", Types.INTEGER));
      return taskDef;
    }
View Full Code Here


       
        Object returnValue = targetMethod.invoke(targetObject, params);
       
        Map outputs = new HashMap();
        if (methodDef.hasReturnType()) {
          ParameterDef outputDef = methodDef.getReturnType();
          outputs.put(outputDef.getName(), returnValue);
        }
       
        return outputs;
    }
View Full Code Here

        //method
        ParameterDef [] params = targetMethodDef.getParameterDefs();
        for(int i=0; i<params.length; i++)
            def.addInput(params[i]);
           
        ParameterDef returnType = targetMethodDef.getReturnType();
        if (returnType != null)
            def.addOutput(returnType);
       
        return def;
    }
View Full Code Here

    }
    /**
     * Returns true if the given parameter is the target method return value
     */
    public boolean isMethodReturnParam(String name) {
        ParameterDef returnType = this.targetMethodDef.getReturnType();
        return returnType != null && returnType.getName().equals(name);
    }
View Full Code Here

      Map outputs = new HashMap();
     
      //add return value:
      MethodDefinition methodDef = config.getTargetMethodDef();
      if (methodDef.hasReturnType()) {
        ParameterDef returnDef = methodDef.getReturnType();
        outputs.put(returnDef.getName(), returnValue);
      }
     
      //add properties:
      if (config.hasPropertyBinding()) {
        PropertyBindingDef binding = config.getPropertyBinding();
View Full Code Here

   *   <return>...</return>
   * </method>
   */
  protected MethodDefinition parseMethod(Element elem) throws InvalidXMLException {
    List params = new ArrayList();
    ParameterDef returnType = null;

    List children = elem.getChildren();
    Element child;
    for (int i=0; i<children.size(); i++) {
      child = (Element)children.get(i);
View Full Code Here

    for (int i=0; i<children.size(); i++) {
      child = (Element)children.get(i);
      String name = child.getName().toLowerCase();

      if (name.equals("input") || name.equals("output")) {
        ParameterDef param = parseParameter(child);

        String propName = child.getAttributeValue("property");
        if (propName == null)
          propName = param.getName();

        if (name.equals("input")) {
          Method method = getSetter(klass, propName, param);
          propDef.setInput(param, method);
        }
View Full Code Here

    if (defaultElem != null)
      defaultValue = parseValue(defaultElem.getText(), dataType.getRepresentationClass());

    //create parameter:

    ParameterDef param = new ParameterDef(name, dataType, description);

    if (displayName != null)
      param.setDisplayName(displayName);

    if (options != null) {
      for (int i=0; i<options.size(); i++)
        param.addOption((Option)options.get(i));
    }

    if (defaultValue != null)
      param.setDefaultValue(defaultValue);

    return param;
  }
View Full Code Here

    public static void test1() throws Exception {
      //define a method of type: 
      //  String method(String text)
        MethodDefinition methodDef = new MethodDefinition();
       
        ParameterDef inDef = new ParameterDef("text", Types.STRING);
        ParameterDef outDef = new ParameterDef("output", Types.STRING);
        methodDef.setParameterDefs(new ParameterDef [] {inDef});
        methodDef.setReturnType(outDef);
       
        //acquire method reference:
        test_java obj = new test_java();
View Full Code Here

        Constructor constructor = targetClass.getConstructor(new Class [] {String.class});
       
        //define method:
        //    String write(String message)
        MethodDefinition targetMethodDef = new MethodDefinition();
        ParameterDef inDef = new ParameterDef("message", Types.STRING);
        ParameterDef outDef = new ParameterDef("output", Types.STRING);
        targetMethodDef.setParameterDefs(new ParameterDef [] {inDef});
        targetMethodDef.setReturnType(outDef);
       
        //define constructor:
        //     TestClass(String prefix)
        MethodDefinition constructorDef = new MethodDefinition();
        ParameterDef prefixDef = new ParameterDef("prefix", Types.STRING);
        constructorDef.setParameterDefs(new ParameterDef [] {prefixDef});
       
        //define property bindings:
        //    void   setSuffix(String suffix)
        //    String getValue()
        PropertyBindingDef propertyDef = new PropertyBindingDef();
        propertyDef.setInput(new ParameterDef("suffix", Types.STRING),
                ParameterUtil.getSetter(targetClass, "suffix", String.class));
        propertyDef.setOutput(new ParameterDef("value", Types.STRING),
                ParameterUtil.getGetter(targetClass, "value", String.class));
       
        //execute:
        ObjectInvocationConfig config = new ObjectInvocationConfig(
                targetClass, constructor, targetMethod,
View Full Code Here

TOP

Related Classes of gri.tasks.ParameterDef

Copyright © 2018 www.massapicom. 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.