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.Iterator;
020: import java.util.Locale;
021:
022: import org.apache.pluto.om.common.DisplayName;
023: import org.apache.pluto.om.common.DisplayNameSet;
024: import org.apache.pluto.util.StringUtils;
025:
026: /**
027: *
028: *
029: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
030: *
031: * @version CVS $Id: DisplayNameSetImpl.java 433543 2006-08-22 06:22:54Z crossley $
032: */
033: public class DisplayNameSetImpl extends AbstractSupportSet implements
034: DisplayNameSet, java.io.Serializable, Support {
035:
036: /* (non-Javadoc)
037: * @see org.apache.pluto.om.common.DisplayNameSet#get(java.util.Locale)
038: */
039: public DisplayName get(Locale locale) {
040: Iterator iterator = this .iterator();
041: while (iterator.hasNext()) {
042: DisplayName displayName = (DisplayName) iterator.next();
043: if (displayName.getLocale().equals(locale)) {
044: return displayName;
045: }
046: }
047: return null;
048: }
049:
050: /* (non-Javadoc)
051: * @see org.apache.cocoon.portal.pluto.om.common.Support#postBuild(java.lang.Object)
052: */
053: public void postBuild(Object parameter) throws Exception {
054: // nothing to do
055: }
056:
057: public void postLoad(Object parameter) throws Exception {
058: Iterator iterator = this .iterator();
059: while (iterator.hasNext()) {
060: ((DisplayNameImpl) iterator.next()).postLoad(parameter);
061: }
062: }
063:
064: /* (non-Javadoc)
065: * @see org.apache.cocoon.portal.pluto.om.common.Support#postStore(java.lang.Object)
066: */
067: public void postStore(Object parameter) throws Exception {
068: // nothing to do
069: }
070:
071: /* (non-Javadoc)
072: * @see org.apache.cocoon.portal.pluto.om.common.Support#preBuild(java.lang.Object)
073: */
074: public void preBuild(Object parameter) throws Exception {
075: // nothing to do
076: }
077:
078: /* (non-Javadoc)
079: * @see org.apache.cocoon.portal.pluto.om.common.Support#preStore(java.lang.Object)
080: */
081: public void preStore(Object parameter) throws Exception {
082: // nothing to do
083: }
084:
085: /* (non-Javadoc)
086: * @see java.lang.Object#toString()
087: */
088: public String toString() {
089: return toString(0);
090: }
091:
092: public String toString(int indent) {
093: StringBuffer buffer = new StringBuffer(50);
094: StringUtils.newLine(buffer, indent);
095: buffer.append(getClass().toString());
096: buffer.append(": ");
097: Iterator iterator = this .iterator();
098: while (iterator.hasNext()) {
099: buffer.append(((DisplayNameImpl) iterator.next())
100: .toString(indent + 2));
101: }
102: return buffer.toString();
103: }
104:
105: }
|