Top Description Inners Fields Constructors Methods
org.apache.avro.io.parsing

public Class Parser

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.avro.io.parsing.SkipParser
Imports
java.io.IOException, java.util.Arrays, org.apache.avro.AvroTypeException

Parser is the class that maintains the stack for parsing. This class is used by encoders, which are not required to skip.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Parser.ActionHandler

The parser knows how to handle the terminal and non-terminal symbols.

Field Summary

Modifier and TypeField and Description
protected int
protected Symbol[]
protected final Parser.ActionHandler

Constructor Summary

AccessConstructor and Description
public
Parser(Symbol root, Parser.ActionHandler symbolHandler)

Method Summary

Modifier and TypeMethod and Description
public final Symbol

Returns:

The terminal symbol at the top of the stack unless an implicit action resulted in another symbol, in which case that symbol is returned.
advance
(Symbol
The symbol to match against the terminal at the top of the stack.
input
)

Recursively replaces the symbol at the top of the stack with its production, until the top is a terminal.

public int
depth()

Returns the depth of the stack.

private void
expandStack()

If there is no sufficient room in the stack, use this expand it.

public Symbol
popSymbol()

Pops and returns the top symbol from the stack.

public final void
processImplicitActions()

Performs any implicit actions at the top the stack, expanding any production (other than the root) that may be encountered.

public final void
processTrailingImplicitActions()

Performs any "trailing" implicit actions at the top the stack.

public final void
pushProduction(Symbol sym)

Pushes the production for the given symbol sym.

public void
pushSymbol(Symbol sym)

Pushes sym on to the stack.

public void
public Symbol
topSymbol()

Returns the top symbol from the stack.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

posback to summary
protected int pos
stackback to summary
protected Symbol[] stack
symbolHandlerback to summary
protected final Parser.ActionHandler symbolHandler

Constructor Detail

Parserback to summary
public Parser(Symbol root, Parser.ActionHandler symbolHandler)

Method Detail

advanceback to summary
public final Symbol advance(Symbol input) throws IOException

Recursively replaces the symbol at the top of the stack with its production, until the top is a terminal. Then checks if the top symbol matches the terminal symbol suppled terminal.

Parameters
input:Symbol

The symbol to match against the terminal at the top of the stack.

Returns:Symbol

The terminal symbol at the top of the stack unless an implicit action resulted in another symbol, in which case that symbol is returned.

depthback to summary
public int depth()

Returns the depth of the stack.

expandStackback to summary
private void expandStack()

If there is no sufficient room in the stack, use this expand it.

popSymbolback to summary
public Symbol popSymbol()

Pops and returns the top symbol from the stack.

processImplicitActionsback to summary
public final void processImplicitActions() throws IOException

Performs any implicit actions at the top the stack, expanding any production (other than the root) that may be encountered. This method will fail if there are any repeaters on the stack.

processTrailingImplicitActionsback to summary
public final void processTrailingImplicitActions() throws IOException

Performs any "trailing" implicit actions at the top the stack.

pushProductionback to summary
public final void pushProduction(Symbol sym)

Pushes the production for the given symbol sym. If sym is a repeater and input is either Symbol#ARRAY_END or Symbol#MAP_END pushes nothing.

pushSymbolback to summary
public void pushSymbol(Symbol sym)

Pushes sym on to the stack.

resetback to summary
public void reset()
topSymbolback to summary
public Symbol topSymbol()

Returns the top symbol from the stack.

org.apache.avro.io.parsing back to summary

public Interface Parser.ActionHandler

Known Direct Implementers
org.apache.avro.io.JsonDecoder, org.apache.avro.io.JsonEncoder, org.apache.avro.io.ParsingDecoder, org.apache.avro.io.ValidatingDecoder, org.apache.avro.io.ValidatingEncoder

The parser knows how to handle the terminal and non-terminal symbols. But it needs help from outside to handle implicit and explicit actions. The clients implement this interface to provide this help.

Method Summary

Modifier and TypeMethod and Description
public Symbol

Returns:

null if advance() is to continue processing the stack. If not null the return value will be returned by advance().
doAction
(Symbol
The input symbol from the caller of advance
input
,
Symbol
The symbol at the top the stack.
top
)

Handle the action symbol top when the input is sought to be taken off the stack.

Method Detail

doActionback to summary
public Symbol doAction(Symbol input, Symbol top) throws IOException

Handle the action symbol top when the input is sought to be taken off the stack.

Parameters
input:Symbol

The input symbol from the caller of advance

top:Symbol

The symbol at the top the stack.

Returns:Symbol

null if advance() is to continue processing the stack. If not null the return value will be returned by advance().