Interface ConfigOrigin


  • public interface ConfigOrigin
    Represents the origin (such as filename and line number) of a ConfigValue for use in error messages. Obtain the origin of a value with ConfigValue.origin(). Exceptions may have an origin, see ConfigException.origin, but be careful because ConfigException.origin() may return null.

    It's best to use this interface only for debugging; its accuracy is "best effort" rather than guaranteed, and a potentially-noticeable amount of memory could probably be saved if origins were not kept around, so in the future there might be some option to discard origins.

    Do not implement this interface; it should only be implemented by the config library. Arbitrary implementations will not work because the library internals assume a specific concrete implementation. Also, this interface is likely to grow new methods over time, so third-party implementations will break.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.String> comments()
      Returns any comments that appeared to "go with" this place in the file.
      java.lang.String description()
      Returns a string describing the origin of a value or exception.
      java.lang.String filename()
      Returns a filename describing the origin.
      int lineNumber()
      Returns a line number where the value or exception originated.
      java.lang.String resource()
      Returns a classpath resource name describing the origin.
      java.net.URL url()
      Returns a URL describing the origin.
    • Method Detail

      • description

        java.lang.String description()
        Returns a string describing the origin of a value or exception. This will never return null.
        Returns:
        string describing the origin
      • filename

        java.lang.String filename()
        Returns a filename describing the origin. This will return null if the origin was not a file.
        Returns:
        filename of the origin or null
      • url

        java.net.URL url()
        Returns a URL describing the origin. This will return null if the origin has no meaningful URL.
        Returns:
        url of the origin or null
      • resource

        java.lang.String resource()
        Returns a classpath resource name describing the origin. This will return null if the origin was not a classpath resource.
        Returns:
        resource name of the origin or null
      • lineNumber

        int lineNumber()
        Returns a line number where the value or exception originated. This will return -1 if there's no meaningful line number.
        Returns:
        line number or -1 if none is available
      • comments

        java.util.List<java.lang.String> comments()
        Returns any comments that appeared to "go with" this place in the file. Often an empty list, but never null. The details of this are subject to change, but at the moment comments that are immediately before an array element or object field, with no blank line after the comment, "go with" that element or field.
        Returns:
        any comments that seemed to "go with" this origin, empty list if none