Part of Macker's power is its ability to apply rules to a whole categories of classes which have certain roles or characteristics. Macker relies on you to use naming and packaging conventions to make these roles and layers well-defined -- the programmer still has to think a bit about what they're doing! (Macker will is also able to look at some attributes other than name; see filters. Strong AI which intuits the role of a particular class, however, is not currently in scope.)
At the heart of class categorization is a simple regular expression syntax, governed by just a few rules:
java.lang.String
").
java
", "lang
", "String
"). The wildcard *
matches zero or more characters within a part, while **
matches across part boundaries.
**
prefix and suffix.)
Here are a few examples to give you the idea:
This regex... | ...will match these classes... | ...but not these. |
---|---|---|
java.lang.* | java.lang.String | java.lang.reflect.Method
java.language.MadeUpClass |
java.lang.** | java.lang.String
java.lang.reflect.Method |
java.language.MadeUpClass |
java.lang** | java.lang.String
java.lang.reflect.Method java.language.MadeUpClass |
|
String | String (a hypothetical class named "String" not in a package) |
java.lang.String (the actual Java language String class) |
java.lang.String | java.lang.String | String |
*String* | String | java.lang.String
java.lang.StringBuffer java.text.AttributedString |
**String* | String
java.lang.String java.lang.StringBuffer java.text.AttributedString |
|
**String | String
java.lang.String java.text.AttributedString |
java.lang.StringBuffer |
**.String* | String
java.lang.String java.lang.StringBuffer |
java.text.AttributedString |
Note that the Macker regex syntax currently does not support any sort of "OR" construct. This is because one can accomplish the same thing using composite patterns (explained in the next section). I might consider adding this functionality to the actual regex syntax if there is demand for it.
Macker does not currently support any alternate regex syntaxes. In the future, it will include support for Java regex and/or Apache regexp. (Although Macker currently uses Apache regexp internally, I'm holding off on exposing its syntax as part of Macker's published API.)