Statistics
| Revision:

root / branches / Mobile_Compatible_Hito_1 / libFMap_data / src / org / gvsig / data / vectorial / filter / IsNotEqualToImpl.java @ 21563

History | View | Annotate | Download (2.1 KB)

1
/*
2
 *    GeoTools - OpenSource mapping toolkit
3
 *    http://geotools.org
4
 *    (C) 2006, GeoTools Project Managment Committee (PMC)
5
 *        
6
 *    This library is free software; you can redistribute it and/or
7
 *    modify it under the terms of the GNU Lesser General Public
8
 *    License as published by the Free Software Foundation;
9
 *    version 2.1 of the License.
10
 *
11
 *    This library is distributed in the hope that it will be useful,
12
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 *    Lesser General Public License for more details.
15
 */
16
package org.gvsig.data.vectorial.filter;
17

    
18
import org.opengis.filter.FilterFactory;
19
import org.opengis.filter.FilterVisitor;
20
import org.opengis.filter.PropertyIsNotEqualTo;
21
import org.opengis.filter.expression.Expression;
22

    
23

    
24
public class IsNotEqualToImpl extends BinaryComparisonAbstract
25
        implements PropertyIsNotEqualTo {
26

    
27

    
28
        protected IsNotEqualToImpl(Expression e1, Expression e2) {
29
                this(e1, e2, true );
30
        }
31
        
32
        protected IsNotEqualToImpl(Expression expression1, Expression expression2, boolean matchCase ) {
33
                super(expression1, expression2, matchCase);
34
                
35
        }
36

    
37
        //@Override
38
        public boolean evaluate(Object feature) {
39
//                Object[] values = eval( feature );
40
//                Object value1 = values[ 0 ];
41
//                Object value2 = values[ 1 ];
42
                final Object value1 = eval(expression1, feature);
43
        final Object value2 = eval(expression2, feature);
44
                boolean notEqual = (value1 == null && value2 != null) ||
45
                        (value1 != null && value2 == null) ||
46
                    (value1 != null && !value1.equals( value2 ));
47
                
48
                if ( !notEqual ) {
49
                        return false;
50
                }
51
                
52
                //not equal, case insensitive?
53
                if ( !isMatchingCase() && value1 != null && value2 != null ) {
54
                        //fall back to string and check the case insensitive flag
55
                        String s1 = (String)value1;
56
                        String s2 = (String)value2;
57
                        
58
                        return !s1.equalsIgnoreCase( s2 );
59
                }
60
                
61
                return true;
62
        }
63
        
64
        public Object accept(FilterVisitor visitor, Object extraData) {
65
                return visitor.visit( this, extraData );
66
        }
67

    
68
}