You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by fr...@apache.org on 2001/11/17 18:31:02 UTC
cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions BasicSelect.java
froehlich 01/11/17 09:31:02
Modified: apps/db/src/java/org/apache/avalon/db/basic/actions
BasicSelect.java
Log:
new type definition
Revision Changes Path
1.26 +32 -36 jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicSelect.java
Index: BasicSelect.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicSelect.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- BasicSelect.java 2001/11/15 00:50:46 1.25
+++ BasicSelect.java 2001/11/17 17:31:01 1.26
@@ -22,9 +22,13 @@
import org.apache.avalon.db.data.ValidationException;
import org.apache.avalon.db.data.Table;
import org.apache.avalon.db.data.Column;
+import org.apache.avalon.db.data.impl.StringConstantColumn;
import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -55,12 +59,13 @@
private String[] mTablenames;
static {
mOperators = new Hashtable();
- addOperator("=","mequal");
- addOperator(">","greater");
- addOperator("<","smaller");
- addOperator("<>","unequal");
- addOperator("<=","smallerequal");
- addOperator(">=","greaterequal");
+ addOperator("=","testEqual");
+ addOperator(">","testGreaterThan");
+ addOperator("<","testSmallerThan");
+ addOperator("<>","testNotEqual");
+ addOperator("<=","testSmallerThanOrEqual");
+ addOperator(">=","testGreaterThanOrEqual");
+ addOperator("like","testLike");
}
private static void addOperator(String operator, String method) {
mOperators.put(operator,method);
@@ -123,9 +128,13 @@
if(!mWhereBuffer.toString().equals("")) {
RhinoHelper rh = new RhinoHelper();
Matched rc = new Matched();
+ ConstantColumn cc = new ConstantColumn();
+ TestHelper testHelper = new TestHelper();
rh.addBean("row",row);
- rh.addBean("my",this);
+ rh.addBean("cc",cc);
+ rh.addBean("testHelper",testHelper);
rh.addBean("rc",rc);
+ rh.addBean("table",mTable);
getLogger().debug("mWhereBuffer.toString()" + mWhereBuffer.toString());
rh.executeAction("if (" + mWhereBuffer.toString() + ") { rc.itDidMatch(true); } ");
return rc.didItMatch();
@@ -144,6 +153,12 @@
}
}
+ public class ConstantColumn {
+ public Column getConstantColumn(String name, String value) {
+ return new StringConstantColumn(name,value);
+ }
+ }
+
private boolean checkSelectStructure(Element rootElement) {
NodeList subRootNodes = mRootElement.getChildNodes();
@@ -312,10 +327,12 @@
getLogger().debug("expr=" + expr);
try {
Enumeration enum = mOperators.keys();
+ getLogger().debug("mOperators.size()=" + mOperators.size());
while(enum.hasMoreElements()) {
operator = (String)enum.nextElement();
getLogger().debug("matching operator = " + operator);
getLogger().debug("matching function = " + mOperators.get(operator));
+ /*
StringTokenizer strtok = new StringTokenizer(expr,operator);
strarr = new String[strtok.countTokens()];
int cnt = 0;
@@ -325,14 +342,21 @@
strarr[cnt] = s;
cnt++;
}
+ */
+ RE re = new RE(operator);
+ strarr = re.split(expr);
if(strarr.length > 1) {
method = (String)mOperators.get(operator);
getLogger().debug("matched function = " + method);
result = strarr;
}
}
- method = "my." + method + "(row.getValue(\"" + result[0] + "\"),\"" + result[1] + "\")";
+ method = "testHelper." + method + "(table.getColumn(\"" + result[0]
+ + "\"),cc.getConstantColumn(\"constantcolumn\",\"" + result[1] + "\"),row)";
getLogger().debug("method=" + method);
+
+ } catch (RESyntaxException rse) {
+ getLogger().error("composeExpr(): RESyntaxException",rse);
} catch (Exception e) {
getLogger().error("composeExpr(): Exception",e);
}
@@ -357,35 +381,7 @@
return columns;
}
- public boolean mequal(String leftexpr,String rightexpr) throws ActionException {
- getLogger().debug("leftexpr=" + leftexpr);
- getLogger().debug("rightexpr=" + rightexpr);
- return leftexpr.equals(rightexpr);
- }
-
- public boolean smaller(String leftexpr,String rightexpr) throws ActionException {
- throw new ActionException("operation not supported ");
- }
- public boolean greater(String leftexpr,String rightexpr) throws ActionException {
- throw new ActionException("operation not supported ");
- }
-
- public boolean unequal(String leftexpr,String rightexpr) throws ActionException {
- return !leftexpr.equals(rightexpr);
- }
-
- public boolean like(String leftexpr,String rightexpr) throws ActionException {
- throw new ActionException("operation not supported ");
- }
-
- public boolean smallerequal(String leftexpr,String rightexpr) throws ActionException {
- throw new ActionException("operation not supported ");
- }
-
- public boolean greaterequal(String leftexpr,String rightexpr) throws ActionException {
- throw new ActionException("operation not supported ");
- }
public void execute(Object[] params) throws ActionException {
getLogger().debug("select execute prepared");
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>