mirror of
https://github.com/lightbend/config.git
synced 2025-02-24 02:00:46 +08:00
Split ConfigIncludeContext from Parseable out into its own file
This commit is contained in:
parent
8c6b204905
commit
5e7b929b65
@ -65,12 +65,7 @@ public abstract class Parseable implements ConfigParseable {
|
|||||||
protected void postConstruct(ConfigParseOptions baseOptions) {
|
protected void postConstruct(ConfigParseOptions baseOptions) {
|
||||||
this.initialOptions = fixupOptions(baseOptions);
|
this.initialOptions = fixupOptions(baseOptions);
|
||||||
|
|
||||||
this.includeContext = new ConfigIncludeContext() {
|
this.includeContext = new SimpleIncludeContext(this);
|
||||||
@Override
|
|
||||||
public ConfigParseable relativeTo(String filename) {
|
|
||||||
return Parseable.this.relativeTo(filename);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (initialOptions.getOriginDescription() != null)
|
if (initialOptions.getOriginDescription() != null)
|
||||||
initialOrigin = SimpleConfigOrigin.newSimple(initialOptions.getOriginDescription());
|
initialOrigin = SimpleConfigOrigin.newSimple(initialOptions.getOriginDescription());
|
||||||
@ -80,6 +75,7 @@ public abstract class Parseable implements ConfigParseable {
|
|||||||
|
|
||||||
// the general idea is that any work should be in here, not in the
|
// the general idea is that any work should be in here, not in the
|
||||||
// constructor,
|
// constructor,
|
||||||
|
|
||||||
// so that exceptions are thrown from the public parse() function and not
|
// so that exceptions are thrown from the public parse() function and not
|
||||||
// from the creation of the Parseable. Essentially this is a lazy field.
|
// from the creation of the Parseable. Essentially this is a lazy field.
|
||||||
// The parser should close the reader when it's done with it.
|
// The parser should close the reader when it's done with it.
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2011-2012 Typesafe Inc. <http://typesafe.com>
|
||||||
|
*/
|
||||||
|
package com.typesafe.config.impl;
|
||||||
|
|
||||||
|
import com.typesafe.config.ConfigIncludeContext;
|
||||||
|
import com.typesafe.config.ConfigParseable;
|
||||||
|
|
||||||
|
class SimpleIncludeContext implements ConfigIncludeContext {
|
||||||
|
|
||||||
|
private final Parseable parseable;
|
||||||
|
|
||||||
|
SimpleIncludeContext(Parseable parseable) {
|
||||||
|
this.parseable = parseable;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleIncludeContext() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleIncludeContext withParseable(Parseable parseable) {
|
||||||
|
return new SimpleIncludeContext(parseable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigParseable relativeTo(String filename) {
|
||||||
|
if (parseable != null)
|
||||||
|
return parseable.relativeTo(filename);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user