001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.om.impl;
018:
019: import java.util.Locale;
020:
021: import org.apache.jetspeed.util.JetspeedLocale;
022: import org.apache.jetspeed.om.common.MutableDescription;
023:
024: /**
025: * DescriptionImpl
026: * <br>
027: * Basic Implementation of the <code>MutableDescription</code>
028: * interface.
029: *
030: * @see org.apache.jetspeed.om.common.MutableDescription
031: *
032: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
033: * @version $Id: DescriptionImpl.java 516448 2007-03-09 16:25:47Z ate $
034: *
035: */
036: public abstract class DescriptionImpl implements MutableDescription {
037:
038: private String description;
039: private Locale locale;
040:
041: protected long parentId;
042:
043: protected long id;
044:
045: /**
046: * Tells OJB which class to use to materialize.
047: */
048: protected String ojbConcreteClass = DescriptionImpl.class.getName();
049:
050: public DescriptionImpl() {
051: super ();
052: // always init to default locale
053: locale = JetspeedLocale.getDefaultLocale();
054: }
055:
056: public DescriptionImpl(Locale locale, String description) {
057: this ();
058: this .locale = locale;
059: this .description = description;
060:
061: }
062:
063: /**
064: * @see org.apache.jetspeed.om.registry.Description#setDescription(java.lang.String)
065: */
066: public void setDescription(String description) {
067: this .description = description;
068:
069: }
070:
071: /**
072: * @see org.apache.jetspeed.om.common.MutableDescription#setLocale(java.util.Locale)
073: */
074: public void setLocale(Locale locale) {
075: this .locale = locale;
076:
077: }
078:
079: /**
080: * @see org.apache.jetspeed.om.registry.Description#getDescription()
081: */
082: public String getDescription() {
083: return description;
084: }
085:
086: /**
087: * @see org.apache.pluto.om.common.Description#getLocale()
088: */
089: public Locale getLocale() {
090: return locale;
091: }
092:
093: public void setLanguage(String lang) {
094: String[] localeArray = lang.split("[-|_]");
095: String country = "";
096: String variant = "";
097: for (int i = 0; i < localeArray.length; i++) {
098: if (i == 0) {
099: lang = localeArray[i];
100: } else if (i == 1) {
101: country = localeArray[i];
102: } else if (i == 2) {
103: variant = localeArray[i];
104: }
105: }
106: this .locale = new Locale(lang, country, variant);
107: }
108:
109: }
|