Package gri.gridp.modules

Examples of gri.gridp.modules.Flag


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

    Flag flag = new Flag(paramName);

    //child elements:
    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"))
        flag.setTitle(child.getText());
      else if (name.equals("help"))
        flag.setHelp(child.getText());
      else if (name.equals("true-value"))
        flag.setTrueValue(child.getText());
      else if (name.equals("false-value"))
        flag.setFalseValue(child.getText());
      else if (name.equals("default")) {
        boolean value = child.getText().toLowerCase().equals("true");
        flag.setDefault(new Boolean(value));
      }
      else if (name.equals("scriptlet"))
        flag.setScriptlet(child.getText());
    }

    if (flag.getTrueValue() == null)
      throw new InvalidModuleException("Flag parameter must have 'true-value' specified to be useful");

    return flag;
  }
View Full Code Here


  protected String getTextValue(Parameter param, Object objValue) throws MissingParameterException, IOException {
    String textValue;

    //flag:
    if (param instanceof Flag) {
      Flag flagParam = (Flag)param;

      //obtain boolean value:
      Boolean value = (Boolean)objValue;
      if (value == null) {
        if (!flagParam.hasDefault())
          return null;

        value = flagParam.getDefault();
      }

      //translate boolean value to text we will put in script:
        textValue = flagParam.getValue(value.booleanValue());
        System.out.println("Flag text: " + textValue);
    }

    //basic parameter:
    else if (param instanceof BasicParameter)  {
View Full Code Here

            }
        }
       
        //flag (set type)
        else if (param instanceof Flag) {
            Flag flagParam = (Flag)param;
            System.out.println(flagParam);
            if (flagParam.hasDefault()) {
          System.out.println("flag default: " + flagParam.getDefault());
                newParam.setDefaultValue(flagParam.getDefault());
            }
        }
       
        return newParam;
    }
View Full Code Here

TOP

Related Classes of gri.gridp.modules.Flag

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.