View Javadoc

1   /* This file is part of COPAL (COntext Provisioning for All).
2    *
3    * COPAL is a part of SM4All (Smart hoMes for All) project.
4    *
5    * COPAL is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU Lesser General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * COPAL is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public License
16   * along with COPAL. If not, see <http://www.gnu.org/licenses/>.
17   */
18  package at.ac.tuwien.infosys.sm4all.copal.api.service;
19  
20  import at.ac.tuwien.infosys.sm4all.copal.api.event.ContextEventType;
21  import at.ac.tuwien.infosys.sm4all.copal.api.util.AlreadyRegisteredException;
22  import at.ac.tuwien.infosys.sm4all.copal.api.util.NotRegisteredException;
23  import at.ac.tuwien.infosys.sm4all.copal.api.util.Observable;
24  import at.ac.tuwien.infosys.sm4all.copal.api.util.Registry;
25  import at.ac.tuwien.infosys.sm4all.copal.api.util.RegistryObservable.RegistrationState;
26  import at.ac.tuwien.infosys.sm4all.copal.api.util.RegistryObservable.RegistryObserver;
27  
28  /**
29   * Interface which COPAL provides to register, unregister, and query
30   * {@link ContextEventType}s.
31   * 
32   * @author sanjin
33   */
34  public interface ContextEventTypeRegistry
35          extends
36          Registry<String, ContextEventType>,
37          Observable<RegistrationState, ContextEventType, RegistryObserver<ContextEventType>> {
38  
39      /**
40       * Register specified {@link ContextEventType}.
41       * 
42       * @param eventType the {@link ContextEventType}.
43       * @throws AlreadyRegisteredException if a {@link ContextEventType} with
44       *         same name is already registered.
45       */
46      @Override
47      void register(ContextEventType eventType) throws AlreadyRegisteredException;
48  
49      /**
50       * Unregister {@link ContextEventType} with specified name.
51       * 
52       * @param name the name of the {@link ContextEventType}.
53       * @throws NotRegisteredException if no {@link ContextEventType} with
54       *         specified name is registered.
55       */
56      @Override
57      void unregister(String name) throws NotRegisteredException;
58  
59      /**
60       * Returns if a {@link ContextEventType} with specified name is currently
61       * registered.
62       * 
63       * @param name the name of the {@link ContextEventType}.
64       * @return if a {@link ContextEventType} with specified name is currently
65       *         registered.
66       */
67      @Override
68      boolean isRegistered(String name);
69  
70      /**
71       * Returns {@link ContextEventType} with specified name.
72       * 
73       * @param name the name of the {@link ContextEventType}.
74       * @return the {@link ContextEventType} or <code>null</code> if there is no
75       *         such {@link ContextEventType} registered.
76       */
77      @Override
78      ContextEventType get(String name);
79  
80      /**
81       * Returns all currently registered {@link ContextEventType}s.
82       * 
83       * @return all currently registered {@link ContextEventType}s.
84       */
85      @Override
86      ContextEventType[] getAll();
87  }