schema_salad.java_codegen

Java code generator for a given schema salad definition.

Attributes

USE_ONE_OR_LIST_OF_TYPES

BASIC_JAVA_IDENTIFIER_RE

prims

Exceptions

SchemaException

Indicates error with the provided schema definition.

Classes

CodeGenBase

Abstract base class for schema salad code generators.

LazyInitDef

Lazy initialization logic.

TypeDef

Schema Salad type description.

JavaCodeGen

Abstract base class for schema salad code generators.

Functions

shortname(inputid)

Return the last segment of the provided fragment or path.

doc_to_doc_string(doc[, indent_level])

Module Contents

class schema_salad.java_codegen.CodeGenBase

Abstract base class for schema salad code generators.

declare_type(declared_type)

Add this type to our collection, if needed.

Parameters:

declared_type (TypeDef)

Return type:

TypeDef

add_lazy_init(lazy_init)

Add lazy initialization logic for a given type.

Parameters:

lazy_init (LazyInitDef)

Return type:

None

add_vocab(name, uri)

Add the given name as an abbreviation for the given URI.

Parameters:
Return type:

None

abstract prologue()

Trigger to generate the prolouge code.

Return type:

None

static safe_name(name)
Abstractmethod:

Parameters:

name (str)

Return type:

str

Generate a safe version of the given name.

abstract begin_class(classname, extends, doc, abstract, field_names, idfield, optional_fields)

Produce the header for the given class.

Parameters:
  • classname (str)

  • extends (MutableSequence[str])

  • doc (str)

  • abstract (bool)

  • field_names (MutableSequence[str])

  • idfield (str)

  • optional_fields (Set[str])

Return type:

None

abstract end_class(classname, field_names)

Signal that we are done with this class.

Parameters:
  • classname (str)

  • field_names (List[str])

Return type:

None

abstract type_loader(type_declaration, container=None, no_link_check=None)

Parse the given type declaration and declare its components.

Parameters:
  • type_declaration (Union[List[Any], Dict[str, Any]])

  • container (Optional[str])

  • no_link_check (Optional[bool])

Return type:

TypeDef

abstract declare_field(name, fieldtype, doc, optional, subscope)

Output the code to load the given field.

Parameters:
Return type:

None

abstract declare_id_field(name, fieldtype, doc, optional)

Output the code to handle the given ID field.

Parameters:
Return type:

None

abstract uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check=None)

Construct the TypeDef for the given URI loader.

Parameters:
Return type:

TypeDef

abstract idmap_loader(field, inner, map_subject, map_predicate)

Construct the TypeDef for the given mapped ID loader.

Parameters:
Return type:

TypeDef

abstract typedsl_loader(inner, ref_scope)

Construct the TypeDef for the given DSL loader.

Parameters:
Return type:

TypeDef

abstract epilogue(root_loader)

Trigger to generate the epilouge code.

Parameters:

root_loader (TypeDef)

Return type:

None

abstract secondaryfilesdsl_loader(inner)

Construct the TypeDef for secondary files.

Parameters:

inner (TypeDef)

Return type:

TypeDef

class schema_salad.java_codegen.LazyInitDef(name, init)

Lazy initialization logic.

Parameters:
__slots__ = ('name', 'init')
class schema_salad.java_codegen.TypeDef(name, init, is_uri=False, scoped_id=False, ref_scope=0, loader_type=None, instance_type=None, abstract=False)

Schema Salad type description.

Parameters:
  • name (str)

  • init (str)

  • is_uri (bool)

  • scoped_id (bool)

  • ref_scope (Optional[int])

  • loader_type (Optional[str])

  • instance_type (Optional[str])

  • abstract (bool)

__slots__ = ['name', 'init', 'is_uri', 'scoped_id', 'ref_scope', 'loader_type', 'instance_type', 'abstract']
exception schema_salad.java_codegen.SchemaException(msg, sl=None, children=None, bullet_for_children='')

Bases: SchemaSaladException

digraph inheritancebe5f3ef5c7 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "SchemaException" [URL="../exceptions/index.html#schema_salad.exceptions.SchemaException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Indicates error with the provided schema definition."]; "SchemaSaladException" -> "SchemaException" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SchemaSaladException" [URL="../exceptions/index.html#schema_salad.exceptions.SchemaSaladException",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for all schema-salad exceptions."]; }

Indicates error with the provided schema definition.

Parameters:
schema_salad.java_codegen.shortname(inputid)

Return the last segment of the provided fragment or path.

Parameters:

inputid (str)

Return type:

str

schema_salad.java_codegen.USE_ONE_OR_LIST_OF_TYPES = False
schema_salad.java_codegen.BASIC_JAVA_IDENTIFIER_RE
schema_salad.java_codegen.doc_to_doc_string(doc, indent_level=0)
Parameters:
  • doc (Optional[str])

  • indent_level (int)

Return type:

str

schema_salad.java_codegen.prims
class schema_salad.java_codegen.JavaCodeGen(base, target, examples, package, copyright)

Bases: schema_salad.codegen_base.CodeGenBase

digraph inheritance75c0201e38 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "CodeGenBase" [URL="../codegen_base/index.html#schema_salad.codegen_base.CodeGenBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for schema salad code generators."]; "JavaCodeGen" [URL="#schema_salad.java_codegen.JavaCodeGen",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "CodeGenBase" -> "JavaCodeGen" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Abstract base class for schema salad code generators.

Parameters:
  • base (str)

  • target (Optional[str])

  • examples (Optional[str])

  • package (str)

  • copyright (Optional[str])

prologue()

Trigger to generate the prolouge code.

Return type:

None

static property_name(name)
Parameters:

name (str)

Return type:

str

static safe_name(name)

Generate a safe version of the given name.

Parameters:

name (str)

Return type:

str

interface_name(n)
Parameters:

n (str)

Return type:

str

begin_class(classname, extends, doc, abstract, field_names, idfield, optional_fields)

Produce the header for the given class.

Parameters:
  • classname (str)

  • extends (MutableSequence[str])

  • doc (str)

  • abstract (bool)

  • field_names (MutableSequence[str])

  • idfield (str)

  • optional_fields (Set[str])

Return type:

None

end_class(classname, field_names)

Finish this class.

Parameters:
  • classname (str)

  • field_names (List[str])

Return type:

None

type_loader(type_declaration, container=None, no_link_check=None)

Parse the given type declaration and declare its components.

Parameters:
  • type_declaration (Union[List[Any], Dict[str, Any], str])

  • container (Optional[str])

  • no_link_check (Optional[bool])

Return type:

schema_salad.codegen_base.TypeDef

type_loader_enum(type_declaration)
Parameters:

type_declaration (Dict[str, Any])

Return type:

schema_salad.codegen_base.TypeDef

declare_field(name, fieldtype, doc, optional, subscope)

Output the code to load the given field.

Parameters:
Return type:

None

declare_id_field(name, fieldtype, doc, optional)

Output the code to handle the given ID field.

Parameters:
Return type:

None

uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check=None)

Construct the TypeDef for the given URI loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

idmap_loader(field, inner, map_subject, map_predicate)

Construct the TypeDef for the given mapped ID loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

typedsl_loader(inner, ref_scope)

Construct the TypeDef for the given DSL loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

to_java(val)
Parameters:

val (Any)

Return type:

Any

epilogue(root_loader)

Trigger to generate the epilouge code.

Parameters:

root_loader (schema_salad.codegen_base.TypeDef)

Return type:

None

secondaryfilesdsl_loader(inner)

Construct the TypeDef for secondary files.

Parameters:

inner (schema_salad.codegen_base.TypeDef)

Return type:

schema_salad.codegen_base.TypeDef