1 package com.genimen.djeneric.tools.generator.core.nodes; 2 3 import com.genimen.djeneric.tools.generator.core.DjentelParserEngine; 4 import com.genimen.djeneric.tools.generator.core.SimpleNode; 5 import com.genimen.djeneric.tools.generator.core.util.ParseContext; 6 7 public class ConstNode extends SimpleNode 8 { 9 10 private String key; 11 private Object _constval; 12 13 public ConstNode(int i) 14 { 15 super(i); 16 } 17 18 public ConstNode(DjentelParserEngine p, int i) 19 { 20 super(p, i); 21 } 22 23 public String toString() 24 { 25 return getKey() + " = " + getConst(); 26 } 27 28 public String getName() 29 { 30 return "const"; 31 } 32 33 public void setKey(String key) 34 { 35 this.key = key; 36 } 37 38 public String getKey() 39 { 40 return key; 41 } 42 43 public void setString(String v) 44 { v = v.substring(1); 46 v = v.substring(0, v.length() - 1); 47 48 _constval = v; 49 } 50 51 public void setBoolean(Boolean b) 52 { 53 _constval = b; 54 } 55 56 public void setChar(String v) 57 { v = v.substring(1); 59 v = v.substring(0, v.length() - 1); 60 61 if (v.startsWith("\\")) 62 { 63 if (v.equals("\\n")) v = "\n"; 64 else if (v.equals("\\t")) v = "\t"; 65 else if (v.equals("\\b")) v = "\b"; 66 else if (v.equals("\\r")) v = "\r"; 67 else if (v.equals("\\f")) v = "\f"; 68 else if (v.equals("\\\\")) v = "\\"; 69 else if (v.equals("\\'")) v = "'"; 70 else if (v.equals("\\\"")) v = "\""; 71 } 72 _constval = String.valueOf(v.charAt(0)); 73 } 74 75 public void setInteger(Integer i) 76 { 77 _constval = i; 78 } 79 80 public void setFloat(Float f) 81 { 82 _constval = f; 83 } 84 85 public Object getConst() 86 { 87 return _constval; 88 } 89 90 public String evaluate(ParseContext context) 91 { 92 context.pushConst(getKey(), getConst()); 93 return ""; 94 } 95 96 } | Popular Tags |