01: package org.drools.eclipse.core;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: /**
07: * This represents a rule.
08: *
09: * @author <a href="mailto:kris_verlaenen@hotmail.com">kris verlaenen </a>
10: */
11: public class Rule extends DroolsElement {
12:
13: private final String ruleName;
14: private Map attributes = new HashMap();
15:
16: Rule(Package parent, String ruleName) {
17: super (parent);
18: this .ruleName = ruleName;
19: }
20:
21: public Package getParentPackage() {
22: return (Package) getParent();
23: }
24:
25: public String getRuleName() {
26: return ruleName;
27: }
28:
29: public RuleAttribute getAttribute(String attributeName) {
30: return (RuleAttribute) attributes.get(attributeName);
31: }
32:
33: public int getType() {
34: return RULE;
35: }
36:
37: public DroolsElement[] getChildren() {
38: return NO_ELEMENTS;
39: }
40:
41: public String toString() {
42: return ruleName;
43: }
44:
45: // These are helper methods for creating the model and should not
46: // be used directly. Use DroolsModelBuilder instead.
47:
48: void addAttribute(RuleAttribute attribute) {
49: attributes.put(attribute.getAttributeName(), attribute);
50: }
51:
52: }
|