org.geotools.filter.AttributeExpressionImpl Java Examples

The following examples show how to use org.geotools.filter.AttributeExpressionImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtractAttributes.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Extract property attribute.
 *
 * @param attributeType the attribute type
 * @param foundList the found list
 * @param attribute the attribute
 */
private void extractPropertyAttribute(
        Class<?> attributeType, List<String> foundList, AttributeExpressionImpl attribute) {
    String attributeName = attribute.getPropertyName();

    // Determine if attribute is a geometry
    if ((GeometryTypeMapping.getGeometryType(attributeType) != GeometryTypeEnum.UNKNOWN)
            || (attributeType == Geometry.class)) {
        if (!geometryFieldList.contains(attributeName)) {
            geometryFieldList.add(attributeName);
        }
    } else {
        if (!fieldList.containsKey(attributeName) && (attributeName != null)) {
            DataSourceAttributeData field =
                    new DataSourceAttributeData(attributeName, attributeType, null);
            processedFieldList.add(field);
            fieldList.put(attributeName, field);
            foundList.add(attributeName);
        }
    }
}
 
Example #2
Source File: FieldConfigBaseTest.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigBase#attributeUpdated(java.lang.String)}.
 */
@Test
public void testAttributeUpdated() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field =
            new TestFieldConfigBase(
                    new FieldConfigCommonData(
                            String.class, expectedFieldId, expectedLabel, false, false));

    TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
    field.addDataChangedListener(listener);

    String attributeName = "test attribute";
    assertFalse(listener.hasBeenCalled());
    field.attributeUpdated(attributeName);
    assertTrue(listener.hasBeenCalled());

    assertEquals(ExpressionTypeEnum.E_ATTRIBUTE, field.getExpressionType());
    Expression expression = field.getExpression();
    assertTrue(expression instanceof AttributeExpressionImpl);
    assertTrue(attributeName.compareTo(expression.toString()) == 0);
}
 
Example #3
Source File: LongValues.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof Long) {
        this.value = (Long) aValue;
    } else if (aValue instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue;
        value = literal.evaluate(value, Long.class);
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
 
Example #4
Source File: FloatValues.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof Float) {
        this.value = (Float) aValue;
    } else if (aValue instanceof Double) {
        this.value = ((Double) aValue).floatValue();
    } else if (aValue instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue;
        value = literal.evaluate(value, Float.class);
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
 
Example #5
Source File: NumberValues.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@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;
    }
}
 
Example #6
Source File: BooleanValues.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof Boolean) {
        this.value = (Boolean) aValue;
    } else if (aValue instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue;
        value = literal.evaluate(value, Boolean.class);
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
 
Example #7
Source File: StringValues.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue != null) {
        if (aValue instanceof String) {
            this.value = (String) aValue;
        } else if (aValue instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue;
            value = literal.evaluate(value, String.class);
        } else if ((aValue instanceof AttributeExpressionImpl)
                || (aValue instanceof FunctionExpressionImpl)
                || (aValue instanceof MathExpressionImpl)) {
            this.expression = (Expression) aValue;
        } else {
            this.value = aValue.toString();
        }
    }
}
 
Example #8
Source File: DoubleValues.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@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;
    }
}
 
Example #9
Source File: CoordinateReferenceSystemValues.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@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);
        }
    }
}
 
Example #10
Source File: TextAreaValues.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue != null) {
        if (aValue instanceof String) {
            this.value = (String) aValue;
        } else if (aValue instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl literal = (LiteralExpressionImpl) aValue;
            value = literal.evaluate(value, String.class);
        } else if ((aValue instanceof AttributeExpressionImpl)
                || (aValue instanceof FunctionExpressionImpl)
                || (aValue instanceof MathExpressionImpl)) {
            this.expression = (Expression) aValue;
        } else {
            this.value = aValue.toString();
        }
    }
}
 
Example #11
Source File: IntegerValues.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@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;
    }
}
 
Example #12
Source File: EnumValues.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue != null) {
        if (aValue instanceof LiteralExpressionImpl) {
            value = ((Expression) aValue).toString();
        } else if ((aValue instanceof AttributeExpressionImpl)
                || (aValue instanceof FunctionExpressionImpl)
                || (aValue instanceof MathExpressionImpl)) {
            this.expression = (Expression) aValue;
        } else {
            if (aValue instanceof String) {
                value = ((String) aValue);
            }
        }
    }
}
 
Example #13
Source File: FilterPanelv2.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds the expression.
 *
 * @param node the node
 * @return the expression
 */
private Expression addExpression(ExpressionNode node) {
    Expression expression = node.getExpression();

    if (expression instanceof LiteralExpressionImpl) {
        return expression;
    } else if (expression instanceof AttributeExpressionImpl) {
        return expression;
    } else if (expression instanceof FunctionExpressionImpl) {
        FunctionExpressionImpl functionExpression = (FunctionExpressionImpl) expression;

        return addFunctionExpression(node, expression, functionExpression);
    } else if (expression instanceof MathExpressionImpl) {
        MathExpressionImpl mathExpression = (MathExpressionImpl) expression;
        return addMathsExpression(node, mathExpression);
    } else if (expression instanceof Function) {
        Function function = (Function) expression;
        return addFunction(node, function);
    }
    return null;
}
 
Example #14
Source File: ExtractAttributes.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Extract attribute.
 *
 * @param attributeType the attribute type
 * @param expression the expression
 * @param foundList the found list
 * @return the class
 */
protected Class<?> extractAttribute(
        Class<?> attributeType, Expression expression, List<String> foundList) {
    Class<?> returnType = String.class;

    if (expression instanceof AttributeExpressionImpl) {
        AttributeExpressionImpl attribute = (AttributeExpressionImpl) expression;
        extractPropertyAttribute(attributeType, foundList, attribute);
    } else if (expression instanceof Function) {
        Function function = (Function) expression;
        returnType = extractFunctionAttribute(foundList, function);
    } else if (expression instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
        returnType = extractLiteralAttribute(returnType, literal);
    }

    return returnType;
}
 
Example #15
Source File: DataSourceAttributePanel.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the attribute.
 *
 * @param expression the new attribute
 */
public void setAttribute(Expression expression) {
    String propertyName = null;

    if (expression instanceof PropertyExistsFunction) {
        Expression e = ((PropertyExistsFunction) expression).getParameters().get(0);
        Object value = ((LiteralExpressionImpl) e).getValue();
        propertyName = ((AttributeExpressionImpl) value).getPropertyName();
    } else if (expression instanceof AttributeExpressionImpl) {
        propertyName = ((AttributeExpressionImpl) expression).getPropertyName();
    } else if (expression instanceof LiteralExpressionImpl) {
        propertyName =
                AttributeUtils.extract(
                        (String) ((LiteralExpressionImpl) expression).getValue());
    }

    if (propertyName != null) {
        oldValueObj = propertyName;

        attributeComboBox.setSelectedItem(propertyName);
    } else {
        oldValueObj = propertyName;
        attributeComboBox.setSelectedIndex(-1);
    }
}
 
Example #16
Source File: AttributeSelection.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Populate.
 *
 * @param expression the expression
 */
public void populate(Expression expression) {
    if (expression != null) {
        populateAttributeComboxBox(expression);

        if ((expression instanceof NilExpression)
                || (expression instanceof ConstantExpression)
                || (expression instanceof LiteralExpressionImpl)) {
            valuePanel.populateExpression(expression);
        } else if (expression instanceof AttributeExpressionImpl) {
            setAttribute(expression);
        } else {
            expressionPanel.populateExpression(expression);
        }
    }
}
 
Example #17
Source File: AttributeSelection.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Populate.
 *
 * @param expression the expression
 */
public void populateAttributeComboxBox(Expression expression) {

    String panelName;

    // Clear out any old values
    expressionPanel.populateExpression(null);
    dataSourceAttributePanel.setAttribute(null);

    if (expression == null) {
        panelName = ValueSubPanel.getPanelName();
    } else if (expression instanceof NilExpression) {
        panelName = ValueSubPanel.getPanelName();
    } else if (expression instanceof ConstantExpression) {
        panelName = ValueSubPanel.getPanelName();
    } else if (expression instanceof LiteralExpressionImpl) {
        panelName = ValueSubPanel.getPanelName();
    } else if (expression instanceof AttributeExpressionImpl) {
        panelName = DataSourceAttributePanel.getPanelName();
    } else {
        panelName = ExpressionSubPanel.getPanelName();
    }

    oldValueObj = panelName;
    attributeChooserComboBox.setSelectedItem(panelName);
}
 
Example #18
Source File: FieldConfigGeometryField.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Populate expression.
 *
 * @param objValue the obj value
 */
/*
 * (non-Javadoc)
 *
 * @see com.sldeditor.ui.detail.config.FieldConfigBase#populateExpression(java.lang.Object)
 */
@Override
public void populateExpression(Object objValue) {
    String propertyName = null;

    if (objValue instanceof PropertyExistsFunction) {
        Expression e = ((PropertyExistsFunction) objValue).getParameters().get(0);
        propertyName = e.toString();
    } else if (objValue instanceof AttributeExpressionImpl) {
        propertyName = ((AttributeExpressionImpl) objValue).getPropertyName();
    } else if (objValue instanceof LiteralExpressionImpl) {
        propertyName =
                AttributeUtils.extract((String) ((LiteralExpressionImpl) objValue).getValue());
    }

    populateField(propertyName);
}
 
Example #19
Source File: FieldConfigBase.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Populate literal expression.
 *
 * @param expression the expression
 */
private void populateLiteralExpression(Expression expression) {
    LiteralExpressionImpl lExpression = (LiteralExpressionImpl) expression;

    Object objValue = lExpression.getValue();

    if (objValue instanceof AttributeExpressionImpl) {
        expressionType = ExpressionTypeEnum.E_ATTRIBUTE;

        if (attributeSelectionPanel != null) {
            attributeSelectionPanel.setAttribute((AttributeExpressionImpl) objValue);
        }

        setCachedExpression((AttributeExpressionImpl) objValue);
    } else {
        expressionType = ExpressionTypeEnum.E_VALUE;

        populateExpression(objValue);

        valueUpdated();
    }
}
 
Example #20
Source File: FieldConfigBase.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Populate.
 *
 * @param expression the expression
 */
public void populate(Expression expression) {
    if (attributeSelectionPanel != null) {
        attributeSelectionPanel.populateAttributeComboxBox(expression);
    }

    if (expression == null) {
        expressionType = ExpressionTypeEnum.E_VALUE;

        revertToDefaultValue();

        valueUpdated();
    } else {
        if (expression instanceof LiteralExpressionImpl) {
            populateLiteralExpression(expression);
        } else if (expression instanceof ConstantExpression) {
            populateConstantExpression(expression);
        } else if (expression instanceof NilExpression) {
            populateNilExpression();
        } else if (expression instanceof ProcessFunction) {
            populateProcessFunction(expression);
        } else if (expression instanceof AttributeExpressionImpl) {
            populateAttributeExpression(expression);
        } else if ((expression instanceof FunctionExpressionImpl)
                || (expression instanceof BinaryExpression)) {
            expressionType = ExpressionTypeEnum.E_EXPRESSION;

            if (attributeSelectionPanel != null) {
                attributeSelectionPanel.populate(expression);
            }

            setCachedExpression(expression);
        } else {
            expressionType = ExpressionTypeEnum.E_EXPRESSION;
        }
    }

    setValueFieldState();
}
 
Example #21
Source File: FilterValues.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof Filter) {
        this.value = (Filter) aValue;
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof LiteralExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
 
Example #22
Source File: StyleValues.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof Style) {
        this.value = (Style) aValue;
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof LiteralExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
 
Example #23
Source File: FieldConfigBase.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Attribute updated.
 *
 * @param attributeName the attribute name
 */
@Override
public void attributeUpdated(String attributeName) {
    expressionType = ExpressionTypeEnum.E_ATTRIBUTE;

    NameImpl name = new NameImpl(attributeName);
    setCachedExpression(new AttributeExpressionImpl(name));

    setValueFieldState();
    fireDataChanged();
}
 
Example #24
Source File: UnitValues.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof Unit) {
        this.value = (Unit) aValue;
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof LiteralExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
 
Example #25
Source File: KernelJAIValues.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof KernelJAI) {
        this.value = (KernelJAI) aValue;
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof LiteralExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
 
Example #26
Source File: TimePeriodValues.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof TimePeriod) {
        this.value = (TimePeriod) aValue;
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof LiteralExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
 
Example #27
Source File: DateValues.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof Date) {
        this.value = (Date) aValue;
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof LiteralExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
 
Example #28
Source File: JAIToolsRangeValues.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof Range) {
        this.value = (Range) aValue;
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof LiteralExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}
 
Example #29
Source File: ExpressionNode.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the expression.
 *
 * @param expression the expression to set
 */
public void setExpression(Expression expression) {
    this.expression = expression;
    if (expression instanceof LiteralExpressionImpl) {
        Object value = ((LiteralExpressionImpl) expression).getValue();
        if (value instanceof AttributeExpressionImpl) {
            this.expression = (AttributeExpressionImpl) value;
        }
    }

    setDisplayString();

    this.removeAllChildren();

    if (this.expression instanceof EnvFunction) {
        setEnvFunction();
    } else if (this.expression instanceof FunctionExpression) {
        setFunctionExpression();
    } else if (this.expression instanceof FunctionImpl) {
        setFunctionImpl();
    } else if (this.expression instanceof Function) {
        setFunction();
    } else if (expression instanceof MathExpressionImpl) {
        setMathExpression(expression);
    } else if (expression instanceof AttributeExpressionImpl) {
        //        AttributeExpressionImpl property = (AttributeExpressionImpl) expression;

        // TypeManager.getInstance().setLiteralType(literal.getValue().getClass());
    } else if (expression instanceof LiteralExpressionImpl) {
        LiteralExpressionImpl literal = (LiteralExpressionImpl) expression;
        if (literal.getValue() != null) {
            TypeManager.getInstance().setDataType(literal.getValue().getClass());
        }
    }
}
 
Example #30
Source File: JAIExtRangeValues.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setValue(Object aValue) {
    this.value = null;
    this.expression = null;

    if (aValue instanceof Range) {
        this.value = (Range) aValue;
    } else if ((aValue instanceof AttributeExpressionImpl)
            || (aValue instanceof LiteralExpressionImpl)
            || (aValue instanceof FunctionExpressionImpl)
            || (aValue instanceof MathExpressionImpl)) {
        this.expression = (Expression) aValue;
    }
}