View Javadoc
1   /*
2    * Copyright (c) 2002-2022, City of 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.plugins.unittree.business.action;
35  
36  import java.util.Locale;
37  
38  import fr.paris.lutece.portal.service.i18n.I18nService;
39  
40  /**
41   *
42   * AbstractAction
43   *
44   */
45  public abstract class AbstractAction implements IAction
46  {
47      private int _nIdAction;
48      private String _strUrl;
49      private String _strNameKey;
50      private String _strDescriptionKey;
51      private Locale _locale;
52      private String _strIcon;
53      private String _strPermission;
54  
55      /**
56       * Set the id action
57       * 
58       * @param nIdAction
59       *            the nIdAction to set
60       */
61      public void setIdAction( int nIdAction )
62      {
63          this._nIdAction = nIdAction;
64      }
65  
66      /**
67       * Get the id action
68       * 
69       * @return the nIdAction
70       */
71      public int getIdAction( )
72      {
73          return _nIdAction;
74      }
75  
76      /**
77       * Implements Localizable
78       * 
79       * @param locale
80       *            The current locale
81       */
82      public void setLocale( Locale locale )
83      {
84          _locale = locale;
85      }
86  
87      /**
88       * Return the Url
89       * 
90       * @return The Url
91       */
92      public String getUrl( )
93      {
94          return _strUrl;
95      }
96  
97      /**
98       * Set the Url
99       * 
100      * @param strUrl
101      *            The Url
102      */
103     public void setUrl( String strUrl )
104     {
105         _strUrl = strUrl;
106     }
107 
108     /**
109      * Returns the NameKey
110      * 
111      * @return The NameKey
112      */
113     public String getNameKey( )
114     {
115         return _strNameKey;
116     }
117 
118     /**
119      * Returns the Name
120      * 
121      * @return The Name
122      */
123     public String getName( )
124     {
125         return I18nService.getLocalizedString( _strNameKey, _locale );
126     }
127 
128     /**
129      * Sets the NameKey
130      * 
131      * @param strNameKey
132      *            The NameKey
133      */
134     public void setNameKey( String strNameKey )
135     {
136         _strNameKey = strNameKey;
137     }
138 
139     /**
140      * Returns the DescriptionKey
141      * 
142      * @return The DescriptionKey
143      */
144     public String getDescriptionKey( )
145     {
146         return _strDescriptionKey;
147     }
148 
149     /**
150      * Returns the Description
151      * 
152      * @return The Description
153      */
154     public String getDescription( )
155     {
156         return I18nService.getLocalizedString( _strDescriptionKey, _locale );
157     }
158 
159     /**
160      * Sets the DescriptionKey
161      * 
162      * @param strDescriptionKey
163      *            The DescriptionKey
164      */
165     public void setDescriptionKey( String strDescriptionKey )
166     {
167         _strDescriptionKey = strDescriptionKey;
168     }
169 
170     /**
171      * Returns the icon
172      * 
173      * @return The icon
174      */
175     public String getIcon( )
176     {
177         return _strIcon;
178     }
179 
180     /**
181      * Sets the icon
182      * 
183      * @param strIcon
184      *            The icon
185      */
186     public void setIcon( String strIcon )
187     {
188         _strIcon = strIcon;
189     }
190 
191     /**
192      * Returns the permission associated to the action
193      * 
194      * @return The permission
195      */
196     public String getPermission( )
197     {
198         return _strPermission;
199     }
200 
201     /**
202      * Sets the Permission
203      * 
204      * @param strPermission
205      *            The Permission
206      */
207     public void setPermission( String strPermission )
208     {
209         _strPermission = strPermission;
210     }
211 
212     /**
213      * {@inheritDoc}
214      */
215     @Override
216     public int hashCode( )
217     {
218         final int prime = 31;
219         int result = 1;
220         result = ( prime * result ) + _nIdAction;
221 
222         return result;
223     }
224 
225     /**
226      * {@inheritDoc}
227      */
228     @Override
229     public boolean equals( Object obj )
230     {
231         if ( this == obj )
232         {
233             return true;
234         }
235 
236         if ( obj == null )
237         {
238             return false;
239         }
240 
241         if ( getClass( ) != obj.getClass( ) )
242         {
243             return false;
244         }
245 
246         AbstractAction./../../../../fr/paris/lutece/plugins/unittree/business/action/AbstractAction.html#AbstractAction">AbstractAction other = (AbstractAction) obj;
247 
248         return ( _nIdAction != other._nIdAction );
249     }
250 }