KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > hql > ast > tree > LiteralNode


1 // $Id: LiteralNode.java,v 1.1 2005/07/12 20:27:16 steveebersole Exp $
2
package org.hibernate.hql.ast.tree;
3
4 import org.hibernate.Hibernate;
5 import org.hibernate.hql.antlr.HqlSqlTokenTypes;
6 import org.hibernate.hql.ast.util.ColumnHelper;
7 import org.hibernate.type.Type;
8
9 import antlr.SemanticException;
10
11 /**
12  * Represents a literal.
13  *
14  * @author josh Jan 8, 2005 10:09:53 AM
15  */

16 public class LiteralNode extends AbstractSelectExpression implements HqlSqlTokenTypes {
17
18     public void setScalarColumnText(int i) throws SemanticException {
19         ColumnHelper.generateSingleScalarColumn( this, i );
20     }
21
22     public Type getDataType() {
23         switch ( getType() ) {
24             case NUM_INT:
25                 return Hibernate.INTEGER;
26             case NUM_FLOAT:
27                 return Hibernate.FLOAT;
28             case NUM_LONG:
29                 return Hibernate.LONG;
30             case NUM_DOUBLE:
31                 return Hibernate.DOUBLE;
32             case QUOTED_STRING:
33                 return Hibernate.STRING;
34             case TRUE:
35             case FALSE:
36                 return Hibernate.BOOLEAN;
37             default:
38                 return null;
39         }
40     }
41
42 }
43
Popular Tags