java.lang.Object
dev.metaschema.databind.io.ValidationContext
Provides contextual information for validation errors during parsing.
This class bundles together:
- Source URI - the document being parsed
- Location - line and column within the document
- Path - the path to the current element in the document structure
- Format - whether parsing XML, JSON, or YAML
This context is passed to problem handlers to enable rich, informative error messages that help users locate and understand validation errors.
-
Method Summary
Modifier and TypeMethodDescriptionFormat the location information as a human-readable string.Format the path information for display.Get the format being parsed.dev.metaschema.core.model.IResourceLocationGet the location within the document.getPath()Get the path to the current element.Get the source URI of the document being parsed.static ValidationContextCreate a new validation context.static ValidationContextofUnknownLocation(URI source, String path, Format format) Create a validation context with unknown location.toString()
-
Method Details
-
of
@NonNull public static ValidationContext of(@Nullable URI source, @NonNull dev.metaschema.core.model.IResourceLocation location, @NonNull String path, @NonNull Format format) Create a new validation context.- Parameters:
source- the source URI, may be nulllocation- the resource location, must not be nullpath- the current path, must not be nullformat- the format being parsed, must not be null- Returns:
- a new validation context
-
ofUnknownLocation
@NonNull public static ValidationContext ofUnknownLocation(@Nullable URI source, @NonNull String path, @NonNull Format format) Create a validation context with unknown location.- Parameters:
source- the source URI, may be nullpath- the current pathformat- the format being parsed- Returns:
- a new validation context with unknown location
-
getSource
Get the source URI of the document being parsed.- Returns:
- the source URI, or null if not available
-
getLocation
Get the location within the document.- Returns:
- the resource location
-
getPath
Get the path to the current element.- Returns:
- the element path
-
getFormat
Get the format being parsed.- Returns:
- the format
-
formatLocation
Format the location information as a human-readable string.The format is: "in 'source' at line:column" or "at line:column" if no source is available, or empty string if location is unknown.
- Returns:
- a formatted location string
-
formatPath
Format the path information for display.- Returns:
- the path, or "at document root" if path is empty or "/"
-
toString
-