1 37 package org.webharvest.runtime.variables; 38 39 import java.util.ArrayList ; 40 import java.util.List ; 41 42 45 public class NodeVariable implements IVariable { 46 47 private Object data; 48 49 public NodeVariable(Object data) { 50 this.data = data; 51 } 52 53 public String toString() { 54 if (data == null) { 55 return null; 56 } else if (data instanceof byte[]) { 57 return new String ((byte[]) data); 58 } else { 59 return data.toString(); 60 } 61 } 62 63 public byte[] toBinary() { 64 if (data == null) { 65 return null; 66 } else if (data instanceof byte[]) { 67 return (byte[]) data; 68 } else { 69 return data.toString().getBytes(); 70 } 71 } 72 73 public List toList() { 74 List list = new ArrayList (); 75 if (!isEmpty()) { 76 list.add(this); 77 } 78 79 return list; 80 } 81 82 public String toText() { 83 return toString(); 84 } 85 86 public boolean isEmpty() { 87 return (data == null) || ( "".equals(toString()) ); 88 } 89 90 public Object getWrappedObject() { 91 return this.data; 92 } 93 94 } | Popular Tags |