26798509511f9d0470591ce003593c07a272044f
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SDK / java / org / iotivity / service / ssm / DataReader.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    DataReader.java
22  *
23  * @brief    This file provides a class that represents context model data package's reader
24  *
25  */
26
27 package org.iotivity.service.ssm;
28
29 import java.util.List;
30
31 /**
32 * @class    DataReader
33 * @brief     This class represents context model data package's reader and contains
34 *           API's to be used by IQueryEngineEvent listeners to handle the model data.
35 *
36 */
37 public class DataReader
38 {
39
40         private int pDataReaderInstance;
41
42         public DataReader(int dataReaderInstance)
43         {
44             pDataReaderInstance = dataReaderInstance;
45         }
46
47         /**
48          * Get affected context models. The CQL(context query language) can specify
49          *       multiple ContextModels for retrieving data so a list of string of affected
50          *       context models is returned
51          *
52          * @return List<String> - affected ContextModel list
53          * 
54          */
55         public List<String> getAffectedModels()
56         {
57             return CoreController.getInstance().getAffectedModels(
58                        pDataReaderInstance);
59         }
60
61         /**
62          * Get affected model data count. There can be multiple data models existing
63          *       from the given condition, return the count.
64          *
65          * @param modelName 
66          *              - affected ContextModel name
67          *
68          * @return int  - affected dataId count
69          * 
70          */
71         public int getModelDataCount(String modelName) throws Exception
72         {
73             return CoreController.getInstance().getModelDataCount(
74                 pDataReaderInstance, modelName);
75         }
76
77         /**
78          * Get actual Context Model data
79          *
80          * @param modelName 
81          *              - affected ContextModel name
82          *
83          * @param dataIndex 
84          *              - affected dataId index
85          *
86          * @return ModelData  - affected ContextModel data reader
87          * 
88          */
89         public ModelData getModelData(String modelName, int dataIndex)
90         throws Exception
91         {
92             return CoreController.getInstance().getModelData(pDataReaderInstance,
93             modelName, dataIndex);
94         }
95 }