Package gri.gridp.modules

Examples of gri.gridp.modules.BasicParameter


      throw new InvalidModuleException("Invalid parameter: missing required 'name' attribute");
    else
      paramName = nameAttribute.getValue();

    //create:
    BasicParameter param = new BasicParameter(paramName, type);

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

      if (name.equals("title"))
        param.setTitle(child.getText());
      else if (name.equals("help"))
        param.setHelp(child.getText());
      else if (name.equals("options"))  {
        ListSerializer serializer = new ListSerializer(
            new OptionSerializer(), "option");
        param.setOptionList(serializer.readList(child));
      }
      else if (name.equals("default"))
        param.setDefault(child.getText());
      else if (name.equals("scriptlet"))
        param.setScriptlet(child.getText());
    }

    //assume parameter is required if no scriptlet is present:
    param.setNullScriptlet(
        param.hasScriptlet() ?
            "" : null
    );

    return param;
  }
View Full Code Here


        System.out.println("Flag text: " + textValue);
    }

    //basic parameter:
    else if (param instanceof BasicParameter)  {
      BasicParameter basicParam = (BasicParameter)param;

      if (basicParam.getParameterType().equals("file")) {
        File file = (File)objValue;
        if (file == null)
          return null;

        if (!file.getParentFile().equals(this.workingDirectory)) {
          File newFile = new File(this.workingDirectory, file.getName());
          copy(file, newFile);
          textValue = newFile.getName();
        }
        else
          textValue = file.getName();
      }
      else {
        String value = (String)objValue;
        if (value == null) {
          if (!basicParam.hasDefault())
            return null;

          value = basicParam.getDefault();
        }

        //TODO: validate against options

        textValue = value;
View Full Code Here

  // ------------------------------------------------------- Test

  public static void main(String [] args) {
    try {
      BasicParameter p = new BasicParameter("param");
      p.setScriptlet("-p $param");
      p.setParameterType("string");

      gri.gridp.modules.Script script = new gri.gridp.modules.Script();
      script.setText("myprogram $param");

      Function f = new Function();
View Full Code Here

        newParam.setDisplayName(param.getTitle());
        newParam.setDescription(param.getHelp());
       
        //basic parameter (options & default):
        if (param instanceof BasicParameter) {
            BasicParameter basicParam = (BasicParameter)param;
           
            if (basicParam.hasDefault())
                newParam.setDefaultValue(basicParam.getDefault());
           
            if (basicParam.hasOptions()) {
                List options = basicParam.getOptionList();
                for (int i=0; i<options.size(); i++) {
                    gri.gridp.modules.Option option = (gri.gridp.modules.Option)options.get(i);
                    gri.tasks.Option newOption = new gri.tasks.Option(
                            option.getDisplayText(),
                            option.getValue()
View Full Code Here

TOP

Related Classes of gri.gridp.modules.BasicParameter

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.