01: // $Id: LiteralNode.java 10060 2006-06-28 02:53:39Z steve.ebersole@jboss.com $
02: package org.hibernate.hql.ast.tree;
03:
04: import org.hibernate.Hibernate;
05: import org.hibernate.hql.antlr.HqlSqlTokenTypes;
06: import org.hibernate.hql.ast.util.ColumnHelper;
07: import org.hibernate.type.Type;
08:
09: 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
17: HqlSqlTokenTypes {
18:
19: public void setScalarColumnText(int i) throws SemanticException {
20: ColumnHelper.generateSingleScalarColumn(this , i);
21: }
22:
23: public Type getDataType() {
24: switch (getType()) {
25: case NUM_INT:
26: return Hibernate.INTEGER;
27: case NUM_FLOAT:
28: return Hibernate.FLOAT;
29: case NUM_LONG:
30: return Hibernate.LONG;
31: case NUM_DOUBLE:
32: return Hibernate.DOUBLE;
33: case QUOTED_STRING:
34: return Hibernate.STRING;
35: case TRUE:
36: case FALSE:
37: return Hibernate.BOOLEAN;
38: default:
39: return null;
40: }
41: }
42: }
|