View Javadoc

1   /*
2    * Copyright 2003,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /* 
17  
18   */
19  
20  package org.apache.pluto.portalImpl.om.common.impl;
21  
22  import java.util.Iterator;
23  import java.util.Locale;
24  
25  import org.apache.pluto.om.common.DisplayName;
26  import org.apache.pluto.om.common.DisplayNameSet;
27  import org.apache.pluto.portalImpl.om.common.AbstractSupportSet;
28  import org.apache.pluto.portalImpl.om.common.Support;
29  import org.apache.pluto.util.StringUtils;
30  
31  public class DisplayNameSetImpl extends AbstractSupportSet implements DisplayNameSet, java.io.Serializable, Support {
32  
33      // DisplayNameSet implementation.
34      
35      public DisplayName get(Locale locale)
36      {        
37          Iterator iterator = this.iterator();
38          while (iterator.hasNext()) {
39              DisplayName displayName = (DisplayName)iterator.next();
40              if (displayName.getLocale().equals(locale)) {
41                  return displayName;
42              }
43          }
44          return null;
45      }
46  
47  
48      // Support implementation.
49  
50      /* (non-Javadoc)
51       * @see org.apache.pluto.portalImpl.om.common.Support#postBuild(Object)
52       */
53      public void postBuild(Object parameter) throws Exception {
54      }
55  
56      /* (non-Javadoc)
57       * @see org.apache.pluto.portalImpl.om.common.Support#postLoad(Object)
58       */
59      public void postLoad(Object parameter) throws Exception {
60          Iterator iterator = this.iterator();
61          while (iterator.hasNext()) {
62              ((DisplayNameImpl) iterator.next()).postLoad(parameter);
63          }
64      }
65  
66      /* (non-Javadoc)
67       * @see org.apache.pluto.portalImpl.om.common.Support#postStore(Object)
68       */
69      public void postStore(Object parameter) throws Exception {
70      }
71  
72      /* (non-Javadoc)
73       * @see org.apache.pluto.portalImpl.om.common.Support#preBuild(Object)
74       */
75      public void preBuild(Object parameter) throws Exception {
76      }
77  
78      /* (non-Javadoc)
79       * @see org.apache.pluto.portalImpl.om.common.Support#preStore(Object)
80       */
81      public void preStore(Object parameter) throws Exception {
82      }
83  
84      // additional methods.
85  
86      public String toString()
87      {
88          return toString(0);
89      }
90  
91      public String toString(int indent)
92      {
93          StringBuffer buffer = new StringBuffer(50);
94          StringUtils.newLine(buffer,indent);
95          buffer.append(getClass().toString());
96          buffer.append(": ");
97          Iterator iterator = this.iterator();
98          while (iterator.hasNext()) {
99              buffer.append(((DisplayNameImpl)iterator.next()).toString(indent+2));
100         }
101         return buffer.toString();
102     }
103 
104 
105 }