Statistics
| Revision:

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

History | View | Annotate | Download (2.2 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.PropertyIsBetween;
21
import org.opengis.filter.expression.Expression;
22

    
23
/**
24
 * Straight implementation of GeoAPI interface.
25
 * 
26
 * @author Justin Deoliveira, The Open Planning Project
27
 */
28
public class IsBetweenImpl extends BinaryComparisonAbstract implements PropertyIsBetween {
29

    
30
        private Expression expression;
31
        private Expression alower;
32
        private Expression aupper;
33

    
34
        protected IsBetweenImpl(Expression lower, Expression expression, Expression upper ){
35
                super(lower,upper);
36
                this.expression = expression;
37
                this.alower=lower;
38
                this.aupper=upper;
39
        }
40
        
41
        public Expression getExpression() {
42
                return expression;
43
        }
44
        
45
        public boolean evaluate(Object feature) {
46
                Object value = expression.evaluate( feature );
47
                if ( value == null ) {
48
                        return false;
49
                }
50
                
51
                //get the boundaries
52
                Object lower = alower.evaluate(feature ) ;
53
                Object upper = aupper.evaluate(feature ) ;
54
                
55
                if ( lower == null || upper == null || value==null ) {
56
                        return true;
57
                }
58
                
59
                Comparable lc = comparable( lower );
60
                Comparable o = comparable( value );
61
                Comparable uc = comparable( upper );
62

    
63
                return compare (lc,o) <= 0 && compare(uc,o) >= 0;
64
        }
65

    
66
        public Object accept(FilterVisitor visitor, Object extraData) {
67
                return visitor.visit( this, extraData );
68
        }
69

    
70
        public Expression getLowerBoundary() {
71
                return getExpression1();
72
        }
73

    
74
        public Expression getUpperBoundary() {
75
                return getExpression2();
76
        }
77

    
78
        
79
}