Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / service / simulator / java / sdk / src / org / oic / simulator / server / SimulatorCollectionResource.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
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
17 package org.oic.simulator.server;
18
19 import java.util.Vector;
20
21 import org.oic.simulator.InvalidArgsException;
22 import org.oic.simulator.SimulatorException;
23
24 /**
25  * This class represents a collection type resource which provides a set of APIs
26  * that are specific to collection resource for adding/removing child resources
27  * and obtaining all child resources from the collection.
28  */
29 public final class SimulatorCollectionResource extends SimulatorResource {
30
31     /**
32      * API to add child resource to collection.
33      *
34      * @param resource
35      *            Child resource to be added to collection.
36      *
37      * @throws InvalidArgsException
38      *             This exception will be thrown on invalid input.
39      * @throws SimulatorException
40      *             This exception will be thrown on occurrence of error in
41      *             native.
42      */
43     public void addChildResource(SimulatorResource resource)
44             throws InvalidArgsException, SimulatorException {
45         nativeAddChildResource(resource);
46     }
47
48     /**
49      * API to remove child resource from collection.
50      *
51      * @param resource
52      *            Child resource to be removed from collection.
53      *
54      * @throws InvalidArgsException
55      *             This exception will be thrown on invalid input.
56      * @throws SimulatorException
57      *             This exception will be thrown on occurrence of error in
58      *             native.
59      */
60     public void removeChildResource(SimulatorResource resource)
61             throws InvalidArgsException, SimulatorException {
62         nativeRemoveChildResource(resource);
63     }
64
65     /**
66      * API to remove child resource from collection.
67      *
68      * @param uri
69      *            URI of child resource to be removed from collection.
70      *
71      * @throws InvalidArgsException
72      *             This exception will be thrown on invalid input.
73      * @throws SimulatorException
74      *             This exception will be thrown on occurrence of error in
75      *             native.
76      */
77     public void removeChildResourceByUri(String uri)
78             throws InvalidArgsException, SimulatorException {
79         nativeRemoveChildResourceByUri(uri);
80     }
81
82     /**
83      * API to get list of child resources.
84      *
85      * @return Vector of child resources {@link SimulatorResource}.
86      *
87      * @throws SimulatorException
88      *             This exception will be thrown on occurrence of error in
89      *             native.
90      */
91     public Vector<SimulatorResource> getChildResources()
92             throws SimulatorException {
93         return nativeGetChildResources();
94     }
95
96     private SimulatorCollectionResource(long nativeHandle) {
97         mNativeHandle = nativeHandle;
98     }
99
100     private native void nativeAddChildResource(SimulatorResource resource);
101
102     private native void nativeRemoveChildResource(SimulatorResource resource);
103
104     private native void nativeRemoveChildResourceByUri(String uri);
105
106     private native Vector<SimulatorResource> nativeGetChildResources();
107 }