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 * Handles an expression of a repository query.<br>
020 * The formal view depends on the implementation of the query.
021 */
022public interface Expression
023{
024    /** Enumeration of available operators in {@link Expression} */
025    public enum Operator 
026    {
027        /** Constant of test's operator for 'like' comparison. Works only for type String */
028        WD 
029        {
030            @Override
031            public String toString()
032            {
033                return "~";
034            }
035        },
036        /** Constant of test's operator for 'less than' comparison */
037        LT 
038        {
039            @Override
040            public String toString()
041            {
042                return "<";
043            }
044        },
045        /** Constant of test's operator for 'less than or equals to' comparison */
046        LE 
047        {
048            @Override
049            public String toString()
050            {
051                return "<=";
052            }
053        },
054        /** Constant of test's operator for 'greater than' comparison */
055        GT 
056        {
057            @Override
058            public String toString()
059            {
060                return ">";
061            }
062        },
063        /** Constant of test's operator for 'greater than or equals to' comparison */
064        GE 
065        {
066            @Override
067            public String toString()
068            {
069                return ">=";
070            }
071        },
072        /** Constant of test's operator for 'equals to' comparison */
073        EQ 
074        {
075            @Override
076            public String toString()
077            {
078                return "=";
079            }
080        },
081        /** Constant of test's operator for 'not equals to' comparison */
082        NE 
083        {
084            @Override
085            public String toString()
086            {
087                return "!=";
088            }
089        }
090    }
091
092    /**
093     * Build the expression.
094     * @return The XPath view of the expression.
095     */
096    public String build();
097}