Class SchemaWrapper


  • public class SchemaWrapper
    extends java.lang.Object
    A wrapper class to try and avoid tight coupling to the org.everit.json.schema library.
    • Constructor Summary

      Constructors 
      Constructor Description
      SchemaWrapper​(java.lang.String schemaPath)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canAppend​(java.lang.String field)
      Can this field have values appended to it? (is it a list?)
      java.lang.Object getBlankValue​(java.lang.Class schemaClass)
      Return the "blank" value to use for fields of the for given schema class.
      java.lang.Object getDefaultValue​(org.everit.json.schema.Schema schema)
      Get the default value for fields of the given schema.
      java.lang.String[] getFields()  
      org.everit.json.schema.Schema getFieldSchema​(java.lang.String field)
      Get the schema that applies to the given field.
      org.everit.json.schema.Schema getListFieldItemSchema​(java.lang.String field)
      Get the schema that applies to items within the given list field.
      org.everit.json.schema.ObjectSchema getObjectSchema()  
      java.lang.String getSchemaPath()  
      org.json.JSONObject getTemplate()
      Get a skeleton JSON object, to be applied to new Research Objects that use this schema.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SchemaWrapper

        public SchemaWrapper​(java.lang.String schemaPath)
        Parameters:
        schemaPath - A path to the schema, e.g. /schemas/draft_task.schema.json
    • Method Detail

      • getSchemaPath

        public java.lang.String getSchemaPath()
      • getObjectSchema

        public org.everit.json.schema.ObjectSchema getObjectSchema()
      • getFields

        public java.lang.String[] getFields()
      • getTemplate

        public org.json.JSONObject getTemplate()
        Get a skeleton JSON object, to be applied to new Research Objects that use this schema.
        Returns:
        The template JSON object.
      • getDefaultValue

        public java.lang.Object getDefaultValue​(org.everit.json.schema.Schema schema)
        Get the default value for fields of the given schema. If no default value is explicitly provided by the schema, a default blank value will be used ([], {} or null).
        Parameters:
        schema -
        Returns:
      • getBlankValue

        public java.lang.Object getBlankValue​(java.lang.Class schemaClass)
        Return the "blank" value to use for fields of the for given schema class. For an array: [], for an object: {}, for anything else: null
        Parameters:
        schemaClass - The schema class to check.
        Returns:
      • getFieldSchema

        public org.everit.json.schema.Schema getFieldSchema​(java.lang.String field)
        Get the schema that applies to the given field.
        Parameters:
        field - The name of the field.
        Returns:
      • getListFieldItemSchema

        public org.everit.json.schema.Schema getListFieldItemSchema​(java.lang.String field)
        Get the schema that applies to items within the given list field.
        Parameters:
        field - The name of the list field.
        Returns:
      • canAppend

        public boolean canAppend​(java.lang.String field)
        Can this field have values appended to it? (is it a list?)
        Parameters:
        field - The name of the field.
        Returns: