1 2 12 package com.versant.core.jdo.query; 13 14 17 public class LiteralNode extends LeafNode { 18 19 public static final int TYPE_STRING = 1; 20 public static final int TYPE_OTHER = 2; 21 22 public static final int TYPE_BOOLEAN = 3; 23 public static final int TYPE_CHAR = 4; 24 public static final int TYPE_LONG = 5; 25 public static final int TYPE_DOUBLE = 7; 26 27 public static final int TYPE_NULL = 8; 28 29 32 public int type; 33 36 public String value; 37 38 public LiteralNode(Node parent, int type, String value) { 39 this.parent = parent; 40 this.type = type; 41 this.value = value; 42 } 43 44 public Object accept(NodeVisitor visitor, Object [] results) { 45 return visitor.visitLiteralNode(this, results); 46 } 47 48 public String toString() { 49 StringBuffer s = new StringBuffer (); 50 s.append(super.toString()); 51 s.append(' '); 52 s.append(value); 53 s.append(' '); 54 s.append(toTypeStr(type)); 55 return s.toString(); 56 } 57 58 private static String toTypeStr(int t) { 59 switch (t) { 60 case TYPE_STRING: return "STRING"; 61 case TYPE_OTHER: return "OTHER"; 62 case TYPE_BOOLEAN: return "BOOLEAN"; 63 case TYPE_CHAR: return "CHAR"; 64 case TYPE_LONG: return "LONG"; 65 case TYPE_DOUBLE: return "DOUBLE"; 66 case TYPE_NULL: return "NULL"; 67 } 68 return "UNKNOWN(" + t + ")"; 69 } 70 71 public Field visit(MemVisitor visitor, Object obj) { 72 return visitor.visitLiteralNode(this, obj); 73 } 74 75 public Object arrive(NodeVisitor v, Object msg) { 76 return v.arriveLiteralNode(this, msg); 77 } 78 79 } 80 81 | Popular Tags |