Class Configuration
java.lang.Object
org.torproject.metrics.collector.conf.Configuration
public class Configuration
extends java.lang.Object
Initialize configuration with defaults from collector.properties,
unless a configuration properties file is available.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FIELDSEP
-
Constructor Summary
Constructors Constructor Description Configuration()
-
Method Summary
Modifier and Type Method Description void
clear()
clears all properties.boolean
getBool(Key key)
Returns aboolean
property (case insensitiv), e.g.int
getInt(Key key)
Parse an integer property and translate the String"inf"
into Integer.MAX_VALUE.long
getLong(Key key)
Parse a long property.java.nio.file.Path
getPath(Key key)
Returns aPath
property, e.g.java.util.Properties
getPropertiesCopy()
Return a copy of all properties.java.lang.String
getProperty(java.lang.String key)
Retrieves the value for key.java.lang.String
getProperty(java.lang.String key, java.lang.String def)
Retrieves the value for key returning a default for non-existing keys.java.util.Set<SourceType>
getSourceTypeSet(Key key)
Returns aSourceType
as List, e.g.java.lang.String[]
getStringArray(Key key)
ReturnsString[]
from a property.java.net.URL
getUrl(Key key)
Returns aURL
property, e.g.java.net.URL[]
getUrlArray(Key key)
ReturnsURL[]
from a property.void
load(java.io.InputStream fis)
Loads properties from the given stream.void
loadAndCheckConfiguration(java.nio.file.Path confPath)
Load the configuration from the given path.void
putAll(java.util.Properties allProps)
Add all given properties.void
setProperty(java.lang.String key, java.lang.String value)
Sets the value for key.int
size()
Count of properties.
-
Field Details
-
FIELDSEP
public static final java.lang.String FIELDSEP- See Also:
- Constant Field Values
-
-
Constructor Details
-
Configuration
public Configuration()
-
-
Method Details
-
loadAndCheckConfiguration
Load the configuration from the given path.- Throws:
ConfigurationException
-
getPropertiesCopy
public java.util.Properties getPropertiesCopy()Return a copy of all properties. -
load
public void load(java.io.InputStream fis) throws java.io.IOExceptionLoads properties from the given stream.- Throws:
java.io.IOException
-
getProperty
public java.lang.String getProperty(java.lang.String key)Retrieves the value for key. -
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String def)Retrieves the value for key returning a default for non-existing keys. -
setProperty
public void setProperty(java.lang.String key, java.lang.String value)Sets the value for key. -
clear
public void clear()clears all properties. -
putAll
public void putAll(java.util.Properties allProps)Add all given properties. -
size
public int size()Count of properties. -
getStringArray
ReturnsString[]
from a property. Commas seperate array elements, e.g.,propertyname = a1, a2, a3
- Throws:
ConfigurationException
-
getBool
Returns aboolean
property (case insensitiv), e.g.propertyOne = True
.- Throws:
ConfigurationException
-
getInt
Parse an integer property and translate the String"inf"
into Integer.MAX_VALUE. Verifies that this enum is a Key for an integer value.- Throws:
ConfigurationException
-
getLong
Parse a long property. Verifies that this enum is a Key for a Long value.- Throws:
ConfigurationException
-
getPath
Returns aPath
property, e.g.pathProperty = /my/path/file
.- Throws:
ConfigurationException
-
getSourceTypeSet
Returns aSourceType
as List, e.g.sourcetypeproperty = Remote, Sync
.- Throws:
ConfigurationException
-
getUrl
Returns aURL
property, e.g.urlProperty = https://my.url.here
.- Throws:
ConfigurationException
-
getUrlArray
ReturnsURL[]
from a property. Commas seperate array elements, e.g.,propertyname = a1.example.org, a2.example2.com, a3.example3.net
- Throws:
ConfigurationException
-