1 24 package org.ofbiz.minilang.method.envops; 25 26 import java.util.*; 27 28 import org.w3c.dom.*; 29 import org.ofbiz.base.util.*; 30 import org.ofbiz.minilang.*; 31 import org.ofbiz.minilang.method.*; 32 33 40 public class MapToMap extends MethodOperation { 41 42 public static final String module = MapToMap.class.getName(); 43 44 ContextAccessor mapAcsr; 45 ContextAccessor toMapAcsr; 46 47 public MapToMap(Element element, SimpleMethod simpleMethod) { 48 super(element, simpleMethod); 49 mapAcsr = new ContextAccessor(element.getAttribute("map-name")); 50 toMapAcsr = new ContextAccessor(element.getAttribute("to-map-name")); 51 } 52 53 public boolean exec(MethodContext methodContext) { 54 Map fromMap = null; 55 if (!mapAcsr.isEmpty()) { 56 fromMap = (Map) mapAcsr.get(methodContext); 57 58 if (fromMap == null) { 59 if (Debug.infoOn()) Debug.logInfo("Map not found with name " + mapAcsr + ", not copying from this map", module); 60 fromMap = new HashMap(); 61 mapAcsr.put(methodContext, fromMap); 62 } 63 } 64 65 if (!toMapAcsr.isEmpty()) { 66 Map toMap = (Map) toMapAcsr.get(methodContext); 67 if (toMap == null) { 68 if (Debug.verboseOn()) Debug.logVerbose("Map not found with name " + toMapAcsr + ", creating new map", module); 69 toMap = new HashMap(); 70 toMapAcsr.put(methodContext, toMap); 71 } 72 73 toMap.putAll(fromMap); 74 } else { 75 methodContext.putAllEnv(fromMap); 76 } 77 return true; 78 } 79 80 public String rawString() { 81 return "<map-to-map/>"; 83 } 84 public String expandedString(MethodContext methodContext) { 85 return this.rawString(); 87 } 88 } 89 | Popular Tags |