KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jahia.services.sites;
2
3 import java.io.Serializable JavaDoc;
4
5 /**
6  * <p>Title: Site language mapping bean</p>
7  * <p>Description: This bean represents an entry for a language mapping in a
8  * site. A language mapping allows to define "routes" to resolve languages.
9  * A typical example of a language mapping could be :</p>
10  * <p> fr -> fr_FR </p>
11  * <p>This is particularly interesting for Jahia since the needs of configuraiton
12  * for the languages might evolve over time, and there is no need to redefine
13  * all the content when needed to do simple mappings such as this one.
14  * </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 SiteLanguageMapping implements Serializable JavaDoc {
23     private int id = -1;
24     private String JavaDoc fromLanguageCode;
25     private String JavaDoc toLanguageCode;
26     private int siteID;
27
28     /**
29      * Internal constructor used only for persistance purposes. For new objects
30      * to be serialized, check the constructor that doesn't take an ID.
31      *
32      * @param id the identifier from the database
33      * @param siteID the identifier for the site in which this mapping
34      * resides.
35      * @param fromLanguageCode the language code from which we want to resolve
36      * @param toLanguageCode the language code to which we want the
37      * fromLanguageCode to point.
38      */

39     protected SiteLanguageMapping (int id, int siteID, String JavaDoc fromLanguageCode,
40                                    String JavaDoc toLanguageCode) {
41         this.id = id;
42         this.siteID = siteID;
43         this.fromLanguageCode = fromLanguageCode;
44         this.toLanguageCode = toLanguageCode;
45     }
46
47     /**
48      * Public constructor destined for building this bean first in memory to
49      * be saved in the database later.
50      *
51      * @param siteID the identifier for the site in which this mapping
52      * resides.
53      * @param fromLanguageCode the language code from which we want to resolve
54      * @param toLanguageCode the language code to which we want the
55      * fromLanguageCode to point.
56      */

57     public SiteLanguageMapping (int siteID, String JavaDoc fromLanguageCode, String JavaDoc toLanguageCode) {
58         this.siteID = siteID;
59         this.fromLanguageCode = fromLanguageCode;
60         this.toLanguageCode = toLanguageCode;
61     }
62
63     /**
64      * Returns the value of the database identifier for this bean.
65      *
66      * @return the integer corresponding to the ID in the database, OR -1 if
67      * this bean exists only in memory.
68      */

69     public int getId () {
70         return id;
71     }
72
73     /**
74      * Used by the persistance manager to set an ID for a bean that was
75      * previously created in memory. From this call on this bean exists in
76      * the persistant store
77      *
78      * @param id the integer corresponding to the database identifier
79      */

80     protected void setId (int id) {
81         this.id = id;
82     }
83
84     /**
85      * Set the site identifier this mapping belongs to.
86      *
87      * @param siteID an integer containing the site identifier for this
88      * mapping.
89      */

90     public void setSiteID (int siteID) {
91         this.siteID = siteID;
92     }
93
94     /**
95      * Returns the site identifier this mapping belongs to.
96      *
97      * @return an integer representing the unique site identifier this mapping
98      * belongs to.
99      */

100     public int getSiteID () {
101         return siteID;
102     }
103
104     /**
105      * Sets the languageCode to map to another languageCode. Use the
106      * setToLanguageCode to set the target corresponding to this source
107      * language code.
108      *
109      * @param fromLanguageCode the language code (corresponding to a
110      * Locale.toString() compliant output) that we want to map for
111      */

112     public void setFromLanguageCode (String JavaDoc fromLanguageCode) {
113         this.fromLanguageCode = fromLanguageCode;
114     }
115
116     /**
117      * Returns the current "source" language code in this mapping. The format
118      * of this String is compliant to the Locale.toString() output.
119      *
120      * @return a String in the Locale.toString() format corresponding to the
121      * source of the mapping.
122      */

123     public String JavaDoc getFromLanguageCode () {
124         return fromLanguageCode;
125     }
126
127     /**
128      * Sets the target languageCode for this mapping. This strings format
129      * must compliant to the output of Locale.toString().
130      *
131      * @param toLanguageCode a String containing a Locale.toString() formatted
132      * language code that will correspond to the target language for the
133      * from language code defined also in this bean.
134      */

135     public void setToLanguageCode (String JavaDoc toLanguageCode) {
136         this.toLanguageCode = toLanguageCode;
137     }
138
139     /**
140      * Returns the value of the "target" language code in this mapping
141      *
142      * @return a String in a Locale.toString() compliant format that represents
143      * the target language code in this mapping.
144      */

145     public String JavaDoc getToLanguageCode () {
146         return toLanguageCode;
147     }
148 }
149
Popular Tags