Exemplo n.º 1
0
 private static ControlInfo parseAction(String string, PArray array) throws Exception {
   // optional array(1) is properties
   PMap properties;
   if (array.getSize() > 1) {
     properties = PMap.coerce(array.get(1));
   } else {
     properties = PMap.EMPTY;
   }
   return new ControlInfo(EMPTY_INFO, EMPTY_INFO, EMPTY_DEFAULTS, Type.Action, properties, string);
 }
Exemplo n.º 2
0
 private static ControlInfo valueOf(String string) throws ArgumentFormatException {
   try {
     PArray arr = PArray.valueOf(string);
     Type type = Type.valueOf(arr.get(0).toString());
     switch (type) {
       case Function:
         return parseFunction(string, arr);
       case Action:
         return parseAction(string, arr);
       default:
         return parseProperty(string, type, arr);
     }
   } catch (Exception ex) {
     throw new ArgumentFormatException(ex);
   }
 }
Exemplo n.º 3
0
  private String buildString() {

    switch (type) {
      case Action:
        return PArray.valueOf(PString.valueOf(type), properties).toString();
      case Function:
        return PArray.valueOf(
                PString.valueOf(type), PArray.valueOf(inputs), PArray.valueOf(outputs), properties)
            .toString();
      default:
        return PArray.valueOf(
                PString.valueOf(type),
                PArray.valueOf(outputs),
                PArray.valueOf(defaults),
                properties)
            .toString();
    }
  }
Exemplo n.º 4
0
 private static ControlInfo parseProperty(String string, Type type, PArray array)
     throws Exception {
   // array(1) is outputs
   PArray args = PArray.coerce(array.get(1));
   ArgumentInfo[] outputs = new ArgumentInfo[args.getSize()];
   for (int i = 0; i < outputs.length; i++) {
     outputs[i] = ArgumentInfo.coerce(args.get(i));
   }
   ArgumentInfo[] inputs = type == Type.ReadOnlyProperty ? EMPTY_INFO : outputs;
   // array(2) is defaults
   args = PArray.coerce(array.get(2));
   Argument[] defs = new Argument[args.getSize()];
   for (int i = 0; i < defs.length; i++) {
     defs[i] = PString.coerce(args.get(i));
   }
   // optional array(3) is properties
   PMap properties;
   if (array.getSize() > 3) {
     properties = PMap.coerce(array.get(3));
   } else {
     properties = PMap.EMPTY;
   }
   return new ControlInfo(inputs, outputs, defs, type, properties, string);
 }
Exemplo n.º 5
0
 private static ControlInfo parseFunction(String string, PArray array) throws Exception {
   // array(1) is inputs
   PArray args = PArray.coerce(array.get(1));
   ArgumentInfo[] inputs = new ArgumentInfo[args.getSize()];
   for (int i = 0; i < inputs.length; i++) {
     inputs[i] = ArgumentInfo.coerce(args.get(i));
   }
   // array(2) is outputs
   args = PArray.coerce(array.get(2));
   ArgumentInfo[] outputs = new ArgumentInfo[args.getSize()];
   for (int i = 0; i < outputs.length; i++) {
     outputs[i] = ArgumentInfo.coerce(args.get(i));
   }
   // optional array(3) is properties
   PMap properties;
   if (array.getSize() > 3) {
     properties = PMap.coerce(array.get(3));
   } else {
     properties = PMap.EMPTY;
   }
   return new ControlInfo(inputs, outputs, EMPTY_DEFAULTS, Type.Function, properties, string);
 }