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.cocoon.portal.pluto.om.common;
018:
019: import java.util.Locale;
020:
021: import org.apache.pluto.om.common.DisplayName;
022: import org.apache.pluto.util.StringUtils;
023:
024: /**
025: *
026: *
027: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
028: *
029: * @version CVS $Id: DisplayNameImpl.java 433543 2006-08-22 06:22:54Z crossley $
030: */
031: public class DisplayNameImpl implements DisplayName,
032: java.io.Serializable, Support {
033:
034: private String displayName;
035: private Locale locale; // default locale
036: private String castorLocale;
037:
038: public DisplayNameImpl() {
039: // nothing to do
040: }
041:
042: /* (non-Javadoc)
043: * @see org.apache.pluto.om.common.DisplayName#getDisplayName()
044: */
045: public String getDisplayName() {
046: return displayName;
047: }
048:
049: /* (non-Javadoc)
050: * @see org.apache.pluto.om.common.DisplayName#getLocale()
051: */
052: public Locale getLocale() {
053: return locale;
054: }
055:
056: /* (non-Javadoc)
057: * @see org.apache.cocoon.portal.pluto.om.common.Support#postLoad(java.lang.Object)
058: */
059: public void postLoad(Object parameter) throws Exception {
060: if (castorLocale == null) {
061: locale = Locale.ENGLISH;
062: } else {
063: locale = new Locale(castorLocale, "");
064: }
065: }
066:
067: /* (non-Javadoc)
068: * @see org.apache.cocoon.portal.pluto.om.common.Support#postStore(java.lang.Object)
069: */
070: public void postStore(Object parameter) throws Exception {
071: // nothing to do
072: }
073:
074: /* (non-Javadoc)
075: * @see org.apache.cocoon.portal.pluto.om.common.Support#preBuild(java.lang.Object)
076: */
077: public void preBuild(Object parameter) throws Exception {
078: // nothing to do
079: }
080:
081: /* (non-Javadoc)
082: * @see org.apache.cocoon.portal.pluto.om.common.Support#preStore(java.lang.Object)
083: */
084: public void preStore(Object parameter) throws Exception {
085: // nothing to do
086: }
087:
088: /* (non-Javadoc)
089: * @see org.apache.cocoon.portal.pluto.om.common.Support#postBuild(java.lang.Object)
090: */
091: public void postBuild(Object parameter) throws Exception {
092: // nothing to do
093: }
094:
095: /* (non-Javadoc)
096: * @see java.lang.Object#toString()
097: */
098: public String toString() {
099: return toString(0);
100: }
101:
102: public String toString(int indent) {
103: StringBuffer buffer = new StringBuffer(50);
104: StringUtils.newLine(buffer, indent);
105: buffer.append(getClass().toString());
106: buffer.append(": displayName='");
107: buffer.append(displayName);
108: buffer.append("', locale='");
109: buffer.append(locale);
110: buffer.append("'");
111: return buffer.toString();
112: }
113:
114: public void setDisplayName(String displayName) {
115: this .displayName = displayName;
116: }
117:
118: public void setLocale(Locale locale) {
119: this .locale = locale;
120: }
121:
122: /**
123: * Returns the castorLocale.
124: * @return String
125: */
126: public String getCastorLocale() {
127: return castorLocale;
128: }
129:
130: /**
131: * Sets the castorLocale.
132: * @param castorLocale The castorLocale to set
133: */
134: public void setCastorLocale(String castorLocale) {
135: this.castorLocale = castorLocale;
136: }
137: }
|