public StringNode asStringNode() { throw new InvalidPathException("Expected string node"); }
public UndefinedNode asUndefinedNode() { throw new InvalidPathException("Expected undefined node"); }
public PathNode asPathNode() { throw new InvalidPathException("Expected path node"); }
public PredicateNode asPredicateNode() { throw new InvalidPathException("Expected predicate node"); }
public static boolean fail(String message) { throw new InvalidPathException(message); } }
public PatternNode asPatternNode() { throw new InvalidPathException("Expected regexp node"); }
public JsonNode asJsonNode() { throw new InvalidPathException("Expected json node"); }
public BooleanNode asBooleanNode() { throw new InvalidPathException("Expected boolean node"); }
public NullNode asNullNode() { throw new InvalidPathException("Expected null node"); }
public NumberNode asNumberNode() { throw new InvalidPathException("Expected number node"); }
public ValueListNode asValueListNode() { throw new InvalidPathException("Expected value list node"); }
public ClassNode asClassNode() { throw new InvalidPathException("Expected class node"); }
private static Integer parseInteger(String token) { try { return Integer.parseInt(token); } catch (Exception e){ throw new InvalidPathException("Failed to parse token in ArrayIndexOperation: " + token, e); } } }
public PropertyPathToken(List<String> properties, char stringDelimiter) { if (properties.isEmpty()) { throw new InvalidPathException("Empty properties"); } this.properties = properties; this.stringDelimiter = Character.toString(stringDelimiter); }
public static LogicalOperator fromString(String operatorString){ if(AND.operatorString.equals(operatorString)) return AND; else if(NOT.operatorString.equals(operatorString)) return NOT; else if(OR.operatorString.equals(operatorString)) return OR; else throw new InvalidPathException("Failed to parse operator " + operatorString); } }
/** * Returns the function by name or throws InvalidPathException if function not found. * * @see #FUNCTIONS * @see PathFunction * * @param name * The name of the function * * @return * The implementation of a function * * @throws InvalidPathException */ public static PathFunction newFunction(String name) throws InvalidPathException { Class functionClazz = FUNCTIONS.get(name); if(functionClazz == null){ throw new InvalidPathException("Function with name: " + name + " does not exist."); } else { try { return (PathFunction)functionClazz.newInstance(); } catch (Exception e) { throw new InvalidPathException("Function of name: " + name + " cannot be created", e); } } } }
public static RelationalOperator fromString(String operatorString){ for (RelationalOperator operator : RelationalOperator.values()) { if(operator.operatorString.equals(operatorString.toUpperCase()) ){ return operator; } } throw new InvalidPathException("Filter operator " + operatorString + " is not supported!"); }
public static ArrayIndexOperation parse(String operation) { //check valid chars for (int i = 0; i < operation.length(); i++) { char c = operation.charAt(i); if (!isDigit(c) && c != ',' && c != ' ' && c != '-') { throw new InvalidPathException("Failed to parse ArrayIndexOperation: " + operation); } } String[] tokens = COMMA.split(operation, -1); List<Integer> tempIndexes = new ArrayList<Integer>(tokens.length); for (String token : tokens) { tempIndexes.add(parseInteger(token)); } return new ArrayIndexOperation(tempIndexes); }
/** * Parse the provided criteria * * Deprecated use {@link Filter#parse(String)} * * @param criteria * @return a criteria */ @Deprecated public static Criteria parse(String criteria) { if(criteria == null){ throw new InvalidPathException("Criteria can not be null"); } String[] split = criteria.trim().split(" "); if(split.length == 3){ return create(split[0], split[1], split[2]); } else if(split.length == 1){ return create(split[0], "EXISTS", "true"); } else { throw new InvalidPathException("Could not parse criteria"); } }
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); }