KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > sites > SiteLanguageSettings


1 package org.jahia.services.sites;
2
3 import java.io.Serializable JavaDoc;
4
5
6 /**
7  * <p>Title: Site language settings</p>
8  * <p>Description: contains the information about a language configured on
9  * a site. It contains information such as wether the language is activated on
10  * a site, the position in the order of preferences for this language, wether
11  * it is a mandatory language and finally it's language code, which is either
12  * an RFC 3066 language or a language code extension defined in Jahia's XML
13  * language definition file.
14  * This is usally part of a collection within a JahiaSite object.</p>
15  * <p>Copyright: Copyright (c) 2002</p>
16  * <p>Company: </p>
17  *
18  * @author Serge Huber
19  * @version 1.0
20  */

21
22 public class SiteLanguageSettings implements Serializable JavaDoc {
23
24     private int ID;
25     private int siteID;
26     private boolean activated;
27     private int rank;
28     private boolean mandatory;
29     private String JavaDoc code;
30     private boolean inPersistantStorage = false;
31     private boolean dataModified = false;
32
33     /**
34      * General bean constructor, with most of the values represented except
35      * the internal dataModified boolean. This is used notably by the
36      * persistance manager for these objects.
37      *
38      * @param ID identifier of the language setting in the database. If we
39      * are creating new objects not yet existing the in the database, this
40      * value will be ignored.
41      * @param siteID the site identifier this object is attached to.
42      * @param code the language code identifier for which to store the settings
43      * @param activated a boolean that specifies whether this language is
44      * active for the specified site
45      * @param rank the rank importance of this language. The lower the value
46      * the higher the rank
47      * @param mandatory specifies whether this language is mandatory for the
48      * specified site (influences the validation process of a page)
49      * @param existsInPersistantStorage a boolean that allows to indicate
50      * whether this object comes from the persistance manager. If you only
51      * need to create objects that are not yet existing in the storage space,
52      * we suggest the usage of the other constructor.
53      */

54     public SiteLanguageSettings (int ID, int siteID, String JavaDoc code,
55                                  boolean activated, int rank,
56                                  boolean mandatory,
57                                  boolean existsInPersistantStorage) {
58         this.ID = ID;
59         this.siteID = siteID;
60         this.code = code;
61         this.activated = activated;
62         this.rank = rank;
63         this.mandatory = mandatory;
64         this.inPersistantStorage = existsInPersistantStorage;
65     }
66
67     /**
68      * See the general constructor for details. Basically this alternative
69      * constructor is used when needed to create objects that don't yet exist
70      * in the database and that will be stored there later. This is why it has
71      * no ID or existsInPersistantStorage value
72      *
73      * @param siteID the site identifier this object is attached to.
74      * @param code the language code identifier for which to store the settings
75      * @param activated a boolean that specifies whether this language is
76      * active for the specified site
77      * @param rank the rank importance of this language. The lower the value
78      * the higher the rank
79      * @param mandatory specifies whether this language is mandatory for the
80      * specified site (influences the validation process of a page)
81      */

82     public SiteLanguageSettings (int siteID, String JavaDoc code,
83                                  boolean activated, int rank,
84                                  boolean mandatory) {
85         this (-1, siteID, code, activated, rank, mandatory, false);
86     }
87
88
89     /**
90      * Sets the database ID for the entry. This is used to when working with
91      * objects that don't exist yet in the persistant store. Basically we can
92      * create the object with a fake ID (ie -1) and then the backend system
93      * calls this method to set the ID to it's real value once it is stored.
94      *
95      * @param ID an integer representing the database id.
96      */

97     protected void setID (int ID) {
98         // this.dataModified = true;
99
this.ID = ID;
100     }
101
102     /**
103      * Retrieve the language setting database ID.
104      *
105      * @return an integer containing the database ID for this language setting
106      */

107     public int getID () {
108         return ID;
109     }
110
111     /**
112      * Retrieve the site identifier for this language setting.
113      *
114      * @return an integer containing the site identifier for this language
115      * setting entry.
116      */

117     public int getSiteID () {
118         return siteID;
119     }
120
121     /**
122      * Returns the language code for this language setting entry.
123      *
124      * @return a String object containing a language code (by default RFC 3066
125      * language codes but could be a Jahia extension) representing the language
126      * we are configuring
127      */

128     public String JavaDoc getCode () {
129         return code;
130     }
131
132     /**
133      * Returns true if the language is activated
134      *
135      * @return true if language is activated
136      */

137     public boolean isActivated () {
138         return activated;
139     }
140
141     /**
142      * Returns the rank for this language setting. The rank setting allows
143      * to specify the order of preference for site languages, and therefore
144      * allowing to fall back to other languages if content doesn't exist in a
145      * language, and also specifies the default language. The lower the rank,
146      * the more important the language (0=most important, ....)
147      *
148      * @return an integer (0-based) representing the rank of the language
149      */

150     public int getRank () {
151         return rank;
152     }
153
154     /**
155      * Sets the rank for this language entry. The rank setting allows
156      * to specify the order of preference for site languages, and therefore
157      * allowing to fall back to other languages if content doesn't exist in a
158      * language, and also specifies the default language. The lower the rank,
159      * the more important the language (0=most important, ....)
160      *
161      * @param rank an integer (0-based) representing the rank we set for this
162      * language. No verification on duplicate rank values is made here so make
163      * sure it is unique before setting this value.
164      */

165     public void setRank (int rank) {
166         this.dataModified = true;
167         this.rank = rank;
168     }
169
170     /**
171      * Returns true if the language is mandatory, meaning that before the page
172      * may be validated that all the field and containers must have content
173      * defined for this language.
174      *
175      * @return true if the language is mandatory on this site.
176      */

177     public boolean isMandatory () {
178         return mandatory;
179     }
180
181     /**
182      * Returns true if the data contained in this bean comes from the persistant
183      * storage values. It is not changed if the data is modified. For this
184      * information check out the isDataModified method.
185      *
186      * @return true if the bean comes from the persistant storage, false
187      * otherwise.
188      */

189     public boolean isInPersistantStorage () {
190         return inPersistantStorage;
191     }
192
193     /**
194      * Returns true if the data has been modified since the initial call to
195      * the constructor.
196      *
197      * @return true if the data has been modified.
198      */

199     public boolean isDataModified () {
200         return dataModified;
201     }
202
203     /**
204      * Allows to set the internal bean status to note that it has now been
205      * updated in the persistant storage and therefore is synchronized.
206      *
207      * @param dataModified set the value to true if the data has been
208      * synchronized with the persistant storage.
209      */

210     public void setDataModified (boolean dataModified) {
211         this.dataModified = dataModified;
212     }
213
214     /**
215      * Sets the activation property of a language. If a language is active
216      * it means that users can browse, add content, etc in that language.
217      *
218      * @param activated a boolean true if the language is active
219      */

220     public void setActivated (boolean activated) {
221         this.dataModified = true;
222         this.activated = activated;
223     }
224
225     /**
226      * Sets the mandatory property for a language. A mandatory language means
227      * that all the content on a page must exist in a mandatory language before
228      * it can be published
229      *
230      * @param mandatory a boolean. true means the language is mandatory.
231      */

232     public void setMandatory (boolean mandatory) {
233         this.dataModified = true;
234         this.mandatory = mandatory;
235     }
236
237 }
238
Popular Tags