001: /*
002: * Copyright 2006 JBoss Inc
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: *
016: * Created on Jun 18, 2007
017: */
018: package org.drools.rule.builder.dialect.java.parser;
019:
020: import java.util.LinkedList;
021: import java.util.List;
022:
023: /**
024: * A descriptor class for a local variable declaration in a java code block
025: *
026: * @author etirelli
027: */
028: public class JavaLocalDeclarationDescr {
029: private int start;
030: private int end;
031: private String type;
032: private List modifiers;
033: private List identifiers;
034:
035: public JavaLocalDeclarationDescr() {
036: this (-1, -1, "");
037: }
038:
039: public JavaLocalDeclarationDescr(int start, int end, String type) {
040: this .start = start;
041: this .end = end;
042: this .type = type;
043: this .modifiers = new LinkedList();
044: this .identifiers = new LinkedList();
045: }
046:
047: public int getEnd() {
048: return end;
049: }
050:
051: public void setEnd(int finalOffset) {
052: this .end = finalOffset;
053: }
054:
055: public List getIdentifiers() {
056: return identifiers;
057: }
058:
059: public void setIdentifiers(List identifiers) {
060: this .identifiers = identifiers;
061: }
062:
063: public void addIdentifier(IdentifierDescr identifier) {
064: this .identifiers.add(identifier);
065: }
066:
067: public void addIdentifier(String identifier, int start, int end) {
068: this .identifiers
069: .add(new IdentifierDescr(identifier, start, end));
070: }
071:
072: public List getModifiers() {
073: return modifiers;
074: }
075:
076: public void setModifiers(List modifiers) {
077: this .modifiers = modifiers;
078: }
079:
080: public void addModifier(String modifier) {
081: this .modifiers.add(modifier);
082: }
083:
084: public int getStart() {
085: return start;
086: }
087:
088: public void setStart(int startingOffset) {
089: this .start = startingOffset;
090: }
091:
092: public void updateStart(int start) {
093: if (this .start == -1) {
094: this .setStart(start);
095: }
096: }
097:
098: public String getType() {
099: return type;
100: }
101:
102: public void setType(String type) {
103: this .type = type;
104: }
105:
106: public static class IdentifierDescr {
107: private String identifier;
108: private int start;
109: private int end;
110:
111: public IdentifierDescr() {
112: this ("", -1, -1);
113: }
114:
115: public IdentifierDescr(String identifier, int start, int end) {
116: this .identifier = identifier;
117: this .start = start;
118: this .end = end;
119: }
120:
121: public int getEnd() {
122: return end;
123: }
124:
125: public void setEnd(int end) {
126: this .end = end;
127: }
128:
129: public String getIdentifier() {
130: return identifier;
131: }
132:
133: public void setIdentifier(String identifier) {
134: this .identifier = identifier;
135: }
136:
137: public int getStart() {
138: return start;
139: }
140:
141: public void setStart(int start) {
142: this.start = start;
143: }
144: }
145:
146: }
|