Package net.ontopia.utils
Class PropertyUtils
- java.lang.Object
-
- net.ontopia.utils.PropertyUtils
-
public class PropertyUtils extends Object
INTERNAL: Utility class for handling properties and their values.
-
-
Constructor Summary
Constructors Constructor Description PropertyUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
getInt(String property_value)
static int
getInt(String property_value, int default_value)
INTERNAL: Returns the property value as an int.static String
getProperty(Map<String,String> properties, String name)
INTERNAL: Helper method used to get better error messages with less typing.static String
getProperty(Map<String,String> properties, String name, boolean required)
INTERNAL: Helper method used to get better error messages with less typing.static String
getProperty(Map<String,String> properties, String name, String fallback)
INTERNAL: Helper method used to get better error messages with less typing.static boolean
isTrue(String property_value, boolean default_value)
static Properties
loadProperties(File propfile)
INTERNAL; Reads properties from a file.static Properties
loadProperties(InputStream istream)
static Properties
loadPropertiesFromClassPath(String resource)
static Map<String,String>
subset(Map<String,String> properties, String prefix)
static Map<String,String>
toMap(Properties properties)
-
-
-
Method Detail
-
getProperty
public static String getProperty(Map<String,String> properties, String name)
INTERNAL: Helper method used to get better error messages with less typing.
-
getProperty
public static String getProperty(Map<String,String> properties, String name, String fallback)
INTERNAL: Helper method used to get better error messages with less typing.
-
getProperty
public static String getProperty(Map<String,String> properties, String name, boolean required)
INTERNAL: Helper method used to get better error messages with less typing.
-
isTrue
public static boolean isTrue(String property_value, boolean default_value)
-
getInt
public static int getInt(String property_value, int default_value)
INTERNAL: Returns the property value as an int. If the value is not set or any problems occur the default value is returned.
-
getInt
public static int getInt(String property_value) throws NumberFormatException
- Throws:
NumberFormatException
-
loadProperties
public static Properties loadProperties(File propfile) throws IOException
INTERNAL; Reads properties from a file.- Throws:
IOException
-
loadPropertiesFromClassPath
public static Properties loadPropertiesFromClassPath(String resource) throws IOException
- Throws:
IOException
-
loadProperties
public static Properties loadProperties(InputStream istream) throws IOException
- Throws:
IOException
-
toMap
public static Map<String,String> toMap(Properties properties)
-
-