01: package org.drools.eclipse.core;
02:
03: import org.eclipse.core.resources.IFile;
04:
05: /**
06: * This represents a drools model element. It is linked to its direct
07: * parents and its children. If relevant, Drools model elements refer
08: * to the file they are defined in and the offset and length of that
09: * element in the file.
10: *
11: * @author <a href="mailto:kris_verlaenen@hotmail.com">kris verlaenen </a>
12: */
13: public abstract class DroolsElement {
14:
15: public static final int RULESET = 0;
16: public static final int PACKAGE = 1;
17: public static final int RULE = 2;
18: public static final int QUERY = 3;
19: public static final int FUNCTION = 4;
20: public static final int TEMPLATE = 5;
21: public static final int EXPANDER = 6;
22: public static final int GLOBAL = 7;
23: public static final int IMPORT = 8;
24: public static final int RULE_ATTRIBUTE = 9;
25:
26: protected static final DroolsElement[] NO_ELEMENTS = new DroolsElement[0];
27:
28: private DroolsElement parent;
29: private IFile file;
30: private int offset;
31: private int length;
32:
33: protected DroolsElement(DroolsElement parent) {
34: this .parent = parent;
35: }
36:
37: public abstract int getType();
38:
39: public DroolsElement getParent() {
40: return parent;
41: }
42:
43: public abstract DroolsElement[] getChildren();
44:
45: public IFile getFile() {
46: return file;
47: }
48:
49: public int getOffset() {
50: return offset;
51: }
52:
53: public int getLength() {
54: return length;
55: }
56:
57: // These are helper methods for creating the model and should not
58: // be used directly. Use DroolsModelBuilder instead.
59:
60: void setFile(IFile file, int offset, int length) {
61: this.file = file;
62: this.offset = offset;
63: this.length = length;
64: }
65:
66: }
|