19 using System.Collections.Generic;
    21 using Newtonsoft.Json.Linq;
    33         public IList<string> 
Symbols { 
get; 
private set;  }
    38         private readonly IDictionary<string, int> symbolMap;
    57             JArray jsymbols = jtok[
"symbols"] as JArray;
    61             List<string> symbols = 
new List<string>();
    62             IDictionary<string, int> symbolMap = 
new Dictionary<string, int>();
    64             foreach (JValue jsymbol 
in jsymbols)
    66                 string s = (string)jsymbol.Value;
    67                 if (symbolMap.ContainsKey(s))
    73             return new EnumSchema(name, aliases, symbols, symbolMap, props, names);
    84         private EnumSchema(
SchemaName name, IList<SchemaName> aliases, List<string> symbols,
    85                             IDictionary<String, int> symbolMap, PropertyMap props, SchemaNames names)
    86                             : base(
Type.Enumeration, name, aliases, props, names)
    88             if (
null == name.Name) 
throw new SchemaParseException(
"name cannot be null for enum schema.");
    90             this.symbolMap = symbolMap;
    99         protected internal override void WriteJsonFields(Newtonsoft.Json.JsonTextWriter writer, 
   102             base.WriteJsonFields(writer, names, encspace);
   103             writer.WritePropertyName(
"symbols");
   104             writer.WriteStartArray();
   105             foreach (
string s 
in this.
Symbols)
   106                 writer.WriteValue(s);
   107             writer.WriteEndArray();
   119             if (symbolMap.TryGetValue(symbol, out result)) 
return result;
   128         public string this[
int index]
   133                 throw new AvroException(
"Enumeration out of range. Must be less than " + 
Symbols.Count + 
", but is " + index);
   144             return symbolMap.ContainsKey(symbol);
   153             return Symbols.GetEnumerator();
   163             if (obj == 
this) 
return true;
   170                     return areEqual(that.Props, 
this.Props);
   183             foreach (
string s 
in Symbols) result += 23 * s.GetHashCode();
   194             if (writerSchema.
Tag != 
Tag) 
return false;
 static SchemaName GetName(JToken jtok, string encspace)
Parses the name and namespace from the given JSON schema object then creates SchemaName object includ...
 
IList< string > Symbols
List of strings representing the enum symbols
 
static int getHashCode(object obj)
Hash code helper function
 
static IList< SchemaName > GetAliases(JToken jtok, string space, string encspace)
Parses the 'aliases' property from the given JSON token
 
override int GetHashCode()
Hashcode function
 
override bool CanRead(Schema writerSchema)
Checks if this schema can read data written by the given schema.
 
Class for enum type schemas
 
int Count
Count of enum symbols
 
bool InAliases(SchemaName name)
 
Base class for all schema types
 
bool Contains(string symbol)
Checks if given symbol is in the list of enum symbols
 
Type
Enum for schema types
 
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
 
int Ordinal(string symbol)
Returns the position of the given symbol within this enum.
 
Class to store schema name, namespace and enclosing namespace
 
internal override void WriteJsonFields(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
Writes enum schema in JSON format
 
A class that contains a list of named schemas.
 
override int GetHashCode()
 
override bool Equals(object obj)
Checks equality of two enum schema
 
override bool Equals(Object obj)
Compares two schema names
 
IEnumerator< string > GetEnumerator()
Returns an enumerator that enumerates the symbols in this enum schema in the order of their definitio...
 
String EncSpace
Namespace from the most tightly enclosing schema
 
static bool areEqual(object o1, object o2)
Compares two objects, null is equal to null
 
String Space
Namespace specified within the schema
 
Type Tag
Schema type property
 
Base class for all named schemas: fixed, enum, record
 
SchemaName SchemaName
Name of the schema, contains name, namespace and enclosing namespace