You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2012/04/19 17:09:08 UTC
svn commit: r1327981 [7/9] - in
/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang: ./ method/
method/callops/ method/conditional/ method/entityops/ method/envops/
method/eventops/ method/ifops/ method/otherops/ method/serviceops/ operation/
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/FieldToList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/FieldToList.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/FieldToList.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/FieldToList.java Thu Apr 19 15:09:03 2012
@@ -18,34 +18,28 @@
*******************************************************************************/
package org.ofbiz.minilang.method.envops;
-import java.util.*;
+import java.util.List;
+import java.util.Map;
import javolution.util.FastList;
-import org.w3c.dom.*;
-import org.ofbiz.base.util.*;
-import org.ofbiz.minilang.*;
-import org.ofbiz.minilang.method.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Copies an environment field to a list
*/
public class FieldToList extends MethodOperation {
- public static final class FieldToListFactory implements Factory<FieldToList> {
- public FieldToList createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new FieldToList(element, simpleMethod);
- }
-
- public String getName() {
- return "field-to-list";
- }
- }
public static final String module = FieldToList.class.getName();
- ContextAccessor<Map<String, ? extends Object>> mapAcsr;
ContextAccessor<Object> fieldAcsr;
ContextAccessor<List<Object>> listAcsr;
+ ContextAccessor<Map<String, ? extends Object>> mapAcsr;
public FieldToList(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
@@ -58,45 +52,50 @@ public class FieldToList extends MethodO
@Override
public boolean exec(MethodContext methodContext) {
Object fieldVal = null;
-
if (!mapAcsr.isEmpty()) {
Map<String, ? extends Object> fromMap = mapAcsr.get(methodContext);
-
if (fromMap == null) {
Debug.logWarning("Map not found with name " + mapAcsr + ", Not copying to list", module);
return true;
}
-
fieldVal = fieldAcsr.get(fromMap, methodContext);
} else {
// no map name, try the env
fieldVal = fieldAcsr.get(methodContext);
}
-
if (fieldVal == null) {
Debug.logWarning("Field value not found with name " + fieldAcsr + " in Map with name " + mapAcsr + ", Not copying to list", module);
return true;
}
-
List<Object> toList = listAcsr.get(methodContext);
-
if (toList == null) {
- if (Debug.verboseOn()) Debug.logVerbose("List not found with name " + listAcsr + ", creating new list", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("List not found with name " + listAcsr + ", creating new list", module);
toList = FastList.newInstance();
listAcsr.put(methodContext, toList);
}
-
toList.add(fieldVal);
return true;
}
@Override
- public String rawString() {
- return "<field-to-list list-name=\"" + this.listAcsr + "\" field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
- }
- @Override
public String expandedString(MethodContext methodContext) {
// TODO: something more than a stub/dummy
return this.rawString();
}
+
+ @Override
+ public String rawString() {
+ return "<field-to-list list-name=\"" + this.listAcsr + "\" field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
+ }
+
+ public static final class FieldToListFactory implements Factory<FieldToList> {
+ public FieldToList createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new FieldToList(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "field-to-list";
+ }
+ }
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/FirstFromList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/FirstFromList.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/FirstFromList.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/FirstFromList.java Thu Apr 19 15:09:03 2012
@@ -18,26 +18,20 @@
*******************************************************************************/
package org.ofbiz.minilang.method.envops;
-import java.util.*;
+import java.util.List;
-import org.w3c.dom.*;
-import org.ofbiz.base.util.*;
-import org.ofbiz.minilang.*;
-import org.ofbiz.minilang.method.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Get the first entry from the list
*/
public class FirstFromList extends MethodOperation {
- public static final class FirstFromListFactory implements Factory<FirstFromList> {
- public FirstFromList createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new FirstFromList(element, simpleMethod);
- }
-
- public String getName() {
- return "first-from-list";
- }
- }
public static final String module = FirstFromList.class.getName();
@@ -56,25 +50,33 @@ public class FirstFromList extends Metho
Debug.logWarning("No list-name specified in iterate tag, doing nothing", module);
return true;
}
-
List<? extends Object> theList = listAcsr.get(methodContext);
-
if (UtilValidate.isEmpty(theList)) {
entryAcsr.put(methodContext, null);
return true;
}
-
entryAcsr.put(methodContext, theList.get(0));
return true;
}
@Override
- public String rawString() {
- return "<first-from-list list-name=\"" + this.listAcsr + "\" entry-name=\"" + this.entryAcsr + "\"/>";
- }
- @Override
public String expandedString(MethodContext methodContext) {
// TODO: something more than a stub/dummy
return this.rawString();
}
+
+ @Override
+ public String rawString() {
+ return "<first-from-list list-name=\"" + this.listAcsr + "\" entry-name=\"" + this.entryAcsr + "\"/>";
+ }
+
+ public static final class FirstFromListFactory implements Factory<FirstFromList> {
+ public FirstFromList createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new FirstFromList(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "first-from-list";
+ }
+ }
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Iterate.java Thu Apr 19 15:09:03 2012
@@ -39,49 +39,34 @@ import org.w3c.dom.Element;
* Process sub-operations for each entry in the list
*/
public class Iterate extends MethodOperation {
- public static final class IterateFactory implements Factory<Iterate> {
- public Iterate createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new Iterate(element, simpleMethod);
- }
-
- public String getName() {
- return "iterate";
- }
- }
public static final String module = Iterate.class.getName();
- protected List<MethodOperation> subOps = FastList.newInstance();
-
protected ContextAccessor<Object> entryAcsr;
protected ContextAccessor<Object> listAcsr;
+ protected List<MethodOperation> subOps = FastList.newInstance();
public Iterate(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
this.entryAcsr = new ContextAccessor<Object>(element.getAttribute("entry"), element.getAttribute("entry-name"));
this.listAcsr = new ContextAccessor<Object>(element.getAttribute("list"), element.getAttribute("list-name"));
-
SimpleMethod.readOperations(element, subOps, simpleMethod);
}
@Override
public boolean exec(MethodContext methodContext) {
-
if (listAcsr.isEmpty()) {
Debug.logWarning("No list-name specified in iterate tag, doing nothing: " + rawString(), module);
return true;
}
-
Object oldEntryValue = entryAcsr.get(methodContext);
Object objList = listAcsr.get(methodContext);
if (objList instanceof EntityListIterator) {
EntityListIterator eli = (EntityListIterator) objList;
-
GenericValue theEntry;
try {
while ((theEntry = eli.next()) != null) {
entryAcsr.put(methodContext, theEntry);
-
if (!SimpleMethod.runSubOps(subOps, methodContext)) {
// only return here if it returns false, otherwise just carry on
return false;
@@ -106,15 +91,13 @@ public class Iterate extends MethodOpera
}
} else if (objList instanceof Collection<?>) {
Collection<Object> theCollection = UtilGenerics.checkCollection(objList);
-
if (theCollection.size() == 0) {
- if (Debug.verboseOn()) Debug.logVerbose("Collection with name " + listAcsr + " has zero entries, doing nothing: " + rawString(), module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("Collection with name " + listAcsr + " has zero entries, doing nothing: " + rawString(), module);
return true;
}
-
- for (Object theEntry: theCollection) {
+ for (Object theEntry : theCollection) {
entryAcsr.put(methodContext, theEntry);
-
if (!SimpleMethod.runSubOps(subOps, methodContext)) {
// only return here if it returns false, otherwise just carry on
return false;
@@ -123,27 +106,33 @@ public class Iterate extends MethodOpera
} else if (objList instanceof Iterator<?>) {
Iterator<Object> theIterator = UtilGenerics.cast(objList);
if (!theIterator.hasNext()) {
- if (Debug.verboseOn()) Debug.logVerbose("List with name " + listAcsr + " has no more entries, doing nothing: " + rawString(), module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("List with name " + listAcsr + " has no more entries, doing nothing: " + rawString(), module);
return true;
}
-
while (theIterator.hasNext()) {
Object theEntry = theIterator.next();
entryAcsr.put(methodContext, theEntry);
-
if (!SimpleMethod.runSubOps(subOps, methodContext)) {
// only return here if it returns false, otherwise just carry on
return false;
}
}
} else {
- if (Debug.infoOn()) Debug.logInfo("List not found with name " + listAcsr + ", doing nothing: " + rawString(), module);
+ if (Debug.infoOn())
+ Debug.logInfo("List not found with name " + listAcsr + ", doing nothing: " + rawString(), module);
return true;
}
entryAcsr.put(methodContext, oldEntryValue);
return true;
}
+ @Override
+ public String expandedString(MethodContext methodContext) {
+ // TODO: something more than a stub/dummy
+ return this.rawString();
+ }
+
public List<MethodOperation> getSubOps() {
return this.subOps;
}
@@ -153,9 +142,14 @@ public class Iterate extends MethodOpera
// TODO: something more than the empty tag
return "<iterate list-name=\"" + this.listAcsr + "\" entry-name=\"" + this.entryAcsr + "\"/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- // TODO: something more than a stub/dummy
- return this.rawString();
+
+ public static final class IterateFactory implements Factory<Iterate> {
+ public Iterate createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new Iterate(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "iterate";
+ }
}
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/IterateMap.java Thu Apr 19 15:09:03 2012
@@ -34,42 +34,28 @@ import org.w3c.dom.Element;
* Process sub-operations for each entry in the map
*/
public class IterateMap extends MethodOperation {
- public static final class IterateMapFactory implements Factory<IterateMap> {
- public IterateMap createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new IterateMap(element, simpleMethod);
- }
-
- public String getName() {
- return "iterate-map";
- }
- }
public static final String module = IterateMap.class.getName();
- List<MethodOperation> subOps = FastList.newInstance();
-
ContextAccessor<Object> keyAcsr;
- ContextAccessor<Object> valueAcsr;
ContextAccessor<Map<? extends Object, ? extends Object>> mapAcsr;
+ List<MethodOperation> subOps = FastList.newInstance();
+ ContextAccessor<Object> valueAcsr;
public IterateMap(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
this.keyAcsr = new ContextAccessor<Object>(element.getAttribute("key"), element.getAttribute("key-name"));
this.valueAcsr = new ContextAccessor<Object>(element.getAttribute("value"), element.getAttribute("value-name"));
this.mapAcsr = new ContextAccessor<Map<? extends Object, ? extends Object>>(element.getAttribute("map"), element.getAttribute("map-name"));
-
SimpleMethod.readOperations(element, subOps, simpleMethod);
}
@Override
public boolean exec(MethodContext methodContext) {
-
-
if (mapAcsr.isEmpty()) {
Debug.logWarning("No map-name specified in iterate tag, doing nothing: " + rawString(), module);
return true;
}
-
Object oldKey = keyAcsr.get(methodContext);
Object oldValue = valueAcsr.get(methodContext);
if (oldKey != null) {
@@ -78,18 +64,18 @@ public class IterateMap extends MethodOp
if (oldValue != null) {
Debug.logWarning("In iterate-map the value had a non-null value before entering the loop for the operation: " + this.rawString(), module);
}
-
Map<? extends Object, ? extends Object> theMap = mapAcsr.get(methodContext);
if (theMap == null) {
- if (Debug.infoOn()) Debug.logInfo("Map not found with name " + mapAcsr + ", doing nothing: " + rawString(), module);
+ if (Debug.infoOn())
+ Debug.logInfo("Map not found with name " + mapAcsr + ", doing nothing: " + rawString(), module);
return true;
}
if (theMap.size() == 0) {
- if (Debug.verboseOn()) Debug.logVerbose("Map with name " + mapAcsr + " has zero entries, doing nothing: " + rawString(), module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("Map with name " + mapAcsr + " has zero entries, doing nothing: " + rawString(), module);
return true;
}
-
- for (Map.Entry<? extends Object, ? extends Object> theEntry: theMap.entrySet()) {
+ for (Map.Entry<? extends Object, ? extends Object> theEntry : theMap.entrySet()) {
keyAcsr.put(methodContext, theEntry.getKey());
valueAcsr.put(methodContext, theEntry.getValue());
@@ -98,10 +84,15 @@ public class IterateMap extends MethodOp
return false;
}
}
-
return true;
}
+ @Override
+ public String expandedString(MethodContext methodContext) {
+ // TODO: something more than a stub/dummy
+ return this.rawString();
+ }
+
public List<MethodOperation> getSubOps() {
return this.subOps;
}
@@ -110,9 +101,14 @@ public class IterateMap extends MethodOp
public String rawString() {
return "<iterate-map map-name=\"" + this.mapAcsr + "\" key=\"" + this.keyAcsr + "\" value=\"" + this.valueAcsr + "\"/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- // TODO: something more than a stub/dummy
- return this.rawString();
+
+ public static final class IterateMapFactory implements Factory<IterateMap> {
+ public IterateMap createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new IterateMap(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "iterate-map";
+ }
}
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ListToList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ListToList.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ListToList.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ListToList.java Thu Apr 19 15:09:03 2012
@@ -18,28 +18,21 @@
*******************************************************************************/
package org.ofbiz.minilang.method.envops;
-import java.util.*;
+import java.util.List;
import javolution.util.FastList;
-import org.w3c.dom.*;
-import org.ofbiz.base.util.*;
-import org.ofbiz.minilang.*;
-import org.ofbiz.minilang.method.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Copies an environment field to a list
*/
public class ListToList extends MethodOperation {
- public static final class ListToListFactory implements Factory<ListToList> {
- public ListToList createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new ListToList(element, simpleMethod);
- }
-
- public String getName() {
- return "list-to-list";
- }
- }
public static final String module = ListToList.class.getName();
@@ -56,30 +49,40 @@ public class ListToList extends MethodOp
public boolean exec(MethodContext methodContext) {
List<Object> fromList = listAcsr.get(methodContext);
List<Object> toList = toListAcsr.get(methodContext);
-
if (fromList == null) {
- if (Debug.infoOn()) Debug.logInfo("List not found with name " + listAcsr + ", not copying list", module);
+ if (Debug.infoOn())
+ Debug.logInfo("List not found with name " + listAcsr + ", not copying list", module);
return true;
}
-
if (toList == null) {
- if (Debug.verboseOn()) Debug.logVerbose("List not found with name " + toListAcsr + ", creating new list", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("List not found with name " + toListAcsr + ", creating new list", module);
toList = FastList.newInstance();
toListAcsr.put(methodContext, toList);
}
-
toList.addAll(fromList);
return true;
}
@Override
+ public String expandedString(MethodContext methodContext) {
+ // TODO: something more than a stub/dummy
+ return this.rawString();
+ }
+
+ @Override
public String rawString() {
// TODO: something more than the empty tag
return "<list-to-list/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- // TODO: something more than a stub/dummy
- return this.rawString();
+
+ public static final class ListToListFactory implements Factory<ListToList> {
+ public ListToList createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new ListToList(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "list-to-list";
+ }
}
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/Loop.java Thu Apr 19 15:09:03 2012
@@ -22,39 +22,28 @@ import java.util.List;
import javolution.util.FastList;
-import org.w3c.dom.Element;
-
-import org.ofbiz.minilang.method.MethodOperation;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.minilang.SimpleMethod;
import org.ofbiz.minilang.method.ContextAccessor;
import org.ofbiz.minilang.method.MethodContext;
-import org.ofbiz.minilang.SimpleMethod;
-import org.ofbiz.base.util.Debug;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Loop
*/
public class Loop extends MethodOperation {
- public static final class LoopFactory implements Factory<Loop> {
- public Loop createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new Loop(element, simpleMethod);
- }
-
- public String getName() {
- return "loop";
- }
- }
public static final String module = Loop.class.getName();
- protected List<MethodOperation> subOps = FastList.newInstance();
- protected ContextAccessor<Integer> fieldAcsr;
- protected String countStr;
+ protected String countStr;
+ protected ContextAccessor<Integer> fieldAcsr;
+ protected List<MethodOperation> subOps = FastList.newInstance();
public Loop(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
this.fieldAcsr = new ContextAccessor<Integer>(element.getAttribute("field"));
this.countStr = element.getAttribute("count");
-
SimpleMethod.readOperations(element, subOps, simpleMethod);
}
@@ -71,12 +60,10 @@ public class Loop extends MethodOperatio
Debug.logError(e, module);
return false;
}
-
if (count < 0) {
Debug.logWarning("Unable to execute loop operation because the count variable is negative: " + rawString(), module);
return false;
}
-
for (int i = 0; i < count; i++) {
fieldAcsr.put(methodContext, i);
if (!SimpleMethod.runSubOps(subOps, methodContext)) {
@@ -84,10 +71,14 @@ public class Loop extends MethodOperatio
return false;
}
}
-
return true;
}
+ @Override
+ public String expandedString(MethodContext methodContext) {
+ return this.rawString();
+ }
+
public List<MethodOperation> getSubOps() {
return this.subOps;
}
@@ -97,8 +88,13 @@ public class Loop extends MethodOperatio
return "<loop count=\"" + this.countStr + "\"/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- return this.rawString();
+ public static final class LoopFactory implements Factory<Loop> {
+ public Loop createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new Loop(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "loop";
+ }
}
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/MapToMap.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/MapToMap.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/MapToMap.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/MapToMap.java Thu Apr 19 15:09:03 2012
@@ -18,28 +18,21 @@
*******************************************************************************/
package org.ofbiz.minilang.method.envops;
-import java.util.*;
+import java.util.Map;
import javolution.util.FastMap;
-import org.w3c.dom.*;
-import org.ofbiz.base.util.*;
-import org.ofbiz.minilang.*;
-import org.ofbiz.minilang.method.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Copies a map field to a map field
*/
public class MapToMap extends MethodOperation {
- public static final class MapToMapFactory implements Factory<MapToMap> {
- public MapToMap createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new MapToMap(element, simpleMethod);
- }
-
- public String getName() {
- return "map-to-map";
- }
- }
public static final String module = MapToMap.class.getName();
@@ -57,22 +50,21 @@ public class MapToMap extends MethodOper
Map<String, Object> fromMap = null;
if (!mapAcsr.isEmpty()) {
fromMap = mapAcsr.get(methodContext);
-
if (fromMap == null) {
- if (Debug.infoOn()) Debug.logInfo("Map not found with name " + mapAcsr + ", not copying from this map", module);
+ if (Debug.infoOn())
+ Debug.logInfo("Map not found with name " + mapAcsr + ", not copying from this map", module);
fromMap = FastMap.newInstance();
mapAcsr.put(methodContext, fromMap);
}
}
-
if (!toMapAcsr.isEmpty()) {
Map<String, Object> toMap = toMapAcsr.get(methodContext);
if (toMap == null) {
- if (Debug.verboseOn()) Debug.logVerbose("Map not found with name " + toMapAcsr + ", creating new map", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("Map not found with name " + toMapAcsr + ", creating new map", module);
toMap = FastMap.newInstance();
toMapAcsr.put(methodContext, toMap);
}
-
toMap.putAll(fromMap);
} else {
methodContext.putAllEnv(fromMap);
@@ -81,13 +73,24 @@ public class MapToMap extends MethodOper
}
@Override
+ public String expandedString(MethodContext methodContext) {
+ // TODO: something more than a stub/dummy
+ return this.rawString();
+ }
+
+ @Override
public String rawString() {
// TODO: something more than the empty tag
return "<map-to-map/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- // TODO: something more than a stub/dummy
- return this.rawString();
+
+ public static final class MapToMapFactory implements Factory<MapToMap> {
+ public MapToMap createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new MapToMap(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "map-to-map";
+ }
}
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/OrderMapList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/OrderMapList.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/OrderMapList.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/OrderMapList.java Thu Apr 19 15:09:03 2012
@@ -18,72 +18,74 @@
*******************************************************************************/
package org.ofbiz.minilang.method.envops;
-import java.util.*;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import javolution.util.FastList;
-import org.w3c.dom.*;
-import org.ofbiz.base.util.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.collections.FlexibleMapAccessor;
import org.ofbiz.base.util.collections.MapComparator;
-import org.ofbiz.minilang.*;
-import org.ofbiz.minilang.method.*;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Copies an environment field to a list
*/
public class OrderMapList extends MethodOperation {
- public static final class OrderMapListFactory implements Factory<OrderMapList> {
- public OrderMapList createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new OrderMapList(element, simpleMethod);
- }
-
- public String getName() {
- return "order-map-list";
- }
- }
public static final String module = FieldToList.class.getName();
protected ContextAccessor<List<Map<Object, Object>>> listAcsr;
- protected List<FlexibleMapAccessor<String>> orderByAcsrList = FastList.newInstance();
protected MapComparator mc;
+ protected List<FlexibleMapAccessor<String>> orderByAcsrList = FastList.newInstance();
public OrderMapList(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
listAcsr = new ContextAccessor<List<Map<Object, Object>>>(element.getAttribute("list"), element.getAttribute("list-name"));
-
- for (Element orderByElement: UtilXml.childElementList(element, "order-by")) {
- FlexibleMapAccessor<String> fma = FlexibleMapAccessor.getInstance(UtilValidate.isNotEmpty(orderByElement.getAttribute("field")) ?
- orderByElement.getAttribute("field") : orderByElement.getAttribute("field-name"));
+ for (Element orderByElement : UtilXml.childElementList(element, "order-by")) {
+ FlexibleMapAccessor<String> fma = FlexibleMapAccessor.getInstance(UtilValidate.isNotEmpty(orderByElement.getAttribute("field")) ? orderByElement.getAttribute("field") : orderByElement.getAttribute("field-name"));
this.orderByAcsrList.add(fma);
}
-
this.mc = new MapComparator(this.orderByAcsrList);
}
@Override
public boolean exec(MethodContext methodContext) {
-
List<Map<Object, Object>> orderList = listAcsr.get(methodContext);
-
if (orderList == null) {
- if (Debug.infoOn()) Debug.logInfo("List not found with name " + listAcsr + ", not ordering/sorting list.", module);
+ if (Debug.infoOn())
+ Debug.logInfo("List not found with name " + listAcsr + ", not ordering/sorting list.", module);
return true;
}
-
Collections.sort(orderList, mc);
-
return true;
}
@Override
- public String rawString() {
- return "<order-map-list list-name=\"" + this.listAcsr + "\"/>";
- }
- @Override
public String expandedString(MethodContext methodContext) {
// TODO: something more than a stub/dummy
return this.rawString();
}
+
+ @Override
+ public String rawString() {
+ return "<order-map-list list-name=\"" + this.listAcsr + "\"/>";
+ }
+
+ public static final class OrderMapListFactory implements Factory<OrderMapList> {
+ public OrderMapList createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new OrderMapList(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "order-map-list";
+ }
+ }
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java Thu Apr 19 15:09:03 2012
@@ -19,7 +19,6 @@
package org.ofbiz.minilang.method.envops;
import java.sql.Timestamp;
-import com.ibm.icu.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
@@ -33,38 +32,32 @@ import org.ofbiz.minilang.method.MethodC
import org.ofbiz.minilang.method.MethodOperation;
import org.w3c.dom.Element;
+import com.ibm.icu.util.Calendar;
+
/**
* Adjust a Timestamp by a specified time.
*/
public class SetCalendar extends MethodOperation {
- public static final class SetCalendarFactory implements Factory<SetCalendar> {
- public SetCalendar createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new SetCalendar(element, simpleMethod);
- }
- public String getName() {
- return "set-calendar";
- }
- }
public static final String module = SetCalendar.class.getName();
+ protected FlexibleStringExpander daysExdr;
+ protected FlexibleStringExpander defaultExdr;
protected ContextAccessor<Timestamp> field;
protected ContextAccessor<Object> fromField;
- protected FlexibleStringExpander valueExdr;
- protected FlexibleStringExpander defaultExdr;
- protected FlexibleStringExpander yearsExdr;
- protected FlexibleStringExpander monthsExdr;
- protected FlexibleStringExpander daysExdr;
protected FlexibleStringExpander hoursExdr;
- protected FlexibleStringExpander minutesExdr;
- protected FlexibleStringExpander secondsExdr;
+ protected FlexibleStringExpander localeExdr;
protected FlexibleStringExpander millisExdr;
- protected FlexibleStringExpander periodAlignStart;
+ protected FlexibleStringExpander minutesExdr;
+ protected FlexibleStringExpander monthsExdr;
protected FlexibleStringExpander periodAlignEnd;
- protected FlexibleStringExpander localeExdr;
- protected FlexibleStringExpander timeZoneExdr;
- protected boolean setIfNull; // default to false
+ protected FlexibleStringExpander periodAlignStart;
+ protected FlexibleStringExpander secondsExdr;
protected boolean setIfEmpty; // default to true
+ protected boolean setIfNull; // default to false
+ protected FlexibleStringExpander timeZoneExdr;
+ protected FlexibleStringExpander valueExdr;
+ protected FlexibleStringExpander yearsExdr;
public SetCalendar(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
@@ -87,7 +80,6 @@ public class SetCalendar extends MethodO
this.setIfNull = "true".equals(element.getAttribute("set-if-null"));
// default to true, anything but false is true
this.setIfEmpty = !"false".equals(element.getAttribute("set-if-empty"));
-
if (!this.fromField.isEmpty() && !this.valueExdr.isEmpty()) {
throw new IllegalArgumentException("Cannot specify a from-field [" + element.getAttribute("from-field") + "] and a value [" + element.getAttribute("value") + "] on the set-calendar action in a screen widget");
}
@@ -98,25 +90,25 @@ public class SetCalendar extends MethodO
Object newValue = null;
if (!this.fromField.isEmpty()) {
newValue = this.fromField.get(methodContext);
- if (Debug.verboseOn()) Debug.logVerbose("In screen getting value for field from [" + this.fromField.toString() + "]: " + newValue, module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("In screen getting value for field from [" + this.fromField.toString() + "]: " + newValue, module);
} else if (!this.valueExdr.isEmpty()) {
newValue = methodContext.expandString(this.valueExdr);
}
-
// If newValue is still empty, use the default value
if (ObjectType.isEmpty(newValue) && !this.defaultExdr.isEmpty()) {
newValue = methodContext.expandString(this.defaultExdr);
}
-
if (!setIfNull && newValue == null) {
- if (Debug.verboseOn()) Debug.logVerbose("Field value not found (null) with name [" + fromField + "] and value [" + valueExdr + "], and there was not default value, not setting field", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("Field value not found (null) with name [" + fromField + "] and value [" + valueExdr + "], and there was not default value, not setting field", module);
return true;
}
if (!setIfEmpty && ObjectType.isEmpty(newValue)) {
- if (Debug.verboseOn()) Debug.logVerbose("Field value not found (empty) with name [" + fromField + "] and value [" + valueExdr + "], and there was not default value, not setting field", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("Field value not found (empty) with name [" + fromField + "] and value [" + valueExdr + "], and there was not default value, not setting field", module);
return true;
}
-
// Convert attributes to the corresponding data types
Locale locale = null;
TimeZone timeZone = null;
@@ -143,10 +135,10 @@ public class SetCalendar extends MethodO
fromStamp = (Timestamp) ObjectType.simpleTypeConvert(newValue, "Timestamp", UtilDateTime.DATE_TIME_FORMAT, timeZone, locale, true);
} catch (Exception e) {
// Catching all exceptions - even potential ClassCastException
- if (Debug.verboseOn()) Debug.logVerbose("Error converting attributes to objects: " + e.getMessage(), module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("Error converting attributes to objects: " + e.getMessage(), module);
return true;
}
-
// Convert Strings to ints
int years = this.yearsExdr.isEmpty() ? 0 : Integer.parseInt(methodContext.expandString(this.yearsExdr));
int months = this.monthsExdr.isEmpty() ? 0 : Integer.parseInt(methodContext.expandString(this.monthsExdr));
@@ -155,7 +147,6 @@ public class SetCalendar extends MethodO
int minutes = this.minutesExdr.isEmpty() ? 0 : Integer.parseInt(methodContext.expandString(this.minutesExdr));
int seconds = this.secondsExdr.isEmpty() ? 0 : Integer.parseInt(methodContext.expandString(this.secondsExdr));
int millis = this.millisExdr.isEmpty() ? 0 : Integer.parseInt(methodContext.expandString(this.millisExdr));
-
// Adjust calendar
Calendar cal = UtilDateTime.toCalendar(fromStamp, timeZone, locale);
cal.add(Calendar.MILLISECOND, millis);
@@ -165,9 +156,7 @@ public class SetCalendar extends MethodO
cal.add(Calendar.DAY_OF_MONTH, days);
cal.add(Calendar.MONTH, months);
cal.add(Calendar.YEAR, years);
-
Timestamp toStamp = new Timestamp(cal.getTimeInMillis());
-
// Align period start/end
if (!periodAlignStart.isEmpty()) {
String period = methodContext.expandString(periodAlignStart);
@@ -192,7 +181,6 @@ public class SetCalendar extends MethodO
toStamp = UtilDateTime.getYearEnd(toStamp, timeZone, locale);
}
}
-
if (Debug.verboseOn())
Debug.logVerbose("In screen setting calendar [" + this.field.toString(), module);
this.field.put(methodContext, toStamp);
@@ -200,16 +188,24 @@ public class SetCalendar extends MethodO
}
@Override
- public String rawString() {
- return "<set-calendar field=\"" + this.field
- + (this.valueExdr.isEmpty() ? "" : "\" value=\"" + this.valueExdr.getOriginal())
- + (this.fromField.isEmpty() ? "" : "\" from-field=\"" + this.fromField)
- + (this.defaultExdr.isEmpty() ? "" : "\" default-value=\"" + this.defaultExdr.getOriginal())
- + "\"/>";
- }
- @Override
public String expandedString(MethodContext methodContext) {
// TODO: something more than a stub/dummy
return this.rawString();
}
+
+ @Override
+ public String rawString() {
+ return "<set-calendar field=\"" + this.field + (this.valueExdr.isEmpty() ? "" : "\" value=\"" + this.valueExdr.getOriginal()) + (this.fromField.isEmpty() ? "" : "\" from-field=\"" + this.fromField) + (this.defaultExdr.isEmpty() ? "" : "\" default-value=\"" + this.defaultExdr.getOriginal())
+ + "\"/>";
+ }
+
+ public static final class SetCalendarFactory implements Factory<SetCalendar> {
+ public SetCalendar createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new SetCalendar(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "set-calendar";
+ }
+ }
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/SetOperation.java Thu Apr 19 15:09:03 2012
@@ -21,7 +21,11 @@ package org.ofbiz.minilang.method.envops
import javolution.util.FastList;
import javolution.util.FastMap;
-import org.ofbiz.base.util.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.ObjectType;
+import org.ofbiz.base.util.ScriptUtil;
+import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.minilang.SimpleMethod;
import org.ofbiz.minilang.method.ContextAccessor;
@@ -33,25 +37,17 @@ import org.w3c.dom.Element;
* A general set operation to set a field from another field or from a value. Also supports a default-value, and type conversion.
*/
public class SetOperation extends MethodOperation {
- public static final class SetOperationFactory implements Factory<SetOperation> {
- public SetOperation createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new SetOperation(element, simpleMethod);
- }
- public String getName() {
- return "set";
- }
- }
public static final String module = SetOperation.class.getName();
+ protected FlexibleStringExpander defaultExdr;
protected ContextAccessor<Object> field;
protected ContextAccessor<Object> fromField;
- protected FlexibleStringExpander valueExdr;
- protected FlexibleStringExpander defaultExdr;
- protected String type;
- protected boolean setIfNull; // default to false
- protected boolean setIfEmpty; // default to true
protected Class<?> parsedScript = null;
+ protected boolean setIfEmpty; // default to true
+ protected boolean setIfNull; // default to false
+ protected String type;
+ protected FlexibleStringExpander valueExdr;
public SetOperation(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
@@ -68,7 +64,6 @@ public class SetOperation extends Method
this.setIfNull = "true".equals(element.getAttribute("set-if-null"));
// default to true, anything but false is true
this.setIfEmpty = !"false".equals(element.getAttribute("set-if-empty"));
-
if (!this.fromField.isEmpty() && !this.valueExdr.isEmpty()) {
throw new IllegalArgumentException("Cannot specify a from-field [" + element.getAttribute("from-field") + "] and a value [" + element.getAttribute("value") + "] on the set action in a screen widget");
}
@@ -85,25 +80,25 @@ public class SetOperation extends Method
}
} else if (!this.fromField.isEmpty()) {
newValue = this.fromField.get(methodContext);
- if (Debug.verboseOn()) Debug.logVerbose("In screen getting value for field from [" + this.fromField.toString() + "]: " + newValue, module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("In screen getting value for field from [" + this.fromField.toString() + "]: " + newValue, module);
} else if (!this.valueExdr.isEmpty()) {
newValue = methodContext.expandString(this.valueExdr);
}
-
// If newValue is still empty, use the default value
if (ObjectType.isEmpty(newValue) && !this.defaultExdr.isEmpty()) {
newValue = methodContext.expandString(this.defaultExdr);
}
-
if (!setIfNull && newValue == null) {
- if (Debug.verboseOn()) Debug.logVerbose("Field value not found (null) with name [" + fromField + "] and value [" + valueExdr + "], and there was not default value, not setting field", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("Field value not found (null) with name [" + fromField + "] and value [" + valueExdr + "], and there was not default value, not setting field", module);
return true;
}
if (!setIfEmpty && ObjectType.isEmpty(newValue)) {
- if (Debug.verboseOn()) Debug.logVerbose("Field value not found (empty) with name [" + fromField + "] and value [" + valueExdr + "], and there was not default value, not setting field", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("Field value not found (empty) with name [" + fromField + "] and value [" + valueExdr + "], and there was not default value, not setting field", module);
return true;
}
-
if (UtilValidate.isNotEmpty(this.type)) {
if ("NewMap".equals(this.type)) {
newValue = FastMap.newInstance();
@@ -119,25 +114,32 @@ public class SetOperation extends Method
return false;
}
}
- }
-
- if (Debug.verboseOn()) Debug.logVerbose("In screen setting field [" + this.field.toString() + "] to value: " + newValue, module);
+ }
+ if (Debug.verboseOn())
+ Debug.logVerbose("In screen setting field [" + this.field.toString() + "] to value: " + newValue, module);
this.field.put(methodContext, newValue);
return true;
}
@Override
- public String rawString() {
- return "<set field=\"" + this.field
- + (this.valueExdr.isEmpty() ? "" : "\" value=\"" + this.valueExdr.getOriginal())
- + (this.fromField.isEmpty() ? "" : "\" from-field=\"" + this.fromField)
- + (this.defaultExdr.isEmpty() ? "" : "\" default-value=\"" + this.defaultExdr.getOriginal())
- + (UtilValidate.isEmpty(this.type) ? "" : "\" type=\"" + this.type)
- + "\"/>";
- }
- @Override
public String expandedString(MethodContext methodContext) {
// TODO: something more than a stub/dummy
return this.rawString();
}
+
+ @Override
+ public String rawString() {
+ return "<set field=\"" + this.field + (this.valueExdr.isEmpty() ? "" : "\" value=\"" + this.valueExdr.getOriginal()) + (this.fromField.isEmpty() ? "" : "\" from-field=\"" + this.fromField) + (this.defaultExdr.isEmpty() ? "" : "\" default-value=\"" + this.defaultExdr.getOriginal())
+ + (UtilValidate.isEmpty(this.type) ? "" : "\" type=\"" + this.type) + "\"/>";
+ }
+
+ public static final class SetOperationFactory implements Factory<SetOperation> {
+ public SetOperation createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new SetOperation(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "set";
+ }
+ }
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringAppend.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringAppend.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringAppend.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringAppend.java Thu Apr 19 15:09:03 2012
@@ -18,113 +18,113 @@
*******************************************************************************/
package org.ofbiz.minilang.method.envops;
-import java.text.*;
-import java.util.*;
-
-import org.w3c.dom.*;
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Map;
import javolution.util.FastMap;
-import org.ofbiz.base.util.*;
-import org.ofbiz.minilang.*;
-import org.ofbiz.minilang.method.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Appends the specified String to a field
*/
public class StringAppend extends MethodOperation {
- public static final class StringAppendFactory implements Factory<StringAppend> {
- public StringAppend createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new StringAppend(element, simpleMethod);
- }
-
- public String getName() {
- return "string-append";
- }
- }
public static final String module = StringAppend.class.getName();
- String string;
+ ContextAccessor<List<? extends Object>> argListAcsr;
+ ContextAccessor<String> fieldAcsr;
+ ContextAccessor<Map<String, Object>> mapAcsr;
String prefix;
+ String string;
String suffix;
- ContextAccessor<Map<String, Object>> mapAcsr;
- ContextAccessor<String> fieldAcsr;
- ContextAccessor<List<? extends Object>> argListAcsr;
public StringAppend(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
string = element.getAttribute("string");
prefix = element.getAttribute("prefix");
suffix = element.getAttribute("suffix");
-
// the schema for this element now just has the "field" attribute, though the old "field-name" and "map-name" pair is still supported
fieldAcsr = new ContextAccessor<String>(element.getAttribute("field"), element.getAttribute("field-name"));
mapAcsr = new ContextAccessor<Map<String, Object>>(element.getAttribute("map-name"));
-
argListAcsr = new ContextAccessor<List<? extends Object>>(element.getAttribute("arg-list"), element.getAttribute("arg-list-name"));
}
- @Override
- public boolean exec(MethodContext methodContext) {
- if (!mapAcsr.isEmpty()) {
- Map<String, Object> toMap = mapAcsr.get(methodContext);
-
- if (toMap == null) {
- if (Debug.verboseOn()) Debug.logVerbose("Map not found with name " + mapAcsr + ", creating new map", module);
- toMap = FastMap.newInstance();
- mapAcsr.put(methodContext, toMap);
- }
-
- String oldValue = fieldAcsr.get(toMap, methodContext);
- fieldAcsr.put(toMap, this.appendString(oldValue, methodContext), methodContext);
- } else {
- String oldValue = fieldAcsr.get(methodContext);
- fieldAcsr.put(methodContext, this.appendString(oldValue, methodContext));
- }
-
- return true;
- }
-
public String appendString(String oldValue, MethodContext methodContext) {
String value = methodContext.expandString(string);
String prefixValue = methodContext.expandString(prefix);
String suffixValue = methodContext.expandString(suffix);
-
if (!argListAcsr.isEmpty()) {
List<? extends Object> argList = argListAcsr.get(methodContext);
if (UtilValidate.isNotEmpty(argList)) {
value = MessageFormat.format(value, argList.toArray());
}
}
-
StringBuilder newValue = new StringBuilder();
if (UtilValidate.isNotEmpty(value)) {
if (UtilValidate.isEmpty(oldValue)) {
newValue.append(value);
} else {
newValue.append(oldValue);
- if (prefixValue != null) newValue.append(prefixValue);
+ if (prefixValue != null)
+ newValue.append(prefixValue);
newValue.append(value);
- if (suffixValue != null) newValue.append(suffixValue);
+ if (suffixValue != null)
+ newValue.append(suffixValue);
}
} else {
if (UtilValidate.isEmpty(oldValue)) {
newValue.append(oldValue);
}
}
-
return newValue.toString();
}
@Override
- public String rawString() {
- // TODO: something more than the empty tag
- return "<string-append string=\"" + this.string + "\" prefix=\"" + this.prefix + "\" suffix=\"" + this.suffix + "\" field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
+ public boolean exec(MethodContext methodContext) {
+ if (!mapAcsr.isEmpty()) {
+ Map<String, Object> toMap = mapAcsr.get(methodContext);
+ if (toMap == null) {
+ if (Debug.verboseOn())
+ Debug.logVerbose("Map not found with name " + mapAcsr + ", creating new map", module);
+ toMap = FastMap.newInstance();
+ mapAcsr.put(methodContext, toMap);
+ }
+ String oldValue = fieldAcsr.get(toMap, methodContext);
+ fieldAcsr.put(toMap, this.appendString(oldValue, methodContext), methodContext);
+ } else {
+ String oldValue = fieldAcsr.get(methodContext);
+ fieldAcsr.put(methodContext, this.appendString(oldValue, methodContext));
+ }
+ return true;
}
+
@Override
public String expandedString(MethodContext methodContext) {
// TODO: something more than a stub/dummy
return this.rawString();
}
+
+ @Override
+ public String rawString() {
+ // TODO: something more than the empty tag
+ return "<string-append string=\"" + this.string + "\" prefix=\"" + this.prefix + "\" suffix=\"" + this.suffix + "\" field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
+ }
+
+ public static final class StringAppendFactory implements Factory<StringAppend> {
+ public StringAppend createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new StringAppend(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "string-append";
+ }
+ }
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToField.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToField.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToField.java Thu Apr 19 15:09:03 2012
@@ -18,16 +18,20 @@
*******************************************************************************/
package org.ofbiz.minilang.method.envops;
-import java.text.*;
-import java.util.*;
-
-import org.w3c.dom.*;
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Map;
import javolution.util.FastMap;
-import org.ofbiz.base.util.*;
-import org.ofbiz.minilang.*;
-import org.ofbiz.minilang.method.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.MessageString;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Copies the specified String to a field
@@ -35,23 +39,14 @@ import org.ofbiz.minilang.method.*;
@Deprecated
@MethodOperation.DeprecatedOperation("set")
public class StringToField extends MethodOperation {
- public static final class StringToFieldFactory implements Factory<StringToField> {
- public StringToField createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new StringToField(element, simpleMethod);
- }
-
- public String getName() {
- return "string-to-field";
- }
- }
public static final String module = StringToField.class.getName();
- String string;
- ContextAccessor<Map<String, Object>> mapAcsr;
- ContextAccessor<Object> fieldAcsr;
ContextAccessor<List<? extends Object>> argListAcsr;
+ ContextAccessor<Object> fieldAcsr;
+ ContextAccessor<Map<String, Object>> mapAcsr;
String messageFieldName;
+ String string;
public StringToField(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
@@ -65,26 +60,23 @@ public class StringToField extends Metho
@Override
public boolean exec(MethodContext methodContext) {
String valueStr = methodContext.expandString(string);
-
if (!argListAcsr.isEmpty()) {
List<? extends Object> argList = argListAcsr.get(methodContext);
if (UtilValidate.isNotEmpty(argList)) {
valueStr = MessageFormat.format(valueStr, argList.toArray());
}
}
-
Object value;
if (UtilValidate.isNotEmpty(this.messageFieldName)) {
value = new MessageString(valueStr, this.messageFieldName, true);
} else {
value = valueStr;
}
-
if (!mapAcsr.isEmpty()) {
Map<String, Object> toMap = mapAcsr.get(methodContext);
-
if (toMap == null) {
- if (Debug.verboseOn()) Debug.logVerbose("Map not found with name " + mapAcsr + ", creating new map", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("Map not found with name " + mapAcsr + ", creating new map", module);
toMap = FastMap.newInstance();
mapAcsr.put(methodContext, toMap);
}
@@ -92,18 +84,28 @@ public class StringToField extends Metho
} else {
fieldAcsr.put(methodContext, value);
}
-
return true;
}
@Override
+ public String expandedString(MethodContext methodContext) {
+ // TODO: something more than a stub/dummy
+ return this.rawString();
+ }
+
+ @Override
public String rawString() {
// TODO: something more than the empty tag
return "<string-to-field string=\"" + this.string + "\" field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- // TODO: something more than a stub/dummy
- return this.rawString();
+
+ public static final class StringToFieldFactory implements Factory<StringToField> {
+ public StringToField createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new StringToField(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "string-to-field";
+ }
}
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToList.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToList.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/StringToList.java Thu Apr 19 15:09:03 2012
@@ -18,37 +18,31 @@
*******************************************************************************/
package org.ofbiz.minilang.method.envops;
-import java.text.*;
-import java.util.*;
-
-import org.w3c.dom.*;
+import java.text.MessageFormat;
+import java.util.List;
import javolution.util.FastList;
-import org.ofbiz.base.util.*;
-import org.ofbiz.minilang.*;
-import org.ofbiz.minilang.method.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.MessageString;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Appends the specified String to a List
*/
public class StringToList extends MethodOperation {
- public static final class StringToListFactory implements Factory<StringToList> {
- public StringToList createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new StringToList(element, simpleMethod);
- }
-
- public String getName() {
- return "string-to-list";
- }
- }
public static final String module = StringToList.class.getName();
- String string;
- ContextAccessor<List<Object>> listAcsr;
ContextAccessor<List<? extends Object>> argListAcsr;
+ ContextAccessor<List<Object>> listAcsr;
String messageFieldName;
+ String string;
public StringToList(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
@@ -67,33 +61,42 @@ public class StringToList extends Method
valueStr = MessageFormat.format(valueStr, argList.toArray());
}
}
-
Object value;
if (UtilValidate.isNotEmpty(this.messageFieldName)) {
value = new MessageString(valueStr, this.messageFieldName, true);
} else {
value = valueStr;
}
-
List<Object> toList = listAcsr.get(methodContext);
if (toList == null) {
- if (Debug.verboseOn()) Debug.logVerbose("List not found with name " + listAcsr + ", creating new List", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("List not found with name " + listAcsr + ", creating new List", module);
toList = FastList.newInstance();
listAcsr.put(methodContext, toList);
}
toList.add(value);
-
return true;
}
@Override
+ public String expandedString(MethodContext methodContext) {
+ // TODO: something more than a stub/dummy
+ return this.rawString();
+ }
+
+ @Override
public String rawString() {
// TODO: something more than the empty tag
return "<string-to-list string=\"" + this.string + "\" list-name=\"" + this.listAcsr + "\"/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- // TODO: something more than a stub/dummy
- return this.rawString();
+
+ public static final class StringToListFactory implements Factory<StringToList> {
+ public StringToList createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new StringToList(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "string-to-list";
+ }
}
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ToString.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ToString.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ToString.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/envops/ToString.java Thu Apr 19 15:09:03 2012
@@ -18,46 +18,39 @@
*******************************************************************************/
package org.ofbiz.minilang.method.envops;
-import java.util.*;
-
-import org.w3c.dom.*;
+import java.util.Map;
import javolution.util.FastMap;
-import org.ofbiz.base.util.*;
-import org.ofbiz.minilang.*;
-import org.ofbiz.minilang.method.*;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.ObjectType;
+import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Converts the specified field to a String, using toString()
*/
public class ToString extends MethodOperation {
- public static final class ToStringFactory implements Factory<ToString> {
- public ToString createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new ToString(element, simpleMethod);
- }
-
- public String getName() {
- return "to-string";
- }
- }
public static final String module = ToString.class.getName();
- ContextAccessor<Map<String, Object>> mapAcsr;
ContextAccessor<Object> fieldAcsr;
String format;
+ ContextAccessor<Map<String, Object>> mapAcsr;
Integer numericPadding;
public ToString(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
-
// the schema for this element now just has the "field" attribute, though the old "field-name" and "map-name" pair is still supported
fieldAcsr = new ContextAccessor<Object>(element.getAttribute("field"), element.getAttribute("field-name"));
mapAcsr = new ContextAccessor<Map<String, Object>>(element.getAttribute("map-name"));
-
format = element.getAttribute("format");
-
String npStr = element.getAttribute("numeric-padding");
if (UtilValidate.isNotEmpty(npStr)) {
try {
@@ -68,19 +61,36 @@ public class ToString extends MethodOper
}
}
+ public String doToString(Object obj, MethodContext methodContext) {
+ String outStr = null;
+ try {
+ if (UtilValidate.isNotEmpty(format)) {
+ outStr = (String) ObjectType.simpleTypeConvert(obj, "String", format, methodContext.getTimeZone(), methodContext.getLocale(), true);
+ } else {
+ outStr = obj.toString();
+ }
+ } catch (GeneralException e) {
+ Debug.logError(e, "", module);
+ outStr = obj.toString();
+ }
+ if (this.numericPadding != null) {
+ outStr = StringUtil.padNumberString(outStr, this.numericPadding.intValue());
+ }
+ return outStr;
+ }
+
@Override
public boolean exec(MethodContext methodContext) {
if (!mapAcsr.isEmpty()) {
Map<String, Object> toMap = mapAcsr.get(methodContext);
-
if (toMap == null) {
// it seems silly to create a new map, but necessary since whenever
// an env field like a Map or List is referenced it should be created, even if empty
- if (Debug.verboseOn()) Debug.logVerbose("Map not found with name " + mapAcsr + ", creating new map", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("Map not found with name " + mapAcsr + ", creating new map", module);
toMap = FastMap.newInstance();
mapAcsr.put(methodContext, toMap);
}
-
Object obj = fieldAcsr.get(toMap, methodContext);
if (obj != null) {
fieldAcsr.put(toMap, doToString(obj, methodContext), methodContext);
@@ -91,28 +101,13 @@ public class ToString extends MethodOper
fieldAcsr.put(methodContext, doToString(obj, methodContext));
}
}
-
return true;
}
- public String doToString(Object obj, MethodContext methodContext) {
- String outStr = null;
- try {
- if (UtilValidate.isNotEmpty(format)) {
- outStr = (String) ObjectType.simpleTypeConvert(obj, "String", format, methodContext.getTimeZone(), methodContext.getLocale(), true);
- } else {
- outStr = obj.toString();
- }
- } catch (GeneralException e) {
- Debug.logError(e, "", module);
- outStr = obj.toString();
- }
-
- if (this.numericPadding != null) {
- outStr = StringUtil.padNumberString(outStr, this.numericPadding.intValue());
- }
-
- return outStr;
+ @Override
+ public String expandedString(MethodContext methodContext) {
+ // TODO: something more than a stub/dummy
+ return this.rawString();
}
@Override
@@ -120,9 +115,14 @@ public class ToString extends MethodOper
// TODO: something more than the empty tag
return "<to-string field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- // TODO: something more than a stub/dummy
- return this.rawString();
+
+ public static final class ToStringFactory implements Factory<ToString> {
+ public ToString createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new ToString(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "to-string";
+ }
}
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/FieldToRequest.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/FieldToRequest.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/FieldToRequest.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/FieldToRequest.java Thu Apr 19 15:09:03 2012
@@ -32,20 +32,11 @@ import org.w3c.dom.Element;
* Copies a map field to a Servlet request attribute
*/
public class FieldToRequest extends MethodOperation {
- public static final class FieldToRequestFactory implements Factory<FieldToRequest> {
- public FieldToRequest createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new FieldToRequest(element, simpleMethod);
- }
-
- public String getName() {
- return "field-to-request";
- }
- }
public static final String module = FieldToRequest.class.getName();
- ContextAccessor<Map<String, ? extends Object>> mapAcsr;
ContextAccessor<Object> fieldAcsr;
+ ContextAccessor<Map<String, ? extends Object>> mapAcsr;
FlexibleServletAccessor<Object> requestAcsr;
public FieldToRequest(Element element, SimpleMethod simpleMethod) {
@@ -77,20 +68,30 @@ public class FieldToRequest extends Meth
Debug.logWarning("Field value not found with name " + fieldAcsr + " in Map with name " + mapAcsr, module);
return true;
}
-
requestAcsr.put(methodContext.getRequest(), fieldVal, methodContext.getEnvMap());
}
return true;
}
@Override
+ public String expandedString(MethodContext methodContext) {
+ // TODO: something more than a stub/dummy
+ return this.rawString();
+ }
+
+ @Override
public String rawString() {
// TODO: add all attributes and other info
return "<field-to-request field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- // TODO: something more than a stub/dummy
- return this.rawString();
+
+ public static final class FieldToRequestFactory implements Factory<FieldToRequest> {
+ public FieldToRequest createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new FieldToRequest(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "field-to-request";
+ }
}
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/FieldToSession.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/FieldToSession.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/FieldToSession.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/FieldToSession.java Thu Apr 19 15:09:03 2012
@@ -32,20 +32,11 @@ import org.w3c.dom.Element;
* Copies a map field to a Servlet session attribute
*/
public class FieldToSession extends MethodOperation {
- public static final class FieldToSessionFactory implements Factory<FieldToSession> {
- public FieldToSession createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new FieldToSession(element, simpleMethod);
- }
-
- public String getName() {
- return "field-to-session";
- }
- }
public static final String module = FieldToSession.class.getName();
- ContextAccessor<Map<String, ? extends Object>> mapAcsr;
ContextAccessor<Object> fieldAcsr;
+ ContextAccessor<Map<String, ? extends Object>> mapAcsr;
FlexibleServletAccessor<Object> sessionAcsr;
public FieldToSession(Element element, SimpleMethod simpleMethod) {
@@ -77,20 +68,30 @@ public class FieldToSession extends Meth
Debug.logWarning("Field value not found with name " + fieldAcsr + " in Map with name " + mapAcsr, module);
return true;
}
-
sessionAcsr.put(methodContext.getRequest().getSession(), fieldVal, methodContext.getEnvMap());
}
return true;
}
@Override
+ public String expandedString(MethodContext methodContext) {
+ // TODO: something more than a stub/dummy
+ return this.rawString();
+ }
+
+ @Override
public String rawString() {
// TODO: add all attributes and other info
return "<field-to-session field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- // TODO: something more than a stub/dummy
- return this.rawString();
+
+ public static final class FieldToSessionFactory implements Factory<FieldToSession> {
+ public FieldToSession createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new FieldToSession(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "field-to-session";
+ }
}
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/RequestParametersToList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/RequestParametersToList.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/RequestParametersToList.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/RequestParametersToList.java Thu Apr 19 15:09:03 2012
@@ -18,27 +18,22 @@
*******************************************************************************/
package org.ofbiz.minilang.method.eventops;
-import java.util.*;
+import java.util.List;
-import org.w3c.dom.*;
import javolution.util.FastList;
-import org.ofbiz.base.util.*;
-import org.ofbiz.minilang.*;
-import org.ofbiz.minilang.method.*;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.ContextAccessor;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
/**
* Copies a Servlet request parameter values to a list
*/
public class RequestParametersToList extends MethodOperation {
- public static final class RequestParametersToListFactory implements Factory<RequestParametersToList> {
- public RequestParametersToList createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new RequestParametersToList(element, simpleMethod);
- }
-
- public String getName() {
- return "request-parameters-to-list";
- }
- }
public static final String module = RequestParametersToList.class.getName();
@@ -63,31 +58,39 @@ public class RequestParametersToList ext
listVal = UtilMisc.toListArray(parameterValues);
}
}
-
// if listVal is null, use a empty list;
if (listVal == null) {
listVal = FastList.newInstance();
}
-
List<String> toList = listAcsr.get(methodContext);
-
if (toList == null) {
- if (Debug.verboseOn()) Debug.logVerbose("List not found with name " + listAcsr + ", creating new list", module);
+ if (Debug.verboseOn())
+ Debug.logVerbose("List not found with name " + listAcsr + ", creating new list", module);
toList = FastList.newInstance();
listAcsr.put(methodContext, toList);
}
-
toList.addAll(listVal);
return true;
}
@Override
- public String rawString() {
- return "<request-parameters-to-list request-name=\"" + this.requestName + "\" list-name=\"" + this.listAcsr + "\"/>";
- }
- @Override
public String expandedString(MethodContext methodContext) {
// TODO: something more than a stub/dummy
return this.rawString();
}
+
+ @Override
+ public String rawString() {
+ return "<request-parameters-to-list request-name=\"" + this.requestName + "\" list-name=\"" + this.listAcsr + "\"/>";
+ }
+
+ public static final class RequestParametersToListFactory implements Factory<RequestParametersToList> {
+ public RequestParametersToList createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new RequestParametersToList(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "request-parameters-to-list";
+ }
+ }
}
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/RequestToField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/RequestToField.java?rev=1327981&r1=1327980&r2=1327981&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/RequestToField.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/eventops/RequestToField.java Thu Apr 19 15:09:03 2012
@@ -21,6 +21,7 @@ package org.ofbiz.minilang.method.evento
import java.util.Map;
import javolution.util.FastMap;
+
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.collections.FlexibleServletAccessor;
import org.ofbiz.minilang.SimpleMethod;
@@ -33,22 +34,13 @@ import org.w3c.dom.Element;
* Copies a Servlet request attribute to a map field
*/
public class RequestToField extends MethodOperation {
- public static final class RequestToFieldFactory implements Factory<RequestToField> {
- public RequestToField createMethodOperation(Element element, SimpleMethod simpleMethod) {
- return new RequestToField(element, simpleMethod);
- }
-
- public String getName() {
- return "request-to-field";
- }
- }
public static final String module = RequestToField.class.getName();
- ContextAccessor<Map<String, Object>> mapAcsr;
+ String defaultVal;
ContextAccessor<Object> fieldAcsr;
+ ContextAccessor<Map<String, Object>> mapAcsr;
FlexibleServletAccessor<Object> requestAcsr;
- String defaultVal;
public RequestToField(Element element, SimpleMethod simpleMethod) {
super(element, simpleMethod);
@@ -56,14 +48,12 @@ public class RequestToField extends Meth
mapAcsr = new ContextAccessor<Map<String, Object>>(element.getAttribute("map-name"));
fieldAcsr = new ContextAccessor<Object>(element.getAttribute("field"), element.getAttribute("field-name"));
requestAcsr = new FlexibleServletAccessor<Object>(element.getAttribute("request-name"), fieldAcsr.toString());
-
defaultVal = element.getAttribute("default");
}
@Override
public boolean exec(MethodContext methodContext) {
String defaultVal = methodContext.expandString(this.defaultVal);
-
Object fieldVal = null;
// only run this if it is in an EVENT context
if (methodContext.getMethodType() == MethodContext.EVENT) {
@@ -72,7 +62,6 @@ public class RequestToField extends Meth
Debug.logWarning("Request attribute value not found with name " + requestAcsr, module);
}
}
-
// if fieldVal is null, or is a String and has zero length, use defaultVal
if (fieldVal == null) {
fieldVal = defaultVal;
@@ -83,16 +72,13 @@ public class RequestToField extends Meth
fieldVal = defaultVal;
}
}
-
if (!mapAcsr.isEmpty()) {
Map<String, Object> fromMap = mapAcsr.get(methodContext);
-
if (fromMap == null) {
Debug.logWarning("Map not found with name " + mapAcsr + " creating a new map", module);
fromMap = FastMap.newInstance();
mapAcsr.put(methodContext, fromMap);
}
-
fieldAcsr.put(fromMap, fieldVal, methodContext);
} else {
fieldAcsr.put(methodContext, fieldVal);
@@ -101,13 +87,24 @@ public class RequestToField extends Meth
}
@Override
+ public String expandedString(MethodContext methodContext) {
+ // TODO: something more than a stub/dummy
+ return this.rawString();
+ }
+
+ @Override
public String rawString() {
// TODO: add all attributes and other info
return "<request-to-field request-name=\"" + this.requestAcsr + "\" field-name=\"" + this.fieldAcsr + "\" map-name=\"" + this.mapAcsr + "\"/>";
}
- @Override
- public String expandedString(MethodContext methodContext) {
- // TODO: something more than a stub/dummy
- return this.rawString();
+
+ public static final class RequestToFieldFactory implements Factory<RequestToField> {
+ public RequestToField createMethodOperation(Element element, SimpleMethod simpleMethod) {
+ return new RequestToField(element, simpleMethod);
+ }
+
+ public String getName() {
+ return "request-to-field";
+ }
}
}