01: /*
02: * SimpleReadtable.java
03: *
04: * Copyright 1997 Massachusetts Institute of Technology.
05: * All Rights Reserved.
06: *
07: * Author: Ora Lassila
08: *
09: * $Id: SimpleReadtable.java,v 1.2 1998/01/22 13:09:19 bmahe Exp $
10: */
11:
12: package org.w3c.tools.sexpr;
13:
14: /**
15: * Basic implementation of the Readtable interface, a dispatch table.
16: */
17: public class SimpleReadtable implements Readtable {
18:
19: private SExprParser parsers[];
20:
21: /**
22: * Initializes an empty dispatch table (no associations).
23: */
24: public SimpleReadtable() {
25: this .parsers = new SExprParser[256];
26: }
27:
28: /**
29: * Copy constructor.
30: */
31: public SimpleReadtable(SimpleReadtable table) {
32: this .parsers = new SExprParser[256];
33: for (int i = 0; i < 256; i++)
34: this .parsers[i] = table.parsers[i];
35: }
36:
37: public SExprParser getParser(char key) {
38: return parsers[(int) key];
39: }
40:
41: public SExprParser addParser(char key, SExprParser parser) {
42: parsers[(int) key] = parser;
43: return parser;
44: }
45:
46: }
|