propertieson steroids: containing all that is missing in JDK: UTF-8 support, macros, sections, profiles, fully configurable... and more! Properties are stored in one or more
*.propsfiles, but its architecture is open for any type of source.
.props. Still, Props is compatible with Java properties and knows to load
*.propertiesas well. Here is screenshot of a
UTF-8encoded. However, Jodd Props will always load Java's properties using
=) or colon (
:) are used to assign property values.
+=to append values (separated by comma) of properties with the same name.
;), or a sharp sign (
#) and extend to the end of a line. It doesn't have to be the first character of a line.
\) escapes the next character (e.g.,
\#is a literal
\\is a literal
\), the value is continued on the next line with a new line character included.
\\uXXXXis encoded as a character. Also
\fare encoded as characters as well.
Propsin many different ways: from a
Properties. Once loaded, props are ready for usage. Values can be looked up using the
getValue()method. This method always returns a
]. Properties following a section definition belong to that section. Section name is added as a prefix to section properties. Section ends with empty section definition
or with a new section start or end of the file.
>. One key may contain one or more profile definitions. Profile definition can exist anywhere in the key name, even in the middle of the word; however, it is a good practice to put them at the end.
deploy) and have no base value.
getBaseValue()method. Base properties are those that don't belong to any profile.
getValues()methods each and every time, Props allows defining so-called active profiles externally, in the same
propsfiles used for loading properties.
propsfiles - this way the configuration set can be changed (i.e. active profiles can be modified) without the need to recompile the code. Active profiles are defined under the special base key named
Hi!, since the active profile is
oneand contains 100 properties. The second profile is an inner property named
one.two. It contains only 1 property (
key1) - but all properties from its upper profile are available! What happens when Java code calls the following:
props.getValue("key1", "one.two")? Props will:
}. Here is a simple example:
Something nice. Macros can refer to any existing property key, no matter where it is defined.
useActiveProfilesWhenResolvingMacros. Here is an example:
fooprofile is set as active? Since
/foo, therefore the
data.pathis going to be set to
data.pathvalue is going to be
rootmacro will always use the
fooprofile regardless of the currently selected profiles. So
data.pathvalue would be always be:
skipDuplicatesByPosition()during iterator building.
<=to minimize duplication of the props. Above props can be written as: