001 // $HeadURL: 002 // /cvsroot/deegree/src/org/deegree/ogcwebservices/getcapabilities/Contents.java,v 003 // 1.1 2004/06/23 11:55:40 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 java.util.HashMap; 041 import java.util.Map; 042 043 /** 044 * ScalarCapabilitiesBean 045 * 046 * @author <a href="mailto:tfr@users.sourceforge.net">Torsten Friebe </a> 047 * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider </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 ScalarCapabilities { 053 054 private boolean supportsLogicalOperators; 055 056 /** 057 * keys are Strings (operator names), values are Operator-instances 058 */ 059 private Map<String, Operator> comparisonOperators; 060 061 /** 062 * keys are Strings (operator names), values are Operator-instances 063 */ 064 private Map<String, Operator> arithmeticOperators; 065 066 /** 067 * Creates a new <code>ScalarCapabilities</code> instance. 068 * 069 * @param supportsLogicalOperators 070 * @param comparisonOperators 071 * may be null 072 * @param arithmeticOperators 073 * may be null 074 */ 075 public ScalarCapabilities( boolean supportsLogicalOperators, Operator[] comparisonOperators, 076 Operator[] arithmeticOperators ) { 077 this.supportsLogicalOperators = supportsLogicalOperators; 078 setComparisonOperators( comparisonOperators ); 079 setArithmeticOperators( arithmeticOperators ); 080 } 081 082 /** 083 * 084 * @return true, if it supports them 085 */ 086 public boolean hasLogicalOperatorsSupport() { 087 return supportsLogicalOperators; 088 } 089 090 /** 091 * 092 * @param supportsLogicalOperators 093 */ 094 public void setLogicalOperatorsSupport( boolean supportsLogicalOperators ) { 095 this.supportsLogicalOperators = supportsLogicalOperators; 096 } 097 098 /** 099 * 100 * @param comparisonOperators 101 */ 102 public void setComparisonOperators( Operator[] comparisonOperators ) { 103 this.comparisonOperators = new HashMap<String, Operator>(); 104 if ( comparisonOperators != null ) { 105 for ( int i = 0; i < comparisonOperators.length; i++ ) { 106 this.comparisonOperators.put( comparisonOperators[i].getName(), comparisonOperators[i] ); 107 } 108 } 109 } 110 111 /** 112 * 113 * @return Comparison Operators 114 */ 115 public Operator[] getComparisonOperators() { 116 return comparisonOperators.values().toArray( new Operator[comparisonOperators.values().size()] ); 117 } 118 119 /** 120 * 121 * @param arithmeticOperators 122 * may be null 123 */ 124 public void setArithmeticOperators( Operator[] arithmeticOperators ) { 125 this.arithmeticOperators = new HashMap<String, Operator>(); 126 if ( arithmeticOperators != null ) { 127 for ( int i = 0; i < arithmeticOperators.length; i++ ) { 128 this.arithmeticOperators.put( arithmeticOperators[i].getName(), arithmeticOperators[i] ); 129 } 130 } 131 } 132 133 /** 134 * 135 * @return Arithmetic Operators 136 */ 137 public Operator[] getArithmeticOperators() { 138 return arithmeticOperators.values().toArray( new Operator[arithmeticOperators.values().size()] ); 139 } 140 141 /** 142 * Returns if the given operator is supported. 143 * 144 * @param operatorName 145 * @return if the given operator is supported. 146 */ 147 public boolean hasComparisonOperator( String operatorName ) { 148 149 // hack to cope with 1.0.0 simple comparisons (type doesn't map to a unique 1.1.0 operator) 150 if (OperatorFactory100.OPERATOR_SIMPLE_COMPARISONS.equals( operatorName )) { 151 // assume simple comparison operations are supported when equal to is supported 152 operatorName = OperatorFactory110.EQUAL_TO; 153 } 154 155 return comparisonOperators.get( operatorName ) != null ? true : false; 156 } 157 158 /** 159 * Returns if the given operator is supported. 160 * 161 * @param operatorName 162 * @return if the given operator is supported. 163 */ 164 public boolean hasArithmeticOperator( String operatorName ) { 165 return arithmeticOperators.get( operatorName ) != null ? true : false; 166 } 167 }