public static ArraySliceOperation parse(String operation){ //check valid chars for (int i = 0; i < operation.length(); i++) { char c = operation.charAt(i); if( !isDigit(c) && c != '-' && c != ':'){ throw new InvalidPathException("Failed to parse SliceOperation: " + operation); } } String[] tokens = operation.split(":"); Integer tempFrom = tryRead(tokens, 0); Integer tempTo = tryRead(tokens, 1); Operation tempOperation; if (tempFrom != null && tempTo == null) { tempOperation = Operation.SLICE_FROM; } else if (tempFrom != null) { tempOperation = Operation.SLICE_BETWEEN; } else if (tempTo != null) { tempOperation = Operation.SLICE_TO; } else { throw new InvalidPathException("Failed to parse SliceOperation: " + operation); } return new ArraySliceOperation(tempFrom, tempTo, tempOperation); }
public static ArraySliceOperation parse(String operation){ //check valid chars for (int i = 0; i < operation.length(); i++) { char c = operation.charAt(i); if( !isDigit(c) && c != '-' && c != ':'){ throw new InvalidPathException("Failed to parse SliceOperation: " + operation); } } String[] tokens = operation.split(":"); Integer tempFrom = tryRead(tokens, 0); Integer tempTo = tryRead(tokens, 1); Operation tempOperpation; if(tempFrom != null && tempTo == null){ tempOperpation = Operation.SLICE_FROM; } else if(tempFrom != null && tempTo != null){ tempOperpation = Operation.SLICE_BETWEEN; } else if(tempFrom == null && tempTo != null){ tempOperpation = Operation.SLICE_TO; } else { throw new InvalidPathException("Failed to parse SliceOperation: " + operation); } return new ArraySliceOperation(tempFrom, tempTo, tempOperpation); }
public static ArraySliceOperation parse(String operation){ //check valid chars for (int i = 0; i < operation.length(); i++) { char c = operation.charAt(i); if( !isDigit(c) && c != '-' && c != ':'){ throw new InvalidPathException("Failed to parse SliceOperation: " + operation); } } String[] tokens = operation.split(":"); Integer tempFrom = tryRead(tokens, 0); Integer tempTo = tryRead(tokens, 1); Operation tempOperpation; if(tempFrom != null && tempTo == null){ tempOperpation = Operation.SLICE_FROM; } else if(tempFrom != null && tempTo != null){ tempOperpation = Operation.SLICE_BETWEEN; } else if(tempFrom == null && tempTo != null){ tempOperpation = Operation.SLICE_TO; } else { throw new InvalidPathException("Failed to parse SliceOperation: " + operation); } return new ArraySliceOperation(tempFrom, tempTo, tempOperpation); }