1 /* 2 * Copyright (C) 2010 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.clearsilver.jsilver.functions.bundles; 18 19 import com.google.clearsilver.jsilver.functions.FunctionRegistry; 20 import com.google.clearsilver.jsilver.functions.operators.AddFunction; 21 import com.google.clearsilver.jsilver.functions.operators.AndFunction; 22 import com.google.clearsilver.jsilver.functions.operators.DivideFunction; 23 import com.google.clearsilver.jsilver.functions.operators.EqualFunction; 24 import com.google.clearsilver.jsilver.functions.operators.ExistsFunction; 25 import com.google.clearsilver.jsilver.functions.operators.GreaterFunction; 26 import com.google.clearsilver.jsilver.functions.operators.GreaterOrEqualFunction; 27 import com.google.clearsilver.jsilver.functions.operators.LessFunction; 28 import com.google.clearsilver.jsilver.functions.operators.LessOrEqualFunction; 29 import com.google.clearsilver.jsilver.functions.operators.ModuloFunction; 30 import com.google.clearsilver.jsilver.functions.operators.MultiplyFunction; 31 import com.google.clearsilver.jsilver.functions.operators.NotEqualFunction; 32 import com.google.clearsilver.jsilver.functions.operators.NotFunction; 33 import com.google.clearsilver.jsilver.functions.operators.NumericAddFunction; 34 import com.google.clearsilver.jsilver.functions.operators.NumericEqualFunction; 35 import com.google.clearsilver.jsilver.functions.operators.NumericFunction; 36 import com.google.clearsilver.jsilver.functions.operators.NumericNotEqualFunction; 37 import com.google.clearsilver.jsilver.functions.operators.OrFunction; 38 import com.google.clearsilver.jsilver.functions.operators.SubtractFunction; 39 import com.google.clearsilver.jsilver.functions.structure.NameFunction; 40 41 /** 42 * Function registry containing core operators used in expressions. 43 * 44 * These are: + - * / % ? ! && || == != < > <= >=, name. 45 * 46 * @see FunctionRegistry 47 */ 48 public class CoreOperators extends FunctionRegistry { 49 50 @Override 51 protected void setupDefaultFunctions() { 52 super.setupDefaultFunctions(); 53 registerFunction("+", new AddFunction()); 54 registerFunction("#+", new NumericAddFunction()); 55 registerFunction("-", new SubtractFunction()); 56 registerFunction("*", new MultiplyFunction()); 57 registerFunction("/", new DivideFunction()); 58 registerFunction("%", new ModuloFunction()); 59 registerFunction("?", new ExistsFunction()); 60 registerFunction("!", new NotFunction()); 61 registerFunction("&&", new AndFunction()); 62 registerFunction("||", new OrFunction()); 63 registerFunction("==", new EqualFunction()); 64 registerFunction("#==", new NumericEqualFunction()); 65 registerFunction("!=", new NotEqualFunction()); 66 registerFunction("#!=", new NumericNotEqualFunction()); 67 registerFunction("<", new LessFunction()); 68 registerFunction(">", new GreaterFunction()); 69 registerFunction("<=", new LessOrEqualFunction()); 70 registerFunction(">=", new GreaterOrEqualFunction()); 71 registerFunction("#", new NumericFunction()); 72 73 // Not an operator, but JSilver cannot function without as it's used by 74 // the <?cs name ?> command. 75 registerFunction("name", new NameFunction()); 76 } 77 78 } 79