Class JsonSchema
- java.lang.Object
- 
- com.inductiveautomation.ignition.common.jsonschema.BaseJsonValidator
- 
- com.inductiveautomation.ignition.common.jsonschema.JsonSchema
 
 
- 
- All Implemented Interfaces:
- JsonValidator
 
 public class JsonSchema extends BaseJsonValidator This is the core of json constraint implementation. It parses json constraint file and generates JsonValidators. The class is thread safe, once it is constructed, it can be used to validate multiple json data concurrently.
- 
- 
Field SummaryFields Modifier and Type Field Description static java.util.regex.PatternIGNITION_SCHEMA_PATTERNstatic java.lang.StringIGNITION_SCHEMA_URNprotected java.util.Map<java.lang.String,JsonValidator>validators- 
Fields inherited from interface com.inductiveautomation.ignition.common.jsonschema.JsonValidatorAT_ROOT
 
- 
 - 
Constructor SummaryConstructors Constructor Description JsonSchema(com.inductiveautomation.ignition.common.gson.JsonElement schemaNode)JsonSchema(com.inductiveautomation.ignition.common.gson.JsonElement schemaNode, JsonSchema subSchema)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacceptsType(JsonType type)Returns true if this schema accepts this typeJsonSchemafindAncestor()java.util.Optional<JsonSchema>findAncestorMatchingPath(java.lang.String matchingPath)java.util.Optional<JsonSchema>findSchemaForPath(JsonPath path)Attempts to find a sub-schema for a specific json path into a hypothetical document that this schema might validate.java.util.Optional<com.inductiveautomation.ignition.common.gson.JsonElement>getChildDefaultValue(JsonType type)java.util.List<java.lang.String>getDeclaredProperties()com.inductiveautomation.ignition.common.gson.JsonElementgetDefaultValue()If the schema specified a default value, it will be returned here.com.inductiveautomation.ignition.common.gson.JsonElementgetDefaultValue(boolean includeExamples)If the schema specified a default value, it will be returned here.java.lang.StringgetDescription()java.lang.StringgetDynamicSuggestionPath()java.util.Map<java.lang.String,com.inductiveautomation.ignition.common.gson.JsonElement>getEnumChoices()java.util.List<com.inductiveautomation.ignition.common.gson.JsonElement>getExamples()java.util.Optional<com.inductiveautomation.ignition.common.gson.JsonElement>getExampleValue()Returns an optional containing an example value if one exists.java.util.Optional<com.inductiveautomation.ignition.common.gson.JsonElement>getExtension(java.lang.String key)Returns the json data attached under this schema's "extension" validator, if any.java.lang.StringgetFormat()ItemsValidatorgetItemsValidator()Finds the ItemsValidator associated with this schema, if there is one.com.inductiveautomation.ignition.common.gson.JsonElementgetRefSchemaNode(java.lang.String ref)Find the schema node for $ref attribute.java.util.List<JsonSchema>getSchemasForItems()java.util.Map<java.lang.String,JsonSchema>getSchemasForProperties()java.util.Map<java.lang.String,com.inductiveautomation.ignition.common.gson.JsonElement>getSuggestions()java.lang.StringgetTitle()TypeValidatorgetTypeValidator()Finds the TypeValidator associated with this schema, if there is one.java.util.Optional<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.util.List<com.inductiveautomation.ignition.common.gson.JsonElement>>>getVisibleWhenCondition()booleanhasChildren()booleanisDeprecated()booleanisType(JsonType type)Returns true if this schema accepts this type and only this typestatic JsonSchemaparse(java.io.InputStream stream)java.lang.StringtoString()java.util.Set<ValidationMessage>validate(com.inductiveautomation.ignition.common.gson.JsonElement jsonElement, com.inductiveautomation.ignition.common.gson.JsonElement rootNode, java.lang.String at)Validate the given JsonElement, the given node is the child node of the root node at given data path.- 
Methods inherited from class com.inductiveautomation.ignition.common.jsonschema.BaseJsonValidatorasInt, buildValidationMessage, debug, equals, getParentSchema, getSchemaNode, getSchemaPath, getSubSchema, getValidatorType, greaterThan, hasSubSchema, lessThan, obtainSubSchemaNode, parseErrorCode, useRefCache, validate
 
- 
 
- 
- 
- 
Field Detail- 
validatorsprotected java.util.Map<java.lang.String,JsonValidator> validators 
 - 
IGNITION_SCHEMA_URNpublic static final java.lang.String IGNITION_SCHEMA_URN - See Also:
- Constant Field Values
 
 - 
IGNITION_SCHEMA_PATTERNpublic static final java.util.regex.Pattern IGNITION_SCHEMA_PATTERN 
 
- 
 - 
Constructor Detail- 
JsonSchemapublic JsonSchema(com.inductiveautomation.ignition.common.gson.JsonElement schemaNode) 
 - 
JsonSchemapublic JsonSchema(com.inductiveautomation.ignition.common.gson.JsonElement schemaNode, JsonSchema subSchema)
 
- 
 - 
Method Detail- 
parsepublic static JsonSchema parse(java.io.InputStream stream) 
 - 
findSchemaForPathpublic java.util.Optional<JsonSchema> findSchemaForPath(JsonPath path) Attempts to find a sub-schema for a specific json path into a hypothetical document that this schema might validate. Only supports finding sub-schemas inside "properties" and "items" keywords.
 - 
getRefSchemaNodepublic com.inductiveautomation.ignition.common.gson.JsonElement getRefSchemaNode(java.lang.String ref) Find the schema node for $ref attribute.- Parameters:
- ref- String
- Returns:
- JsonElement
 
 - 
findAncestorMatchingPathpublic java.util.Optional<JsonSchema> findAncestorMatchingPath(java.lang.String matchingPath) 
 - 
findAncestorpublic JsonSchema findAncestor() 
 - 
validatepublic java.util.Set<ValidationMessage> validate(com.inductiveautomation.ignition.common.gson.JsonElement jsonElement, com.inductiveautomation.ignition.common.gson.JsonElement rootNode, java.lang.String at) Description copied from interface:JsonValidatorValidate the given JsonElement, the given node is the child node of the root node at given data path.- Parameters:
- jsonElement- JsonElement
- rootNode- JsonElement
- at- String
- Returns:
- A list of ValidationMessage if there is any validation error, or an empty list if there is no error.
 
 - 
getTitle@Nullable public java.lang.String getTitle() 
 - 
getDescription@Nullable public java.lang.String getDescription() 
 - 
getDefaultValue@Nullable public com.inductiveautomation.ignition.common.gson.JsonElement getDefaultValue() If the schema specified a default value, it will be returned here. Otherwise, a default value may be derived based on the sub-properties specified.
 - 
getDefaultValue@Nullable public com.inductiveautomation.ignition.common.gson.JsonElement getDefaultValue(boolean includeExamples) If the schema specified a default value, it will be returned here. Otherwise, a default value may be derived based on the sub-properties specified.
 - 
getChildDefaultValuepublic java.util.Optional<com.inductiveautomation.ignition.common.gson.JsonElement> getChildDefaultValue(JsonType type) 
 - 
getExamples@Nonnull public java.util.List<com.inductiveautomation.ignition.common.gson.JsonElement> getExamples() 
 - 
isDeprecatedpublic boolean isDeprecated() 
 - 
getExampleValue@Nonnull public java.util.Optional<com.inductiveautomation.ignition.common.gson.JsonElement> getExampleValue() Returns an optional containing an example value if one exists.
 - 
getFormat@Nullable public java.lang.String getFormat() - Returns:
- The format specifier for this schema, if there is one, null otherwise. There will also be a format validator added to the schema.
 
 - 
getExtension@Nonnull public java.util.Optional<com.inductiveautomation.ignition.common.gson.JsonElement> getExtension(java.lang.String key) Returns the json data attached under this schema's "extension" validator, if any.
 - 
getTypeValidator@Nullable public TypeValidator getTypeValidator() Finds the TypeValidator associated with this schema, if there is one. This can be useful if you want to know the accepted types for this schema.
 - 
getItemsValidator@Nullable public ItemsValidator getItemsValidator() Finds the ItemsValidator associated with this schema, if there is one. The items validator defines an expected shape for each element in a (potentially) arbitrary length sequence.
 - 
isTypepublic boolean isType(JsonType type) Returns true if this schema accepts this type and only this type
 - 
acceptsTypepublic boolean acceptsType(JsonType type) Returns true if this schema accepts this type
 - 
getEnumChoicespublic java.util.Map<java.lang.String,com.inductiveautomation.ignition.common.gson.JsonElement> getEnumChoices() - Returns:
- The map of possible choices for this schema if an `enum` validator is present. Otherwise, empty map.
 
 - 
getSuggestionspublic java.util.Map<java.lang.String,com.inductiveautomation.ignition.common.gson.JsonElement> getSuggestions() - Returns:
- the map of suggested values if a 'suggestions' validator is present, otherwise returns empty map.
 
 - 
getDynamicSuggestionPath@Nullable public java.lang.String getDynamicSuggestionPath() 
 - 
getVisibleWhenConditionpublic java.util.Optional<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.util.List<com.inductiveautomation.ignition.common.gson.JsonElement>>> getVisibleWhenCondition() - Returns:
- pair key: driving property name. pair value: acceptable values that make this node visible
 
 - 
getDeclaredPropertiespublic java.util.List<java.lang.String> getDeclaredProperties() - Returns:
- a list of declared property names declared in a "properties" validator in this schema, or empty list if none.
 
 - 
getSchemasForPropertiespublic java.util.Map<java.lang.String,JsonSchema> getSchemasForProperties() - Returns:
- a map of declared property names and their individual schemas, or an empty map if this schema does not define properties.
 
 - 
getSchemasForItemspublic java.util.List<JsonSchema> getSchemasForItems() - Returns:
- an ordered list of item validators. If a singleton list, pull the
 getItemsValidator(), and then checkItemsValidatorviaItemsValidator.isBoundedSchema()to see whether this schema applies to each element in an arbitrarily-long sequence, or only allows a finite list.
 
 - 
hasChildrenpublic boolean hasChildren() 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-