View Javadoc
1   /*
2    * Copyright (c) 2002-2014, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.portal.service.prefs;
35  
36  import java.util.List;
37  
38  
39  /**
40   * User Preferences Interface
41   */
42  public interface IUserPreferencesService
43  {
44      /**
45       * Get a preference for a given user
46       * @param strUserId The user's ID
47       * @param strKey The preference's key
48       * @param strDefault The default value
49       * @return The preference's value
50       */
51      String get( String strUserId, String strKey, String strDefault );
52  
53      /**
54       * Get an integer preference for a given user
55       * @param strUserId The user's ID
56       * @param strKey The preference's key
57       * @param nDefault The default value
58       * @return The preference's value
59       */
60      int getInt( String strUserId, String strKey, int nDefault );
61  
62      /**
63       * Get a boolean preference for a given user
64       * @param strUserId The user's ID
65       * @param strKey The preference's key
66       * @param bDefault The default value
67       * @return The preference's value
68       */
69      boolean getBoolean( String strUserId, String strKey, boolean bDefault );
70  
71      /**
72       * Get the list of users associated with a key and a value
73       * @param strKey The preference's key
74       * @param strValue The preference's value
75       * @return The list of user id associated with a key and a value, or an
76       *         empty list if no user id is associated with the given parameters.
77       */
78      List<String> getUsers( String strKey, String strValue );
79  
80      /**
81       * Put a preference for a given user
82       * @param strUserId The user's ID
83       * @param strKey The preference's key
84       * @param strValue The value
85       */
86      void put( String strUserId, String strKey, String strValue );
87  
88      /**
89       * Put an integer preference for a given user
90       * @param strUserId The user's ID
91       * @param strKey The preference's key
92       * @param nValue The value
93       */
94      void putInt( String strUserId, String strKey, int nValue );
95  
96      /**
97       * Put a boolean preference for a given user
98       * @param strUserId The user's ID
99       * @param strKey The preference's key
100      * @param bValue The value
101      */
102     void putBoolean( String strUserId, String strKey, boolean bValue );
103 
104     /**
105      * Get all preference keys for a given user
106      * @param strUserId The user's ID
107      * @return The keys
108      */
109     List<String> keys( String strUserId );
110 
111     /**
112      * Clear all preferences for a given user
113      * @param strUserId The user's ID
114      */
115     void clear( String strUserId );
116 
117     /**
118      * Clear a preference for a given user
119      * @param strUserId The user's ID
120      * @param strKey The preference's key
121      */
122     void clearKey( String strUserId, String strKey );
123 
124     /**
125      * Clear all preferences with a given prefix for a given user
126      * @param strUserId The user's ID
127      * @param strPrefix The keys prefix
128      */
129     void clearKeyPrefix( String strUserId, String strPrefix );
130 
131     /**
132      * Cheks if a preference key exists
133      * @param strUserId The User ID
134      * @param strKey The Pref key
135      * @return 1 if exists otherwise false
136      */
137     boolean existsKey( String strUserId, String strKey );
138     /**
139      * Checks if a value is already used for a preference given key 
140      * @param strKey The Pref key
141      * @param strValue The Pref Value
142      * @return 1 if exists otherwise false
143      */
144     boolean existsValueForKey( String strKey,String strValue );
145 }