1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.om.impl;
18
19 import java.util.Locale;
20
21 import org.apache.jetspeed.util.JetspeedLocale;
22 import org.apache.jetspeed.om.common.MutableDescription;
23
24 /***
25 * DescriptionImpl
26 * <br>
27 * Basic Implementation of the <code>MutableDescription</code>
28 * interface.
29 *
30 * @see org.apache.jetspeed.om.common.MutableDescription
31 *
32 * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
33 * @version $Id: DescriptionImpl.java 516448 2007-03-09 16:25:47Z ate $
34 *
35 */
36 public abstract class DescriptionImpl implements MutableDescription
37 {
38
39 private String description;
40 private Locale locale;
41
42 protected long parentId;
43
44 protected long id;
45
46 /***
47 * Tells OJB which class to use to materialize.
48 */
49 protected String ojbConcreteClass = DescriptionImpl.class.getName();
50
51
52
53
54
55
56 public DescriptionImpl()
57 {
58 super();
59
60 locale = JetspeedLocale.getDefaultLocale();
61 }
62
63 public DescriptionImpl(Locale locale, String description)
64 {
65 this();
66 this.locale = locale;
67 this.description = description;
68
69 }
70
71 /***
72 * @see org.apache.jetspeed.om.registry.Description#setDescription(java.lang.String)
73 */
74 public void setDescription(String description)
75 {
76 this.description = description;
77
78 }
79
80 /***
81 * @see org.apache.jetspeed.om.common.MutableDescription#setLocale(java.util.Locale)
82 */
83 public void setLocale(Locale locale)
84 {
85 this.locale = locale;
86
87 }
88
89 /***
90 * @see org.apache.jetspeed.om.registry.Description#getDescription()
91 */
92 public String getDescription()
93 {
94 return description;
95 }
96
97 /***
98 * @see org.apache.pluto.om.common.Description#getLocale()
99 */
100 public Locale getLocale()
101 {
102 return locale;
103 }
104
105 public void setLanguage(String lang)
106 {
107 String[] localeArray = lang.split("[-|_]");
108 String country = "";
109 String variant = "";
110 for (int i = 0; i < localeArray.length; i++)
111 {
112 if (i == 0)
113 {
114 lang = localeArray[i];
115 }
116 else if (i == 1)
117 {
118 country = localeArray[i];
119 }
120 else if (i == 2)
121 {
122 variant = localeArray[i];
123 }
124 }
125 this.locale = new Locale(lang, country, variant);
126 }
127
128 }