001/* 002 * Copyright 2016 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 range. 020 */ 021public class DoubleRangeQuery extends AbstractRangeQuery<Double> 022{ 023 /** 024 * Build a double range query. 025 * @param fieldPath The field path. 026 * @param lower The lower end of the range. 027 * @param upper The upper end of the range. 028 */ 029 public DoubleRangeQuery(String fieldPath, double lower, double upper) 030 { 031 this(fieldPath, lower, upper, true, true); 032 } 033 034 /** 035 * Build a double range query. 036 * @param fieldPath The field path. 037 * @param lower The lower end of the range. 038 * @param upper The upper end of the range. 039 * @param includeLower Whether to include the lower end or not. 040 * @param includeUpper Whether to include the upper end or not. 041 */ 042 public DoubleRangeQuery(String fieldPath, double lower, double upper, boolean includeLower, boolean includeUpper) 043 { 044 super(fieldPath + "_d", lower, upper, includeLower, includeUpper); 045 } 046 047 @Override 048 public String lowerBoundForQuery(Double value) 049 { 050 if (value == null || value.isInfinite()) 051 { 052 return "*"; 053 } 054 055 return super.lowerBoundForQuery(value); 056 } 057 058 @Override 059 public String upperBoundForQuery(Double value) 060 { 061 if (value == null || value.isInfinite()) 062 { 063 return "*"; 064 } 065 066 return super.upperBoundForQuery(value); 067 } 068}