View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
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          // always init to default locale
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 }