001/* 002 * Copyright 2014 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.cms.search.query; 017 018/** 019 * Represents a {@link Query} testing a double field. 020 */ 021public class DoubleQuery extends AbstractFieldQuery 022{ 023 /** The operator. */ 024 protected Operator _operator; 025 /** The boolean value to test. */ 026 protected Double _value; 027 028 /** 029 * Build a DoubleQuery testing the existence of the field. 030 * @param fieldPath the field path 031 */ 032 public DoubleQuery(String fieldPath) 033 { 034 this(fieldPath, Operator.EXISTS, null); 035 } 036 037 /** 038 * Build a DoubleQuery. 039 * @param fieldPath the field's path 040 * @param value the value. 041 */ 042 public DoubleQuery(String fieldPath, Double value) 043 { 044 this(fieldPath, Operator.EQ, value); 045 } 046 047 /** 048 * Build a DoubleQuery. 049 * @param fieldPath the field's path 050 * @param op the operator. 051 * @param value the value. 052 */ 053 public DoubleQuery(String fieldPath, Operator op, Double value) 054 { 055 super(fieldPath); 056 _operator = op; 057 _value = value; 058 } 059 060 /** 061 * Get the operator. 062 * @return the operator. 063 */ 064 public Operator getOperator() 065 { 066 return _operator; 067 } 068 069 /** 070 * Get the value. 071 * @return the value. 072 */ 073 public double getValue() 074 { 075 return _value; 076 } 077 078 @Override 079 public String build() throws QuerySyntaxException 080 { 081 return QueryHelper.getStandardQuery(_fieldPath + "_d", _operator, _value); 082 } 083 084}