1 24 package org.ofbiz.minilang.method; 25 26 import java.util.*; 27 28 import org.w3c.dom.*; 29 import org.ofbiz.base.util.*; 30 import org.ofbiz.minilang.*; 31 32 39 public class FieldString extends MethodString { 40 41 public static final String module = FieldString.class.getName(); 42 43 ContextAccessor fieldAcsr; 44 ContextAccessor mapAcsr; 45 46 public FieldString(Element element, SimpleMethod simpleMethod) { 47 super(element, simpleMethod); 48 fieldAcsr = new ContextAccessor(element.getAttribute("field-name")); 49 mapAcsr = new ContextAccessor(element.getAttribute("map-name")); 50 } 51 52 public String getString(MethodContext methodContext) { 53 Object fieldVal = null; 54 if (!mapAcsr.isEmpty()) { 55 Map fromMap = (Map) mapAcsr.get(methodContext); 56 if (fromMap == null) { 57 Debug.logWarning("Map not found with name " + mapAcsr + ", not getting string value", module); 58 return ""; 59 } 60 fieldVal = fieldAcsr.get(fromMap, methodContext); 61 } else { 62 fieldVal = fieldAcsr.get(methodContext); 64 } 65 66 if (fieldVal == null) { 67 if (Debug.infoOn()) Debug.logInfo("Field value not found with name " + fieldAcsr + " in Map with name " + mapAcsr + ", not getting string value", module); 68 return ""; 69 } 70 71 return fieldVal.toString(); 72 } 73 } 74 | Popular Tags |