public Literal literal(boolean b) { return b ? new LiteralExpressionImpl(Boolean.TRUE) : new LiteralExpressionImpl(Boolean.FALSE); }
return ((Geometry) this.literal).equalsExact(expLit.evaluate(null, Geometry.class)); } else if (expressionType == ExpressionType.LITERAL_INTEGER) { return ((Integer) this.literal).equals(expLit.evaluate(null, Integer.class)); } else if (expressionType == ExpressionType.LITERAL_STRING) { return ((String) this.literal).equals(expLit.evaluate(null, String.class)); } else if (expressionType == ExpressionType.LITERAL_DOUBLE) { return ((Double) this.literal).equals(expLit.evaluate(null, Double.class)); } else if (expressionType == ExpressionType.LITERAL_LONG) { return ((Long) this.literal).equals(expLit.evaluate(null, Long.class)); } else { Object other = expLit.evaluate(null, this.literal.getClass()); if (other != null) { return other.equals(this.literal); other = expLit.getValue(); Object converted = this.evaluate(null, other.getClass()); if (converted != null) { return converted.equals(other); String str1 = (String) this.evaluate(null, String.class); String str2 = (String) expLit.evaluate(null, String.class); return str1 != null && str2 != null && str1.equals(str2); return equals(new LiteralExpressionImpl(other.getValue())); } else { return false;
/** * Gets geometry. * * @param geometry The geometry from the filter. * @throws IllegalFilterException If there are problems creating expression. */ public void geometry(Geometry geometry) throws IllegalFilterException { // Sets the geometry for the expression, as appropriate LOGGER.finer("got geometry: " + geometry.toString()); // if(curExprssn.getType()==ExpressionDefault.LITERAL_GEOMETRY){ // LOGGER.finer("got geometry: "); curExprssn = new LiteralExpressionImpl(); ((LiteralExpressionImpl) curExprssn).setValue(geometry); LOGGER.finer("set expression: " + curExprssn.toString()); currentState = "complete"; LOGGER.finer("set current state: " + currentState); // } }
/** * This method calls {@link #getValue()}. * * @deprecated use {@link #getValue()}. * */ public final Object getLiteral() { return getValue(); }
@Override public void setValue(Object aValue) { this.value = null; this.expression = null; if (aValue instanceof Number) { this.value = (Number) aValue; } else if (aValue instanceof LiteralExpressionImpl) { LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue; value = literal.evaluate(value, Number.class); } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) { this.expression = (Expression) aValue; } }
return ((Geometry) this.literal).equalsExact((Geometry) expLit.evaluate(null, Geometry.class)); } else if (expressionType == LITERAL_INTEGER) { return ((Integer) this.literal).equals((Integer) expLit.evaluate(null, Integer.class)); } else if (expressionType == LITERAL_STRING) { return ((String) this.literal).equals((String) expLit.evaluate(null, String.class)); } else if (expressionType == LITERAL_DOUBLE) { return ((Double) this.literal).equals((Double) expLit.evaluate(null, Double.class)); } else if (expressionType == LITERAL_LONG) { return ((Long) this.literal).equals((Long) expLit.evaluate(null, Long.class)); } else { return true; return equals( new LiteralExpressionImpl( other.getValue() ) ); } else { return false;
public void testLiteralExpression() { LiteralExpressionImpl literal; literal = new LiteralExpressionImpl(1.0D); assertEquals(ExpressionType.LITERAL_DOUBLE, Filters.getExpressionType(literal)); assertEquals(new Double(1.0D), literal.evaluate((Feature) null)); GeometryFactory gf = new GeometryFactory(); literal = new LiteralExpressionImpl(gf.createPoint(new Coordinate(0, 0))); assertEquals(ExpressionType.LITERAL_GEOMETRY, Filters.getExpressionType(literal)); Geometry value = (Geometry) literal.evaluate((Feature) null); assertTrue(gf.createPoint(new Coordinate(0, 0)).equalsExact(value)); literal = new LiteralExpressionImpl(1); assertEquals(ExpressionType.LITERAL_INTEGER, Filters.getExpressionType(literal)); assertEquals(Integer.valueOf(1), literal.evaluate((Feature) null)); literal = new LiteralExpressionImpl(1L); assertEquals(ExpressionType.LITERAL_LONG, Filters.getExpressionType(literal)); assertEquals(Long.valueOf(1), literal.evaluate((Feature) null)); literal = new LiteralExpressionImpl("string value"); assertEquals(ExpressionType.LITERAL_STRING, Filters.getExpressionType(literal)); assertEquals("string value", literal.evaluate((Feature) null)); literal = new LiteralExpressionImpl(new Date(0)); assertEquals(ExpressionType.LITERAL_UNDECLARED, Filters.getExpressionType(literal)); assertEquals(new Date(0), literal.evaluate((Feature) null)); literal = new LiteralExpressionImpl(null); assertEquals(ExpressionType.LITERAL_UNDECLARED, Filters.getExpressionType(literal)); assertNull(literal.evaluate((Feature) null)); }
/** * Constructor with literal. * * @param literal The literal to store inside this expression. * * @throws IllegalFilterException This literal type is not in scope. */ protected LiteralExpressionImpl(Object literal) throws IllegalFilterException { this.setLiteral(literal); }
/** * Constructor with literal. * * @param literal The literal to store inside this expression. * @throws IllegalFilterException This literal type is not in scope. */ public LiteralExpressionImpl(Object literal) throws IllegalFilterException { this.setValue(literal); }
@Override public void setValue(Object aValue) { this.value = null; this.expression = null; if (aValue instanceof LiteralExpressionImpl) { LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue; if (literal.getValue() != null) { value = literal.toString(); } } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) { this.expression = (Expression) aValue; } else { if (aValue instanceof String) { value = ((String) aValue); } } }
/** * This method calls {@link #getValue()}. * * @deprecated use {@link #getValue()}. * */ public final Object getLiteral() { return getValue(); }
@Override public void setValue(Object aValue) { this.value = null; this.expression = null; if (aValue instanceof Integer) { this.value = (Integer) aValue; } else if (aValue instanceof LiteralExpressionImpl) { LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue; value = literal.evaluate(value, Integer.class); } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) { this.expression = (Expression) aValue; } }
/** * Constructor with literal. * * @param literal The literal to store inside this expression. * * @throws IllegalFilterException This literal type is not in scope. */ protected LiteralExpressionImpl(Object literal) throws IllegalFilterException { this.setLiteral(literal); }
/** * Constructor with literal. This alternative constructor is a convinience one for doubles an * Double object will be constructed, and no IllegalFilterException can ever be thrown. * * @param value The double to store inside this expression. */ protected LiteralExpressionImpl(String value) { try { this.setValue(value); } catch (IllegalFilterException ile) { // this is imposible as this is only thrown for // invalid types, and String is a valid type throw new AssertionError("LiteralExpressionImpl is broken, it should accept Strings"); } }
public Literal literal(short s) { return new LiteralExpressionImpl(s); }
/** * Creates the filter. * * @param parameterList the parameter list * @return the filter */ @Override public Filter createFilter(List<Expression> parameterList) { LikeFilterImpl filter = null; if ((parameterList == null) || parameterList.size() != 6) { filter = new IsLikeExtended(); } else { LiteralExpressionImpl pattern = (LiteralExpressionImpl) parameterList.get(1); LiteralExpressionImpl wildcardMulti = (LiteralExpressionImpl) parameterList.get(2); LiteralExpressionImpl wildcardSingle = (LiteralExpressionImpl) parameterList.get(3); LiteralExpressionImpl escape = (LiteralExpressionImpl) parameterList.get(4); LiteralExpressionImpl matchCase = (LiteralExpressionImpl) parameterList.get(5); filter = new IsLikeExtended( parameterList.get(0), (String) pattern.getValue(), (String) wildcardMulti.getValue(), (String) wildcardSingle.getValue(), (String) escape.getValue(), (Boolean) matchCase.getValue()); } return filter; }
@Override public void setValue(Object aValue) { this.value = null; this.expression = null; if (aValue instanceof Double) { this.value = (Double) aValue; } else if (aValue instanceof LiteralExpressionImpl) { LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue; value = literal.evaluate(value, Double.class); } else if ((aValue instanceof AttributeExpressionImpl) || (aValue instanceof FunctionExpressionImpl) || (aValue instanceof MathExpressionImpl)) { this.expression = (Expression) aValue; } }
protected LiteralExpressionImpl(long value) { try { this.setLiteral(new Long(value)); } catch (IllegalFilterException ile) { //this is imposible as this is only thrown for //invalid types, and Double is a valid type throw new AssertionError( "LiteralExpressionImpl is broken, it should accept Longs"); } }
protected LiteralExpressionImpl(long value) { try { this.setValue(Long.valueOf(value)); } catch (IllegalFilterException ile) { // this is imposible as this is only thrown for // invalid types, and Double is a valid type throw new AssertionError("LiteralExpressionImpl is broken, it should accept Longs"); } }
public Literal literal(char c) { return new LiteralExpressionImpl(c); }