19 using System.Collections.Generic;
21 using Newtonsoft.Json.Linq;
39 public override string Name 63 private readonly IList<SchemaName> aliases;
78 return FixedSchema.NewInstance(jo, props, names, encspace);
80 return EnumSchema.NewInstance(jo, props, names, encspace);
87 if (names.
TryGetValue(type,
null, encspace, out result))
103 this.aliases = aliases;
104 if (
null != name.
Name)
105 if (!names.
Add(name,
this))
130 protected static IList<SchemaName>
GetAliases(JToken jtok,
string space,
string encspace)
132 JToken jaliases = jtok[
"aliases"];
133 if (
null == jaliases)
136 if (jaliases.Type != JTokenType.Array)
139 var aliases =
new List<SchemaName>();
140 foreach (JToken jalias
in jaliases)
142 if (jalias.Type != JTokenType.String)
145 aliases.Add(
new SchemaName((
string)jalias, space, encspace));
155 if (name.
Equals(alias))
return true;
166 protected internal override void WriteJson(Newtonsoft.Json.JsonTextWriter writer,
SchemaNames names,
string encspace)
168 if (!names.
Add(
this))
176 name = schemaName.
Name;
177 writer.WriteValue(name);
181 base.WriteJson(writer, names, encspace);
192 this.
SchemaName.WriteJson(writer, names, encspace);
196 writer.WritePropertyName(
"aliases");
197 writer.WriteStartArray();
201 writer.WriteValue(fullname);
203 writer.WriteEndArray();
static SchemaName GetName(JToken jtok, string encspace)
Parses the name and namespace from the given JSON schema object then creates SchemaName object includ...
static IList< SchemaName > GetAliases(JToken jtok, string space, string encspace)
Parses the 'aliases' property from the given JSON token
String? Fullname
Namespace.Name of the schema
Class for enum type schemas
bool TryGetValue(string name, string space, string encspace, out NamedSchema schema)
Tries to get the value for the given name fields
String Name
Name of the schema
bool InAliases(SchemaName name)
Base class for all schema types
override string Name
Name of the schema
NamedSchema(Type type, SchemaName name, IList< SchemaName > aliases, PropertyMap props, SchemaNames names)
Constructor for named schema class
String? Namespace
Namespace of the schema
static string GetRequiredString(JToken jtok, string field)
Retrieves the required string property value for the given property name from the given JSON object.
Type
Enum for schema types
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Class to store schema name, namespace and enclosing namespace
internal override void WriteJsonFields(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
Writes named schema in JSON format
internal override void WriteJson(Newtonsoft.Json.JsonTextWriter writer, SchemaNames names, string encspace)
Writes named schema in JSON format
string Namespace
Namespace of the schema
A class that contains a list of named schemas.
static string GetOptionalString(JToken jtok, string field)
Retrieves the optional string property value for the given property name from the given JSON object.
override bool Equals(Object obj)
Compares two schema names
bool Add(SchemaName name, NamedSchema schema)
Adds a schema name to the map if it doesn't exist yet
String Space
Namespace specified within the schema
string Fullname
Namespace.Name of the schema
Base class for all named schemas: fixed, enum, record
SchemaName SchemaName
Name of the schema, contains name, namespace and enclosing namespace