1 21 23 32 package oracle.toplink.essentials.internal.parsing; 33 34 import oracle.toplink.essentials.exceptions.EJBQLException; 35 import oracle.toplink.essentials.expressions.Expression; 36 37 public class OrderByItemNode extends Node { 38 private SortDirectionNode direction = null; 39 private Node orderByItem = null; 40 41 45 public void validate(ParseTreeContext context) { 46 TypeHelper typeHelper = context.getTypeHelper(); 47 if (orderByItem != null) { 48 orderByItem.validate(context); 49 Object type = orderByItem.getType(); 50 setType(type); 51 if (!typeHelper.isOrderableType(type)) { 52 throw EJBQLException.expectedOrderableOrderByItem( 53 orderByItem.getAsString(), typeHelper.getTypeName(type)); 54 } 55 } 56 } 57 58 59 public Expression generateExpression(GenerationContext context) { 60 boolean oldCheckState = context.shouldCheckSelectNodeBeforeResolving(); 65 ((SelectGenerationContext)context).checkSelectNodeBeforeResolving(true); 66 Expression orderByExpression = getOrderByItem().generateExpression(context); 67 orderByExpression = getDirection().addToExpression(orderByExpression, context); 68 ((SelectGenerationContext)context).checkSelectNodeBeforeResolving(oldCheckState); 69 return orderByExpression; 70 } 71 72 public SortDirectionNode getDirection() { 73 if (direction == null) { 74 setDirection(new SortDirectionNode()); 75 } 76 return direction; 77 } 78 79 public Node getOrderByItem() { 80 return orderByItem; 81 } 82 83 public void setDirection(SortDirectionNode direction) { 84 this.direction = direction; 85 } 86 87 public void setOrderByItem(Node orderByItem) { 88 this.orderByItem = orderByItem; 89 } 90 } 91 | Popular Tags |