01: package org.drools.lang.descr;
02:
03: import java.util.Iterator;
04: import java.util.LinkedList;
05: import java.util.List;
06:
07: public class AccessorDescr extends DeclarativeInvokerDescr {
08:
09: private static final long serialVersionUID = 400L;
10:
11: private String variableName;
12: private LinkedList invokers;
13:
14: public AccessorDescr() {
15: this (null);
16: }
17:
18: public AccessorDescr(final String rootVariableName) {
19: super ();
20: this .variableName = rootVariableName;
21: this .invokers = new LinkedList();
22: }
23:
24: public DeclarativeInvokerDescr[] getInvokersAsArray() {
25: return (DeclarativeInvokerDescr[]) this .invokers
26: .toArray(new DeclarativeInvokerDescr[0]);
27: }
28:
29: public List getInvokers() {
30: return this .invokers;
31: }
32:
33: public void addInvoker(final DeclarativeInvokerDescr accessor) {
34: this .invokers.add(accessor);
35: }
36:
37: public void addFirstInvoker(final DeclarativeInvokerDescr accessor) {
38: this .invokers.addFirst(accessor);
39: }
40:
41: public String getVariableName() {
42: return this .variableName;
43: }
44:
45: public void setVariableName(final String methodName) {
46: this .variableName = methodName;
47: }
48:
49: public String toString() {
50: final StringBuffer buf = new StringBuffer();
51: buf
52: .append((this .variableName != null) ? this .variableName
53: : "");
54: for (final Iterator it = this .invokers.iterator(); it.hasNext();) {
55: if (buf.length() > 0) {
56: buf.append(".");
57: }
58: buf.append(it.next().toString());
59: }
60: return buf.toString();
61: }
62:
63: }
|