db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/odmg/oql OQLLexer.java OQLParser.java
Date Sat, 15 Mar 2003 16:38:12 GMT
brj         2003/03/15 08:38:12

  Modified:    src/java/org/apache/ojb/odmg/oql OQLLexer.java
                        OQLParser.java
  Log:
  Query refactoring
  
  Revision  Changes    Path
  1.6       +18 -11    db-ojb/src/java/org/apache/ojb/odmg/oql/OQLLexer.java
  
  Index: OQLLexer.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/oql/OQLLexer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- OQLLexer.java	10 Mar 2003 06:07:19 -0000	1.5
  +++ OQLLexer.java	15 Mar 2003 16:38:12 -0000	1.6
  @@ -40,25 +40,32 @@
    */
   package org.apache.ojb.odmg.oql;
   
  +import org.apache.ojb.broker.query.*;
  +import java.util.*;
  +
   import java.io.InputStream;
  +import antlr.TokenStreamException;
  +import antlr.TokenStreamIOException;
  +import antlr.TokenStreamRecognitionException;
  +import antlr.CharStreamException;
  +import antlr.CharStreamIOException;
  +import antlr.ANTLRException;
   import java.io.Reader;
   import java.util.Hashtable;
  -
  -import antlr.ANTLRHashString;
  +import antlr.CharScanner;
  +import antlr.InputBuffer;
   import antlr.ByteBuffer;
   import antlr.CharBuffer;
  -import antlr.CharStreamException;
  -import antlr.CharStreamIOException;
  -import antlr.InputBuffer;
  -import antlr.LexerSharedInputState;
  -import antlr.NoViableAltForCharException;
  -import antlr.RecognitionException;
   import antlr.Token;
  +import antlr.CommonToken;
  +import antlr.RecognitionException;
  +import antlr.NoViableAltForCharException;
  +import antlr.MismatchedCharException;
   import antlr.TokenStream;
  -import antlr.TokenStreamException;
  -import antlr.TokenStreamIOException;
  -import antlr.TokenStreamRecognitionException;
  +import antlr.ANTLRHashString;
  +import antlr.LexerSharedInputState;
   import antlr.collections.impl.BitSet;
  +import antlr.SemanticException;
   
   public class OQLLexer extends antlr.CharScanner implements OQLLexerTokenTypes, TokenStream
    {
  
  
  
  1.11      +22 -22    db-ojb/src/java/org/apache/ojb/odmg/oql/OQLParser.java
  
  Index: OQLParser.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/oql/OQLParser.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- OQLParser.java	10 Mar 2003 06:07:19 -0000	1.10
  +++ OQLParser.java	15 Mar 2003 16:38:12 -0000	1.11
  @@ -46,8 +46,8 @@
   
   import org.apache.ojb.broker.query.Criteria;
   import org.apache.ojb.broker.query.Query;
  +import org.apache.ojb.broker.query.QueryByCriteria;
   import org.apache.ojb.broker.query.QueryFactory;
  -
   import antlr.NoViableAltException;
   import antlr.ParserSharedInputState;
   import antlr.RecognitionException;
  @@ -110,8 +110,8 @@
   		return query;
   	}
   	
  -	public final Query  selectQuery() throws RecognitionException, TokenStreamException {
  -		Query query = null;
  +	public final QueryByCriteria  selectQuery() throws RecognitionException, TokenStreamException
{
  +		QueryByCriteria query = null;
   		
   		
   		try {      // for error handling
  @@ -151,19 +151,6 @@
   			}
   			
   			}
  -			{
  -			if ((LA(1)==LITERAL_order)) {
  -				match(LITERAL_order);
  -				match(LITERAL_by);
  -				orderClause(criteria);
  -			}
  -			else if ((LA(1)==EOF||LA(1)==TOK_RPAREN||LA(1)==TOK_SEMIC)) {
  -			}
  -			else {
  -				throw new NoViableAltException(LT(1), getFilename());
  -			}
  -			
  -			}
   			
   			if (clazz != null) {
   			if (projectionAttrs[0].indexOf('.') < 0)
  @@ -181,6 +168,19 @@
   			}
   			}
   			
  +			{
  +			if ((LA(1)==LITERAL_order)) {
  +				match(LITERAL_order);
  +				match(LITERAL_by);
  +				orderClause(query);
  +			}
  +			else if ((LA(1)==EOF||LA(1)==TOK_RPAREN||LA(1)==TOK_SEMIC)) {
  +			}
  +			else {
  +				throw new NoViableAltException(LT(1), getFilename());
  +			}
  +			
  +			}
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -303,18 +303,18 @@
   	}
   	
   	public final void orderClause(
  -		Criteria criteria
  +		QueryByCriteria query
   	) throws RecognitionException, TokenStreamException {
   		
   		
   		try {      // for error handling
  -			sortCriterion(criteria);
  +			sortCriterion(query);
   			{
   			_loop81:
   			do {
   				if ((LA(1)==TOK_COMMA)) {
   					match(TOK_COMMA);
  -					sortCriterion(criteria);
  +					sortCriterion(query);
   				}
   				else {
   					break _loop81;
  @@ -400,7 +400,7 @@
   	}
   	
   	public final void sortCriterion(
  -		Criteria criteria
  +		QueryByCriteria query
   	) throws RecognitionException, TokenStreamException {
   		
   		Token  id = null;
  @@ -435,9 +435,9 @@
   			}
   			
   			if (descending) {
  -			criteria.addOrderByDescending(id.getText());
  +			query.addOrderByDescending(id.getText());
   			} else {
  -			criteria.addOrderByAscending(id.getText());
  +			query.addOrderByAscending(id.getText());
   			}
   			
   		}
  
  
  

Mime
View raw message