org.apache.avro.io.parsing

## Class Symbol

- java.lang.Object
- - org.apache.avro.io.parsing.Symbol

Direct Known Subclasses:
  Symbol.Alternative, Symbol.ImplicitAction, Symbol.IntCheckAction, Symbol.Repeater, Symbol.Root, Symbol.Sequence

    public abstract class Symbol
    extends Object

Symbol is the base of all symbols (terminals and non-terminals) of the grammar.

### Nested Class Summary

Nested Classes
`static class` `Symbol.Alternative`
`static class` `Symbol.DefaultStartAction`
`static class` `Symbol.EnumAdjustAction`
`static class` `Symbol.EnumLabelsAction`
`static class` `Symbol.ErrorAction`
`static class` `Symbol.FieldAdjustAction`
`static class` `Symbol.FieldOrderAction`
`static class` `Symbol.ImplicitAction`
`static class` `Symbol.IntCheckAction`
`static class` `Symbol.Kind`
`static class` `Symbol.Repeater`
`static class` `Symbol.ResolvingAction`
`protected static class` `Symbol.Root`
`protected static class` `Symbol.Sequence`
`static class` `Symbol.SkipAction`
`static class` `Symbol.UnionAdjustAction`
`static class` `Symbol.WriterUnionAction`

### Field Summary

Fields
`static Symbol` `ARRAY_END`
`static Symbol` `ARRAY_START`
`static Symbol` `BOOLEAN`
`static Symbol` `BYTES`
`static Symbol` `DEFAULT_END_ACTION`
`static Symbol` `DOUBLE`
`static Symbol` `ENUM`
`static Symbol` `FIELD_ACTION`
`static Symbol` `FIELD_END`
`static Symbol` `FIXED`
`static Symbol` `FLOAT`
`static Symbol` `INT`
`static Symbol` `ITEM_END`
`Symbol.Kind` `kind`
`static Symbol` `LONG`
`static Symbol` `MAP_END`
`static Symbol` `MAP_KEY_MARKER`
`static Symbol` `MAP_START`
`static Symbol` `NULL` The terminal symbols for the grammar.
`Symbol[]` `production` The production for this symbol.
`static Symbol` `RECORD_END`
`static Symbol` `RECORD_START`
`static Symbol` `STRING`
`static Symbol` `UNION`
`static Symbol` `UNION_END`
`static Symbol` `WRITER_UNION_ACTION`

### Constructor Summary

Constructors
`protected` `Symbol(Symbol.Kind kind)` Constructs a new symbol of the given kind `kind`.
`protected` `Symbol(Symbol.Kind kind, Symbol[] production)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static Symbol.DefaultStartAction` `defaultStartAction(byte[] contents)`
`static Symbol.EnumAdjustAction` `enumAdjustAction(int rsymCount, Object[] adj)`
`static Symbol.EnumLabelsAction` `enumLabelsAction(List<String> symbols)` For JSON.
`static Symbol.FieldAdjustAction` `fieldAdjustAction(int rindex, String fname, Set<String> aliases)`
`static Symbol.FieldOrderAction` `fieldOrderAction(Schema.Field[] fields)`
`Symbol` `flatten(Map<Symbol.Sequence,Symbol.Sequence> map, Map<Symbol.Sequence,List<org.apache.avro.io.parsing.Symbol.Fixup>> map2)`
`int` `flattenedSize()`
`protected static int` `flattenedSize(Symbol[] symbols, int start)` Returns the amount of space required to flatten the given sub-array of symbols.
`static boolean` `hasErrors(Symbol symbol)` Returns true if the Parser contains any Error symbol, indicating that it may fail for some inputs.
`static Symbol.IntCheckAction` `intCheckAction(int size)`
`static Symbol.SkipAction` `skipAction(Symbol symToSkip)`
`static Symbol.UnionAdjustAction` `unionAdjustAction(int rindex, Symbol sym)`
`static Symbol.WriterUnionAction` `writerUnionAction()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### kind

    public final Symbol.Kind kind

#### production

    public final Symbol[] production

The production for this symbol. If this symbol is a terminal this is `null`. Otherwise this holds the the sequence of the symbols that forms the production for this symbol. The sequence is in the reverse order of production. This is useful for easy copying onto parsing stack. Please note that this is a final. So the production for a symbol should be known before that symbol is constructed. This requirement cannot be met for those symbols which are recursive (e.g. a record that holds union a branch of which is the record itself). To resolve this problem, we initialize the symbol with an array of nulls. Later we fill the symbols. Not clean, but works. The other option is to not have this field a final. But keeping it final and thus keeping symbol immutable gives some comfort. See various generators how we generate records.

#### NULL

    public static final Symbol NULL

The terminal symbols for the grammar.

#### BOOLEAN

    public static final Symbol BOOLEAN

#### INT

    public static final Symbol INT

#### LONG

    public static final Symbol LONG

#### FLOAT

    public static final Symbol FLOAT

#### DOUBLE

    public static final Symbol DOUBLE

#### STRING

    public static final Symbol STRING

#### BYTES

    public static final Symbol BYTES

#### FIXED

    public static final Symbol FIXED

#### ENUM

    public static final Symbol ENUM

#### UNION

    public static final Symbol UNION

#### ARRAY_START

    public static final Symbol ARRAY_START

#### ARRAY_END

    public static final Symbol ARRAY_END

#### MAP_START

    public static final Symbol MAP_START

#### MAP_END

    public static final Symbol MAP_END

#### ITEM_END

    public static final Symbol ITEM_END

#### WRITER_UNION_ACTION

    public static final Symbol WRITER_UNION_ACTION

#### FIELD_ACTION

    public static final Symbol FIELD_ACTION

#### RECORD_START

    public static final Symbol RECORD_START

#### RECORD_END

    public static final Symbol RECORD_END

#### UNION_END

    public static final Symbol UNION_END

#### FIELD_END

    public static final Symbol FIELD_END

#### DEFAULT_END_ACTION

    public static final Symbol DEFAULT_END_ACTION

#### MAP_KEY_MARKER

    public static final Symbol MAP_KEY_MARKER

### Constructor Detail

#### Symbol

    protected Symbol(Symbol.Kind kind)

Constructs a new symbol of the given kind `kind`.

#### Symbol

    protected Symbol(Symbol.Kind kind,
                     Symbol[] production)

### Method Detail

#### flatten

    public Symbol flatten(Map<Symbol.Sequence,Symbol.Sequence> map,
                          Map<Symbol.Sequence,List<org.apache.avro.io.parsing.Symbol.Fixup>> map2)

#### flattenedSize

    public int flattenedSize()

#### flattenedSize

    protected static int flattenedSize(Symbol[] symbols,
                                       int start)

Returns the amount of space required to flatten the given sub-array of symbols.

Parameters:
  `symbols` - The array of input symbols.
  `start` - The index where the subarray starts.
Returns:
  The number of symbols that will be produced if one expands the given input.

#### hasErrors

    public static boolean hasErrors(Symbol symbol)

Returns true if the Parser contains any Error symbol, indicating that it may fail for some inputs.

#### intCheckAction

    public static Symbol.IntCheckAction intCheckAction(int size)

#### enumAdjustAction

    public static Symbol.EnumAdjustAction enumAdjustAction(int rsymCount,
                                                           Object[] adj)

#### writerUnionAction

    public static Symbol.WriterUnionAction writerUnionAction()

#### skipAction

    public static Symbol.SkipAction skipAction(Symbol symToSkip)

#### fieldAdjustAction

    public static Symbol.FieldAdjustAction fieldAdjustAction(int rindex,
                                                             String fname,
                                                             Set<String> aliases)

#### fieldOrderAction

    public static Symbol.FieldOrderAction fieldOrderAction(Schema.Field[] fields)

#### defaultStartAction

    public static Symbol.DefaultStartAction defaultStartAction(byte[] contents)

#### unionAdjustAction

    public static Symbol.UnionAdjustAction unionAdjustAction(int rindex,
                                                             Symbol sym)

#### enumLabelsAction

    public static Symbol.EnumLabelsAction enumLabelsAction(List<String> symbols)

For JSON.