01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.bnf;
07:
08: import java.util.HashMap;
09:
10: /**
11: * Represents a BNF rule.
12: */
13: public interface Rule {
14:
15: /**
16: * Get the name of the rule.
17: *
18: * @return the name
19: */
20: String name();
21:
22: /**
23: * Get a random entry.
24: *
25: * @param config
26: * @param level
27: * @return the entry
28: */
29: String random(Bnf config, int level);
30:
31: /**
32: * Get the last entry.
33: *
34: * @return the last entry
35: */
36: Rule last();
37:
38: /**
39: * Update cross references.
40: *
41: * @param ruleMap the reference map
42: */
43: void setLinks(HashMap ruleMap);
44:
45: /**
46: * Add the next possible token for a query.
47: * Used for autocomplete support.
48: *
49: * @param query the query
50: * @param sentence the sentence context
51: */
52: void addNextTokenList(String query, Sentence sentence);
53:
54: /**
55: * Remove a token from a sentence. Used for autocomplete support.
56: *
57: * @param query
58: * the query
59: * @param sentence
60: * the sentence context
61: * @return null if not a match or a partial match, query.substring... if a
62: * full match
63: */
64: String matchRemove(String query, Sentence sentence);
65:
66: }
|