/** * Get the JSON prefix common to all constraints. * @param constraint the constraint to format. * @param code The constraint code. * @return The prefix */ protected String getCommonJsonConstraintPrefix(String code, PathConstraint constraint) { String path = constraint.getPath(); String op = constraint.getOp().toString(); return "{\"path\":\"" + path + "\",\"op\":\"" + op + "\",\"code\":\"" + code + "\""; }
Collection<String> values = PathConstraint.getValues(constraint); Collection<Integer> ids = PathConstraint.getIds(constraint); if (ids != null) { conb.append(",\"ids\":["); String value = PathConstraint.getValue(constraint); String extraValue = PathConstraint.getExtraValue(constraint); if (value != null) { if (constraint instanceof PathConstraintLoop) {
/** * format a type constraint to a JSON representation. * @param constraint the constraint to format. * @return The JSONification. */ protected String typeConstraintToJson(final PathConstraint constraint) { String path = constraint.getPath(); String type = PathConstraint.getType(constraint); return String.format("{\"path\":\"%s\",\"type\":\"%s\"}", path, type); }
private static String handleConstraintWithValue(PathConstraint pc) throws UnhandledFeatureException { ConstraintOp op = pc.getOp(); final String value = PathConstraint.getValue(pc); if (value == null) { throw new IllegalArgumentException("The constraint must have a value."); } return produceCallToConstraints(METHOD_NAMES.get(op), pc.getPath(), value); }
String path = qq(pc.getPath()); String op = qq(pc.getOp().toString()); Collection<String> values = PathConstraint.getValues(pc); if (values == null) { String value = qq(PathConstraint.getValue(pc)); String extraValue = qq(PathConstraint.getExtraValue(pc)); return prefix + ", " + value + ", " + extraValue + ", " + newCode + "));"; } else {
/** * {@inheritDoc} */ @Override public String toString() { return constraint.getPath() + " " + op + " " + value + " (" + extraValue + ", " + objectConstraint + ", " + bagConstraint + ") - " + switchOffAbility; }
throws UnhandledFeatureException { String className = TypeUtil.unqualifiedName(pc.getClass().toString()); String op = pc.getOp().toString(); String value = PathConstraint.getValue(pc); String extraValue = PathConstraint.getExtraValue(pc);
/** * Returns the Set of PathConstraintLoop objects that will participate in the QueryClass * collapsing mechanism. * * @param logic the constraint logic * @param constraints a Map from PathConstraint to code * @return a Set of PathConstraintLoop objects */ protected static Set<PathConstraintLoop> findParticipatingLoops(LogicExpression logic, Map<PathConstraint, String> constraints) { if (logic != null) { LogicExpression.Node node = logic.getRootNode(); Set<String> codes = new HashSet<String>(); findAndCodes(codes, node); Set<PathConstraintLoop> retval = new HashSet<PathConstraintLoop>(); for (Map.Entry<PathConstraint, String> entry : constraints.entrySet()) { if (codes.contains(entry.getValue())) { if (entry.getKey() instanceof PathConstraintLoop) { if (ConstraintOp.EQUALS.equals(entry.getKey().getOp())) { retval.add((PathConstraintLoop) entry.getKey()); } } } } return retval; } return Collections.emptySet(); }
/** * @param constraint constraint to convert * @param code code for constraint, e.g. A * @return constraint in JSON format */ protected String constraintToJson(PathConstraint constraint, String code) { if (PathConstraint.getType(constraint) != null) { // Would be nice to test code instead... return typeConstraintToJson(constraint); } else { return valueConstraintToJson(code, constraint); } }
String path = qq(pc.getPath()); String op = qq(pc.getOp().toString()); Collection<String> values = PathConstraint.getValues(pc); if (values == null) { String value = qq(PathConstraint.getValue(pc)); String extraValue = qq(PathConstraint.getExtraValue(pc)); return prefix + ", " + value + ", " + extraValue + ", " + newCode + "));"; } else {
/** * {@inheritDoc} */ @Override public String toString() { return constraint.getPath() + " " + op + " " + value + " (" + extraValue + ", " + objectConstraint + ", " + bagConstraint + ") - " + switchOffAbility; }
private static String handleConstraintWithValue(PathConstraint pc) throws UnhandledFeatureException { ConstraintOp op = pc.getOp(); final String value = PathConstraint.getValue(pc); if (value == null) { throw new IllegalArgumentException("The constraint must have a value."); } return produceCallToConstraints(METHOD_NAMES.get(op), pc.getPath(), value); }
throws UnhandledFeatureException { String className = TypeUtil.unqualifiedName(pc.getClass().toString()); String op = pc.getOp().toString(); String value = PathConstraint.getValue(pc); String extraValue = PathConstraint.getExtraValue(pc);
/** * Returns the Set of PathConstraintLoop objects that will participate in the QueryClass * collapsing mechanism. * * @param logic the constraint logic * @param constraints a Map from PathConstraint to code * @return a Set of PathConstraintLoop objects */ protected static Set<PathConstraintLoop> findParticipatingLoops(LogicExpression logic, Map<PathConstraint, String> constraints) { if (logic != null) { LogicExpression.Node node = logic.getRootNode(); Set<String> codes = new HashSet<String>(); findAndCodes(codes, node); Set<PathConstraintLoop> retval = new HashSet<PathConstraintLoop>(); for (Map.Entry<PathConstraint, String> entry : constraints.entrySet()) { if (codes.contains(entry.getValue())) { if (entry.getKey() instanceof PathConstraintLoop) { if (ConstraintOp.EQUALS.equals(entry.getKey().getOp())) { retval.add((PathConstraintLoop) entry.getKey()); } } } } return retval; } return Collections.emptySet(); }
/** * @param constraint constraint to convert * @param code code for constraint, e.g. A * @return constraint in JSON format */ protected String constraintToJson(PathConstraint constraint, String code) { if (PathConstraint.getType(constraint) != null) { // Would be nice to test code instead... return typeConstraintToJson(constraint); } else { return valueConstraintToJson(code, constraint); } }
String path = pc.getPath(); ConstraintOp op = pc.getOp(); String value = PathConstraint.getValue(pc); String extraValue = PathConstraint.getExtraValue(pc);
/** * Get the JSON prefix common to all constraints. * @param constraint the constraint to format. * @param code The constraint code. * @return The prefix */ protected String getCommonJsonConstraintPrefix(String code, PathConstraint constraint) { String path = constraint.getPath(); String op = constraint.getOp().toString(); return "{\"path\":\"" + path + "\",\"op\":\"" + op + "\",\"code\":\"" + code + "\""; }
/** * Get the paths of all editable constraints in this template. * * @return the nodes */ public synchronized List<String> getEditablePaths() { List<String> editablePaths = new ArrayList<String>(); for (PathConstraint constraint : editableConstraints) { if (!editablePaths.contains(constraint.getPath())) { editablePaths.add(constraint.getPath()); } } return editablePaths; }
Collection<String> values = PathConstraint.getValues(constraint); Collection<Integer> ids = PathConstraint.getIds(constraint); if (ids != null) { conb.append(",\"ids\":["); String value = PathConstraint.getValue(constraint); String extraValue = PathConstraint.getExtraValue(constraint); if (value != null) { if (constraint instanceof PathConstraintLoop) {
String key1 = pc.getOp().toString().toLowerCase().replace(" ", "_"); String val1 = null; String key2 = null; val1 = new PresentedList(((PathConstraintMultiValue) pc).getValues()).toString(); } else if ("PathConstraintNull".equals(className)) { if (ConstraintOp.IS_NULL.equals(pc.getOp())) { } else if (ConstraintOp.IS_NOT_NULL.equals(pc.getOp())) { + pc.getOp() + ")");