1 package org.hibernate.hql.ast.tree; 3 4 import org.hibernate.Hibernate; 5 import org.hibernate.hql.ast.util.ColumnHelper; 6 import org.hibernate.type.Type; 7 8 import antlr.SemanticException; 9 import antlr.collections.AST; 10 11 14 public class ArithmeticNode extends AbstractSelectExpression { 15 16 21 public Type getDataType() { 22 AST first = getFirstChild(); 23 AST second = getFirstChild().getNextSibling(); 24 if ( !( second instanceof SelectExpression ) ) { 25 if ( first instanceof SelectExpression ) { 26 return ( (SelectExpression) first ).getDataType(); 28 } 29 else { 30 return Hibernate.DOUBLE; } 32 } 33 else { 34 if ( first instanceof SelectExpression) { 35 Type x = ( (SelectExpression) first ).getDataType(); 37 Type y = ( (SelectExpression) second ).getDataType(); 38 if ( x==Hibernate.DOUBLE || y==Hibernate.DOUBLE ) return Hibernate.DOUBLE; 39 if ( x==Hibernate.FLOAT || y==Hibernate.FLOAT ) return Hibernate.FLOAT; 40 if ( x==Hibernate.BIG_DECIMAL || y==Hibernate.BIG_DECIMAL ) return Hibernate.BIG_DECIMAL; 41 if ( x==Hibernate.BIG_INTEGER || y==Hibernate.BIG_INTEGER ) return Hibernate.BIG_INTEGER; 42 if ( x==Hibernate.LONG || y==Hibernate.LONG ) return Hibernate.LONG; 43 if ( x==Hibernate.INTEGER || y==Hibernate.INTEGER ) return Hibernate.INTEGER; 44 return x; 45 } 46 else { 47 return ( (SelectExpression) second ).getDataType(); 49 } 50 } 51 } 52 53 public void setScalarColumnText(int i) throws SemanticException { 54 ColumnHelper.generateSingleScalarColumn( this, i ); 55 } 56 57 } 58 | Popular Tags |