001    // $HeadURL:
002    // /deegreerepository/deegree/src/org/deegree/model/filterencoding/capabilities/OperatorFactory.java,v
003    // 1.1 2005/03/04 16:33:07 mschneider Exp $
004    /*----------------------------------------------------------------------------
005     This file is part of deegree, http://deegree.org/
006     Copyright (C) 2001-2009 by:
007       Department of Geography, University of Bonn
008     and
009       lat/lon GmbH
010    
011     This library is free software; you can redistribute it and/or modify it under
012     the terms of the GNU Lesser General Public License as published by the Free
013     Software Foundation; either version 2.1 of the License, or (at your option)
014     any later version.
015     This library is distributed in the hope that it will be useful, but WITHOUT
016     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
017     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
018     details.
019     You should have received a copy of the GNU Lesser General Public License
020     along with this library; if not, write to the Free Software Foundation, Inc.,
021     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
022    
023     Contact information:
024    
025     lat/lon GmbH
026     Aennchenstr. 19, 53177 Bonn
027     Germany
028     http://lat-lon.de/
029    
030     Department of Geography, University of Bonn
031     Prof. Dr. Klaus Greve
032     Postfach 1147, 53001 Bonn
033     Germany
034     http://www.geographie.uni-bonn.de/deegree/
035    
036     e-mail: info@deegree.org
037    ----------------------------------------------------------------------------*/
038    package org.deegree.model.filterencoding.capabilities;
039    
040    import org.deegree.framework.util.StringTools;
041    import org.deegree.ogcwebservices.getcapabilities.UnknownOperatorNameException;
042    
043    /**
044     *
045     *
046     *
047     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
048     * @author last edited by: $Author: mschneider $
049     *
050     * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
051     */
052    public class OperatorFactory110 {
053    
054        // comparison operators as defined in filterCapabilities.xsd (1.1.0)
055    
056        /**
057         *
058         */
059        public final static String LESS_THAN = "LessThan";
060    
061        /**
062         *
063         */
064        public final static String GREATER_THAN = "GreaterThan";
065    
066        /**
067         *
068         */
069        public final static String LESS_THAN_EQUAL_TO = "LessThanEqualTo";
070    
071        /**
072         *
073         */
074        public final static String GREATER_THAN_EQUAL_TO = "GreaterThanEqualTo";
075    
076        /**
077         *
078         */
079        public final static String EQUAL_TO = "EqualTo";
080    
081        /**
082         *
083         */
084        public final static String NOT_EQUAL_TO = "NotEqualTo";
085    
086        /**
087         *
088         */
089        public final static String LIKE = "Like";
090    
091        /**
092         *
093         */
094        public final static String BETWEEN = "Between";
095    
096        /**
097         *
098         */
099        public final static String NULL_CHECK = "NullCheck";
100    
101        // spatial operators as defined in filterCapabilities.xsd (1.1.0)
102    
103        /**
104         *
105         */
106        public final static String BBOX = "BBOX";
107    
108        /**
109         *
110         */
111        public final static String EQUALS = "Equals";
112    
113        /**
114         *
115         */
116        public final static String DISJOINT = "Disjoint";
117    
118        /**
119         *
120         */
121        public final static String INTERSECTS = "Intersects";
122    
123        /**
124         *
125         */
126        public final static String TOUCHES = "Touches";
127    
128        /**
129         *
130         */
131        public final static String CROSSES = "Crosses";
132    
133        /**
134         *
135         */
136        public final static String WITHIN = "Within";
137    
138        /**
139         *
140         */
141        public final static String CONTAINS = "Contains";
142    
143        /**
144         *
145         */
146        public final static String OVERLAPS = "Overlaps";
147    
148        /**
149         *
150         */
151        public final static String BEYOND = "Beyond";
152    
153        /**
154         *
155         */
156        public final static String DWITHIN = "DWithin";
157    
158        /**
159         *
160         * @param name
161         * @return SpatialOperator for name
162         * @throws UnknownOperatorNameException
163         */
164        public static SpatialOperator createSpatialOperator( String name )
165                                throws UnknownOperatorNameException {
166    
167            if ( name.equals( BBOX ) || name.equals( EQUALS ) || name.equals( DISJOINT ) || name.equals( INTERSECTS )
168                 || name.equals( TOUCHES ) || name.equals( CROSSES ) || name.equals( WITHIN ) || name.equals( CONTAINS )
169                 || name.equals( OVERLAPS ) || name.equals( BEYOND ) || name.equals( DWITHIN ) ) {
170                return new SpatialOperator( name, null );
171            }
172            String msg = StringTools.concat( 200, "'", name, "' is no valid spatial operator (according to filter ",
173                                             "encoding specification 1.1.0.)." );
174            throw new UnknownOperatorNameException( msg );
175        }
176    
177        /**
178         *
179         * @param name
180         * @return Operator for name
181         * @throws UnknownOperatorNameException
182         */
183        public static Operator createComparisonOperator( String name )
184                                throws UnknownOperatorNameException {
185    
186            if ( name.equals( LESS_THAN ) || name.equals( GREATER_THAN ) || name.equals( LESS_THAN_EQUAL_TO )
187                 || name.equals( EQUAL_TO ) || name.equals( LESS_THAN_EQUAL_TO ) || name.equals( GREATER_THAN_EQUAL_TO )
188                 || name.equals( EQUAL_TO ) || name.equals( NOT_EQUAL_TO ) || name.equals( LIKE ) || name.equals( BETWEEN )
189                 || name.equals( NULL_CHECK ) ) {
190                return new Operator( name );
191            }
192            String msg = StringTools.concat( 200, "'", name, "' is no valid comparison operator (according tofilter",
193                                             " encoding specification 1.1.0.)." );
194            throw new UnknownOperatorNameException( msg );
195        }
196    }