Top Description Methods
com.typesafe.config

public Interface ConfigOrigin

Known Direct Implementers
com.typesafe.config.impl.SimpleConfigOrigin
Imports
java.net.URL, java.util.List

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

Modifier and TypeMethod and Description
public List<String>

Returns:

any comments that seemed to "go with" this origin, empty list if none
comments
()

Returns any comments that appeared to "go with" this place in the file.

public String

Returns:

string describing the origin
description
()

Returns a string describing the origin of a value or exception.

public String

Returns:

filename of the origin or null
filename
()

Returns a filename describing the origin.

public int

Returns:

line number or -1 if none is available
lineNumber
()

Returns a line number where the value or exception originated.

public String

Returns:

resource name of the origin or null
resource
()

Returns a classpath resource name describing the origin.

public URL

Returns:

url of the origin or null
url
()

Returns a URL describing the origin.

public ConfigOrigin

Returns:

the ConfigOrigin with the given comments
withComments
(List<String>
the comments used on the returned origin
comments
)

Returns a ConfigOrigin based on this one, but with the given comments.

public ConfigOrigin

Returns:

the created ConfigOrigin
withLineNumber
(int
the new line number
lineNumber
)

Returns a ConfigOrigin based on this one, but with the given line number.

Method Detail

commentsback to summary
public List<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:List<String>

any comments that seemed to "go with" this origin, empty list if none

descriptionback to summary
public String description()

Returns a string describing the origin of a value or exception. This will never return null.

Returns:String

string describing the origin

filenameback to summary
public String filename()

Returns a filename describing the origin. This will return null if the origin was not a file.

Returns:String

filename of the origin or null

lineNumberback to summary
public int lineNumber()

Returns a line number where the value or exception originated. This will return -1 if there's no meaningful line number.

Returns:int

line number or -1 if none is available

resourceback to summary
public String resource()

Returns a classpath resource name describing the origin. This will return null if the origin was not a classpath resource.

Returns:String

resource name of the origin or null

urlback to summary
public URL url()

Returns a URL describing the origin. This will return null if the origin has no meaningful URL.

Returns:URL

url of the origin or null

withCommentsback to summary
public ConfigOrigin withComments(List<String> comments)

Returns a ConfigOrigin based on this one, but with the given comments. Does not modify this instance or any ConfigValues with this origin (since they are immutable). To set the returned origin to a ConfigValue, use ConfigValue#withOrigin.

Note that when the given comments are equal to the comments on this object, a new instance may not be created and this is returned directly.

Parameters
comments:List<String>

the comments used on the returned origin

Returns:ConfigOrigin

the ConfigOrigin with the given comments

Since
1.3.0
withLineNumberback to summary
public ConfigOrigin withLineNumber(int lineNumber)

Returns a ConfigOrigin based on this one, but with the given line number. This origin must be a FILE, URL or RESOURCE. Does not modify this instance or any ConfigValues with this origin (since they are immutable). To set the returned origin to a ConfigValue, use ConfigValue#withOrigin.

Note that when the given lineNumber are equal to the lineNumber on this object, a new instance may not be created and this is returned directly.

Parameters
lineNumber:int

the new line number

Returns:ConfigOrigin

the created ConfigOrigin

Since
1.3.0