1 24 package org.ofbiz.minilang.method; 25 26 import org.w3c.dom.*; 27 28 import org.ofbiz.base.util.*; 29 import org.ofbiz.minilang.*; 30 31 38 public class StringObject extends MethodObject { 39 40 String value; 41 String cdataValue; 42 43 public StringObject(Element element, SimpleMethod simpleMethod) { 44 super(element, simpleMethod); 45 value = element.getAttribute("value"); 46 cdataValue = UtilXml.elementValue(element); 47 } 48 49 50 public String getTypeName() { 51 return "java.lang.String"; 52 } 53 54 public Class getTypeClass(ClassLoader loader) { 55 return java.lang.String .class; 56 } 57 58 public Object getObject(MethodContext methodContext) { 59 String value = methodContext.expandString(this.value); 60 String cdataValue = methodContext.expandString(this.cdataValue); 61 62 boolean valueExists = UtilValidate.isNotEmpty(value); 63 boolean cdataValueExists = UtilValidate.isNotEmpty(cdataValue); 64 65 if (valueExists && cdataValueExists) { 66 return value + cdataValue; 67 } else { 68 if (valueExists) { 69 return value; 70 } else { 71 return cdataValue; 72 } 73 } 74 } 75 } 76 | Popular Tags |