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