Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SDK / java / org / iotivity / service / ssm / QueryEngine.java
1 /******************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20 /**
21  * @file    QueryEngine.java
22  *
23  * @brief    This file provides a class that represents main interface of Query Engine
24  *
25  */
26
27 package org.iotivity.service.ssm;
28
29 /**
30 * @class    QueryEngine
31 * @brief     This class represents main interface of Query Engine to interact with
32 *           SSMCore with in turn interacts with the application.
33 *           QueryEninge class forms the database from the base to respond to
34 *           queries from SSMCore.
35 *
36 */
37 public class QueryEngine
38 {
39         private int pQueryEngineInstance;
40
41         public QueryEngine(int queryEngineInstance)
42         {
43             pQueryEngineInstance = queryEngineInstance;
44         }
45
46         /**
47          * Obtain the instance value of the called query engine object,
48          *          this value is set on creation of the QueryEngine object
49          *
50          * @return int - Instance of the query engine object, set on object's creation
51          * 
52          */
53         public int getQueryEngineInstance()
54         {
55             return pQueryEngineInstance;
56         }
57
58         /**
59          * Execute the query with the QueryEngine and return ContextQuery ID
60          *            for the query
61          *
62          * @param contextQuery 
63          *               - query string to be executed
64          *
65          * @return int - ID of context query executed
66          * 
67          */
68         public int executeContextQuery(String contextQuery) throws Exception
69         {
70             return CoreController.getInstance().executeContextQuery(
71                 pQueryEngineInstance, contextQuery);
72         }
73
74         /**
75          * Register QueryEngineEvent to QueryEngine
76          *
77          * @param queryEngineEvent 
78          *               - the event class to receive QueryEngine events
79          *
80          * @return void
81          * 
82          */
83         public void registerQueryEvent(IQueryEngineEvent queryEngineEvent)
84         {
85             CoreController.getInstance().registerQueryEvent(pQueryEngineInstance,
86                     queryEngineEvent);
87         }
88
89         /**
90          * Kill the registered ContextQuery corresponding to the  to cqid
91          *
92          * @param cqid 
93          *              - ContextQuery ID of the query to be terminated
94          *
95          * @return void
96          * 
97          */
98         public void killContextQuery(int cqid) throws Exception
99         {
100             CoreController.getInstance().killContextQuery(pQueryEngineInstance,
101             cqid);
102         }
103 }