Class PropertiesHelper
java.lang.Object
com.gsitm.ustra.java.data.mybatis.pagination.support.PropertiesHelper
public class ConnectionUtils {
static Properties properties = new Properties();
// ... do load properties
// delegate to properties
static PropertiesHelper props = new PropertiesHelper(properties);
public static Connection getConnection() {
// use getRequiredProperty()
DriverManager.getConnection(props.getRequiredString("jdbc.url"));
}
}
new PropertiesHelper(properties,PropertiesHelper.SYSTEM_PROPERTIES_MODE_OVERRIDE)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCheck system properties if not resolvable in the specified properties.static final intNever check system properties.static final intCheck system properties first, before trying the specified properties. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleanbooleancontainsKey(Object key) booleancontainsValue(Object value) elements()entrySet()尝试从System.getProperty(key)及System.getenv(key)得到值getBoolean(String key) booleangetBoolean(String key, boolean defaultValue) doublefloatintint[]getIntArray(String key) getInteger(String key) longgetNullIfBlank(String key) getNullIfEmpty(String key) getProperty(String key) getProperty(String key, String defaultValue) delegate method startbooleangetRequiredBoolean(String key) getRequiredDouble(String key) getRequiredFloat(String key) intgetRequiredInt(String key) getRequiredLong(String key) getRequiredString(String key) getStartsWithProperties(String prefix) String[]getStringArray(String key) booleanisEmpty()keys()keySet()voidlist(PrintStream out) voidlist(PrintWriter out) voidload(InputStream inStream) voidEnumeration<?>voidvoidsave(OutputStream out, String comments) Deprecated.voidsetProperties(Properties props) setProperty(String key, boolean value) setProperty(String key, double value) setProperty(String key, float value) setProperty(String key, int value) setProperty(String key,int value) ...setProperty(String key, long value) setProperty(String key, String value) intsize()voidstore(OutputStream out, String comments) voidstoreToXML(OutputStream os, String comment) voidstoreToXML(OutputStream os, String comment, String encoding) toString()values()
-
Field Details
-
SYSTEM_PROPERTIES_MODE_NEVER
public static final int SYSTEM_PROPERTIES_MODE_NEVERNever check system properties.- See Also:
-
SYSTEM_PROPERTIES_MODE_FALLBACK
public static final int SYSTEM_PROPERTIES_MODE_FALLBACKCheck system properties if not resolvable in the specified properties. This is the default.- See Also:
-
SYSTEM_PROPERTIES_MODE_OVERRIDE
public static final int SYSTEM_PROPERTIES_MODE_OVERRIDECheck system properties first, before trying the specified properties. This allows system properties to override any other property source.- See Also:
-
-
Constructor Details
-
PropertiesHelper
-
PropertiesHelper
-
-
Method Details
-
getProperties
-
setProperties
-
getRequiredString
-
getNullIfBlank
-
getNullIfEmpty
-
getAndTryFromSystem
尝试从System.getProperty(key)及System.getenv(key)得到值- Returns:
-
getInteger
-
getInt
-
getRequiredInt
-
getLong
-
getLong
-
getRequiredLong
-
getBoolean
-
getBoolean
-
getRequiredBoolean
-
getFloat
-
getFloat
-
getRequiredFloat
-
getDouble
-
getDouble
-
getRequiredDouble
-
setProperty
setProperty(String key,int value) ... start -
setProperty
-
setProperty
-
setProperty
-
setProperty
-
getStringArray
-
getIntArray
-
getStartsWithProperties
-
getProperty
delegate method start -
getProperty
-
setProperty
-
clear
public void clear() -
entrySet
-
propertyNames
-
contains
-
containsKey
-
containsValue
-
elements
-
get
-
isEmpty
public boolean isEmpty() -
keys
-
keySet
-
list
-
list
-
load
- Throws:
IOException
-
loadFromXML
-
put
-
putAll
-
remove
-
save
Deprecated. -
size
public int size() -
store
- Throws:
IOException
-
storeToXML
- Throws:
IOException
-
storeToXML
- Throws:
IOException
-
values
-
toString
-