package journal.reader; import java.text.ParseException; // contains one token // hashes and compares on name and the fact that the token started at the beginning public class Token { public enum Type { START_TOKEN, STRING_TOKEN, INTEGER_TOKEN, HEX_TOKEN } private String value; private boolean atLeftMargin; private int column; private int line; private Type type; private ActionType action = null; public Token(int column, int line, boolean atLeftMargin) { this.column = column; this.line = line; this.atLeftMargin = atLeftMargin; } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || obj.getClass() != this.getClass()) { return false; } Token other = (Token) obj; return (value.equals(other.value) && atLeftMargin == other.atLeftMargin); } public int hashCode() { return value.hashCode(); } public String toString() { StringBuffer buf = new StringBuffer("Token : "); buf.append(value); buf.append(" line = "); buf.append(line); buf.append(" col = "); buf.append(column); buf.append(" start = "); buf.append(atLeftMargin); buf.append(" type = "); buf.append(type); return buf.toString(); } public ActionType getAction() { return action; } public void setValue(String value, Type type) throws ParseException { this.value = value; this.type = type; if (type == Type.START_TOKEN) { setActionType(); } else if (atLeftMargin) { throw new ParseException("Illegal token at left margin : " + this, line); } } private void setActionType() throws ParseException { for(ActionType act : ActionType.values()) { if (value.equals(act.symbol)) { action = act; return; } } throw new ParseException("Not a legal StartToken : " + this, line); } public String getValue() { return value; } public boolean isAtLeftMargin() { return atLeftMargin; } public int getColumn() { return column; } public int getLine() { return line; } public Type getType() { return type; } public void setAtLeftMargin(boolean atLeftMargin) { this.atLeftMargin = atLeftMargin; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 7374 | Sven Erik Knop | Rename/move file(s) - correct location for Eclipse project | ||
#1 | 6467 | Sven Erik Knop |
Added JournalReader, a Java library of useful tools to read and process checkpoints and journals. Added are a readme.txt to explain some details, and a jar file that contains the compiled class files. The programs will need Java 1.6 to run. |