public class Props
extends java.lang.Object
| Constructor and Description |
|---|
Props()
Constructor for empty props with empty parent.
|
Props(Props parent)
Constructor for empty Props with parent override.
|
Props(Props parent,
java.io.File file)
Load props from a file.
|
Props(Props parent,
java.io.InputStream inputStream)
Create props from property input streams
|
Props(Props parent,
java.util.Map<java.lang.String,java.lang.String>... props)
Create properties from maps of properties
|
Props(Props parent,
java.util.Properties... properties)
Create properties from Properties objects
|
Props(Props parent,
Props props)
Create a Props object with the contents set to that of props.
|
Props(Props parent,
java.lang.String filepath)
Load props from a file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearLocal()
Clear the current Props, but leaves the parent untouched.
|
static Props |
clone(Props p)
Clones the Props p object and all of its parents.
|
boolean |
containsKey(java.lang.Object k)
Check key in current Props then search in parent
|
boolean |
containsValue(java.lang.Object value)
Check value in current Props then search in parent
|
boolean |
equals(java.lang.Object o)
override object's default equal function
|
java.lang.String |
get(java.lang.Object key)
Return value if available in current Props otherwise return from parent
|
boolean |
getBoolean(java.lang.String key)
Returns true if the value equals "true".
|
boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Returns true if the value equals "true".
|
java.lang.Class<?> |
getClass(java.lang.String key)
Attempts to return the Class that corresponds to the Props value.
|
java.lang.Class<?> |
getClass(java.lang.String key,
boolean initialize,
java.lang.ClassLoader cl) |
java.lang.Class<?> |
getClass(java.lang.String key,
java.lang.Class<?> defaultClass)
Gets the class from the Props.
|
double |
getDouble(java.lang.String name)
Returns the double representation of the value.
|
double |
getDouble(java.lang.String name,
double defaultValue)
Returns the double representation of the value.
|
Props |
getEarliestAncestor()
Get the Root Props Object
|
java.util.Map<java.lang.String,java.lang.String> |
getFlattened()
Returns a new constructed map of all the flattened properties, the item in the returned
map is sorted alphabetically by the key value.
|
static Props |
getInstance(Props parent,
Props current,
java.lang.String source)
Create a new Props instance
|
int |
getInt(java.lang.String name)
Returns the int representation of the value.
|
int |
getInt(java.lang.String name,
int defaultValue)
Returns the int representation of the value.
|
java.util.Set<java.lang.String> |
getKeySet()
Returns a set of all keys, including the parents
|
long |
getLong(java.lang.String name)
Returns the long representation of the value.
|
long |
getLong(java.lang.String name,
long defaultValue)
Returns the long representation of the value.
|
java.util.Map<java.lang.String,java.lang.String> |
getMapByPrefix(java.lang.String prefix)
Get a new de-duplicated map of all the flattened properties by given prefix.
|
Props |
getParent()
Get parent Props
|
java.lang.String |
getSource()
Get Source information
|
java.lang.String |
getString(java.lang.String key)
Gets the string from the Props.
|
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Gets the string from the Props.
|
java.util.List<java.lang.String> |
getStringList(java.lang.String key)
Returns a list of strings with the comma as the separator of the value
|
java.util.List<java.lang.String> |
getStringList(java.lang.String key,
java.util.List<java.lang.String> defaultValue)
Returns a list of strings with the comma as the separator of the value.
|
java.util.List<java.lang.String> |
getStringList(java.lang.String key,
java.util.List<java.lang.String> defaultValue,
java.lang.String sep)
Returns a list of strings with the sep as the separator of the value.
|
java.util.List<java.lang.String> |
getStringList(java.lang.String key,
java.lang.String sep)
Returns a list of strings with the sep as the separator of the value
|
java.util.List<java.lang.String> |
getStringListFromCluster(java.lang.String key)
Returns a list of clusters with the comma as the separator of the value
e.g., for input string: "thrift://hcat1:port,thrift://hcat2:port;thrift://hcat3:port,thrift://hcat4:port;"
we will get ["thrift://hcat1:port,thrift://hcat2:port", "thrift://hcat3:port,thrift://hcat4:port"]
as output
|
java.net.URI |
getUri(java.lang.String name)
Returns the uri representation of the value.
|
java.net.URI |
getUri(java.lang.String name,
java.lang.Boolean addTrailingSlash) |
java.net.URI |
getUri(java.lang.String name,
java.lang.String defaultValue)
Convert a URI-formatted string value to URI object
|
java.net.URI |
getUri(java.lang.String name,
java.net.URI defaultValue)
Returns the double representation of the value.
|
java.net.URI |
getUri(java.lang.String name,
java.net.URI defaultValue,
java.lang.Boolean addTrailingSlash) |
int |
hashCode()
override object's default hash code function
|
Props |
local()
Returns a copy of only the local values of this props
|
java.util.Set<java.lang.String> |
localKeySet()
Get the key set from the current Props
|
int |
localSize()
The number of unique keys defined by this Props (keys defined only in parent Props are not
counted)
|
void |
logProperties(org.apache.log4j.Logger logger,
java.lang.String comment)
Logs the property in the given logger
|
static Props |
of(Props parent,
java.lang.String... args)
Create a Props from a list of key value pairing.
|
static Props |
of(java.lang.String... args)
Create a Props with a null parent from a list of key value pairing.
|
void |
put(java.util.Properties properties)
Put the given Properties into the Props.
|
java.lang.String |
put(java.lang.String key,
java.lang.Double value)
Put Double.
|
java.lang.String |
put(java.lang.String key,
java.lang.Integer value)
Put integer
|
java.lang.String |
put(java.lang.String key,
java.lang.Long value)
Put Long.
|
java.lang.String |
put(java.lang.String key,
java.lang.String value)
Put the given string value for the string key.
|
void |
putAll(java.util.Map<? extends java.lang.String,? extends java.lang.String> m)
Put everything in the map into the props.
|
void |
putAll(Props p)
Put all properties in the props into the current props.
|
void |
putLocal(Props p)
Puts only the local props from p into the current properties
|
java.lang.String |
removeLocal(java.lang.Object s)
Remove only the local value of key s, and not the parents.
|
void |
setEarliestAncestor(Props parent)
Set the Props Object as the root of this Props Object
|
void |
setParent(Props prop) |
Props |
setSource(java.lang.String source)
Set Source information
|
int |
size()
The number of unique keys defined by this Props and all parent Props
|
void |
storeFlattened(java.io.File file)
Store all properties, those local and also those in parent props
|
void |
storeFlattened(java.io.OutputStream out)
Store all properties, those local and also those in parent props
|
void |
storeLocal(java.io.File file)
Store only those properties defined at this local level
|
void |
storeLocal(java.io.OutputStream out)
Store only those properties defined at this local level
|
java.util.Properties |
toAllProperties()
Returns a java.util.Properties file populated with both current and parent properties.
|
java.util.Properties |
toProperties()
Returns a java.util.Properties file populated with the current Properties in here.
|
java.lang.String |
toString()
override object's default toString function
|
public Props()
public Props(Props parent)
public Props(Props parent, java.lang.String filepath) throws java.io.IOException
java.io.IOExceptionpublic Props(Props parent, java.io.File file) throws java.io.IOException
java.io.IOExceptionpublic Props(Props parent, java.io.InputStream inputStream) throws java.io.IOException
java.io.IOExceptionpublic Props(Props parent, java.util.Map<java.lang.String,java.lang.String>... props)
public Props(Props parent, java.util.Properties... properties)
public static Props of(java.lang.String... args)
public static Props of(Props parent, java.lang.String... args)
public static Props getInstance(Props parent, Props current, java.lang.String source)
parent - parent propscurrent - current propssource - source valuepublic Props getEarliestAncestor()
public void setEarliestAncestor(Props parent)
parent - the earliest ancestor Props Objectpublic void clearLocal()
public boolean containsKey(java.lang.Object k)
public boolean containsValue(java.lang.Object value)
public java.lang.String get(java.lang.Object key)
public java.util.Set<java.lang.String> localKeySet()
public Props getParent()
public void setParent(Props prop)
public java.lang.String put(java.lang.String key,
java.lang.String value)
key - The key to put the value tovalue - The value to do substitution on and storejava.lang.IllegalArgumentException - If the variable given for substitution is not a valid key in
this Props.public void put(java.util.Properties properties)
properties - The properties to putjava.lang.IllegalArgumentException - If the variable given for substitution is not a valid key in
this Props.public java.lang.String put(java.lang.String key,
java.lang.Integer value)
public java.lang.String put(java.lang.String key,
java.lang.Long value)
public java.lang.String put(java.lang.String key,
java.lang.Double value)
public void putAll(java.util.Map<? extends java.lang.String,? extends java.lang.String> m)
public void putAll(Props p)
public void putLocal(Props p)
public java.lang.String removeLocal(java.lang.Object s)
public int size()
public int localSize()
public java.lang.Class<?> getClass(java.lang.String key)
public java.lang.Class<?> getClass(java.lang.String key,
boolean initialize,
java.lang.ClassLoader cl)
public java.lang.Class<?> getClass(java.lang.String key,
java.lang.Class<?> defaultClass)
public java.lang.String getString(java.lang.String key,
java.lang.String defaultValue)
public java.lang.String getString(java.lang.String key)
public java.util.List<java.lang.String> getStringList(java.lang.String key)
public java.util.List<java.lang.String> getStringListFromCluster(java.lang.String key)
public java.util.List<java.lang.String> getStringList(java.lang.String key,
java.lang.String sep)
public java.util.List<java.lang.String> getStringList(java.lang.String key,
java.util.List<java.lang.String> defaultValue)
public java.util.List<java.lang.String> getStringList(java.lang.String key,
java.util.List<java.lang.String> defaultValue,
java.lang.String sep)
public boolean getBoolean(java.lang.String key,
boolean defaultValue)
public boolean getBoolean(java.lang.String key)
public long getLong(java.lang.String name,
long defaultValue)
public long getLong(java.lang.String name)
public int getInt(java.lang.String name,
int defaultValue)
public int getInt(java.lang.String name)
public double getDouble(java.lang.String name,
double defaultValue)
public double getDouble(java.lang.String name)
public java.net.URI getUri(java.lang.String name)
public java.net.URI getUri(java.lang.String name,
java.lang.Boolean addTrailingSlash)
public java.net.URI getUri(java.lang.String name,
java.net.URI defaultValue)
public java.net.URI getUri(java.lang.String name,
java.net.URI defaultValue,
java.lang.Boolean addTrailingSlash)
public java.net.URI getUri(java.lang.String name,
java.lang.String defaultValue)
public void storeLocal(java.io.File file)
throws java.io.IOException
file - The file to write tojava.io.IOException - If the file can't be found or there is an io errorpublic Props local()
public void storeLocal(java.io.OutputStream out)
throws java.io.IOException
out - The output stream to write tojava.io.IOException - If the file can't be found or there is an io errorpublic java.util.Properties toProperties()
public java.util.Properties toAllProperties()
public void storeFlattened(java.io.File file)
throws java.io.IOException
file - The file to store tojava.io.IOException - If there is an error writingpublic void storeFlattened(java.io.OutputStream out)
throws java.io.IOException
out - The stream to write tojava.io.IOException - If there is an error writingpublic java.util.Map<java.lang.String,java.lang.String> getFlattened()
public java.util.Map<java.lang.String,java.lang.String> getMapByPrefix(java.lang.String prefix)
prefix - the prefix stringpublic java.util.Set<java.lang.String> getKeySet()
public void logProperties(org.apache.log4j.Logger logger,
java.lang.String comment)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getSource()
public Props setSource(java.lang.String source)