public class Props
extends java.util.Properties
Constructor and Description |
---|
Props()
default constructor
|
Props(java.io.InputStream... inputStreams)
construct props from a list of input streams
|
Props(java.util.List<java.lang.String> files)
construct props from a list of files
|
Props(java.util.Map<java.lang.String,java.lang.String>... props)
construct props from a list of maps
|
Props(java.util.Properties... properties)
construct props from a list of Properties
|
Props(Props props)
copy constructor
|
Props(java.lang.String... files)
construct props from a list of files
|
Modifier and Type | Method and Description |
---|---|
static Props |
clone(Props p)
clone a Props
|
boolean |
equalsProps(Props p)
compare two props
|
java.lang.Boolean |
getBoolean(java.lang.String key)
get boolean value
|
java.lang.Boolean |
getBoolean(java.lang.String key,
java.lang.Boolean defaultValue)
get boolean value with default value
|
double |
getDouble(java.lang.String name)
get double value
|
java.lang.Double |
getDouble(java.lang.String name,
double defaultValue)
get double value with default value
|
java.lang.Integer |
getInt(java.lang.String name)
get integer value
|
java.lang.Integer |
getInt(java.lang.String name,
java.lang.Integer defaultValue)
get integer value with default value
|
java.util.Set<java.lang.String> |
getKeySet()
get all property names
|
java.lang.Long |
getLong(java.lang.String name)
get long value
|
java.lang.Long |
getLong(java.lang.String name,
java.lang.Long defaultValue)
get long value with default value
|
java.util.Map<java.lang.String,java.lang.String> |
getMapByPrefix(java.lang.String prefix)
Get a map of all properties by string prefix
|
java.util.List<java.lang.String> |
getStringList(java.lang.String key)
get property of "key" and split the value by " ,"
|
java.util.List<java.lang.String> |
getStringList(java.lang.String key,
java.util.List<java.lang.String> defaultValue)
get string list with default value.
|
java.util.List<java.lang.String> |
getStringList(java.lang.String key,
java.util.List<java.lang.String> defaultValue,
java.lang.String sep)
get string list with default value
|
java.util.List<java.lang.String> |
getStringList(java.lang.String key,
java.lang.String sep)
get property of "key" and split the value by "sep"
|
java.net.URI |
getUri(java.lang.String name)
get URI value
|
java.net.URI |
getUri(java.lang.String name,
java.lang.String defaultValue)
get URI value
|
java.net.URI |
getUri(java.lang.String name,
java.net.URI defaultValue)
get URI value with default value
|
protected <T> T |
getValue(java.lang.String key,
java.lang.Class<T> mclass) |
protected <T> T |
getValue(java.lang.String key,
T defaultValue) |
void |
logProperties(java.lang.String comment)
log properties
|
static Props |
of(java.lang.String... args)
build props from a list of strings and interpret them as
key, value, key, value,....
|
void |
put(java.util.Properties properties)
Put the given Properties into the Props.
|
void |
store(java.io.OutputStream out)
Store all properties
|
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
public Props()
public Props(Props props)
props
- public Props(java.lang.String... files) throws java.io.FileNotFoundException, java.io.IOException
files
- paths of filesjava.io.FileNotFoundException
java.io.IOException
public Props(java.util.List<java.lang.String> files) throws java.io.FileNotFoundException, java.io.IOException
files
- paths of filesjava.io.FileNotFoundException
java.io.IOException
public Props(java.io.InputStream... inputStreams) throws java.io.IOException
inputStreams
- java.io.IOException
public Props(java.util.Map<java.lang.String,java.lang.String>... props)
props
- public Props(java.util.Properties... properties)
properties
- public static Props of(java.lang.String... args)
args
- public void put(java.util.Properties properties)
properties
- The properties to putpublic java.util.List<java.lang.String> getStringList(java.lang.String key)
key
- public java.util.List<java.lang.String> getStringList(java.lang.String key, java.lang.String sep)
key
- sep
- public java.util.List<java.lang.String> getStringList(java.lang.String key, java.util.List<java.lang.String> defaultValue)
key
- defaultValue
- public java.util.List<java.lang.String> getStringList(java.lang.String key, java.util.List<java.lang.String> defaultValue, java.lang.String sep)
key
- defaultValue
- protected <T> T getValue(java.lang.String key, T defaultValue) throws java.lang.Exception
java.lang.Exception
protected <T> T getValue(java.lang.String key, java.lang.Class<T> mclass) throws java.lang.Exception
java.lang.Exception
public java.lang.Boolean getBoolean(java.lang.String key, java.lang.Boolean defaultValue) throws java.lang.Exception
key
- defaultValue
- java.lang.Exception
- if value is not of type boolean or stringpublic java.lang.Boolean getBoolean(java.lang.String key) throws java.lang.Exception
key
- java.lang.Exception
- if value is not of type boolean or string or
if value doesn't existpublic java.lang.Long getLong(java.lang.String name, java.lang.Long defaultValue) throws java.lang.Exception
name
- defaultValue
- java.lang.Exception
- if value is not of type long or stringpublic java.lang.Long getLong(java.lang.String name) throws java.lang.Exception
name
- java.lang.Exception
- if value is not of type long or string or
if value doesn't existpublic java.lang.Integer getInt(java.lang.String name, java.lang.Integer defaultValue) throws java.lang.Exception
name
- defaultValue
- java.lang.Exception
- if value is not of type integer or stringpublic java.lang.Integer getInt(java.lang.String name) throws java.lang.Exception
name
- java.lang.Exception
- if value is not of type integer or string or
if value doesn't existpublic java.lang.Double getDouble(java.lang.String name, double defaultValue) throws java.lang.Exception
name
- defaultValue
- java.lang.Exception
- if value is not of type double or stringpublic double getDouble(java.lang.String name) throws java.lang.Exception
name
- java.lang.Exception
- if value is not of type double or string or
if value doesn't existpublic java.net.URI getUri(java.lang.String name, java.net.URI defaultValue) throws java.lang.Exception
name
- defaultValue
- java.lang.Exception
- if value is not of type URI or stringpublic java.net.URI getUri(java.lang.String name, java.lang.String defaultValue) throws java.lang.Exception
name
- defaultValue
- java.lang.Exception
- if value is not of type URI or stringpublic java.net.URI getUri(java.lang.String name) throws java.lang.Exception
name
- java.lang.Exception
- if value is not of type URI or string or
if value doesn't existpublic boolean equalsProps(Props p)
p
- public java.util.Map<java.lang.String,java.lang.String> getMapByPrefix(java.lang.String prefix)
prefix
- The string prefixpublic void store(java.io.OutputStream out) throws java.io.IOException
out
- The stream to write tojava.io.IOException
- If there is an error writingpublic java.util.Set<java.lang.String> getKeySet()
public void logProperties(java.lang.String comment)
comment
-