Class Configuration
- java.lang.Object
-
- org.torproject.metrics.collector.conf.Configuration
-
public class Configuration extends java.lang.ObjectInitialize 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
All Methods Instance Methods Concrete Methods 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 Detail
-
FIELDSEP
public static final java.lang.String FIELDSEP
- See Also:
- Constant Field Values
-
-
Method Detail
-
loadAndCheckConfiguration
public void loadAndCheckConfiguration(java.nio.file.Path confPath) throws ConfigurationExceptionLoad 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
public java.lang.String[] getStringArray(Key key) throws ConfigurationException
ReturnsString[]from a property. Commas seperate array elements, e.g.,propertyname = a1, a2, a3- Throws:
ConfigurationException
-
getBool
public boolean getBool(Key key) throws ConfigurationException
Returns abooleanproperty (case insensitiv), e.g.propertyOne = True.- Throws:
ConfigurationException
-
getInt
public int getInt(Key key) throws ConfigurationException
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
public long getLong(Key key) throws ConfigurationException
Parse a long property. Verifies that this enum is a Key for a Long value.- Throws:
ConfigurationException
-
getPath
public java.nio.file.Path getPath(Key key) throws ConfigurationException
Returns aPathproperty, e.g.pathProperty = /my/path/file.- Throws:
ConfigurationException
-
getSourceTypeSet
public java.util.Set<SourceType> getSourceTypeSet(Key key) throws ConfigurationException
Returns aSourceTypeas List, e.g.sourcetypeproperty = Remote, Sync.- Throws:
ConfigurationException
-
getUrl
public java.net.URL getUrl(Key key) throws ConfigurationException
Returns aURLproperty, e.g.urlProperty = https://my.url.here.- Throws:
ConfigurationException
-
getUrlArray
public java.net.URL[] getUrlArray(Key key) throws ConfigurationException
ReturnsURL[]from a property. Commas seperate array elements, e.g.,propertyname = a1.example.org, a2.example2.com, a3.example3.net- Throws:
ConfigurationException
-
-