| 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; |
| 19 | |
| 20 | import org.wso2.siddhi.query.api.condition.Condition; |
| 21 | import org.wso2.siddhi.query.api.definition.StreamDefinition; |
| 22 | import org.wso2.siddhi.query.api.query.Query; |
| 23 | import org.wso2.siddhi.query.api.query.projection.Projector; |
| 24 | import org.wso2.siddhi.query.api.stream.JoinStream; |
| 25 | import org.wso2.siddhi.query.api.stream.SingleStream; |
| 26 | import org.wso2.siddhi.query.api.stream.Stream; |
| 27 | import org.wso2.siddhi.query.api.stream.pattern.PatternStream; |
| 28 | import org.wso2.siddhi.query.api.stream.pattern.element.PatternElement; |
| 29 | import org.wso2.siddhi.query.api.stream.sequence.SequenceStream; |
| 30 | import org.wso2.siddhi.query.api.stream.sequence.element.SequenceElement; |
| 31 | |
| 32 | public abstract class QueryFactory { |
| 33 | |
| 34 | public static Query createQuery() { |
| 35 | return new Query(); |
| 36 | } |
| 37 | |
| 38 | public static StreamDefinition createStreamDefinition() { |
| 39 | return new StreamDefinition(); |
| 40 | } |
| 41 | |
| 42 | public static SingleStream inputStream(String streamId) { |
| 43 | return new SingleStream(streamId, streamId); |
| 44 | } |
| 45 | |
| 46 | public static Projector outputProjector() { |
| 47 | return new Projector(); |
| 48 | } |
| 49 | |
| 50 | public static Stream joinStream(SingleStream leftStream, JoinStream.Type type, |
| 51 | SingleStream rightStream, |
| 52 | Condition onCompare) { |
| 53 | return new JoinStream(leftStream, type, rightStream, onCompare, JoinStream.EventTrigger.ALL); |
| 54 | } |
| 55 | |
| 56 | public static Stream joinStream(SingleStream leftStream, JoinStream.Type type, |
| 57 | SingleStream rightStream) { |
| 58 | return new JoinStream(leftStream, type, rightStream, null, JoinStream.EventTrigger.ALL); |
| 59 | } |
| 60 | |
| 61 | public static Stream joinStream(SingleStream leftStream, JoinStream.Type type, |
| 62 | SingleStream rightStream, |
| 63 | Condition onCompare, JoinStream.EventTrigger trigger) { |
| 64 | return new JoinStream(leftStream, type, rightStream, onCompare, trigger); |
| 65 | } |
| 66 | |
| 67 | public static SingleStream inputStream(String streamReferenceId, String streamId) { |
| 68 | return new SingleStream(streamReferenceId, streamId); |
| 69 | |
| 70 | } |
| 71 | |
| 72 | public static PatternStream patternStream(PatternElement patternElement) { |
| 73 | return new PatternStream(patternElement); |
| 74 | } |
| 75 | |
| 76 | public static SequenceStream sequenceStream(SequenceElement sequenceElement) { |
| 77 | return new SequenceStream(sequenceElement); |
| 78 | } |
| 79 | } |