1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.pluto.portalImpl.om.entity.impl;
21
22 import org.apache.pluto.om.common.ObjectID;
23 import org.apache.pluto.om.entity.*;
24 import org.apache.pluto.util.StringUtils;
25 import java.util.*;
26
27 import org.apache.pluto.portalImpl.om.common.AbstractSupportSet;
28
29 public class PortletEntityListImpl extends AbstractSupportSet
30 implements PortletEntityList, PortletEntityListCtrl, java.io.Serializable {
31
32
33
34 public PortletEntity get(ObjectID objectId)
35 {
36 Iterator iterator = this.iterator();
37 while (iterator.hasNext()) {
38 PortletEntity portletEntity = (PortletEntity)iterator.next();
39 if (portletEntity.getId().equals(objectId)) {
40 return portletEntity;
41 }
42 }
43 return null;
44 }
45
46
47
48
49 public PortletEntity add(PortletApplicationEntity appEntity, String definitionId) {
50 PortletEntityImpl entity = new PortletEntityImpl();
51
52 int id = -1;
53 for (Iterator iter = iterator(); iter.hasNext();) {
54 PortletEntityImpl ent = (PortletEntityImpl)iter.next();
55 try {
56 id = Math.max(id, Integer.parseInt(ent.getCastorId()));
57 } catch (NumberFormatException e) {
58
59 }
60 }
61 entity.setId(Integer.toString(++id));
62 entity.setDefinitionId(definitionId);
63 entity.setPortletApplicationEntity(appEntity);
64
65 add(entity);
66
67 return entity;
68 }
69
70
71
72 public PortletEntity get(String objectId)
73 {
74 Iterator iterator = this.iterator();
75 while (iterator.hasNext()) {
76 PortletEntity portletEntity = (PortletEntity)iterator.next();
77 if (portletEntity.getId().equals(objectId)) {
78 return portletEntity;
79 }
80 }
81 return null;
82 }
83
84 public String toString()
85 {
86 return toString(0);
87 }
88
89 public String toString(int indent)
90 {
91 StringBuffer buffer = new StringBuffer(50);
92 StringUtils.newLine(buffer,indent);
93 buffer.append(getClass().toString());
94 buffer.append(": ");
95 Iterator iterator = this.iterator();
96 while (iterator.hasNext()) {
97 buffer.append(((PortletEntityImpl)iterator.next()).toString(indent+2));
98 }
99 return buffer.toString();
100 }
101 }