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 /** The logical operator to use in xpath query */ 025 public enum LogicalOperator 026 { 027 /** Logical operator AND */ 028 AND 029 { 030 @Override 031 public String toString() 032 { 033 return " and "; 034 } 035 }, 036 /** Logical operator OR */ 037 OR 038 { 039 @Override 040 public String toString() 041 { 042 return " or "; 043 } 044 } 045 } 046 047 /** Enumeration of available operators in {@link Expression} */ 048 public enum Operator 049 { 050 /** Constant of test's operator for 'like' comparison. Works only for type String */ 051 WD 052 { 053 @Override 054 public String toString() 055 { 056 return "~"; 057 } 058 }, 059 /** Constant of test's operator for 'less than' comparison */ 060 LT 061 { 062 @Override 063 public String toString() 064 { 065 return "<"; 066 } 067 }, 068 /** Constant of test's operator for 'less than or equals to' comparison */ 069 LE 070 { 071 @Override 072 public String toString() 073 { 074 return "<="; 075 } 076 }, 077 /** Constant of test's operator for 'greater than' comparison */ 078 GT 079 { 080 @Override 081 public String toString() 082 { 083 return ">"; 084 } 085 }, 086 /** Constant of test's operator for 'greater than or equals to' comparison */ 087 GE 088 { 089 @Override 090 public String toString() 091 { 092 return ">="; 093 } 094 }, 095 /** Constant of test's operator for 'equals to' comparison */ 096 EQ 097 { 098 @Override 099 public String toString() 100 { 101 return "="; 102 } 103 }, 104 /** Constant of test's operator for 'not equals to' comparison */ 105 NE 106 { 107 @Override 108 public String toString() 109 { 110 return "!="; 111 } 112 } 113 } 114 115 /** 116 * Build the expression. 117 * @return The XPath view of the expression. 118 */ 119 public String build(); 120}