Author: doogie
Date: Wed May 26 14:23:03 2010
New Revision: 948448
URL:
http://svn.apache.org/viewvc?rev=948448&view=revLog:
Allow for dynamic registering of additional operators for extensions.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java?rev=948448&r1=948447&r2=948448&view=diff==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java Wed May 26 14:23:03 2010
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.entity.Delegator;
@@ -54,6 +55,7 @@ public abstract class EntityOperator<L,
public static final int ID_NOT_IN = 13;
public static final int ID_NOT_LIKE = 14;
+ private static final AtomicInteger dynamicId = new AtomicInteger();
private static HashMap<String, EntityOperator<?,?,?>> registry = new HashMap<String, EntityOperator<?,?,?>>();
private static <L,R,T> void registerCase(String name, EntityOperator<L,R,T> operator) {
@@ -61,7 +63,7 @@ public abstract class EntityOperator<L,
registry.put(name.toUpperCase(), operator);
}
- private static <L,R,T> void register(String name, EntityOperator<L,R,T> operator) {
+ public static <L,R,T> void register(String name, EntityOperator<L,R,T> operator) {
registerCase(name, operator);
registerCase(name.replaceAll("-", "_"), operator);
registerCase(name.replaceAll("_", "-"), operator);
@@ -85,6 +87,10 @@ public abstract class EntityOperator<L,
return UtilGenerics.cast(operator);
}
+ public static int requestId() {
+ return dynamicId.get();
+ }
+
public static final EntityComparisonOperator<?,?> EQUALS = new ComparableEntityComparisonOperator<Object>(ID_EQUALS, "=") {
@Override
public boolean compare(Comparable<Object> lhs, Object rhs) { return EntityComparisonOperator.compareEqual(lhs, rhs); }