private void appendValue(RelationQueryNode node, StringBuffer b) { if (node.getValueType() == TYPE_LONG) { b.append(node.getLongValue()); } else if (node.getValueType() == TYPE_DOUBLE) { b.append(node.getDoubleValue()); } else if (node.getValueType() == TYPE_STRING) { b.append("'").append(node.getStringValue().replaceAll("'", "''")).append("'"); } else if (node.getValueType() == TYPE_DATE || node.getValueType() == TYPE_TIMESTAMP) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.setTime(node.getDateValue()); b.append("TIMESTAMP '").append(ISO8601.format(cal)).append("'"); } else { exceptions.add(new InvalidQueryException("Invalid type: " + node.getValueType())); } }
public Object visit(PropertyFunctionQueryNode node, Object data) { String functionName = node.getFunctionName(); if ((functionName.equals(PropertyFunctionQueryNode.LOWER_CASE) || functionName.equals(PropertyFunctionQueryNode.UPPER_CASE)) && rqn.getValueType() != QueryConstants.TYPE_STRING) { String msg = "Upper and lower case function are only supported with String literals"; exceptions.add(new InvalidQueryException(msg)); } return data; } }, null);
private void appendValue(RelationQueryNode node, StringBuffer b) { if (node.getValueType() == TYPE_LONG) { b.append(node.getLongValue()); } else if (node.getValueType() == TYPE_DOUBLE) { b.append(node.getDoubleValue()); } else if (node.getValueType() == TYPE_STRING) { b.append("'").append(node.getStringValue().replaceAll("'", "''")).append("'"); } else if (node.getValueType() == TYPE_DATE || node.getValueType() == TYPE_TIMESTAMP) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.setTime(node.getDateValue()); b.append("TIMESTAMP '").append(ISO8601.format(cal)).append("'"); } else { exceptions.add(new InvalidQueryException("Invalid type: " + node.getValueType())); } }
public Object visit(PropertyFunctionQueryNode node, Object data) { String functionName = node.getFunctionName(); if ((functionName.equals(PropertyFunctionQueryNode.LOWER_CASE) || functionName.equals(PropertyFunctionQueryNode.UPPER_CASE)) && rqn.getValueType() != QueryConstants.TYPE_STRING) { String msg = "Upper and lower case function are only supported with String literals"; exceptions.add(new InvalidQueryException(msg)); } return data; } }, null);
public Object visit(ASTUpperFunction node, Object data) { RelationQueryNode parent = (RelationQueryNode) data; if (parent.getValueType() != QueryConstants.TYPE_STRING) { String msg = "UPPER() function is only supported for String literal"; throw new IllegalArgumentException(msg); } parent.addOperand(factory.createPropertyFunctionQueryNode(parent, PropertyFunctionQueryNode.UPPER_CASE)); return parent; }
public Object visit(ASTUpperFunction node, Object data) { RelationQueryNode parent = (RelationQueryNode) data; if (parent.getValueType() != QueryConstants.TYPE_STRING) { String msg = "UPPER() function is only supported for String literal"; throw new IllegalArgumentException(msg); } parent.addOperand(factory.createPropertyFunctionQueryNode(parent, PropertyFunctionQueryNode.UPPER_CASE)); return parent; }
public Object visit(ASTLowerFunction node, Object data) { RelationQueryNode parent = (RelationQueryNode) data; if (parent.getValueType() != QueryConstants.TYPE_STRING) { String msg = "LOWER() function is only supported for String literal"; throw new IllegalArgumentException(msg); } parent.addOperand(factory.createPropertyFunctionQueryNode(parent, PropertyFunctionQueryNode.LOWER_CASE)); return parent; }
public Object visit(ASTLowerFunction node, Object data) { RelationQueryNode parent = (RelationQueryNode) data; if (parent.getValueType() != QueryConstants.TYPE_STRING) { String msg = "LOWER() function is only supported for String literal"; throw new IllegalArgumentException(msg); } parent.addOperand(factory.createPropertyFunctionQueryNode(parent, PropertyFunctionQueryNode.LOWER_CASE)); return parent; }
if (node.getValueType() == TYPE_LONG) { b.append(node.getLongValue()); } else if (node.getValueType() == TYPE_DOUBLE) { b.append(node.getDoubleValue()); } else if (node.getValueType() == TYPE_STRING) { b.append("'").append(node.getStringValue().replaceAll("'", "''")).append("'"); } else if (node.getValueType() == TYPE_DATE || node.getValueType() == TYPE_TIMESTAMP) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.setTime(node.getDateValue()); b.append(resolver.getJCRName(XPathQueryBuilder.XS_DATETIME)); b.append("('").append(ISO8601.format(cal)).append("')"); } else if (node.getValueType() == TYPE_POSITION) { if (node.getPositionValue() == LocationStepQueryNode.LAST) { b.append("last()"); exceptions.add(new InvalidQueryException("Invalid type: " + node.getValueType()));
if (node.getValueType() == TYPE_LONG) { b.append(node.getLongValue()); } else if (node.getValueType() == TYPE_DOUBLE) { b.append(node.getDoubleValue()); } else if (node.getValueType() == TYPE_STRING) { b.append("'").append(node.getStringValue().replaceAll("'", "''")).append("'"); } else if (node.getValueType() == TYPE_DATE || node.getValueType() == TYPE_TIMESTAMP) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.setTime(node.getDateValue()); b.append(resolver.getJCRName(XPathQueryBuilder.XS_DATETIME)); b.append("('").append(ISO8601.format(cal)).append("')"); } else if (node.getValueType() == TYPE_POSITION) { if (node.getPositionValue() == LocationStepQueryNode.LAST) { b.append("last()"); exceptions.add(new InvalidQueryException("Invalid type: " + node.getValueType()));
public Object visit(RelationQueryNode node, Object data) throws RepositoryException { StringBuffer buffer = (StringBuffer) data; buffer.append(PADDING, 0, indent); buffer.append("+ RelationQueryNode: Op: "); buffer.append(QueryConstants.OPERATION_NAMES.getName(node.getOperation())); buffer.append(" Prop=["); PathQueryNode relPath = node.getRelativePath(); if (relPath == null) { buffer.append(relPath); } else { visit(relPath, buffer); } buffer.append("] Type=").append(QueryConstants.TYPE_NAMES.getName(node.getValueType())); if (node.getValueType() == QueryConstants.TYPE_DATE) { buffer.append(" Value=").append(node.getDateValue()); } else if (node.getValueType() == QueryConstants.TYPE_DOUBLE) { buffer.append(" Value=").append(node.getDoubleValue()); } else if (node.getValueType() == QueryConstants.TYPE_LONG) { buffer.append(" Value=").append(node.getLongValue()); } else if (node.getValueType() == QueryConstants.TYPE_POSITION) { buffer.append(" Value=").append(node.getPositionValue()); } else if (node.getValueType() == QueryConstants.TYPE_STRING) { buffer.append(" Value=").append(node.getStringValue()); } else if (node.getValueType() == QueryConstants.TYPE_TIMESTAMP) { buffer.append(" Value=").append(node.getDateValue()); } buffer.append("\n"); traverse(node.getOperands(), buffer); return buffer; }
public Object visit(RelationQueryNode node, Object data) throws RepositoryException { StringBuffer buffer = (StringBuffer) data; buffer.append(PADDING, 0, indent); buffer.append("+ RelationQueryNode: Op: "); buffer.append(QueryConstants.OPERATION_NAMES.getName(node.getOperation())); buffer.append(" Prop=["); PathQueryNode relPath = node.getRelativePath(); if (relPath == null) { buffer.append(relPath); } else { visit(relPath, buffer); } buffer.append("] Type=").append(QueryConstants.TYPE_NAMES.getName(node.getValueType())); if (node.getValueType() == QueryConstants.TYPE_DATE) { buffer.append(" Value=").append(node.getDateValue()); } else if (node.getValueType() == QueryConstants.TYPE_DOUBLE) { buffer.append(" Value=").append(node.getDoubleValue()); } else if (node.getValueType() == QueryConstants.TYPE_LONG) { buffer.append(" Value=").append(node.getLongValue()); } else if (node.getValueType() == QueryConstants.TYPE_POSITION) { buffer.append(" Value=").append(node.getPositionValue()); } else if (node.getValueType() == QueryConstants.TYPE_STRING) { buffer.append(" Value=").append(node.getStringValue()); } else if (node.getValueType() == QueryConstants.TYPE_TIMESTAMP) { buffer.append(" Value=").append(node.getDateValue()); } buffer.append("\n"); traverse(node.getOperands(), buffer); return buffer; }
/** * Assigns a value to the <code>queryNode</code>. * * @param node must be of type string, decimal, double or integer; otherwise * an InvalidQueryException is added to {@link #exceptions}. * @param queryNode current node in the query tree. */ private void assignValue(SimpleNode node, RelationQueryNode queryNode) { if (node.getId() == JJTSTRINGLITERAL) { queryNode.setStringValue(unescapeQuotes(node.getValue())); } else if (node.getId() == JJTDECIMALLITERAL) { queryNode.setDoubleValue(Double.parseDouble(node.getValue())); } else if (node.getId() == JJTDOUBLELITERAL) { queryNode.setDoubleValue(Double.parseDouble(node.getValue())); } else if (node.getId() == JJTINTEGERLITERAL) { // if this is an expression that contains position() do not change // the type. if (queryNode.getValueType() == QueryConstants.TYPE_POSITION) { queryNode.setPositionValue(Integer.parseInt(node.getValue())); } else { queryNode.setLongValue(Long.parseLong(node.getValue())); } } else { exceptions.add(new InvalidQueryException("Unsupported literal type:" + node.toString())); } }
/** * Assigns a value to the <code>queryNode</code>. * * @param node must be of type string, decimal, double or integer; otherwise * an InvalidQueryException is added to {@link #exceptions}. * @param queryNode current node in the query tree. */ private void assignValue(SimpleNode node, RelationQueryNode queryNode) { if (node.getId() == JJTSTRINGLITERAL) { queryNode.setStringValue(unescapeQuotes(node.getValue())); } else if (node.getId() == JJTDECIMALLITERAL) { queryNode.setDoubleValue(Double.parseDouble(node.getValue())); } else if (node.getId() == JJTDOUBLELITERAL) { queryNode.setDoubleValue(Double.parseDouble(node.getValue())); } else if (node.getId() == JJTINTEGERLITERAL) { // if this is an expression that contains position() do not change // the type. if (queryNode.getValueType() == QueryConstants.TYPE_POSITION) { queryNode.setPositionValue(Integer.parseInt(node.getValue())); } else { queryNode.setLongValue(Long.parseLong(node.getValue())); } } else { exceptions.add(new InvalidQueryException("Unsupported literal type:" + node.toString())); } }
switch (node.getValueType()) { case 0: default: throw new IllegalArgumentException("Unknown relation type: " + node.getValueType()); if (node.getValueType() != QueryConstants.TYPE_STRING) { exceptions.add(new InvalidQueryException("Name function can " + "only be used in conjunction with a string literal"));
switch (node.getValueType()) { case 0: default: throw new IllegalArgumentException("Unknown relation type: " + node.getValueType()); if (node.getValueType() != QueryConstants.TYPE_STRING) { exceptions.add(new InvalidQueryException("Name function can " + "only be used in conjunction with a string literal"));
if (aPred.getType() == QueryNode.TYPE_RELATION) { RelationQueryNode pos = (RelationQueryNode) aPred; if (pos.getValueType() == QueryConstants.TYPE_POSITION) { node.setIndex(pos.getPositionValue());
if (aPred.getType() == QueryNode.TYPE_RELATION) { RelationQueryNode pos = (RelationQueryNode) aPred; if (pos.getValueType() == QueryConstants.TYPE_POSITION) { node.setIndex(pos.getPositionValue());