public class ConfigurationSource extends Object
Modifier and Type | Field and Description |
---|---|
static ConfigurationSource |
COMPOSITE_SOURCE
ConfigurationSource to use with
CompositeConfiguration . |
static ConfigurationSource |
NULL_SOURCE
ConfigurationSource to use with Configurations that do not require a "real" configuration source.
|
Constructor and Description |
---|
ConfigurationSource(InputStream stream)
Constructs a new
ConfigurationSource with the specified input stream. |
ConfigurationSource(InputStream stream,
File file)
Constructs a new
ConfigurationSource with the specified input stream that originated from the specified
file. |
ConfigurationSource(InputStream stream,
Path path)
Constructs a new
ConfigurationSource with the specified input stream that originated from the specified
path. |
ConfigurationSource(InputStream stream,
URL url)
Constructs a new
ConfigurationSource with the specified input stream that originated from the specified
URL. |
ConfigurationSource(InputStream stream,
URL url,
long lastModified)
Constructs a new
ConfigurationSource with the specified input stream that originated from the specified
URL. |
ConfigurationSource(Source source,
byte[] data,
long lastModified)
Constructs a new
ConfigurationSource with the specified source. |
Modifier and Type | Method and Description |
---|---|
static ConfigurationSource |
fromResource(String resource,
ClassLoader loader)
Retrieves the configuration via the ClassLoader.
|
static ConfigurationSource |
fromUri(URI configLocation)
Loads the configuration from a URI.
|
File |
getFile()
Returns the file configuration source, or
null if this configuration source is based on an URL or has
neither a file nor an URL. |
InputStream |
getInputStream()
Returns the input stream that this configuration source was constructed with.
|
long |
getLastModified()
Returns the time the resource was last modified or 0 if it is not available.
|
String |
getLocation()
Returns a string describing the configuration source file or URL, or
null if this configuration source
has neither a file nor an URL. |
URI |
getURI()
Returns a URI representing the configuration resource or null if it cannot be determined.
|
URL |
getURL()
Returns the configuration source URL, or
null if this configuration source is based on a file or has
neither a file nor an URL. |
ConfigurationSource |
resetInputStream()
Returns a new
ConfigurationSource whose input stream is reset to the beginning. |
void |
setData(byte[] data) |
void |
setModifiedMillis(long modifiedMillis) |
void |
setSource(Source source)
Deprecated.
Not used internally, no replacement. TODO remove and make source final.
|
String |
toString() |
public static final ConfigurationSource NULL_SOURCE
public static final ConfigurationSource COMPOSITE_SOURCE
CompositeConfiguration
.public ConfigurationSource(InputStream stream, File file)
ConfigurationSource
with the specified input stream that originated from the specified
file.stream
- the input stream, the caller is responsible for closing this resource.file
- the file where the input stream originatedpublic ConfigurationSource(InputStream stream, Path path)
ConfigurationSource
with the specified input stream that originated from the specified
path.stream
- the input stream, the caller is responsible for closing this resource.path
- the path where the input stream originated.public ConfigurationSource(InputStream stream, URL url)
ConfigurationSource
with the specified input stream that originated from the specified
URL.stream
- the input stream, the caller is responsible for closing this resource.url
- the URL where the input stream originatedpublic ConfigurationSource(InputStream stream, URL url, long lastModified)
ConfigurationSource
with the specified input stream that originated from the specified
URL.stream
- the input stream, the caller is responsible for closing this resource.url
- the URL where the input stream originatedlastModified
- when the source was last modified.public ConfigurationSource(InputStream stream) throws IOException
ConfigurationSource
with the specified input stream. Since the stream is the only source
of data, this constructor makes a copy of the stream contents.stream
- the input stream, the caller is responsible for closing this resource.IOException
- if an exception occurred reading from the specified streampublic ConfigurationSource(Source source, byte[] data, long lastModified)
ConfigurationSource
with the specified source.source
- a Source.data
- data from the sourcelastModified
- when the source was last modified.public File getFile()
null
if this configuration source is based on an URL or has
neither a file nor an URL.null
public URL getURL()
null
if this configuration source is based on a file or has
neither a file nor an URL.null
@Deprecated public void setSource(Source source)
public void setData(byte[] data)
public void setModifiedMillis(long modifiedMillis)
public URI getURI()
public long getLastModified()
public String getLocation()
null
if this configuration source
has neither a file nor an URL.null
public InputStream getInputStream()
public ConfigurationSource resetInputStream() throws IOException
ConfigurationSource
whose input stream is reset to the beginning.ConfigurationSource
IOException
- if a problem occurred while opening the new input streampublic static ConfigurationSource fromUri(URI configLocation)
configLocation
- A URI representing the location of the configuration.public static ConfigurationSource fromResource(String resource, ClassLoader loader)
resource
- The resource to load.loader
- The default ClassLoader to use. Copyright © 1999-2023 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.