Default implementation of the Rules interface that supports the standard rule matching behavior. This class can also be used as a base class for specialized Rules implementations. The matching policies implemented by this class support two different types of pa
| 36 | * </ul> |
| 37 | */ |
| 38 | public class RulesBase implements Rules { |
| 39 | |
| 40 | /** |
| 41 | * Default constructor. |
| 42 | */ |
| 43 | public RulesBase() { |
| 44 | } |
| 45 | |
| 46 | // ----------------------------------------------------- Instance Variables |
| 47 | |
| 48 | /** |
| 49 | * The set of registered Rule instances, keyed by the matching pattern. Each value is a List containing the Rules |
| 50 | * for that pattern, in the order that they were originally registered. |
| 51 | */ |
| 52 | protected HashMap<String,List<Rule>> cache = new HashMap<>(); |
| 53 | |
| 54 | |
| 55 | /** |
| 56 | * The Digester instance with which this Rules instance is associated. |
| 57 | */ |
| 58 | protected Digester digester = null; |
| 59 | |
| 60 | |
| 61 | /** |
| 62 | * The set of registered Rule instances, in the order that they were originally registered. |
| 63 | */ |
| 64 | protected ArrayList<Rule> rules = new ArrayList<>(); |
| 65 | |
| 66 | |
| 67 | // ------------------------------------------------------------- Properties |
| 68 | |
| 69 | /** |
| 70 | * Return the Digester instance with which this Rules instance is associated. |
| 71 | */ |
| 72 | @Override |
| 73 | public Digester getDigester() { |
| 74 | return this.digester; |
| 75 | } |
| 76 | |
| 77 | |
| 78 | /** |
| 79 | * Set the Digester instance with which this Rules instance is associated. |
| 80 | * |
| 81 | * @param digester The newly associated Digester instance |
| 82 | */ |
| 83 | @Override |
| 84 | public void setDigester(Digester digester) { |
| 85 | this.digester = digester; |
| 86 | for (Rule item : rules) { |
| 87 | item.setDigester(digester); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | |
| 92 | // --------------------------------------------------------- Public Methods |
| 93 | |
| 94 | /** |
| 95 | * Register a new Rule instance matching the specified pattern. |
nothing calls this directly
no outgoing calls
no test coverage detected