1 19 package org.apache.cayenne.ejbql.parser; 20 21 import java.util.HashMap ; 22 import java.util.Map ; 23 24 import org.apache.cayenne.ejbql.EJBQLExpressionVisitor; 25 26 30 public class EJBQLSum extends EJBQLAggregateColumn { 31 32 35 static final Map typeMap; 36 37 static { 38 typeMap = new HashMap (); 39 typeMap.put(Integer .class.getName(), Long .class.getName()); 40 typeMap.put(Short .class.getName(), Long .class.getName()); 41 typeMap.put(Float .class.getName(), Double .class.getName()); 42 } 43 44 public EJBQLSum(int id) { 45 super(id); 46 } 47 48 protected boolean visitNode(EJBQLExpressionVisitor visitor) { 49 return visitor.visitSum(this); 50 } 51 52 public String getFunction() { 53 return "SUM"; 54 } 55 56 public String getJavaType(String pathType) { 57 58 if (pathType == null) { 59 return "java.lang.Long"; 60 } 61 62 String mappedType = (String ) typeMap.get(pathType); 65 return mappedType != null ? mappedType : pathType; 66 } 67 } 68 | Popular Tags |