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.portlet.impl;
21  
22  import java.util.HashSet;
23  import java.util.Iterator;
24  
25  import org.apache.pluto.om.common.ObjectID;
26  import org.apache.pluto.om.portlet.PortletApplicationDefinition;
27  import org.apache.pluto.om.portlet.PortletApplicationDefinitionList;
28  import org.apache.pluto.util.StringUtils;
29  
30  public class PortletApplicationDefinitionListImpl extends HashSet
31  implements PortletApplicationDefinitionList, java.io.Serializable {
32  
33      public PortletApplicationDefinitionListImpl()
34      {
35      }
36  
37      // PortletApplicationDefinitionList implementation.
38  
39      public PortletApplicationDefinition get(ObjectID objectId)
40      {
41          Iterator iterator = this.iterator();
42          while (iterator.hasNext()) {
43              PortletApplicationDefinition portletApplicationDefinition = (PortletApplicationDefinition)iterator.next();
44              if (portletApplicationDefinition.getId().equals(objectId)) {
45                  return portletApplicationDefinition;
46              }
47          }
48          return null;
49      }
50  
51      // additional internal methods
52  
53      public PortletApplicationDefinition get(String objectId)
54      {
55          Iterator iterator = this.iterator();
56          while (iterator.hasNext()) {
57              PortletApplicationDefinition portletApplicationDefinition = (PortletApplicationDefinition)iterator.next();
58              if (portletApplicationDefinition.getId().toString().equals(objectId)) {
59                  return portletApplicationDefinition;
60              }
61          }
62          return null;
63      }
64  
65      public String toString()
66      {
67          return toString(0);
68      }
69  
70      public String toString(int indent)
71      {
72          StringBuffer buffer = new StringBuffer(50);
73          StringUtils.newLine(buffer,indent);
74          buffer.append(getClass().toString());
75          buffer.append(": ");
76          Iterator iterator = this.iterator();
77          while (iterator.hasNext()) {
78              buffer.append(((PortletApplicationDefinitionImpl)iterator.next()).toString(indent+2));
79          }
80          return buffer.toString();
81      }
82  }