Package org.spdx.v3jsonldstore
Class JsonLDSchema
- java.lang.Object
- 
- org.spdx.v3jsonldstore.JsonLDSchema
 
- 
 public class JsonLDSchema extends Object Represents the JSON Schema for SPDX 3.X includes a number of convenience methods- Author:
- Gary O'Neall
 
- 
- 
Field SummaryFields Modifier and Type Field Description static Set<String>BOOLEAN_TYPESstatic Set<String>DOUBLE_TYPESstatic Set<String>INTEGER_TYPESstatic Map<String,String>RESERVED_JAVA_WORDSstatic Map<String,String>REVERSE_JAVA_WORDSstatic Set<String>STRING_TYPES
 - 
Constructor SummaryConstructors Constructor Description JsonLDSchema(String schemaFileName, String contextFileName, String modelFileName)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<net.jimblackler.jsonschemafriend.Schema>getAllClasses()List<String>getAnyLicenseInfoTypes()Optional<net.jimblackler.jsonschemafriend.Schema>getClassSchema(String className)List<String>getElementTypes()Optional<org.spdx.storage.PropertyDescriptor>getPropertyDescriptor(String fieldName)Optional<String>getPropertyType(String propertyName)Optional<String>getType(net.jimblackler.jsonschemafriend.Schema classSchema)Optional<URI>getTypeUri(net.jimblackler.jsonschemafriend.Schema classSchema)Optional<String>getVocab(String propertyName)booleanhasProperty(String propertyName, net.jimblackler.jsonschemafriend.Schema schema)booleanisEnum(String propertyName)booleanisIndividual(String propertyName, String propertyValue)booleanisSpdxObject(String propertyName)booleanisSubclassOf(String superClassType, net.jimblackler.jsonschemafriend.Schema subClass)booleanvalidate(com.fasterxml.jackson.databind.JsonNode root)booleanvalidate(File spdxJsonFile)
 
- 
- 
- 
Constructor Detail- 
JsonLDSchemapublic JsonLDSchema(String schemaFileName, String contextFileName, String modelFileName) throws net.jimblackler.jsonschemafriend.GenerationException - Parameters:
- schemaFileName- File name for the schema file in the resources directory
- contextFileName- File name for the context file in the resources directory
- modelFileName- File name for the model file in the resources directory
- Throws:
- net.jimblackler.jsonschemafriend.GenerationException- on schema loading error
 
 
- 
 - 
Method Detail- 
getAllClassespublic Collection<net.jimblackler.jsonschemafriend.Schema> getAllClasses() - Returns:
- a list of schemas for all classes defined in the SPDX schema
 
 - 
isSubclassOfpublic boolean isSubclassOf(String superClassType, net.jimblackler.jsonschemafriend.Schema subClass) throws URISyntaxException - Parameters:
- superClassType- superclass type
- subClass- schema for the subclass
- Returns:
- true if the subClass schema contains the property restrictions for the superclass types
- Throws:
- URISyntaxException- on a bad superClassType string
 
 - 
hasPropertypublic boolean hasProperty(String propertyName, net.jimblackler.jsonschemafriend.Schema schema) - Parameters:
- propertyName- name of the property to check
- schema- schema containing property restrictions
- Returns:
- true if the schema requires a property named propertyName via properties, subSchemas, or allOf
 
 - 
getClassSchemapublic Optional<net.jimblackler.jsonschemafriend.Schema> getClassSchema(String className) - Parameters:
- className- name of the class
- Returns:
- schema for the class if it exists
 
 - 
getTypeUripublic Optional<URI> getTypeUri(net.jimblackler.jsonschemafriend.Schema classSchema) - Parameters:
- classSchema- schema for a class
- Returns:
- type URI for the type of the class from the JSON LD Context
 
 - 
getTypepublic Optional<String> getType(net.jimblackler.jsonschemafriend.Schema classSchema) - Parameters:
- classSchema- Schema for the class
- Returns:
- JSON Schema type name for the class
 
 - 
validatepublic boolean validate(com.fasterxml.jackson.databind.JsonNode root) - Parameters:
- root- Root JSON node of the JSON representation of an SPDX serialization
- Returns:
- true if the JSON node is valid
 
 - 
validatepublic boolean validate(File spdxJsonFile) throws IOException - Parameters:
- spdxJsonFile- file containing SPDX JSON LD content
- Returns:
- true if the JSON in file is valid according to the schema
- Throws:
- IOException- on file IO errors
 
 - 
getAnyLicenseInfoTypespublic List<String> getAnyLicenseInfoTypes() - Returns:
- the anyLicenseInfoTypes
 
 - 
getPropertyTypepublic Optional<String> getPropertyType(String propertyName) - Parameters:
- propertyName- name of the property
- Returns:
- the JSON property type if it exists in the JSON-LD context
 
 - 
getVocabpublic Optional<String> getVocab(String propertyName) - Parameters:
- propertyName- name of a property in the JSON LD schema
- Returns:
- the vocab definition
 
 - 
getPropertyDescriptorpublic Optional<org.spdx.storage.PropertyDescriptor> getPropertyDescriptor(String fieldName) - Parameters:
- fieldName- name of a JSON field / property
- Returns:
- the SPDX model property descriptor for the JSON property
 
 - 
isSpdxObjectpublic boolean isSpdxObject(String propertyName) - Parameters:
- propertyName- Name of the property
- Returns:
- true if the value associated with the property is an ID representing an SPDX Object
 
 - 
isIndividualpublic boolean isIndividual(String propertyName, String propertyValue) - Parameters:
- propertyName- Name of the property
- propertyValue- property value
- Returns:
- true if the propertyValue represents an Individual from the vocabulary
 
 - 
isEnumpublic boolean isEnum(String propertyName) - Parameters:
- propertyName- Name of the property
- Returns:
- true if the propertyValue represents an enumeration
 
 
- 
 
-