Class SettingsUtils
- java.lang.Object
-
- org.certificateservices.messages.utils.SettingsUtils
-
public class SettingsUtils extends java.lang.ObjectUtils used for parsing settings in configuration.
-
-
Constructor Summary
Constructors Constructor Description SettingsUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetProperty(java.util.Properties config, java.lang.String key, java.lang.String alternativeSettings)Looks up a required property and returns null if not set.static java.lang.StringgetRequiredProperty(java.util.Properties config, java.lang.String key)Looks up a required property and throws exception if not set.static java.lang.StringgetRequiredProperty(java.util.Properties config, java.lang.String key, java.lang.String alternativeSettings)Looks up a required property and throws exception if not set.static java.lang.BooleanparseBoolean(java.util.Properties config, java.lang.String setting, boolean required)Utility to parse a boolean "TRUE" or "FALSE" from the configuration file.static java.lang.BooleanparseBoolean(java.util.Properties config, java.lang.String setting, java.lang.String alternativeSetting, boolean required)Utility to parse a boolean "TRUE" or "FALSE" from the configuration file.static booleanparseBooleanWithDefault(java.util.Properties config, java.lang.String setting, boolean defaultValue)Utility to parse a boolean "TRUE" or "FALSE" from the configuration file with the option of a default value if not set.static booleanparseBooleanWithDefault(java.util.Properties config, java.lang.String setting, java.lang.String alternativeSetting, boolean defaultValue)Utility to parse a boolean "TRUE" or "FALSE" from the configuration file with the option of a default value if not set.static java.lang.String[]parseStringArray(java.util.Properties config, java.lang.String setting, java.lang.String deliminator, boolean required)Method to parse a string with the given deliminator into a String array, with every value trimmed and a PKIMessageException thrown if a required setting isn't set.static java.lang.String[]parseStringArray(java.util.Properties config, java.lang.String setting, java.lang.String deliminator, java.lang.String[] defaulValue)Method to parse a string with the given deliminator into a String array, with every value trimmed.static java.lang.String[]parseStringArray(java.util.Properties config, java.lang.String setting, java.lang.String alternativeSetting, java.lang.String deliminator, boolean required)Method to parse a string with the given deliminator into a String array, with every value trimmed and a PKIMessageException thrown if a required setting isn't set.static java.lang.String[]parseStringArray(java.util.Properties config, java.lang.String setting, java.lang.String alternativeSetting, java.lang.String deliminator, java.lang.String[] defaulValue)Method to parse a string with the given deliminator into a String array, with every value trimmed.
-
-
-
Method Detail
-
parseBoolean
public static java.lang.Boolean parseBoolean(java.util.Properties config, java.lang.String setting, boolean required) throws MessageProcessingExceptionUtility to parse a boolean "TRUE" or "FALSE" from the configuration file.- Parameters:
config- the configuration to fetch setting from.setting- the setting to fetchrequired- if required is a MessageException thrown if setting isn't set.- Returns:
- a boolean value of the setting.
- Throws:
MessageProcessingException- if setting couldn't be read properly from the configuration file.
-
parseBoolean
public static java.lang.Boolean parseBoolean(java.util.Properties config, java.lang.String setting, java.lang.String alternativeSetting, boolean required) throws MessageProcessingExceptionUtility to parse a boolean "TRUE" or "FALSE" from the configuration file.- Parameters:
config- the configuration to fetch setting from.setting- the setting to fetchalternativeSetting- for backward compability settings.required- if required is a MessageException thrown if setting isn't set.- Returns:
- a boolean value of the setting.
- Throws:
MessageProcessingException- if setting couldn't be read properly from the configuration file.
-
parseBooleanWithDefault
public static boolean parseBooleanWithDefault(java.util.Properties config, java.lang.String setting, boolean defaultValue) throws MessageProcessingExceptionUtility to parse a boolean "TRUE" or "FALSE" from the configuration file with the option of a default value if not set.- Parameters:
config- the configuration to fetch setting from.setting- the setting to fetchdefaultValue- value to return if not set.- Returns:
- the boolean setting of the value of the default value if not set.
- Throws:
MessageProcessingException- if setting couldn't be read properly from the configuration file.
-
parseBooleanWithDefault
public static boolean parseBooleanWithDefault(java.util.Properties config, java.lang.String setting, java.lang.String alternativeSetting, boolean defaultValue) throws MessageProcessingExceptionUtility to parse a boolean "TRUE" or "FALSE" from the configuration file with the option of a default value if not set.- Parameters:
config- the configuration to fetch setting from.setting- the setting to fetchalternativeSetting- for backward compability settings.defaultValue- value to return if not set.- Returns:
- the boolean setting of the value of the default value if not set.
- Throws:
MessageProcessingException- if setting couldn't be read properly from the configuration file.
-
parseStringArray
public static java.lang.String[] parseStringArray(java.util.Properties config, java.lang.String setting, java.lang.String deliminator, java.lang.String[] defaulValue)Method to parse a string with the given deliminator into a String array, with every value trimmed.- Parameters:
config- the configuration to read from.setting- the setting to look-up.deliminator- separator used to indicate where to split the string.defaulValue- a default value if- Returns:
- and array of strings splitted and trimmed, never null.
-
parseStringArray
public static java.lang.String[] parseStringArray(java.util.Properties config, java.lang.String setting, java.lang.String alternativeSetting, java.lang.String deliminator, java.lang.String[] defaulValue)Method to parse a string with the given deliminator into a String array, with every value trimmed.- Parameters:
config- the configuration to read from.setting- the setting to look-up.alternativeSetting- for backward compability settings.deliminator- separator used to indicate where to split the string.defaulValue- a default value if- Returns:
- and array of strings splitted and trimmed, never null.
-
parseStringArray
public static java.lang.String[] parseStringArray(java.util.Properties config, java.lang.String setting, java.lang.String deliminator, boolean required) throws MessageProcessingExceptionMethod to parse a string with the given deliminator into a String array, with every value trimmed and a PKIMessageException thrown if a required setting isn't set.- Parameters:
config- the configuration to read from.setting- the setting to look-up.deliminator- separator used to indicate where to split the string.required- if an exception should be thrown if setting isn't set.- Returns:
- and array of strings splitted and trimmed, never null.
- Throws:
MessageProcessingException
-
parseStringArray
public static java.lang.String[] parseStringArray(java.util.Properties config, java.lang.String setting, java.lang.String alternativeSetting, java.lang.String deliminator, boolean required) throws MessageProcessingExceptionMethod to parse a string with the given deliminator into a String array, with every value trimmed and a PKIMessageException thrown if a required setting isn't set.- Parameters:
config- the configuration to read from.setting- the setting to look-up.alternativeSetting- for backward compability settings.deliminator- separator used to indicate where to split the string.required- if an exception should be thrown if setting isn't set.- Returns:
- and array of strings splitted and trimmed, never null.
- Throws:
MessageProcessingException
-
getRequiredProperty
public static java.lang.String getRequiredProperty(java.util.Properties config, java.lang.String key) throws MessageProcessingExceptionLooks up a required property and throws exception if not set.- Parameters:
config- the configuration to read from.setting- the setting to look-up.- Returns:
- the value if set.
- Throws:
MessageException- if setting wasn't set or set to ""MessageProcessingException
-
getRequiredProperty
public static java.lang.String getRequiredProperty(java.util.Properties config, java.lang.String key, java.lang.String alternativeSettings) throws MessageProcessingExceptionLooks up a required property and throws exception if not set.- Parameters:
config- the configuration to read from.setting- the setting to look-up.alternativeSetting- for backward compability settings.- Returns:
- the value if set.
- Throws:
MessageException- if setting wasn't set or set to ""MessageProcessingException
-
getProperty
public static java.lang.String getProperty(java.util.Properties config, java.lang.String key, java.lang.String alternativeSettings)Looks up a required property and returns null if not set.- Parameters:
config- the configuration to read from.setting- the setting to look-up.alternativeSetting- for backward compability settings.- Returns:
- the value if set.
-
-