Exemplo n.º 1
0
 @Override
 public String[] unparse(LoadContext context, KitTable kitTable) {
   StringBuilder sb = new StringBuilder();
   List<TableEntry> list = kitTable.getList();
   if (list.isEmpty()) {
     return null;
   }
   boolean first = true;
   for (TableEntry rl : list) {
     if (!first) {
       sb.append(Constants.PIPE);
     }
     Collection<String> unparse = context.unparse(rl.gear);
     if (unparse.size() == 1) {
       sb.append(unparse.iterator().next());
     } else {
       for (String s : unparse) {
         sb.append('[');
         sb.append(s);
         sb.append(']');
       }
     }
     sb.append(Constants.PIPE);
     sb.append(rl.lowRange.toString());
     if (!rl.lowRange.equals(rl.highRange)) {
       sb.append(',');
       sb.append(rl.highRange.toString());
     }
     first = false;
   }
   return new String[] {sb.toString()};
 }
Exemplo n.º 2
0
 private boolean processRange(KitTable kitTable, KitGear optionInfo, String range) {
   if (isEmpty(range) || hasIllegalSeparator(',', range)) {
     return false;
   }
   ParsingSeparator sep = new ParsingSeparator(range, ',');
   String minString = sep.next();
   String maxString;
   if (sep.hasNext()) {
     maxString = sep.next();
   } else {
     maxString = range;
   }
   if (sep.hasNext()) {
     return false;
   }
   Formula min = FormulaFactory.getFormulaFor(minString);
   if (!min.isValid()) {
     Logging.errorPrint("Min Formula in " + getTokenName() + " was not valid: " + min.toString());
     return false;
   }
   Formula max = FormulaFactory.getFormulaFor(maxString);
   if (!max.isValid()) {
     Logging.errorPrint("Max Formula in " + getTokenName() + " was not valid: " + max.toString());
     return false;
   }
   kitTable.addGear(optionInfo, min, max);
   return true;
 }