1 16 package org.directwebremoting.dwrp; 17 18 import java.util.List ; 19 20 import org.directwebremoting.extend.OutboundContext; 21 import org.directwebremoting.extend.OutboundVariable; 22 23 27 public class ArrayOutboundVariable extends AbstractOutboundVariable implements OutboundVariable 28 { 29 33 public ArrayOutboundVariable(OutboundContext outboundContext) 34 { 35 super(outboundContext); 36 } 37 38 42 public void init(List aOvs) 43 { 44 this.ovs = aOvs; 45 setChildren(ovs); 46 } 47 48 51 protected NotInlineDefinition getNotInlineDefinition() 52 { 53 StringBuffer buffer = new StringBuffer (); 54 55 for (int i = 0; i < ovs.size(); i++) 56 { 57 OutboundVariable nested = (OutboundVariable) ovs.get(i); 58 String varName = getVariableName(); 59 60 if (nested != null) 61 { 62 buffer.append(varName); 63 buffer.append('['); 64 buffer.append(i); 65 buffer.append("]="); 66 buffer.append(nested.getAssignCode()); 67 buffer.append(';'); 68 } 69 } 70 buffer.append("\r\n"); 71 72 return new NotInlineDefinition("var " + getVariableName() + "=[];", buffer.toString()); 73 } 74 75 78 protected String getInlineDefinition() 79 { 80 StringBuffer buffer = new StringBuffer (); 81 82 buffer.append("["); 83 84 boolean first = true; 85 for (int i = 0; i < ovs.size(); i++) 86 { 87 OutboundVariable ov = (OutboundVariable) ovs.get(i); 88 89 if (!first) 90 { 91 buffer.append(','); 92 } 93 94 buffer.append(ov.getAssignCode()); 95 96 first = false; 97 } 98 buffer.append("]"); 99 100 return buffer.toString(); 101 } 102 103 106 public String toString() 107 { 108 return "Array:" + toStringDefinitionHint() + ":" + ovs; 109 } 110 111 114 private List ovs; 115 } 116 | Popular Tags |