1 56 package org.objectstyle.cayenne.exp; 57 58 import java.util.LinkedList ; 59 60 66 final class ASTStack extends LinkedList { 67 static boolean booleanFromObject(Object object) { 68 if (object instanceof Boolean ) { 70 return ((Boolean ) object).booleanValue(); 71 } 72 73 if (object instanceof Number ) { 74 return ((Number ) object).intValue() != 0; 75 } 76 77 return object != null; 78 } 79 80 83 Object pop() { 84 return remove(size() - 1); 85 } 86 87 90 boolean popBoolean() { 91 Object obj = pop(); 92 return booleanFromObject(obj); 93 } 94 95 98 Comparable popComparable() { 99 return (Comparable ) pop(); 100 } 101 102 105 int popInt() { 106 return ((Integer ) pop()).intValue(); 107 } 108 109 112 public Object peekObject() { 113 return get(size() - 1); 114 } 115 116 119 boolean peekBoolean() { 120 Object obj = peekObject(); 121 return booleanFromObject(obj); 122 } 123 124 127 int peekInt() { 128 return ((Integer ) peekObject()).intValue(); 129 } 130 131 134 void push(Object obj) { 135 add(obj); 136 } 137 138 141 void push(boolean b) { 142 add(b ? Boolean.TRUE : Boolean.FALSE); 143 } 144 } | Popular Tags |