CoreOperators.java revision 712c262ddf6790c16a8567053f616c71da7e1856
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
17package com.google.clearsilver.jsilver.functions.bundles;
18
19import com.google.clearsilver.jsilver.functions.FunctionRegistry;
20import com.google.clearsilver.jsilver.functions.operators.AddFunction;
21import com.google.clearsilver.jsilver.functions.operators.AndFunction;
22import com.google.clearsilver.jsilver.functions.operators.DivideFunction;
23import com.google.clearsilver.jsilver.functions.operators.EqualFunction;
24import com.google.clearsilver.jsilver.functions.operators.ExistsFunction;
25import com.google.clearsilver.jsilver.functions.operators.GreaterFunction;
26import com.google.clearsilver.jsilver.functions.operators.GreaterOrEqualFunction;
27import com.google.clearsilver.jsilver.functions.operators.LessFunction;
28import com.google.clearsilver.jsilver.functions.operators.LessOrEqualFunction;
29import com.google.clearsilver.jsilver.functions.operators.ModuloFunction;
30import com.google.clearsilver.jsilver.functions.operators.MultiplyFunction;
31import com.google.clearsilver.jsilver.functions.operators.NotEqualFunction;
32import com.google.clearsilver.jsilver.functions.operators.NotFunction;
33import com.google.clearsilver.jsilver.functions.operators.NumericAddFunction;
34import com.google.clearsilver.jsilver.functions.operators.NumericEqualFunction;
35import com.google.clearsilver.jsilver.functions.operators.NumericFunction;
36import com.google.clearsilver.jsilver.functions.operators.NumericNotEqualFunction;
37import com.google.clearsilver.jsilver.functions.operators.OrFunction;
38import com.google.clearsilver.jsilver.functions.operators.SubtractFunction;
39import com.google.clearsilver.jsilver.functions.structure.NameFunction;
40
41/**
42 * Function registry containing core operators used in expressions.
43 *
44 * These are: + - * / % ? ! && || == != < > &lt= >=, name.
45 *
46 * @see FunctionRegistry
47 */
48public 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