You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2003/06/21 13:05:20 UTC

cvs commit: db-ojb/src/java/org/apache/ojb/odmg/oql OQLParser.java

arminw      2003/06/21 04:05:20

  Modified:    src/java/org/apache/ojb/broker/util/configuration/impl
                        ConfigurationAbstractImpl.java
               src/java/org/apache/ojb/odmg/oql OQLParser.java
  Log:
  use ClassHelper to
  lookup Class object
  
  Revision  Changes    Path
  1.6       +3 -2      db-ojb/src/java/org/apache/ojb/broker/util/configuration/impl/ConfigurationAbstractImpl.java
  
  Index: ConfigurationAbstractImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/configuration/impl/ConfigurationAbstractImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ConfigurationAbstractImpl.java	24 Dec 2002 13:28:58 -0000	1.5
  +++ ConfigurationAbstractImpl.java	21 Jun 2003 11:05:20 -0000	1.6
  @@ -57,6 +57,7 @@
   import org.apache.ojb.broker.util.configuration.Configuration;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  +import org.apache.ojb.broker.util.ClassHelper;
   
   import java.io.File;
   import java.io.InputStream;
  @@ -350,7 +351,7 @@
           Class clazz = null;
           try
           {
  -            clazz = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
  +            clazz = ClassHelper.getClass(className);
           }
           catch (ClassNotFoundException e)
           {
  
  
  
  1.12      +134 -134  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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- OQLParser.java	15 Mar 2003 16:38:12 -0000	1.11
  +++ OQLParser.java	21 Jun 2003 11:05:20 -0000	1.12
  @@ -48,6 +48,7 @@
   import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.query.QueryByCriteria;
   import org.apache.ojb.broker.query.QueryFactory;
  +import org.apache.ojb.broker.util.ClassHelper;
   import antlr.NoViableAltException;
   import antlr.ParserSharedInputState;
   import antlr.RecognitionException;
  @@ -86,8 +87,8 @@
   
   	public final Query  buildQuery() throws RecognitionException, TokenStreamException {
   		Query query = null;
  -		
  -		
  +
  +
   		try {      // for error handling
   			query=selectQuery();
   			{
  @@ -99,7 +100,7 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
   		}
   		catch (RecognitionException ex) {
  @@ -109,32 +110,32 @@
   		}
   		return query;
   	}
  -	
  +
   	public final QueryByCriteria  selectQuery() throws RecognitionException, TokenStreamException {
   		QueryByCriteria query = null;
  -		
  -		
  +
  +
   		try {      // for error handling
  -			
  +
   			Class clazz = null;
   			Criteria criteria = new Criteria();
   			String[] projectionAttrs;
   			boolean distinct = false;
  -			
  +
   			match(LITERAL_select);
   			{
   			if ((LA(1)==LITERAL_distinct)) {
   				match(LITERAL_distinct);
  -				
  +
   				distinct = true;
  -				
  +
   			}
   			else if ((LA(1)==TOK_STAR||LA(1)==Identifier)) {
   			}
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
   			projectionAttrs=projectionAttributes();
   			match(LITERAL_from);
  @@ -149,9 +150,9 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
  -			
  +
   			if (clazz != null) {
   			if (projectionAttrs[0].indexOf('.') < 0)
   			{
  @@ -167,7 +168,7 @@
   			criteria, distinct);
   			}
   			}
  -			
  +
   			{
   			if ((LA(1)==LITERAL_order)) {
   				match(LITERAL_order);
  @@ -179,7 +180,7 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
   		}
   		catch (RecognitionException ex) {
  @@ -189,26 +190,26 @@
   		}
   		return query;
   	}
  -	
  +
   	public final String[]  projectionAttributes() throws RecognitionException, TokenStreamException {
   		String[] projectionAttrs = null;
  -		
  +
   		Token  id = null;
   		Token  id1 = null;
  -		
  +
   		try {      // for error handling
  -			
  +
   			String first = null;
   			ArrayList list = null;
  -			
  +
   			{
   			if ((LA(1)==Identifier)) {
   				id = LT(1);
   				match(Identifier);
   				{
  -				
  +
   				first = id.getText();
  -				
  +
   				}
   				{
   				_loop78:
  @@ -218,20 +219,20 @@
   						id1 = LT(1);
   						match(Identifier);
   						{
  -						
  +
   						if (list == null)
   						{
   						list = new ArrayList();
   						list.add(first);
   						}
   						list.add(id1.getText());
  -						
  +
   						}
   					}
   					else {
   						break _loop78;
   					}
  -					
  +
   				} while (true);
   				}
   			}
  @@ -241,9 +242,9 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
  -			
  +
   			if (list == null)
   			{
   			projectionAttrs = new String[] {first};
  @@ -252,8 +253,8 @@
   			{
   			projectionAttrs = (String[]) list.toArray(new String[list.size()]);
   			}
  -			
  -			
  +
  +
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -262,22 +263,21 @@
   		}
   		return projectionAttrs;
   	}
  -	
  +
   	public final Class  fromClause() throws RecognitionException, TokenStreamException {
   		Class clazz = null;
  -		
  +
   		Token  id = null;
  -		
  +
   		try {      // for error handling
   			id = LT(1);
   			match(Identifier);
  -			
  +
   			try {
  -			clazz = Class.forName(id.getText(), true,
  -			Thread.currentThread().getContextClassLoader());
  +			clazz = ClassHelper.getClass(id.getText());
   			} catch (Exception e) {
   			}
  -			
  +
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -286,12 +286,12 @@
   		}
   		return clazz;
   	}
  -	
  +
   	public final void whereClause(
   		Criteria criteria
   	) throws RecognitionException, TokenStreamException {
  -		
  -		
  +
  +
   		try {      // for error handling
   			orExpr(criteria);
   		}
  @@ -301,12 +301,12 @@
   			consumeUntil(_tokenSet_5);
   		}
   	}
  -	
  +
   	public final void orderClause(
   		QueryByCriteria query
   	) throws RecognitionException, TokenStreamException {
  -		
  -		
  +
  +
   		try {      // for error handling
   			sortCriterion(query);
   			{
  @@ -319,7 +319,7 @@
   				else {
   					break _loop81;
   				}
  -				
  +
   			} while (true);
   			}
   		}
  @@ -329,16 +329,16 @@
   			consumeUntil(_tokenSet_2);
   		}
   	}
  -	
  +
   	public final Query  existsQuery() throws RecognitionException, TokenStreamException {
   		Query query = null;
  -		
  -		
  +
  +
   		try {      // for error handling
  -			
  +
   			Class clazz = null;
   			Criteria criteria = new Criteria();
  -			
  +
   			match(LITERAL_exists);
   			projectionAttributes();
   			match(LITERAL_in);
  @@ -353,13 +353,13 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
  -			
  +
   			if (clazz != null) {
   			query = QueryFactory.newQuery(clazz, criteria);
   			}
  -					
  +
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -368,12 +368,12 @@
   		}
   		return query;
   	}
  -	
  +
   	public final void orExpr(
   		Criteria criteria
   	) throws RecognitionException, TokenStreamException {
  -		
  -		
  +
  +
   		try {      // for error handling
   			andExpr(criteria);
   			{
  @@ -388,7 +388,7 @@
   				else {
   					break _loop87;
   				}
  -				
  +
   			} while (true);
   			}
   		}
  @@ -398,13 +398,13 @@
   			consumeUntil(_tokenSet_5);
   		}
   	}
  -	
  +
   	public final void sortCriterion(
   		QueryByCriteria query
   	) throws RecognitionException, TokenStreamException {
  -		
  +
   		Token  id = null;
  -		
  +
   		try {      // for error handling
   			boolean descending = false;
   			id = LT(1);
  @@ -423,7 +423,7 @@
   				else {
   					throw new NoViableAltException(LT(1), getFilename());
   				}
  -				
  +
   				}
   			}
   			else if ((_tokenSet_8.member(LA(1)))) {
  @@ -431,15 +431,15 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
  -			
  +
   			if (descending) {
   			query.addOrderByDescending(id.getText());
   			} else {
   			query.addOrderByAscending(id.getText());
   			}
  -			
  +
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -447,12 +447,12 @@
   			consumeUntil(_tokenSet_8);
   		}
   	}
  -	
  +
   	public final void andExpr(
   		Criteria criteria
   	) throws RecognitionException, TokenStreamException {
  -		
  -		
  +
  +
   		try {      // for error handling
   			quantifierExpr(criteria);
   			{
  @@ -467,7 +467,7 @@
   				else {
   					break _loop90;
   				}
  -				
  +
   			} while (true);
   			}
   		}
  @@ -477,12 +477,12 @@
   			consumeUntil(_tokenSet_5);
   		}
   	}
  -	
  +
   	public final void quantifierExpr(
   		Criteria criteria
   	) throws RecognitionException, TokenStreamException {
  -		
  -		
  +
  +
   		try {      // for error handling
   			switch ( LA(1)) {
   			case TOK_LPAREN:
  @@ -528,17 +528,17 @@
   			consumeUntil(_tokenSet_5);
   		}
   	}
  -	
  +
   	public final void equalityExpr(
   		Criteria criteria
   	) throws RecognitionException, TokenStreamException {
  -		
  +
   		Token  id = null;
  -		
  +
   		try {      // for error handling
  -			
  +
   				Object value = null;
  -			
  +
   			id = LT(1);
   			match(Identifier);
   			{
  @@ -559,7 +559,7 @@
   				else {
   					throw new NoViableAltException(LT(1), getFilename());
   				}
  -				
  +
   				}
   				break;
   			}
  @@ -578,7 +578,7 @@
   				else {
   					throw new NoViableAltException(LT(1), getFilename());
   				}
  -				
  +
   				}
   				break;
   			}
  @@ -597,7 +597,7 @@
   				else {
   					throw new NoViableAltException(LT(1), getFilename());
   				}
  -				
  +
   				}
   				break;
   			}
  @@ -643,18 +643,18 @@
   			consumeUntil(_tokenSet_5);
   		}
   	}
  -	
  +
   	public final void likeExpr(
   		Criteria criteria
   	) throws RecognitionException, TokenStreamException {
  -		
  +
   		Token  id = null;
  -		
  +
   		try {      // for error handling
  -			
  +
   			boolean negative = false;
   			Object value = null;
  -			
  +
   			id = LT(1);
   			match(Identifier);
   			{
  @@ -667,17 +667,17 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
   			match(LITERAL_like);
   			value=literal();
  -			
  +
   			if (negative) {
   			criteria.addNotLike(id.getText(), value);
   			} else {
   			criteria.addLike(id.getText(), value);
   			}
  -			
  +
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -685,13 +685,13 @@
   			consumeUntil(_tokenSet_5);
   		}
   	}
  -	
  +
   	public final void undefinedExpr(
   		Criteria criteria
   	) throws RecognitionException, TokenStreamException {
  -		
  +
   		Token  id = null;
  -		
  +
   		try {      // for error handling
   			boolean negative = false;
   			{
  @@ -706,19 +706,19 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
   			match(TOK_LPAREN);
   			id = LT(1);
   			match(Identifier);
   			match(TOK_RPAREN);
  -			
  +
   			if (negative) {
   			criteria.addNotNull(id.getText());
   			} else {
   			criteria.addIsNull(id.getText());
   			}
  -			
  +
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -726,19 +726,19 @@
   			consumeUntil(_tokenSet_5);
   		}
   	}
  -	
  +
   	public final void betweenExpr(
   		Criteria criteria
   	) throws RecognitionException, TokenStreamException {
  -		
  +
   		Token  id = null;
  -		
  +
   		try {      // for error handling
  -			
  +
   			boolean negative = false;
   			Object lower = null;
   			Object upper = null;
  -			
  +
   			id = LT(1);
   			match(Identifier);
   			{
  @@ -751,19 +751,19 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
   			match(LITERAL_between);
   			lower=literal();
   			match(LITERAL_and);
   			upper=literal();
  -			
  +
   			if (negative) {
   			criteria.addNotBetween(id.getText(), lower, upper);
   			} else {
   			criteria.addBetween(id.getText(), lower, upper);
   			}
  -			
  +
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -771,18 +771,18 @@
   			consumeUntil(_tokenSet_5);
   		}
   	}
  -	
  +
   	public final void inExpr(
   		Criteria criteria
   	) throws RecognitionException, TokenStreamException {
  -		
  +
   		Token  id = null;
  -		
  +
   		try {      // for error handling
  -			
  +
   				 boolean negative = false;
   				 Collection coll;
  -			
  +
   			id = LT(1);
   			match(Identifier);
   			{
  @@ -795,17 +795,17 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
   			match(LITERAL_in);
   			coll=argList();
  -			
  +
   			if (negative) {
   			criteria.addNotIn(id.getText(), coll);
   			} else {
   			criteria.addIn(id.getText(), coll);
   			}
  -			
  +
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -813,17 +813,17 @@
   			consumeUntil(_tokenSet_5);
   		}
   	}
  -	
  +
   	public final void existsExpr(
   		Criteria criteria
   	) throws RecognitionException, TokenStreamException {
  -		
  -		
  +
  +
   		try {      // for error handling
  -			
  +
   			Query subQuery = null;
   			boolean negative = false;
  -			
  +
   			{
   			if ((LA(1)==LITERAL_not)) {
   				match(LITERAL_not);
  @@ -834,7 +834,7 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
   			{
   			if ((LA(1)==LITERAL_exists) && (LA(2)==TOK_LPAREN)) {
  @@ -849,15 +849,15 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
  -			
  +
   			if (negative) {
   			criteria.addNotExists(subQuery);
   			} else {
   			criteria.addExists(subQuery);
   			}
  -			
  +
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -865,10 +865,10 @@
   			consumeUntil(_tokenSet_5);
   		}
   	}
  -	
  +
   	public final Object  literal() throws RecognitionException, TokenStreamException {
   		Object value = null;
  -		
  +
   		Token  tokInt = null;
   		Token  tokADbl = null;
   		Token  tokEDbl = null;
  @@ -877,7 +877,7 @@
   		Token  tokDate = null;
   		Token  tokTime = null;
   		Token  tokTs = null;
  -		
  +
   		try {      // for error handling
   			switch ( LA(1)) {
   			case TOK_DOLLAR:
  @@ -903,7 +903,7 @@
   			{
   				tokInt = LT(1);
   				match(TOK_UNSIGNED_INTEGER);
  -				
  +
   					try
   					{
   						value = Integer.valueOf(tokInt.getText());
  @@ -912,7 +912,7 @@
   					{
   						value = Long.valueOf(tokInt.getText());
   					}
  -				
  +
   				break;
   			}
   			case TOK_APPROXIMATE_NUMERIC_LITERAL:
  @@ -980,16 +980,16 @@
   		}
   		return value;
   	}
  -	
  +
   	public final Collection  argList() throws RecognitionException, TokenStreamException {
   		Collection coll = null;
  -		
  -		
  +
  +
   		try {      // for error handling
  -			
  +
   					Collection temp = new Vector();
   				    Object val;
  -				
  +
   			match(TOK_LPAREN);
   			{
   			if ((_tokenSet_12.member(LA(1)))) {
  @@ -1006,7 +1006,7 @@
   					else {
   						break _loop113;
   					}
  -					
  +
   				} while (true);
   				}
   			}
  @@ -1015,12 +1015,12 @@
   			else {
   				throw new NoViableAltException(LT(1), getFilename());
   			}
  -			
  +
   			}
   			match(TOK_RPAREN);
  -			
  +
   					if (!temp.isEmpty()) {coll = temp;}
  -					
  +
   		}
   		catch (RecognitionException ex) {
   			reportError(ex);
  @@ -1029,8 +1029,8 @@
   		}
   		return coll;
   	}
  -	
  -	
  +
  +
   	public static final String[] _tokenNames = {
   		"<0>",
   		"EOF",
  @@ -1094,7 +1094,7 @@
   		"\"time\"",
   		"\"timestamp\""
   	};
  -	
  +
   	private static final long _tokenSet_0_data_[] = { 2L, 0L };
   	public static final BitSet _tokenSet_0 = new BitSet(_tokenSet_0_data_);
   	private static final long _tokenSet_1_data_[] = { 4398046511250L, 0L };
  @@ -1123,5 +1123,5 @@
   	public static final BitSet _tokenSet_12 = new BitSet(_tokenSet_12_data_);
   	private static final long _tokenSet_13_data_[] = { 848822976643282L, 0L };
   	public static final BitSet _tokenSet_13 = new BitSet(_tokenSet_13_data_);
  -	
  +
   	}