## org.h2.bnf
Class RuleOptional

    java.lang.Object
      org.h2.bnf.RuleOptional

All Implemented Interfaces:
  Rule

    public class RuleOptional

extends java.lang.Object
implements Rule

Represents an optional BNF rule.

Method Summary
`void` `addNextTokenList(Sentence sentence)` Add the next possible token for a query.
`java.lang.String` `getHtmlRailroad(Bnf config, boolean topLevel)` Get the HTML railroad.
`Rule` `last()` Get the last entry.
`boolean` `matchRemove(Sentence sentence)` Remove a token from a sentence.
`java.lang.String` `name()` Get the name of the rule.
`java.lang.String` `random(Bnf config, int level)` Get a random entry.
`void` `setLinks(java.util.HashMap<java.lang.String,RuleHead> ruleMap)` Update cross references.
`java.lang.String` `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### getHtmlRailroad

    public java.lang.String getHtmlRailroad(Bnf config,
                                            boolean topLevel)

  Description copied from interface: `Rule`
  Get the HTML railroad.

  Specified by:
    `getHtmlRailroad` in interface `Rule`
  Parameters:
    `config` - the configuration
    `topLevel` - true if line break are permitted
  Returns:
    the railroad

### name

    public java.lang.String name()

  Description copied from interface: `Rule`
  Get the name of the rule.

  Specified by:
    `name` in interface `Rule`
  Returns:
    the name

### random

    public java.lang.String random(Bnf config,
                                   int level)

  Description copied from interface: `Rule`
  Get a random entry.

  Specified by:
    `random` in interface `Rule`
  Parameters:
    `config` - the configuration
    `level` - the call level
  Returns:
    the entry

### last

    public Rule last()

  Description copied from interface: `Rule`
  Get the last entry.

  Specified by:
    `last` in interface `Rule`
  Returns:
    the last entry

### setLinks

    public void setLinks(java.util.HashMap<java.lang.String,RuleHead> ruleMap)

  Description copied from interface: `Rule`
  Update cross references.

  Specified by:
    `setLinks` in interface `Rule`
  Parameters:
    `ruleMap` - the reference map

### matchRemove

    public boolean matchRemove(Sentence sentence)

  Description copied from interface: `Rule`
  Remove a token from a sentence. Used for autocomplete support. If there was a match, the query in the sentence is updated (the matched token is removed).

  Specified by:
    `matchRemove` in interface `Rule`
  Parameters:
    `sentence` - the sentence context
  Returns:
    false if not a match or a partial match, true if a full match

### addNextTokenList

    public void addNextTokenList(Sentence sentence)

  Description copied from interface: `Rule`
  Add the next possible token for a query. Used for autocomplete support.

  Specified by:
    `addNextTokenList` in interface `Rule`
  Parameters:
    `sentence` - the sentence context