001/* 002 * Copyright 2010 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.plugins.repository.query.expression; 017 018/** 019 * Constructs an {@link Expression} corresponding to the double comparison with a metadata. 020 */ 021public class DoubleExpression implements Expression 022{ 023 private double _value; 024 private Operator _operator; 025 private MetadataExpression _metadata; 026 027 /** 028 * Creates the comparison Expression. 029 * @param metadata the metadata name 030 * @param operator the operator to make the comparison 031 * @param value the double value 032 */ 033 public DoubleExpression(String metadata, Operator operator, double value) 034 { 035 _value = value; 036 _operator = operator; 037 _metadata = new MetadataExpression(metadata); 038 } 039 040 /** 041 * Creates the comparison Expression. 042 * @param metadata the metadata name 043 * @param operator the operator to make the comparison 044 * @param value the double value 045 * @param unversioned true if the metadata is unversioned, false otherwise. 046 */ 047 public DoubleExpression(String metadata, Operator operator, double value, boolean unversioned) 048 { 049 _value = value; 050 _operator = operator; 051 _metadata = new MetadataExpression(metadata, unversioned); 052 } 053 054 public String build() 055 { 056 return _metadata.build() + " " + _operator + " " + Double.toString(_value); 057 } 058}