Exemple #1
0
  @Override
  protected ParseResult parseNonEmptyToken(LoadContext context, KitTable kitTable, String value) {
    ParsingSeparator sep = new ParsingSeparator(value, '|');
    while (sep.hasNext()) {
      String thing = sep.next();
      if (thing.length() == 0) {
        return new ParseResult.Fail(
            getTokenName() + " arguments has invalid pipe separator: " + value, context);
      }
      KitGear optionInfo = new KitGear();
      for (String s : thing.split("[\\[\\]]")) {
        if (s.length() == 0) {
          continue;
        }
        int colonLoc = s.indexOf(':');
        if (colonLoc == -1) {
          return new ParseResult.Fail(
              "Expected colon in Value item: " + s + " within: " + value, context);
        }
        String key = s.substring(0, colonLoc);
        String thingValue = s.substring(colonLoc + 1);
        try {
          boolean passed = context.processToken(optionInfo, key, thingValue);
          if (!passed) {
            return new ParseResult.Fail("Failure in token: " + key, context);
          }
        } catch (PersistenceLayerException e) {
          return new ParseResult.Fail("Failure in token: " + key + " " + e.getMessage(), context);
        }
      }
      if (!sep.hasNext()) {
        return new ParseResult.Fail("Odd token count in Value: " + value, context);
      }
      String range = sep.next();
      if (!processRange(kitTable, optionInfo, range)) {
        return new ParseResult.Fail(
            "Invalid Range in Value: " + range + " within " + value, context);
      }
    }

    return ParseResult.SUCCESS;
  }