1 16 package org.apache.cocoon.portal.pluto.om.common; 17 18 import java.util.ArrayList ; 19 import java.util.Collection ; 20 import java.util.Iterator ; 21 22 import org.apache.pluto.om.portlet.ContentType; 23 import org.apache.pluto.om.portlet.ContentTypeSet; 24 import org.apache.pluto.util.StringUtils; 25 26 33 public class ContentTypeSetImpl extends AbstractSupportSet 34 implements ContentTypeSet, java.io.Serializable { 35 36 private ContentType anyContentType; 38 39 42 public ContentType get(String contentType) { 43 Iterator iterator = this.iterator(); 44 while (iterator.hasNext()) { 45 ContentType _contentType = (ContentType)iterator.next(); 46 if (_contentType.getContentType().equals(contentType)) { 47 return _contentType; 48 } 49 } 50 return null; 51 } 52 53 56 public void postLoad(Object parameter) throws Exception { 57 super.postLoad(parameter); 58 59 Collection allPortletModes = new ArrayList (); 60 61 Iterator contentTypes = this.iterator(); 62 while (contentTypes.hasNext()){ 63 ContentType aContentType = (ContentType)contentTypes.next(); 64 Iterator portletModes = aContentType.getPortletModes(); 65 66 while(portletModes.hasNext()) { 67 Object portletMode = portletModes.next(); 68 if(!allPortletModes.contains(portletMode)) { 69 allPortletModes.add(portletMode); 70 } 71 } 72 } 73 74 ContentTypeImpl _anyContentType = new ContentTypeImpl(); 75 _anyContentType.setPortletModes(allPortletModes); 76 anyContentType = _anyContentType; 77 } 78 79 80 83 public String toString() { 84 return toString(0); 85 } 86 87 public String toString(int indent) { 88 StringBuffer buffer = new StringBuffer (50); 89 StringUtils.newLine(buffer,indent); 90 buffer.append(getClass().toString()); 91 buffer.append(": "); 92 Iterator iterator = this.iterator(); 93 while (iterator.hasNext()) { 94 buffer.append(((ContentTypeImpl)iterator.next()).toString(indent+2)); 95 } 96 return buffer.toString(); 97 } 98 99 public boolean supportsPortletMode(javax.portlet.PortletMode portletMode) { 100 return anyContentType.supportsPortletMode(portletMode); 101 } 102 } 103 | Popular Tags |