01: /*
02: * Copyright 2006 JBoss Inc
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: *
16: * Created on May 22, 2007
17: */
18: package org.drools.lang;
19:
20: import java.util.HashMap;
21: import java.util.Map;
22:
23: /**
24: * A class to hold contextual information during DRL parsing
25: *
26: * @author etirelli, krisv
27: */
28: public class Location {
29:
30: public static final int LOCATION_UNKNOWN = 0;
31:
32: public static final int LOCATION_LHS_BEGIN_OF_CONDITION = 1;
33: public static final int LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS = 2;
34: public static final int LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR = 3;
35: public static final int LOCATION_LHS_BEGIN_OF_CONDITION_NOT = 4;
36:
37: public static final int LOCATION_LHS_INSIDE_CONDITION_START = 100;
38: public static final int LOCATION_LHS_INSIDE_CONDITION_OPERATOR = 101;
39: public static final int LOCATION_LHS_INSIDE_CONDITION_ARGUMENT = 102;
40: public static final int LOCATION_LHS_INSIDE_CONDITION_END = 103;
41:
42: public static final int LOCATION_LHS_INSIDE_EVAL = 200;
43:
44: public static final int LOCATION_LHS_FROM = 300;
45: public static final int LOCATION_LHS_FROM_COLLECT = 301;
46: public static final int LOCATION_LHS_FROM_ACCUMULATE = 302;
47: public static final int LOCATION_LHS_FROM_ACCUMULATE_INIT = 303;
48: public static final int LOCATION_LHS_FROM_ACCUMULATE_INIT_INSIDE = 304;
49: public static final int LOCATION_LHS_FROM_ACCUMULATE_ACTION = 305;
50: public static final int LOCATION_LHS_FROM_ACCUMULATE_ACTION_INSIDE = 306;
51: public static final int LOCATION_LHS_FROM_ACCUMULATE_REVERSE = 307;
52: public static final int LOCATION_LHS_FROM_ACCUMULATE_REVERSE_INSIDE = 308;
53: public static final int LOCATION_LHS_FROM_ACCUMULATE_RESULT = 309;
54: public static final int LOCATION_LHS_FROM_ACCUMULATE_RESULT_INSIDE = 310;
55:
56: public static final int LOCATION_RHS = 1000;
57: public static final int LOCATION_RULE_HEADER = 2000;
58:
59: public static final String LOCATION_PROPERTY_CLASS_NAME = "ClassName";
60: public static final String LOCATION_PROPERTY_PROPERTY_NAME = "PropertyName";
61: public static final String LOCATION_PROPERTY_OPERATOR = "Operator";
62: public static final String LOCATION_EVAL_CONTENT = "EvalContent";
63: public static final String LOCATION_FROM_CONTENT = "FromContent";
64: public static final String LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT = "FromAccumulateInitContent";
65: public static final String LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT = "FromAccumulateActionContent";
66: public static final String LOCATION_PROPERTY_FROM_ACCUMULATE_REVERSE_CONTENT = "FromAccumulateReverseContent";
67: public static final String LOCATION_PROPERTY_FROM_ACCUMULATE_RESULT_CONTENT = "FromAccumulateResultContent";
68: public static final String LOCATION_PROPERTY_FROM_ACCUMULATE_EXPRESSION_CONTENT = "FromAccumulateExpressionContent";
69: public static final String LOCATION_LHS_CONTENT = "LHSContent";
70: public static final String LOCATION_RHS_CONTENT = "RHSContent";
71: public static final String LOCATION_HEADER_CONTENT = "HeaderContent";
72:
73: private int type;
74: private Map properties = new HashMap();
75:
76: public Location(int type) {
77: this .type = type;
78: }
79:
80: public int getType() {
81: return type;
82: }
83:
84: public void setProperty(String name, Object value) {
85: properties.put(name, value);
86: }
87:
88: public Object getProperty(String name) {
89: return properties.get(name);
90: }
91:
92: public void setType(int type) {
93: this.type = type;
94: }
95: }
|