Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /gef/src/org/tigris/gef/ocl/OCLEvaluator.java

gef
Discussion topic

Back to topic list

CVS update: /gef/src/org/tigris/gef/ocl/OCLEvaluator.java

Reply

Author bobtarling
Full name Bob Tarling
Date 2006-07-05 02:27:13 PDT
Message User: bobtarling
Date: 2006-07-05 02:27:13-0700
Log:
 Improve error reporting in exception

File Changes:

Directory: /gef/src/org/tigris/gef/ocl/
====================​===================

File [changed]: OCLEvaluator.java
Url: http://gef.tigris.or​g/source/browse/gef/​src/org/tigris/gef/o​cl/OCLEvaluator.java​?r1=1.22&r2=1.23​
Delta lines: +18 -16
---------------------
--- OCLEvaluator.java 2006-06-11 15:12:06-0700 1.22
+++ OCLEvaluator.java 2006-07-05 02:27:11-0700 1.23
@@ -106,34 +106,36 @@
     } // end of eval()
     
     private List eval(Map bindings, String expr, List targets) throws ExpansionException {
+ String partExpr = expr;
         try {
- int firstPos;
- int secPos;
- int numElements;
- String property;
- while(expr.length() > 0) {
+ while(partExpr.length() > 0) {
                 List v = new ArrayList();
- firstPos = expr.indexOf(".");
- secPos = expr.indexOf(".", firstPos + 1);
+ int firstPos = partExpr.indexOf(".");
+ int secPos = partExpr.indexOf(".", firstPos + 1);
+ String property;
                 if(secPos == -1) { // <expr>::= ".<property>"
- property = expr.substring(firstPos + 1);
- expr = "";
+ property = partExpr.substring(firstPos + 1);
+ partExpr = "";
                 } else { // <expr>::= ".<property>.​<expr>"
- property = expr.substring(firstPos + 1, secPos);
- expr = expr.substring(secPos); //+1
+ property = partExpr.substring(firstPos + 1, secPos);
+ partExpr = partExpr.substring(secPos); //+1
                 }
     
- numElements = targets.size();
+ int numElements = targets.size();
                 for(int i = 0; i < numElements; i++) {
                     v.add(evaluateProper​ty(targets.get(i), property));
                 }
     
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Flattening to get targets for " + expr + "(" + partExpr + ")");
+ }
+
                 targets = new Vector(flatten(v));
                 // the results of evaluating a property may result in a List
             }
         } catch (Exception e) {
             throw new ExpansionException(
- "Exception while expanding the expression " + expr, e);
+ "Exception while expanding the expression " + expr + " (" + partExpr + ")" , e);
         }
     
         return targets;
@@ -253,11 +255,11 @@
      * non-lists.
      */
     private void flattenInto(Object o, List accum) {
+
         if(o instanceof List) {
             List oList = (List)o;
- int count = oList.size();
- for(int i = 0; i < count; ++i) {
- Object p = oList.get(i);
+ for (Iterator it = oList.iterator(); it.hasNext(); ) {
+ Object p = it.next();
                 flattenInto(p, accum);
             }
         } else {

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /gef/src/org/tigris/gef/ocl/OCLEvaluator.java bobtarling Bob Tarling 2006-07-05 02:27:13 PDT
Messages per page: