1 37 package org.webharvest.runtime.variables; 38 39 40 public class Appender { 41 42 public static NodeVariable appendText(IVariable[] vars) { 43 String result = ""; 44 for (int i = 0; i < vars.length; i++) { 45 result += vars[i] == null ? "" : vars[i].toString(); 46 } 47 48 return new NodeVariable(result); 49 } 50 51 public static NodeVariable appendBinary(IVariable[] vars) { 52 byte[] result = null; 53 for (int i = 0; i < vars.length; i++) { 54 byte[] curr = vars[i].toBinary(); 55 if (curr != null) { 56 if (result == null) { 57 result = curr; 58 } else { 59 byte[] newResult = new byte[result.length + curr.length]; 60 System.arraycopy(result, 0, newResult, 0, result.length); 61 System.arraycopy(curr, 0, newResult, result.length, curr.length); 62 result = newResult; 63 } 64 } 65 } 66 67 return new NodeVariable(result); 68 } 69 70 71 } 72 | Popular Tags |