public class PropertiesParser extends Object
This is an utility calss used to parse the properties.
Constructor and Description |
---|
PropertiesParser(Properties props) |
Modifier and Type | Method and Description |
---|---|
boolean |
getBooleanProperty(String name) |
boolean |
getBooleanProperty(String name,
boolean def) |
byte |
getByteProperty(String name) |
byte |
getByteProperty(String name,
byte def) |
char |
getCharProperty(String name) |
char |
getCharProperty(String name,
char def) |
double |
getDoubleProperty(String name) |
double |
getDoubleProperty(String name,
double def) |
float |
getFloatProperty(String name) |
float |
getFloatProperty(String name,
float def) |
int[] |
getIntArrayProperty(String name) |
int[] |
getIntArrayProperty(String name,
int[] def) |
int |
getIntProperty(String name) |
int |
getIntProperty(String name,
int def) |
long |
getLongProperty(String name) |
long |
getLongProperty(String name,
long def) |
Properties |
getPropertyGroup(String prefix) |
Properties |
getPropertyGroup(String prefix,
boolean stripPrefix) |
Properties |
getPropertyGroup(String prefix,
boolean stripPrefix,
String[] excludedPrefixes)
Get all properties that start with the given prefix.
|
String[] |
getPropertyGroups(String prefix) |
short |
getShortProperty(String name) |
short |
getShortProperty(String name,
short def) |
String[] |
getStringArrayProperty(String name) |
String[] |
getStringArrayProperty(String name,
String[] def) |
String |
getStringProperty(String name)
Get the trimmed String value of the property with the given
name . |
String |
getStringProperty(String name,
String def)
Get the trimmed String value of the property with the given
name or the given default value if the value is
null or empty after trimming. |
Properties |
getUnderlyingProperties() |
public PropertiesParser(Properties props)
public Properties getUnderlyingProperties()
public String getStringProperty(String name)
name
. If the value the empty String (after
trimming), then it returns null.public String getStringProperty(String name, String def)
name
or the given default value if the value is
null or empty after trimming.public boolean getBooleanProperty(String name)
public boolean getBooleanProperty(String name, boolean def)
public byte getByteProperty(String name) throws NumberFormatException
NumberFormatException
public byte getByteProperty(String name, byte def) throws NumberFormatException
NumberFormatException
public char getCharProperty(String name)
public char getCharProperty(String name, char def)
public double getDoubleProperty(String name) throws NumberFormatException
NumberFormatException
public double getDoubleProperty(String name, double def) throws NumberFormatException
NumberFormatException
public float getFloatProperty(String name) throws NumberFormatException
NumberFormatException
public float getFloatProperty(String name, float def) throws NumberFormatException
NumberFormatException
public int getIntProperty(String name) throws NumberFormatException
NumberFormatException
public int getIntProperty(String name, int def) throws NumberFormatException
NumberFormatException
public int[] getIntArrayProperty(String name) throws NumberFormatException
NumberFormatException
public int[] getIntArrayProperty(String name, int[] def) throws NumberFormatException
NumberFormatException
public long getLongProperty(String name) throws NumberFormatException
NumberFormatException
public long getLongProperty(String name, long def) throws NumberFormatException
NumberFormatException
public short getShortProperty(String name) throws NumberFormatException
NumberFormatException
public short getShortProperty(String name, short def) throws NumberFormatException
NumberFormatException
public Properties getPropertyGroup(String prefix)
public Properties getPropertyGroup(String prefix, boolean stripPrefix)
public Properties getPropertyGroup(String prefix, boolean stripPrefix, String[] excludedPrefixes)
prefix
- The prefix for which to search. If it does not end in
a "." then one will be added to it for search purposes.stripPrefix
- Whether to strip off the given prefix
in the result's keys.excludedPrefixes
- Optional array of fully qualified prefixes to
exclude. For example if prefix
is "a.b.c", then
excludedPrefixes
might be "a.b.c.ignore".Properties
that start with the given prefix,
optionally have that prefix removed, and do not include properties
that start with one of the given excluded prefixes.Copyright 2001-2019, Terracotta, Inc.