Example #1
0
  /** execute */
  public CommandResult execute(CommandContext context) {
    // set output type
    context.setOutputType(getOutputType());

    CommandResult result = new CommandResult(this, context);

    // set result
    result.setOutputString(this.getExpansion());

    // indicate successful execution so that command result processing will work
    result.setExecutedSuccessfully(true);

    // grab input type so we can report back which input was used
    String inputTypeString = (String) context.get(CommandContext.INPUT_TYPE);
    InputType inputType = InputType.get(inputTypeString);

    result.setInputType(inputType);

    return result;
  }
Example #2
0
  public String simplifyPath(String path) {
    int[][] stateTable =
        new int[][] {
          {-1, 1, -1, -1},
          {-1, 1, 2, 3},
          {-1, 1, 2, 2},
          {-1, 5, 2, 4},
          {-1, 1, -1, -1},
          {-1, 1, -1, -1},
        };

    int state = 0;
    String ret = "";

    for (int i = 0; i < path.length(); i++) {
      InputType inputType;
      if (path.charAt(i) == '.') {
        inputType = InputType.DOT;
      } else if (path.charAt(i) == '/') {
        inputType = InputType.SLASH;
      } else {
        inputType = InputType.CHAR_SEQUENCE;
      }
      int prev = state;
      state = stateTable[state][inputType.getValue()];
      if (prev == state && state == 1) {
        continue;
      }
      ret += path.charAt(i);

      if (state == -1) {
        return "/";
      } else if (state == 5) {
        ret = ret.substring(0, ret.length() - 2);
        state = 1;

      } else if (state == 4) {
        int cn = 0;
        if (ret.length() == 3) {
          ret = "";
        }
        for (int j = ret.length() - 1; j >= 0; j--) {
          if (ret.charAt(j) == '/') {
            cn++;
          }
          if (cn == 2) {
            ret = ret.substring(0, j + 1);
            break;
          }
        }
        state = 1;
      }
      if (ret == "") {
        ret = "/";
      }
    }
    if (state == 3) {
      ret = ret.substring(0, ret.length() - 2);
    }
    if (state == 1 && ret.length() > 1) {
      ret = ret.substring(0, ret.length() - 1);
    }
    if (ret.isEmpty()) {
      ret = "/";
    }

    return ret;
  }
Example #3
0
 /**
  * Creates a new Chilitags3D object.
  *
  * @param width Camera image width
  * @param height Camera image height
  * @param processingWidth The camera image will be downsampled to this width before tag pose
  *     estimation
  * @param processingHeight The camera image will be downsampled to this height before tag pose
  *     estimation
  * @param inputType The type/color space of the input
  */
 public Chilitags3D(
     int width, int height, int processingWidth, int processingHeight, InputType inputType) {
   ptr = alloc(width, height, processingWidth, processingHeight, inputType.ordinal());
 }