1 21 package com.presumo.jms.selector; 22 23 import java.util.Hashtable ; 24 25 30 class JmsStringLiteral extends JmsDataType 31 { 32 final String data; 34 35 private static Hashtable instances = null; 38 39 43 47 static JmsStringLiteral getInstance(String newValue) 48 { 49 JmsStringLiteral retval; 50 51 if (instances == null) 52 instances = new Hashtable (); 53 54 retval = (JmsStringLiteral) instances.get(newValue); 55 if (retval == null) { 56 retval = new JmsStringLiteral(newValue); 57 instances.put(newValue, retval); 58 } 59 else { 60 retval.incrementRefCount(); 61 } 62 63 return retval; 64 } 65 66 71 static JmsStringLiteral getUniqueInstance(String newValue) 72 { 73 return new JmsStringLiteral(newValue); 74 } 75 76 80 83 protected JmsStringLiteral(String newValue) 84 { 85 super(false); this.data = newValue; 87 this.stringRepresentation = '\'' + newValue + '\''; 88 } 89 93 96 public String toString() { return data; } 97 98 102 103 JmsBooleanLiteral eq(JmsDataType value) throws SelectorFalseException { 104 105 if (! (value instanceof JmsStringLiteral)) 106 throw SelectorFalseException.getInstance(); 107 108 109 if (this.data.equals(value.toString())) 110 return JmsBooleanLiteral.TRUE; 111 else 112 return JmsBooleanLiteral.FALSE; 113 } 114 115 119 short getType() { return JmsOperand.JMS_STRING_LITERAL; } 120 121 122 protected void delete(JmsOperand parent) { 126 super.delete(parent); 127 if (refcount == 0) { 128 instances.remove(data); 129 if (instances.size() == 0) { 130 instances = null; 131 } 132 } 133 } 134 135 } 136 137 138 | Popular Tags |