1 21 package oracle.toplink.essentials.internal.parsing; 23 24 import java.sql.Date ; 25 import java.sql.Time ; 26 import java.sql.Timestamp ; 27 28 import oracle.toplink.essentials.queryframework.ObjectLevelReadQuery; 29 import oracle.toplink.essentials.queryframework.ReportQuery; 30 import oracle.toplink.essentials.expressions.*; 31 32 40 public class DateFunctionNode extends FunctionalExpressionNode { 41 42 private Class type; 43 44 47 public DateFunctionNode() { 48 super(); 49 } 50 51 55 public void applyToQuery(ObjectLevelReadQuery theQuery, GenerationContext context) { 56 if (theQuery.isReportQuery()){ 57 ReportQuery reportQuery = (ReportQuery)theQuery; 58 reportQuery.addAttribute("date", generateExpression(context), type); 59 } 60 } 61 62 66 public void validate(ParseTreeContext context) { 67 setType(type); 68 } 69 70 74 public Expression generateExpression(GenerationContext context) { 75 Expression expr = context.getBaseExpression(); 76 if (expr == null) { 77 expr = new ExpressionBuilder(); 78 } 79 return expr.currentDateDate(); 80 } 81 82 83 public void useCurrentDate() { 84 type = Date .class; 85 } 86 87 88 public void useCurrentTime() { 89 type = Time .class; 90 } 91 92 93 public void useCurrentTimestamp() { 94 type = Timestamp .class; 95 } 96 97 } 98 | Popular Tags |