package lava.net.common; import java.util.Enumeration; import java.util.Vector; /** * **/ public class VariableModifier implements Cloneable { /** * **/ public final static char VALUE_SEPARATOR = '\t'; /** * **/ public final static char EOL = '\n'; /** * **/ static final public char GLYPH_ASSIGN = '='; /** * **/ static final public char GLYPH_SET = ':'; /** * **/ static final public char GLYPH_AUGMENT = '+'; /** * **/ static final public char GLYPH_DIMINISH = '-'; /** * **/ static final public char GLYPH_QUERY = '?'; /** * **/ char glyph = GLYPH_SET; /** * **/ String name; /** * **/ Value value; /** * **/ public VariableModifier(char glyph, String name, Value value) { this.glyph = glyph; this.name = name; this.value = value; } /** * **/ public char getGlyph() { return glyph; } /** * **/ public String getName() { return name; } /** * **/ public Value getValue() { return value; } /** * **/ public String toString() { return glyph + name + VALUE_SEPARATOR + value + EOL; } /** * **/ public static boolean isTemporary(char glyph) { return glyph == GLYPH_SET; } /** * **/ public static boolean isGlyph(char ch) { return !Character.isLetterOrDigit(ch) && ch != '_'; //switch(ch) { // case GLYPH_ASSIGN: // case GLYPH_SET: // case GLYPH_AUGMENT: // case GLYPH_DIMINISH: // case GLYPH_QUERY: return true; //} //return false; } /** * **/ public int hashCode() { return glyph ^ name.hashCode() ^ value.hashCode(); } /** * **/ public Object clone() { try { VariableModifier m = (VariableModifier)super.clone(); m.value = new Value(value.toString()); return m; } catch(CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(); } } }