| Macro Property Parser |
|
MacroPropertyParser (com.javelin.util.MacroPropertyParser) The MacroPropertyParser is a powerful macro expander that allows complex patterns to be simplified. One of the requirements of the PropertiesReader is that we must specify a number of classes for each table. The declaration of these classes in the property file always follows the same pattern (e.g. <ClassName>Home, <ClassName>Bean). Using the MacroPropertyParser enables all these classes to be expressed without explicitly declaring every property. |
|
Keys and Values $XXX on the left hand side of the = means we are creating a value that will be referred to elsewhere. We call the left hand side the 'key' $XXX on the right hand side of the equals is a reference to the above value and will be substituted. We call the right hand side the 'value' e.g. $PET=Dog property becomes "I love my pet Dog" |
|
THIS $THIS as a value is a reference to key e.g. Address=public interface $THIS Address becomes "public interface Address" You can also use $THIS1-$THIS9 which refer to key, separated by . e.g. Address.name=$THIS2_$THIS1 becomes Address.name=name_Address |
|
CREATE $CREATE as a value is a special command that lets you create more property values e.g. stuff=$CREATE dog=1,cat=2 becomes cat=2 |
|
SELF Now we can use another special value $SELF, which is like $THIS but for $CREATE lines. e.g. stuff=$CREATE $SELF.dog=1,$SELF.cat=2 becomes stuff.cat=2 Like $THIS, we have $SELF1-$SELF9 e.g. stuff.name=$CREATE $SELF=dog,$SELF1.hates=cat becomes stuff.hates=cat You may be wondering why we don't simply use $THIS with $CREATE This is to allow more complex expansions. $SELF is handled first, and $THIS last of all. This allows us to do things like this: e.g. stuff.name=$CREATE $SELF=dog,$SELF1.hates=cat,$SELF1Bean.class=public
class becomes stuffBean.class=public class stuffBean Without the separation of $SELF and $THIS, we'd never be able to get
the properties that we $CREATE to refer to themselves (via $THIS), instead
of referring to |
|
VALUEOF_ We also have a $VALUEOF_ function that lets us get the value of a property, as opposed to a value that we have created with a $ method. E.g. stuff.name=dog XXX becomes "dog" I could have said stuff.name=$stuff.name but sometimes you don't want to have to create $ values so that you can
refer to them multiple times, sometimes its easier to simply us $VALUEOF_ |
|
INCLUDE_ Extra properties file can be included, relative the the properties file. For example for common codes (e..g ISO Country Codes). $INCLUDE=file1.txt[,file2.txt ...] |