Package com.networknt.schema
Class SchemaLocation
- java.lang.Object
-
- com.networknt.schema.SchemaLocation
-
public class SchemaLocation extends java.lang.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 private AbsoluteIri
absoluteIri
private static JsonNodePath
ANCHOR
static SchemaLocation
DOCUMENT
Represents a relative schema location to the current document.private JsonNodePath
fragment
private static JsonNodePath
JSON_POINTER
private java.lang.String
value
-
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(java.lang.String token)
Appends the token to the fragment.static SchemaLocation.Builder
builder()
Returns a builder for buildingSchemaLocation
.boolean
equals(java.lang.Object obj)
AbsoluteIri
getAbsoluteIri()
Gets the canonical absolute IRI of the schema object.JsonNodePath
getFragment()
Gets the fragment.int
hashCode()
static SchemaLocation
of(java.lang.String iri)
Parses a string representing an IRI of the schema location.static java.lang.String
resolve(SchemaLocation schemaLocation, java.lang.String absoluteIriReferenceOrFragment)
Resolves against a absolute IRI reference or fragment.SchemaLocation
resolve(java.lang.String absoluteIriReferenceOrFragment)
Resolves against a absolute IRI reference or fragment.java.lang.String
toString()
-
-
-
Field Detail
-
JSON_POINTER
private static final JsonNodePath JSON_POINTER
-
ANCHOR
private static final JsonNodePath ANCHOR
-
DOCUMENT
public static final SchemaLocation DOCUMENT
Represents a relative schema location to the current document.
-
absoluteIri
private final AbsoluteIri absoluteIri
-
fragment
private final JsonNodePath fragment
-
value
private volatile java.lang.String value
-
-
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(java.lang.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(java.lang.String iri)
Parses a string representing an IRI of the schema location.- Parameters:
iri
- the IRI- Returns:
- the schema location
-
resolve
public SchemaLocation resolve(java.lang.String absoluteIriReferenceOrFragment)
Resolves against a absolute IRI reference or fragment.- Parameters:
absoluteIriReferenceOrFragment
- to resolve- Returns:
- the resolved schema location
-
resolve
public static java.lang.String resolve(SchemaLocation schemaLocation, java.lang.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
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-