private void append(BindVariableValue value) { append("$"); append(value.getBindVariableName()); }
private void append(BindVariableValue value) { append("$"); append(value.getBindVariableName()); }
/** * Test case for {@link QueryObjectModelFactory#bindVariable(String)} */ public void testBindVariableValue() throws RepositoryException { BindVariableValue bindVar = qf.bindVariable(propertyName1); assertEquals("Wrong variable name", propertyName1, bindVar.getBindVariableName()); }
private void append(BindVariableValue value) { append("$"); append(value.getBindVariableName()); }
/** * Returns the value of the given static operand * ({@link Literal literal} or {@link BindVariableValue bind variable}). * * @param operand static operand to be evaluated * @return evaluated value * @throws RepositoryException if a named bind variable is not found, * or if the operand type is unknown */ public Value getValue(StaticOperand operand) throws RepositoryException { if (operand instanceof Literal) { Literal literal = (Literal) operand; return literal.getLiteralValue(); } else if (operand instanceof BindVariableValue) { BindVariableValue bvv = (BindVariableValue) operand; Value value = variables.get(bvv.getBindVariableName()); if (value != null) { return value; } else { throw new RepositoryException( "Unknown bind variable: " + bvv.getBindVariableName()); } } else { throw new UnsupportedRepositoryOperationException( "Unknown static operand type: " + operand); } }
/** * Returns the value of the given static operand * ({@link Literal literal} or {@link BindVariableValue bind variable}). * * @param operand static operand to be evaluated * @return evaluated value * @throws RepositoryException if a named bind variable is not found, * or if the operand type is unknown */ public Value getValue(StaticOperand operand) throws RepositoryException { if (operand instanceof Literal) { Literal literal = (Literal) operand; return literal.getLiteralValue(); } else if (operand instanceof BindVariableValue) { BindVariableValue bvv = (BindVariableValue) operand; Value value = variables.get(bvv.getBindVariableName()); if (value != null) { return value; } else { throw new RepositoryException( "Unknown bind variable: " + bvv.getBindVariableName()); } } else { throw new UnsupportedRepositoryOperationException( "Unknown static operand type: " + operand); } }
/** * Returns the value of the given static operand * ({@link Literal literal} or {@link BindVariableValue bind variable}). * * @param operand static operand to be evaluated * @return evaluated value * @throws RepositoryException if a named bind variable is not found, * or if the operand type is unknown */ public Value getValue(StaticOperand operand) throws RepositoryException { if (operand instanceof Literal) { Literal literal = (Literal) operand; return literal.getLiteralValue(); } else if (operand instanceof BindVariableValue) { BindVariableValue bvv = (BindVariableValue) operand; Value value = variables.get(bvv.getBindVariableName()); if (value != null) { return value; } else { throw new RepositoryException( "Unknown bind variable: " + bvv.getBindVariableName()); } } else { throw new UnsupportedRepositoryOperationException( "Unknown static operand type: " + operand); } }
@Override public Object apply(String field, BindVariableValue op, Map<String, Object> variables) { EsIndexColumn col = columns.column(field); Object value = variables.get(op.getBindVariableName()); if (value instanceof StaticOperand) { return staticOperand((StaticOperand)value).apply(field, (StaticOperand)value, variables); } if (value instanceof DynamicOperand) { return operand((DynamicOperand)value).apply((DynamicOperand)value, variables); } if (value instanceof Object[]) { return col.cast((Object[]) value); } if (value instanceof Collection) { return col.cast((Collection) value); } return col.cast(variables.get(op.getBindVariableName())); } };
@Override public T toLowerValue( StaticOperand operand, Map<String, Object> variables ) { if (operand instanceof Literal) { Literal literal = (Literal)operand; return factory.create(literal.value()); } if (operand instanceof BindVariableValue) { BindVariableValue bind = (BindVariableValue)operand; return factory.create(variables.get(bind.getBindVariableName())); } throw new LocalIndexException("Unexpected static operand: " + operand); }
@Override public T toUpperValue( StaticOperand operand, Map<String, Object> variables ) { if (operand instanceof Literal) { Literal literal = (Literal)operand; return factory.create(literal.value()); } if (operand instanceof BindVariableValue) { BindVariableValue bind = (BindVariableValue)operand; return factory.create(variables.get(bind.getBindVariableName())); } throw new LocalIndexException("Unexpected static operand: " + operand); }
@Override public T toLowerValue( StaticOperand operand, Map<String, Object> variables ) { if (operand instanceof Literal) { Literal literal = (Literal)operand; return factory.create(literal.value()); } if (operand instanceof BindVariableValue) { BindVariableValue bind = (BindVariableValue)operand; return factory.create(variables.get(bind.getBindVariableName())); } throw new LocalIndexException("Unexpected static operand: " + operand); }
@Override public T toUpperValue( StaticOperand operand, Map<String, Object> variables ) { if (operand instanceof Literal) { Literal literal = (Literal)operand; return factory.create(literal.value()); } if (operand instanceof BindVariableValue) { BindVariableValue bind = (BindVariableValue)operand; return factory.create(variables.get(bind.getBindVariableName())); } throw new LocalIndexException("Unexpected static operand: " + operand); }
@Test public void bindVariable() throws RepositoryException { BindVariableValue b = f.bindVariable("bindVariableName"); assertEquals("bindVariableName", b.getBindVariableName()); assertEquals("$bindVariableName", b.toString()); }
dynamicOperandValues[0] = ((Literal) operand1).getLiteralValue(); } else if (operand1 instanceof BindVariableValue) { dynamicOperandValues[0] = valueFactory.createValue(((BindVariableValue) operand1).getBindVariableName()); scalarOperandValue = ((Literal) operand2).getLiteralValue(); } else if (operand2 instanceof BindVariableValue) { scalarOperandValue = valueFactory.createValue(((BindVariableValue) operand2).getBindVariableName()); } else if (operand2 instanceof PropertyValue) { String propName = ((PropertyValue) operand2).getPropertyName();
/** * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, StaticOperand)} */ public void testFullTextSearchWithBindVariableValue() throws RepositoryException { FullTextSearch ftSearch = qf.fullTextSearch( SELECTOR_NAME1, propertyName1, qf.bindVariable(VARIABLE_NAME)); assertEquals("Wrong selector name", SELECTOR_NAME1, ftSearch.getSelectorName()); assertEquals("Wrong propertyName", propertyName1, ftSearch.getPropertyName()); StaticOperand op = ftSearch.getFullTextSearchExpression(); assertNotNull(op); assertTrue("not a BindVariableValue", op instanceof BindVariableValue); BindVariableValue value = (BindVariableValue) op; assertEquals(VARIABLE_NAME, value.getBindVariableName()); }