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