Class SimpleResourceLocation

java.lang.Object
dev.metaschema.core.model.SimpleResourceLocation
All Implemented Interfaces:
IMetaschemaData, IResourceLocation

public final class SimpleResourceLocation extends Object implements IMetaschemaData
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

    Fields
    Modifier and Type
    Field
    Description
    static final IMetaschemaData
    A constant representing an unknown location.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimpleResourceLocation(int line, int column, long charOffset, long byteOffset)
    Construct a new resource location with the specified values.
  • Method Summary

    Modifier and Type
    Method
    Description
    fromJsonLocation(com.fasterxml.jackson.core.JsonLocation location)
    Create a resource location from a Jackson JSON location.
    Create a resource location from an XML stream location.
    long
    Get the zero-based byte offset for a location within a resource.
    long
    Get the zero-based character offset for a location within a resource.
    int
    Get the line column for a location within a resource.
    int
    Get the line for a location within a resource.
    of(int line, int column)
    Create a resource location with just line and column information.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • UNKNOWN

      @NonNull public static final IMetaschemaData 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 unknown
      column - the column number (1-based), or -1 if unknown
      charOffset - the character offset (0-based), or -1 if unknown
      byteOffset - the byte offset (0-based), or -1 if unknown
  • Method Details

    • fromXmlLocation

      @NonNull public static IMetaschemaData fromXmlLocation(Location location)
      Create a resource location from an XML stream location.
      Parameters:
      location - the XML stream location, may be null
      Returns:
      a new resource location, or UNKNOWN if 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 be null
      Returns:
      a new resource location, or UNKNOWN if the input is null
    • of

      @NonNull public static IMetaschemaData of(int line, int column)
      Create a resource location with just line and column information.
      Parameters:
      line - the line number (1-based), or -1 if unknown
      column - the column number (1-based), or -1 if unknown
      Returns:
      a new resource location
    • getLine

      public int getLine()
      Description copied from interface: IResourceLocation
      Get the line for a location within a resource.
      Specified by:
      getLine in interface IResourceLocation
      Returns:
      the line number or -1 if unknown
    • getColumn

      public int getColumn()
      Description copied from interface: IResourceLocation
      Get the line column for a location within a resource.
      Specified by:
      getColumn in interface IResourceLocation
      Returns:
      the column number or -1 if unknown
    • getCharOffset

      public long getCharOffset()
      Description copied from interface: IResourceLocation
      Get the zero-based character offset for a location within a resource.
      Specified by:
      getCharOffset in interface IResourceLocation
      Returns:
      the character offset or -1 if unknown
    • getByteOffset

      public long getByteOffset()
      Description copied from interface: IResourceLocation
      Get the zero-based byte offset for a location within a resource.
      Specified by:
      getByteOffset in interface IResourceLocation
      Returns:
      the byte offset or -1 if unknown
    • toString

      public String toString()
      Overrides:
      toString in class Object