java.lang.Object
dev.metaschema.core.model.SimpleResourceLocation
- All Implemented Interfaces:
IMetaschemaData,IResourceLocation
A simple implementation of
IMetaschemaData that stores location
information from various parser sources.
This class can be used both for bound object metadata during parsing and for validation context in error messages.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IMetaschemaDataA constant representing an unknown location. -
Constructor Summary
ConstructorsConstructorDescriptionSimpleResourceLocation(int line, int column, long charOffset, long byteOffset) Construct a new resource location with the specified values. -
Method Summary
Modifier and TypeMethodDescriptionstatic IMetaschemaDatafromJsonLocation(com.fasterxml.jackson.core.JsonLocation location) Create a resource location from a Jackson JSON location.static IMetaschemaDatafromXmlLocation(Location location) Create a resource location from an XML stream location.longGet the zero-based byte offset for a location within a resource.longGet the zero-based character offset for a location within a resource.intGet the line column for a location within a resource.intgetLine()Get the line for a location within a resource.static IMetaschemaDataof(int line, int column) Create a resource location with just line and column information.toString()
-
Field Details
-
UNKNOWN
A constant representing an unknown location.
-
-
Constructor Details
-
SimpleResourceLocation
public SimpleResourceLocation(int line, int column, long charOffset, long byteOffset) Construct a new resource location with the specified values.- Parameters:
line- the line number (1-based), or -1 if unknowncolumn- the column number (1-based), or -1 if unknowncharOffset- the character offset (0-based), or -1 if unknownbyteOffset- the byte offset (0-based), or -1 if unknown
-
-
Method Details
-
fromXmlLocation
Create a resource location from an XML stream location.- Parameters:
location- the XML stream location, may benull- Returns:
- a new resource location, or
UNKNOWNif the input is null
-
fromJsonLocation
@NonNull public static IMetaschemaData fromJsonLocation(com.fasterxml.jackson.core.JsonLocation location) Create a resource location from a Jackson JSON location.- Parameters:
location- the JSON location, may benull- Returns:
- a new resource location, or
UNKNOWNif the input is null
-
of
Create a resource location with just line and column information.- Parameters:
line- the line number (1-based), or -1 if unknowncolumn- the column number (1-based), or -1 if unknown- Returns:
- a new resource location
-
getLine
public int getLine()Description copied from interface:IResourceLocationGet the line for a location within a resource.- Specified by:
getLinein interfaceIResourceLocation- Returns:
- the line number or
-1if unknown
-
getColumn
public int getColumn()Description copied from interface:IResourceLocationGet the line column for a location within a resource.- Specified by:
getColumnin interfaceIResourceLocation- Returns:
- the column number or
-1if unknown
-
getCharOffset
public long getCharOffset()Description copied from interface:IResourceLocationGet the zero-based character offset for a location within a resource.- Specified by:
getCharOffsetin interfaceIResourceLocation- Returns:
- the character offset or
-1if unknown
-
getByteOffset
public long getByteOffset()Description copied from interface:IResourceLocationGet the zero-based byte offset for a location within a resource.- Specified by:
getByteOffsetin interfaceIResourceLocation- Returns:
- the byte offset or
-1if unknown
-
toString
-