1 16 package org.apache.cocoon.portal.layout; 17 18 import java.util.Map ; 19 import java.util.Set ; 20 import java.util.HashSet ; 21 import java.util.Iterator ; 22 23 import org.apache.cocoon.portal.factory.impl.AbstractProducible; 24 import org.apache.cocoon.portal.pluto.om.common.ParameterImpl; 25 import org.apache.commons.collections.map.LinkedMap; 26 import org.apache.pluto.om.common.Parameter; 27 28 35 public abstract class AbstractLayout 36 extends AbstractProducible 37 implements Layout, Parameters { 38 39 protected String rendererName; 40 41 protected Item parent; 42 43 protected Map parameters = new LinkedMap(); 44 45 48 public final Map getParameters() { 49 return parameters; 50 } 51 52 public final Set getCastorParameters() 53 { 54 Set set = new HashSet (this.parameters.size()); 55 Iterator iterator = this.parameters.entrySet().iterator(); 56 Map.Entry entry; 57 while (iterator.hasNext()) 58 { 59 entry = (Map.Entry ) iterator.next(); 60 ParameterImpl param = new ParameterImpl(); 61 param.setName((String ) entry.getKey()); 62 param.setValue((String ) entry.getValue()); 63 set.add(param); 64 } 65 return set; 66 } 67 68 public void addParameter(Parameter parameter) 69 { 70 parameters.put(parameter.getName(), parameter.getValue()); 71 } 72 73 76 public String getRendererName() { 77 if ( this.rendererName == null ) { 78 return ((LayoutDescription)this.description).getDefaultRendererName(); 79 } 80 return this.rendererName; 81 } 82 83 public void setLayoutRendererName(String value) { 84 this.rendererName = value; 85 } 86 87 public Item getParent() { 88 return this.parent; 89 } 90 91 public void setParent(Item item) { 92 this.parent = item; 93 } 94 95 98 public String getLayoutRendererName() { 99 return this.rendererName; 100 } 101 102 103 106 protected Object clone() throws CloneNotSupportedException { 107 AbstractLayout clone = (AbstractLayout)super.clone(); 108 109 clone.rendererName = this.rendererName; 111 clone.parameters = new LinkedMap(this.parameters); 112 clone.parent = null; 113 114 return clone; 115 } 116 117 120 public Layout copy() { 121 try { 122 return (Layout)this.clone(); 123 } catch (CloneNotSupportedException cnse) { 124 } 126 return null; 127 } 128 } 129 | Popular Tags |