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 ListToList extends MethodOperation { 41 42 public static final String module = ListToList.class.getName(); 43 44 ContextAccessor listAcsr; 45 ContextAccessor toListAcsr; 46 47 public ListToList(Element element, SimpleMethod simpleMethod) { 48 super(element, simpleMethod); 49 listAcsr = new ContextAccessor(element.getAttribute("list-name")); 50 toListAcsr = new ContextAccessor(element.getAttribute("to-list-name")); 51 } 52 53 public boolean exec(MethodContext methodContext) { 54 Object fieldVal = null; 55 56 List fromList = (List) listAcsr.get(methodContext); 57 List toList = (List) toListAcsr.get(methodContext); 58 59 if (fromList == null) { 60 if (Debug.infoOn()) Debug.logInfo("List not found with name " + listAcsr + ", not copying list", module); 61 return true; 62 } 63 64 if (toList == null) { 65 if (Debug.verboseOn()) Debug.logVerbose("List not found with name " + toListAcsr + ", creating new list", module); 66 toList = new LinkedList(); 67 toListAcsr.put(methodContext, toList); 68 } 69 70 toList.addAll(fromList); 71 return true; 72 } 73 74 public String rawString() { 75 return "<list-to-list/>"; 77 } 78 public String expandedString(MethodContext methodContext) { 79 return this.rawString(); 81 } 82 } 83 | Popular Tags |