1 22 package org.jboss.ejb.plugins.cmp.ejbql; 23 24 30 public final class ASTExactNumericLiteral extends SimpleNode { 31 public long value; 32 public String literal; 33 private static final String LOFFER_L = "l"; 34 private static final String UPPER_L = "L"; 35 private static final String OX = "0X"; 36 private static final String Ox = "0x"; 37 private static final String ZERRO = "0"; 38 39 public ASTExactNumericLiteral(int id) { 40 super(id); 41 } 42 43 public void setValue(String number) { 44 literal = number; 45 46 if(number.endsWith(LOFFER_L) || number.endsWith(UPPER_L)) { 48 number = number.substring(0, number.length() - 1); 50 } 51 52 if(number.startsWith(OX) || number.startsWith(Ox)) { 54 if(number.length() == 18) { 58 byte first = Byte.decode(number.substring(0, 3)).byteValue(); 59 if(first >= 8) { 60 number = Ox + (first - 8) + number.substring(3); 61 value = Long.decode(number).longValue() - Long.MAX_VALUE - 1; 62 return; 63 } 64 } 65 } else if(number.startsWith(ZERRO)) { if(number.length() == 23) { 71 if(number.charAt(1) == '1') { 72 number = ZERRO + number.substring(2); 73 value = Long.decode(number).longValue() - Long.MAX_VALUE - 1; 74 return; 75 } 76 } 77 } 78 value = Long.decode(number).longValue(); 79 } 80 81 public String toString() { 82 return literal; 83 } 84 85 86 public Object jjtAccept(JBossQLParserVisitor visitor, Object data) { 87 return visitor.visit(this, data); 88 } 89 } 90 | Popular Tags |