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.StringFIELDSEP -
Constructor Summary
Constructors Constructor Description Configuration() -
Method Summary
Modifier and Type Method Description voidclear()clears all properties.booleangetBool(Key key)Returns abooleanproperty (case insensitiv), e.g.intgetInt(Key key)Parse an integer property and translate the String"inf"into Integer.MAX_VALUE.longgetLong(Key key)Parse a long property.java.nio.file.PathgetPath(Key key)Returns aPathproperty, e.g.java.util.PropertiesgetPropertiesCopy()Return a copy of all properties.java.lang.StringgetProperty(java.lang.String key)Retrieves the value for key.java.lang.StringgetProperty(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 aSourceTypeas List, e.g.java.lang.String[]getStringArray(Key key)ReturnsString[]from a property.java.net.URLgetUrl(Key key)Returns aURLproperty, e.g.java.net.URL[]getUrlArray(Key key)ReturnsURL[]from a property.voidload(java.io.InputStream fis)Loads properties from the given stream.voidloadAndCheckConfiguration(java.nio.file.Path confPath)Load the configuration from the given path.voidputAll(java.util.Properties allProps)Add all given properties.voidsetProperty(java.lang.String key, java.lang.String value)Sets the value for key.intsize()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 abooleanproperty (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 aPathproperty, e.g.pathProperty = /my/path/file.- Throws:
ConfigurationException
-
getSourceTypeSet
Returns aSourceTypeas List, e.g.sourcetypeproperty = Remote, Sync.- Throws:
ConfigurationException
-
getUrl
Returns aURLproperty, 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
-