Package com.networknt.schema
Class SchemaLocation
- java.lang.Object
-
- com.networknt.schema.SchemaLocation
-
public class SchemaLocation extends Object
The schema location is the canonical IRI of the schema object plus a JSON Pointer fragment indicating the subschema that produced a result. In contrast with the evaluation path, the schema location MUST NOT include by-reference applicators such as $ref or $dynamicRef.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SchemaLocation.Builder
Builder for buildingSchemaLocation
.static class
SchemaLocation.Fragment
The fragment can be a JSON pointer to the document or an anchor.
-
Field Summary
Fields Modifier and Type Field Description static SchemaLocation
DOCUMENT
Represents a relative schema location to the current document.
-
Constructor Summary
Constructors Constructor Description SchemaLocation(AbsoluteIri absoluteIri)
Constructs a newSchemaLocation
.SchemaLocation(AbsoluteIri absoluteIri, JsonNodePath fragment)
Constructs a newSchemaLocation
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SchemaLocation
append(int index)
Appends the index to the fragment.SchemaLocation
append(String token)
Appends the token to the fragment.static SchemaLocation.Builder
builder()
Returns a builder for buildingSchemaLocation
.boolean
equals(Object obj)
AbsoluteIri
getAbsoluteIri()
Gets the canonical absolute IRI of the schema object.JsonNodePath
getFragment()
Gets the fragment.int
hashCode()
static SchemaLocation
of(String iri)
Parses a string representing an IRI of the schema location.static String
resolve(SchemaLocation schemaLocation, String absoluteIriReferenceOrFragment)
Resolves against a absolute IRI reference or fragment.SchemaLocation
resolve(String absoluteIriReferenceOrFragment)
Resolves against a absolute IRI reference or fragment.String
toString()
-
-
-
Field Detail
-
DOCUMENT
public static final SchemaLocation DOCUMENT
Represents a relative schema location to the current document.
-
-
Constructor Detail
-
SchemaLocation
public SchemaLocation(AbsoluteIri absoluteIri, JsonNodePath fragment)
Constructs a newSchemaLocation
.- Parameters:
absoluteIri
- canonical absolute IRI of the schema objectfragment
- the fragment
-
SchemaLocation
public SchemaLocation(AbsoluteIri absoluteIri)
Constructs a newSchemaLocation
.- Parameters:
absoluteIri
- canonical absolute IRI of the schema object
-
-
Method Detail
-
getAbsoluteIri
public AbsoluteIri getAbsoluteIri()
Gets the canonical absolute IRI of the schema object.This is a unique identifier indicated by the $id property or id property in Draft 4 and earlier. This does not have to be network accessible.
- Returns:
- the canonical absolute IRI of the schema object.
-
getFragment
public JsonNodePath getFragment()
Gets the fragment.- Returns:
- the fragment
-
append
public SchemaLocation append(String token)
Appends the token to the fragment.- Parameters:
token
- the segment- Returns:
- a new schema location with the segment
-
append
public SchemaLocation append(int index)
Appends the index to the fragment.- Parameters:
index
- the segment- Returns:
- a new schema location with the segment
-
of
public static SchemaLocation of(String iri)
Parses a string representing an IRI of the schema location.- Parameters:
iri
- the IRI- Returns:
- the schema location
-
resolve
public SchemaLocation resolve(String absoluteIriReferenceOrFragment)
Resolves against a absolute IRI reference or fragment.- Parameters:
absoluteIriReferenceOrFragment
- to resolve- Returns:
- the resolved schema location
-
resolve
public static String resolve(SchemaLocation schemaLocation, String absoluteIriReferenceOrFragment)
Resolves against a absolute IRI reference or fragment.- Parameters:
schemaLocation
- the parentabsoluteIriReferenceOrFragment
- to resolve- Returns:
- the resolved schema location
-
builder
public static SchemaLocation.Builder builder()
Returns a builder for buildingSchemaLocation
.- Returns:
- the builder
-
-