001: /*
002: * TryBlock.java Copyright (c) 2006,07 Swaroop Belur
003: *
004: * This program is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU General Public License
006: * as published by the Free Software Foundation; either version 2
007: * of the License, or (at your option) any later version.
008:
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013:
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
017: *
018: */
019:
020: package net.sf.jdec.blocks;
021:
022: import java.util.ArrayList;
023:
024: import net.sf.jdec.constantpool.MethodInfo.ExceptionTable;
025: import net.sf.jdec.constantpool.MethodInfo;
026:
027: public class TryBlock implements TryCatchFinally {
028:
029: private final java.lang.String type = "try";
030: private int numberOfCatchBlks = -1;
031: private boolean hasCatchBlk = false;
032: private boolean hasFinallyBlk = false;
033: private TryBlock parentTry = null;
034: private TryBlock[] tryKids = null;
035: private TryCatchFinally nextBlock = null;
036: private int start = -1;
037: private int end = -1;
038: private ArrayList allCatchesForThisTry = new ArrayList();
039: private FinallyBlock finallyBlock = null;
040: private ExceptionTable tableUsedToCreateTry = null;
041:
042: public MethodInfo.ExceptionTable getBiggestTableUsedToCreateTry() {
043: return biggestTableUsedToCreateTry;
044: }
045:
046: public void setBiggestTableUsedToCreateTry(
047: MethodInfo.ExceptionTable biggestTableUsedToCreateTry) {
048: this .biggestTableUsedToCreateTry = biggestTableUsedToCreateTry;
049: }
050:
051: private ExceptionTable biggestTableUsedToCreateTry = null;
052:
053: public ExceptionTable getTableUsedToCreateTry() {
054: return tableUsedToCreateTry;
055: }
056:
057: public void setTableUsedToCreateTry(
058: ExceptionTable tableUsedToCreateTry) {
059: this .tableUsedToCreateTry = tableUsedToCreateTry;
060: }
061:
062: public int getEnd() {
063: return end;
064: }
065:
066: public void setEnd(int end) {
067: this .end = end;
068: }
069:
070: public int getStart() {
071: return start;
072: }
073:
074: public void setStart(int start) {
075: this .start = start;
076: }
077:
078: public TryBlock() {
079: super ();
080: }
081:
082: public String getType() {
083:
084: return type;
085: }
086:
087: public boolean hasCatchBlk() {
088: return hasCatchBlk;
089: }
090:
091: public void setHasCatchBlk(boolean hasCatchBlk) {
092: this .hasCatchBlk = hasCatchBlk;
093: }
094:
095: public boolean hasFinallyBlk() {
096: return hasFinallyBlk;
097: }
098:
099: public void setHasFinallyBlk(boolean hasFinallyBlk) {
100: this .hasFinallyBlk = hasFinallyBlk;
101: }
102:
103: public int getNumberOfCatchBlks() {
104: return numberOfCatchBlks;
105: }
106:
107: public void setNumberOfCatchBlks(int numberOfCatchBlks) {
108: this .numberOfCatchBlks = numberOfCatchBlks;
109: }
110:
111: public TryBlock getParentTry() {
112: return parentTry;
113: }
114:
115: public void setParentTry(TryBlock parentTry) {
116: this .parentTry = parentTry;
117: }
118:
119: public TryBlock[] getTryKids() {
120: return tryKids;
121: }
122:
123: public void setTryKids(TryBlock[] tryKids) {
124: this .tryKids = tryKids;
125: }
126:
127: public TryCatchFinally getNextBlock() {
128: return nextBlock;
129: }
130:
131: public void setNextBlock(TryCatchFinally nextBlock) {
132: this .nextBlock = nextBlock;
133: }
134:
135: public void addCatchBlk(CatchBlock Catch) {
136: allCatchesForThisTry.add(Catch);
137: }
138:
139: public ArrayList getAllCatchesForThisTry() {
140: return allCatchesForThisTry;
141: }
142:
143: public FinallyBlock getFinallyBlock() {
144: return finallyBlock;
145: }
146:
147: public void setFinallyBlock(FinallyBlock finallyBlock) {
148: this .finallyBlock = finallyBlock;
149: }
150:
151: public CatchBlock getLastCatchBlock() {
152: CatchBlock catchblock = null;
153: if (this .getAllCatchesForThisTry().size() == 0)
154: return null;
155: else {
156: return (CatchBlock) this .getAllCatchesForThisTry().get(
157: this .getAllCatchesForThisTry().size() - 1);
158: }
159: }
160:
161: }
|