public interface ConfigDocument
Because this object is immutable, it is safe to use from multiple threads and there's no need for "defensive copies."
Do not implement interface ConfigDocument
; 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.
Modifier and Type | Method and Description |
---|---|
boolean |
hasPath(java.lang.String path)
Returns a boolean indicating whether or not a ConfigDocument has a value at the desired path.
|
java.lang.String |
render()
The original text of the input, modified if necessary with
any replaced or added values.
|
ConfigDocument |
withoutPath(java.lang.String path)
Returns a new ConfigDocument that is a copy of the current ConfigDocument, but with
all values at the desired path removed.
|
ConfigDocument |
withValue(java.lang.String path,
ConfigValue newValue)
Returns a new ConfigDocument that is a copy of the current
ConfigDocument, but with the desired value set at the
desired path.
|
ConfigDocument |
withValueText(java.lang.String path,
java.lang.String newValue)
Returns a new ConfigDocument that is a copy of the current ConfigDocument,
but with the desired value set at the desired path.
|
withValueText(java.lang.String path, java.lang.String newValue)
path
- the path at which to set the desired valuenewValue
- the value to set at the desired path, represented as a string. This
string will be parsed into a ConfigNode using the same options used to
parse the entire document, and the text will be inserted
as-is into the document. Leading and trailing comments, whitespace, or
newlines are not allowed, and if present an exception will be thrown.
If a concatenation is passed in for newValue but the document was parsed
with JSON, the first value in the concatenation will be parsed and inserted
into the ConfigDocument.withValue(java.lang.String path, ConfigValue newValue)
withValueText(String, String)
,
but takes a ConfigValue instead of a string.path
- the path at which to set the desired valuenewValue
- the value to set at the desired path, represented as a ConfigValue.
The rendered text of the ConfigValue will be inserted into the
ConfigDocument.withoutPath(java.lang.String path)
path
- the path to remove from the documentboolean hasPath(java.lang.String path)
path
- the path to checkjava.lang.String render()