public class ConfigUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_ENCODING |
| Modifier | Constructor and Description |
|---|---|
protected |
ConfigUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Boolean |
getBooleanProperty(org.apache.commons.configuration2.Configuration config,
String key)
Returns the specified Boolean property from the configuration
|
static Boolean |
getBooleanProperty(org.apache.commons.configuration2.Configuration config,
String key,
Boolean defaultValue)
Returns the specified Boolean property from the configuration
|
static org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> |
getConfigurationAt(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config,
String key)
Returns the sub-configuration whose root is the specified key.
|
static List<org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>> |
getConfigurationsAt(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config,
String key)
Returns the sub-configurations whose root is the specified key.
|
static Integer |
getIntegerProperty(org.apache.commons.configuration2.Configuration config,
String key)
Returns the specified Integer property from the configuration
|
static Integer |
getIntegerProperty(org.apache.commons.configuration2.Configuration config,
String key,
Integer defaultValue)
Returns the specified Integer property from the configuration
|
static Long |
getLongProperty(org.apache.commons.configuration2.Configuration config,
String key)
Returns the specified Long property from the configuration
|
static Long |
getLongProperty(org.apache.commons.configuration2.Configuration config,
String key,
Long defaultValue)
Returns the specified Long property from the configuration
|
static Boolean |
getRequiredBooleanProperty(org.apache.commons.configuration2.Configuration config,
String key)
Returns the specified Boolean property from the configuration.
|
static org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> |
getRequiredConfigurationAt(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config,
String key)
Returns the sub-configuration whose root is the specified key.
|
static List<org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>> |
getRequiredConfigurationsAt(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config,
String key)
Returns the sub-configurations whose root is the specified key.
|
static Integer |
getRequiredIntegerProperty(org.apache.commons.configuration2.Configuration config,
String key)
Returns the specified Integer property from the configuration.
|
static Long |
getRequiredLongProperty(org.apache.commons.configuration2.Configuration config,
String key)
Returns the specified Long property from the configuration.
|
static String[] |
getRequiredStringArrayProperty(org.apache.commons.configuration2.Configuration config,
String key)
Returns the specified String array property from the configuration.
|
static String |
getRequiredStringProperty(org.apache.commons.configuration2.Configuration config,
String key)
Returns the specified String property from the configuration.
|
static String[] |
getStringArrayProperty(org.apache.commons.configuration2.Configuration config,
String key)
Returns the specified String array property from the configuration.
|
static String |
getStringProperty(org.apache.commons.configuration2.Configuration config,
String key)
Returns the specified String property from the configuration
|
static String |
getStringProperty(org.apache.commons.configuration2.Configuration config,
String key,
String defaultValue)
Returns the specified String property from the configuration
|
static org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> |
readXmlConfiguration(InputStream input,
Map<String,org.apache.commons.configuration2.interpol.Lookup> prefixLookups)
Reads the XML configuration from the specified input stream, using the
DEFAULT_ENCODING. |
static org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> |
readXmlConfiguration(InputStream input,
Map<String,org.apache.commons.configuration2.interpol.Lookup> prefixLookups,
String fileEncoding)
Reads the XML configuration from the specified input stream, using the given file encoding.
|
static org.apache.commons.configuration2.XMLConfiguration |
readXmlConfiguration(org.springframework.core.io.Resource resource,
char listDelimiter,
Map<String,org.apache.commons.configuration2.interpol.Lookup> prefixLookups) |
static org.apache.commons.configuration2.HierarchicalConfiguration<?> |
readYamlConfiguration(Reader reader,
Map<String,org.apache.commons.configuration2.interpol.Lookup> prefixLookups) |
public static final String DEFAULT_ENCODING
public static org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> readXmlConfiguration(InputStream input, Map<String,org.apache.commons.configuration2.interpol.Lookup> prefixLookups) throws ConfigurationException
DEFAULT_ENCODING.input - the input stream from where to read the configurationHierarchicalConfigurationConfigurationException - if an error occurs while reading the configurationpublic static org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> readXmlConfiguration(InputStream input, Map<String,org.apache.commons.configuration2.interpol.Lookup> prefixLookups, String fileEncoding) throws ConfigurationException
input - the input stream from where to read the configurationfileEncoding - the encoding of the file. If not specified DEFAULT_ENCODING will be usedHierarchicalConfigurationConfigurationException - if an error occurs while reading the configurationpublic static org.apache.commons.configuration2.XMLConfiguration readXmlConfiguration(org.springframework.core.io.Resource resource,
char listDelimiter,
Map<String,org.apache.commons.configuration2.interpol.Lookup> prefixLookups)
throws ConfigurationException
ConfigurationExceptionpublic static org.apache.commons.configuration2.HierarchicalConfiguration<?> readYamlConfiguration(Reader reader, Map<String,org.apache.commons.configuration2.interpol.Lookup> prefixLookups) throws ConfigurationException
ConfigurationExceptionpublic static String getStringProperty(org.apache.commons.configuration2.Configuration config, String key) throws ConfigurationException
config - the configurationkey - the key of the propertyConfigurationException - if an error occurredpublic static String getStringProperty(org.apache.commons.configuration2.Configuration config, String key, String defaultValue) throws ConfigurationException
config - the configurationkey - the key of the propertydefaultValue - the default value if the property is not foundConfigurationException - if an error occurredpublic static String getRequiredStringProperty(org.apache.commons.configuration2.Configuration config, String key) throws ConfigurationException
MissingConfigurationException is thrown.config - the configurationkey - the key of the propertyMissingConfigurationException - if the property is missing from the configurationConfigurationException - if an error occurredpublic static Boolean getBooleanProperty(org.apache.commons.configuration2.Configuration config, String key) throws ConfigurationException
config - the configurationkey - the key of the propertyConfigurationException - if an error occurredpublic static Boolean getBooleanProperty(org.apache.commons.configuration2.Configuration config, String key, Boolean defaultValue) throws ConfigurationException
config - the configurationkey - the key of the propertydefaultValue - the default value if the property is not foundConfigurationException - if an error occurredpublic static Boolean getRequiredBooleanProperty(org.apache.commons.configuration2.Configuration config, String key) throws ConfigurationException
MissingConfigurationException is thrown.config - the configurationkey - the key of the propertyMissingConfigurationException - if the property is missing from the configurationConfigurationException - if an error occurredpublic static Integer getIntegerProperty(org.apache.commons.configuration2.Configuration config, String key) throws ConfigurationException
config - the configurationkey - the key of the propertyConfigurationException - if an error occurredpublic static Integer getIntegerProperty(org.apache.commons.configuration2.Configuration config, String key, Integer defaultValue) throws ConfigurationException
config - the configurationkey - the key of the propertydefaultValue - the default value if the property is not foundConfigurationException - if an error occurredpublic static Integer getRequiredIntegerProperty(org.apache.commons.configuration2.Configuration config, String key) throws ConfigurationException
MissingConfigurationException is thrown.config - the configurationkey - the key of the propertyMissingConfigurationException - if the property is missing from the configurationConfigurationException - if an error occurredpublic static Long getLongProperty(org.apache.commons.configuration2.Configuration config, String key) throws ConfigurationException
config - the configurationkey - the key of the propertyConfigurationException - if an error occurredpublic static Long getLongProperty(org.apache.commons.configuration2.Configuration config, String key, Long defaultValue) throws ConfigurationException
config - the configurationkey - the key of the propertydefaultValue - the default value if the property is not foundConfigurationException - if an error occurredpublic static Long getRequiredLongProperty(org.apache.commons.configuration2.Configuration config, String key) throws ConfigurationException
MissingConfigurationException is thrown.config - the configurationkey - the key of the propertyMissingConfigurationException - if the property is missing from the configurationConfigurationException - if an error occurredpublic static String[] getStringArrayProperty(org.apache.commons.configuration2.Configuration config, String key) throws ConfigurationException
config - the configurationkey - the key of the propertyConfigurationException - if an error occurredpublic static String[] getRequiredStringArrayProperty(org.apache.commons.configuration2.Configuration config, String key) throws ConfigurationException
MissingConfigurationException is thrown. A String array property is normally specified as
a String with values separated by commas in the configuration.config - the configurationkey - the key of the propertyMissingConfigurationException - if the property is missing from the configurationConfigurationException - if an error occurredpublic static org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> getConfigurationAt(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config,
String key)
throws ConfigurationException
config - the main configurationkey - the sub-configuration keyConfigurationException - if an error occurspublic static org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> getRequiredConfigurationAt(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config,
String key)
throws ConfigurationException
MissingConfigurationException is thrown.config - the main configurationkey - the sub-configuration keyMissingConfigurationException - if the sub-configuration is missing from the configurationConfigurationException - if an error occurspublic static List<org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>> getConfigurationsAt(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config, String key) throws ConfigurationException
config - the main configurationkey - the sub-configurations keyConfigurationException - if an error occurspublic static List<org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>> getRequiredConfigurationsAt(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config, String key) throws ConfigurationException
MissingConfigurationException is thrownconfig - the main configurationkey - the sub-configurations keyMissingConfigurationException - if the sub-configurations are missing from the configurationConfigurationException - if an error occursCopyright © 2020 CrafterCMS. All rights reserved.