|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjodd.props.Props
public class Props
Super properties: fast, configurable, supports (ini) sections, profiles.
Basic parsing rules:
| Field Summary | |
|---|---|
protected java.lang.String[] |
activeProfiles
|
protected java.lang.String |
activeProfilesProp
|
protected PropsData |
data
|
protected boolean |
initialized
|
protected PropsParser |
parser
|
| Constructor Summary | |
|---|---|
|
Props()
Creates new props. |
protected |
Props(PropsParser parser)
|
| Method Summary | |
|---|---|
protected Props |
clone()
Clones props by creating new instance and copying current configuration. |
int |
countTotalProperties()
Counts the total number of properties, including all profiles. |
void |
extractBaseProps(java.util.Map target)
Extract base props (no profiles). |
void |
extractBaseSubProps(java.util.Map target,
java.lang.String... wildcardPatterns)
|
void |
extractProps(java.util.Map target)
Extracts props belonging to active profiles. |
void |
extractProps(java.util.Map target,
java.lang.String... profiles)
Extract props of given profiles. |
void |
extractSubProps(java.util.Map target,
java.lang.String... wildcardPatterns)
|
void |
extractSubProps(java.util.Map target,
java.lang.String[] profiles,
java.lang.String[] wildcardPatterns)
|
java.lang.String[] |
getActiveProfiles()
Returns active profiles or null if none defined. |
java.lang.String |
getBaseValue(java.lang.String key)
Returns string value of base property. |
java.lang.String |
getValue(java.lang.String key)
Returns value of property, using active profiles. |
java.lang.String |
getValue(java.lang.String key,
java.lang.String... profiles)
Returns string value of given profiles. |
protected void |
initialize()
Initializes props by replacing macros in values with the lookup values. |
void |
load(java.io.File file)
Loads props from the file. |
void |
load(java.io.File file,
java.lang.String encoding)
Loads properties from the file in provided encoding. |
void |
load(java.io.InputStream in)
Loads properties from input stream. |
void |
load(java.io.InputStream in,
java.lang.String encoding)
Loads properties from input stream and provided encoding. |
void |
load(java.util.Map<?,?> p)
Loads base properties from the provided java properties. |
void |
load(java.util.Map<?,?> map,
java.lang.String prefix)
Loads base properties from java Map using provided prefix. |
void |
load(java.lang.String data)
Loads props from the string. |
void |
loadEnvironment(java.lang.String prefix)
Loads environment properties with given prefix. |
void |
loadSystemProperties(java.lang.String prefix)
Loads system properties with given prefix. |
protected void |
parse(java.lang.String data)
Parses input string and loads provided properties map. |
protected void |
resolveActiveProfiles()
Resolves active profiles from property. |
void |
setActiveProfiles(java.lang.String... activeProfiles)
Overrides active profiles. |
void |
setAppendDuplicateProps(boolean appendDuplicateProps)
Appends duplicate props. |
void |
setEscapeNewLineValue(java.lang.String escapeNewLineValue)
Specifies the new line string when EOL is escaped. |
void |
setIgnorePrefixWhitespacesOnNewLine(boolean ignorePrefixWhitespacesOnNewLine)
Defines if the prefix whitespaces should be ignored when value is split into the lines. |
void |
setMultilineValues(boolean multilineValues)
Enables multiline values. |
void |
setSkipEmptyProps(boolean skipEmptyProps)
Skips empty properties. |
void |
setValue(java.lang.String key,
java.lang.String value)
Sets default value. |
void |
setValue(java.lang.String key,
java.lang.String value,
java.lang.String profile)
Sets value on some profile. |
void |
setValueTrimLeft(boolean valueTrimLeft)
Specifies should the values be trimmed from the left. |
void |
setValueTrimRight(boolean valueTrimRight)
Specifies should the values be trimmed from the right. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final PropsParser parser
protected final PropsData data
protected java.lang.String activeProfilesProp
protected java.lang.String[] activeProfiles
protected volatile boolean initialized
| Constructor Detail |
|---|
public Props()
protected Props(PropsParser parser)
| Method Detail |
|---|
protected Props clone()
clone in class java.lang.Objectpublic java.lang.String[] getActiveProfiles()
null if none defined.
public void setActiveProfiles(java.lang.String... activeProfiles)
public void setEscapeNewLineValue(java.lang.String escapeNewLineValue)
public void setValueTrimLeft(boolean valueTrimLeft)
true.
public void setValueTrimRight(boolean valueTrimRight)
true.
public void setIgnorePrefixWhitespacesOnNewLine(boolean ignorePrefixWhitespacesOnNewLine)
public void setSkipEmptyProps(boolean skipEmptyProps)
public void setAppendDuplicateProps(boolean appendDuplicateProps)
public void setMultilineValues(boolean multilineValues)
protected void parse(java.lang.String data)
public void load(java.lang.String data)
public void load(java.io.File file)
throws java.io.IOException
java.io.IOException
public void load(java.io.File file,
java.lang.String encoding)
throws java.io.IOException
java.io.IOException
public void load(java.io.InputStream in)
throws java.io.IOException
java.io.IOException
public void load(java.io.InputStream in,
java.lang.String encoding)
throws java.io.IOException
java.io.IOExceptionpublic void load(java.util.Map<?,?> p)
public void load(java.util.Map<?,?> map,
java.lang.String prefix)
public void loadSystemProperties(java.lang.String prefix)
null it will not be ignored.
public void loadEnvironment(java.lang.String prefix)
null it will not be used.
public int countTotalProperties()
public java.lang.String getBaseValue(java.lang.String key)
string value of base property.
Returns null if property doesn't exist.
public java.lang.String getValue(java.lang.String key)
public java.lang.String getValue(java.lang.String key,
java.lang.String... profiles)
string value of given profiles. If key is not
found under listed profiles, base properties will be searched.
Returns null if property doesn't exist.
public void setValue(java.lang.String key,
java.lang.String value)
public void setValue(java.lang.String key,
java.lang.String value,
java.lang.String profile)
public void extractBaseProps(java.util.Map target)
public void extractProps(java.util.Map target)
public void extractProps(java.util.Map target,
java.lang.String... profiles)
public void extractBaseSubProps(java.util.Map target,
java.lang.String... wildcardPatterns)
public void extractSubProps(java.util.Map target,
java.lang.String... wildcardPatterns)
public void extractSubProps(java.util.Map target,
java.lang.String[] profiles,
java.lang.String[] wildcardPatterns)
protected void initialize()
protected void resolveActiveProfiles()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||