org.apache.avro.io.parsing
Class Symbol

java.lang.Object
  extended by 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
static class Symbol.Alternative
           
static class Symbol.DefaultStartAction
           
static class Symbol.EnumAdjustAction
           
static class Symbol.EnumLabelsAction
          For JSON.
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
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 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
           
 
Constructor Summary
protected Symbol(Symbol.Kind kind)
          Constructs a new symbol of the given kind kind.
protected Symbol(Symbol.Kind kind, Symbol[] production)
           
 
Method Summary
 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.
 
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 confort. 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

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

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.


Copyright © 2010 The Apache Software Foundation