public class SafePropertyAccessor extends Object
Constructor and Description |
---|
SafePropertyAccessor() |
Modifier and Type | Method and Description |
---|---|
static boolean |
getBoolean(String property)
An extension over
Boolean.getBoolean method. |
static boolean |
getBoolean(String property,
boolean defValue)
An extension over
Boolean.getBoolean method. |
static Map<String,String> |
getenv()
An extension over
System.getenv method. |
static String |
getenv(String name)
An extension over
System.getenv method. |
static int |
getInt(String property)
An extension over
System.getProperty method
that additionally produces an int value. |
static int |
getInt(String property,
int defValue)
An extension over
System.getProperty method
that additionally produces an int value. |
static String |
getProperty(String property)
An extension over
System.getProperty method. |
static String |
getProperty(String property,
String defValue)
An extension over
System.getProperty method. |
static boolean |
isSecurityProtected(String property)
Returns
true if the access to the system property
is restricted (i.e., when System.getProperty()
throws SecurityException). |
public static boolean getBoolean(String property)
Boolean.getBoolean
method.
Returns true if and only if the system property
named by the argument exists and is equal to the string "true".
If there is no property with the specified name, or if the specified
name is empty or null, or if the access to the property is
restricted, then false is returned.property
- The system property name.public static boolean getBoolean(String property, boolean defValue)
Boolean.getBoolean
method.
Handles security restrictions, and provides default value
in case when access to the property is restricted,
of when the property does not exist.property
- The system property name.defValue
- The default value.public static String getProperty(String property)
System.getProperty
method.
Handles security restrictions, and returns null
if the access to the property is restricted.property
- The system property name.public static String getProperty(String property, String defValue)
System.getProperty
method.
Handles security restrictions, and returns the default
value if the access to the property is restricted.property
- The system property name.defValue
- The default value.public static int getInt(String property)
System.getProperty
method
that additionally produces an int value.
Handles security restrictions, and returns 0
if the access to the property is restricted.property
- The system property name.public static int getInt(String property, int defValue)
System.getProperty
method
that additionally produces an int value.
Handles security restrictions, and returns the default
value if the access to the property is restricted.property
- The system property name.defValue
- The default value.public static boolean isSecurityProtected(String property)
true
if the access to the system property
is restricted (i.e., when System.getProperty()
throws SecurityException).property
- The system property name.true
if the access is restricted,
false
otherwise.public static String getenv(String name)
System.getenv
method.
Handles security restrictions, and returns null
if the access to the environment variable is restricted.name
- The environment variable name.Copyright © 2001-2015 JRuby. All Rights Reserved.