Class SchemaWrapper
- java.lang.Object
-
- uk.org.esciencelab.researchobjectservice.profile.SchemaWrapper
-
public class SchemaWrapper extends java.lang.ObjectA 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 booleancanAppend(java.lang.String field)Can this field have values appended to it? (is it a list?)java.lang.ObjectgetBlankValue(java.lang.Class schemaClass)Return the "blank" value to use for fields of the for given schema class.java.lang.ObjectgetDefaultValue(org.everit.json.schema.Schema schema)Get the default value for fields of the given schema.java.lang.String[]getFields()org.everit.json.schema.SchemagetFieldSchema(java.lang.String field)Get the schema that applies to the given field.org.everit.json.schema.SchemagetListFieldItemSchema(java.lang.String field)Get the schema that applies to items within the given list field.org.everit.json.schema.ObjectSchemagetObjectSchema()java.lang.StringgetSchemaPath()org.json.JSONObjectgetTemplate()Get a skeleton JSON object, to be applied to new Research Objects that use this schema.
-
-
-
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:
-
-