1 | /* |
2 | * Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. |
3 | * |
4 | * WSO2 Inc. licenses this file to you under the Apache License, |
5 | * Version 2.0 (the "License"); you may not use this file except |
6 | * in compliance with the License. |
7 | * You may obtain a copy of the License at |
8 | * |
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | * |
11 | * Unless required by applicable law or agreed to in writing, |
12 | * software distributed under the License is distributed on an |
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | * KIND, either express or implied. See the License for the |
15 | * specific language governing permissions and limitations |
16 | * under the License. |
17 | */ |
18 | package org.wso2.siddhi.query.api.expression; |
19 | |
20 | |
21 | import org.wso2.siddhi.query.api.expression.constant.BoolConstant; |
22 | import org.wso2.siddhi.query.api.expression.constant.DoubleConstant; |
23 | import org.wso2.siddhi.query.api.expression.constant.FloatConstant; |
24 | import org.wso2.siddhi.query.api.expression.constant.IntConstant; |
25 | import org.wso2.siddhi.query.api.expression.constant.LongConstant; |
26 | import org.wso2.siddhi.query.api.expression.constant.StringConstant; |
27 | |
28 | public abstract class Expression { |
29 | public static StringConstant value(String value) { |
30 | return new StringConstant(value); |
31 | } |
32 | |
33 | public static IntConstant value(int value) { |
34 | return new IntConstant(value); |
35 | } |
36 | |
37 | public static LongConstant value(long value) { |
38 | return new LongConstant(value); |
39 | } |
40 | |
41 | public static DoubleConstant value(double value) { |
42 | return new DoubleConstant(value); |
43 | } |
44 | |
45 | public static FloatConstant value(float value) { |
46 | return new FloatConstant(value); |
47 | } |
48 | |
49 | public static BoolConstant value(boolean value) { |
50 | return new BoolConstant(value); |
51 | } |
52 | |
53 | public static Variable variable(String streamId, String attributeName) { |
54 | return new Variable(streamId, attributeName); |
55 | } |
56 | |
57 | public static Add add(Expression leftValue, Expression rightValue) { |
58 | return new Add(leftValue, rightValue); |
59 | } |
60 | |
61 | public static Minus minus(Expression leftValue, Expression rightValue) { |
62 | return new Minus(leftValue, rightValue); |
63 | } |
64 | |
65 | public static Multiply multiply(Expression leftValue, Expression rightValue) { |
66 | return new Multiply(leftValue, rightValue); |
67 | } |
68 | |
69 | public static Divide divide(Expression leftValue, Expression rightValue) { |
70 | return new Divide(leftValue, rightValue); |
71 | } |
72 | |
73 | public static Mod mod(Expression leftValue, Expression rightValue) { |
74 | return new Mod(leftValue, rightValue); |
75 | } |
76 | |
77 | public static Variable variable(String attributeName) { |
78 | return new Variable(null, attributeName); |
79 | } |
80 | |
81 | // public abstract Attribute.Type getType(); |
82 | |
83 | // public abstract void inferType(Map<String, StreamDefinition> streamDefinitionMap); |
84 | |
85 | public static Variable variable(String streamId,int position, String attributeName) { |
86 | return new Variable(streamId,position, attributeName); |
87 | } |
88 | } |