001: /*
002: * Copyright (c) 2001-2007, Jean Tessier
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions
007: * are met:
008: *
009: * * Redistributions of source code must retain the above copyright
010: * notice, this list of conditions and the following disclaimer.
011: *
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: *
016: * * Neither the name of Jean Tessier nor the names of his contributors
017: * may be used to endorse or promote products derived from this software
018: * without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
021: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
022: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
023: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
024: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
027: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
028: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
029: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031: */
032:
033: package com.jeantessier.classreader;
034:
035: import java.util.*;
036:
037: public class MockVisitor extends VisitorBase {
038: private List<Classfile> visitedClassfiles = new LinkedList<Classfile>();
039: private List<ConstantValue_attribute> visitedConstantValue_attributes = new LinkedList<ConstantValue_attribute>();
040: private List<Code_attribute> visitedCode_attributes = new LinkedList<Code_attribute>();
041: private List<Exceptions_attribute> visitedExceptions_attributes = new LinkedList<Exceptions_attribute>();
042: private List<InnerClasses_attribute> visitedInnerClasses_attributes = new LinkedList<InnerClasses_attribute>();
043: private List<Synthetic_attribute> visitedSynthetic_attributes = new LinkedList<Synthetic_attribute>();
044: private List<SourceFile_attribute> visitedSourceFile_attributes = new LinkedList<SourceFile_attribute>();
045: private List<LineNumberTable_attribute> visitedLineNumberTable_attributes = new LinkedList<LineNumberTable_attribute>();
046: private List<LocalVariableTable_attribute> visitedLocalVariableTable_attributes = new LinkedList<LocalVariableTable_attribute>();
047: private List<Deprecated_attribute> visitedDeprecated_attributes = new LinkedList<Deprecated_attribute>();
048: private List<Custom_attribute> visitedCustom_attributes = new LinkedList<Custom_attribute>();
049: private List<Instruction> visitedInstructions = new LinkedList<Instruction>();
050: private List<ExceptionHandler> visitedExceptionHandlers = new LinkedList<ExceptionHandler>();
051: private List<InnerClass> visitedInnerClasses = new LinkedList<InnerClass>();
052: private List<LineNumber> visitedLineNumbers = new LinkedList<LineNumber>();
053: private List<LocalVariable> visitedLocalVariables = new LinkedList<LocalVariable>();
054:
055: public List<Classfile> getVisitedClassfiles() {
056: return visitedClassfiles;
057: }
058:
059: public List<ConstantValue_attribute> getVisitedConstantValue_attributes() {
060: return visitedConstantValue_attributes;
061: }
062:
063: public List<Code_attribute> getVisitedCode_attributes() {
064: return visitedCode_attributes;
065: }
066:
067: public List<Exceptions_attribute> getVisitedExceptions_attributes() {
068: return visitedExceptions_attributes;
069: }
070:
071: public List<InnerClasses_attribute> getVisitedInnerClasses_attributes() {
072: return visitedInnerClasses_attributes;
073: }
074:
075: public List<Synthetic_attribute> getVisitedSynthetic_attributes() {
076: return visitedSynthetic_attributes;
077: }
078:
079: public List<SourceFile_attribute> getVisitedSourceFile_attributes() {
080: return visitedSourceFile_attributes;
081: }
082:
083: public List<LineNumberTable_attribute> getVisitedLineNumberTable_attributes() {
084: return visitedLineNumberTable_attributes;
085: }
086:
087: public List<LocalVariableTable_attribute> getVisitedLocalVariableTable_attributes() {
088: return visitedLocalVariableTable_attributes;
089: }
090:
091: public List<Deprecated_attribute> getVisitedDeprecated_attributes() {
092: return visitedDeprecated_attributes;
093: }
094:
095: public List<Custom_attribute> getVisitedCustom_attributes() {
096: return visitedCustom_attributes;
097: }
098:
099: public List<Instruction> getVisitedInstructions() {
100: return visitedInstructions;
101: }
102:
103: public List<ExceptionHandler> getVisitedExceptionHandlers() {
104: return visitedExceptionHandlers;
105: }
106:
107: public List<InnerClass> getVisitedInnerClasses() {
108: return visitedInnerClasses;
109: }
110:
111: public List<LineNumber> getVisitedLineNumbers() {
112: return visitedLineNumbers;
113: }
114:
115: public List<LocalVariable> getVisitedLocalVariables() {
116: return visitedLocalVariables;
117: }
118:
119: public void visitClassfile(Classfile classfile) {
120: visitedClassfiles.add(classfile);
121:
122: super .visitClassfile(classfile);
123: }
124:
125: public void visitConstantValue_attribute(
126: ConstantValue_attribute attribute) {
127: visitedConstantValue_attributes.add(attribute);
128:
129: super .visitConstantValue_attribute(attribute);
130: }
131:
132: public void visitCode_attribute(Code_attribute attribute) {
133: visitedCode_attributes.add(attribute);
134:
135: super .visitCode_attribute(attribute);
136: }
137:
138: public void visitExceptions_attribute(Exceptions_attribute attribute) {
139: visitedExceptions_attributes.add(attribute);
140:
141: super .visitExceptions_attribute(attribute);
142: }
143:
144: public void visitInnerClasses_attribute(
145: InnerClasses_attribute attribute) {
146: visitedInnerClasses_attributes.add(attribute);
147:
148: super .visitInnerClasses_attribute(attribute);
149: }
150:
151: public void visitSynthetic_attribute(Synthetic_attribute attribute) {
152: visitedSynthetic_attributes.add(attribute);
153:
154: super .visitSynthetic_attribute(attribute);
155: }
156:
157: public void visitSourceFile_attribute(SourceFile_attribute attribute) {
158: visitedSourceFile_attributes.add(attribute);
159:
160: super .visitSourceFile_attribute(attribute);
161: }
162:
163: public void visitLineNumberTable_attribute(
164: LineNumberTable_attribute attribute) {
165: visitedLineNumberTable_attributes.add(attribute);
166:
167: super .visitLineNumberTable_attribute(attribute);
168: }
169:
170: public void visitLocalVariableTable_attribute(
171: LocalVariableTable_attribute attribute) {
172: visitedLocalVariableTable_attributes.add(attribute);
173:
174: super .visitLocalVariableTable_attribute(attribute);
175: }
176:
177: public void visitDeprecated_attribute(Deprecated_attribute attribute) {
178: visitedDeprecated_attributes.add(attribute);
179:
180: super .visitDeprecated_attribute(attribute);
181: }
182:
183: public void visitCustom_attribute(Custom_attribute attribute) {
184: visitedCustom_attributes.add(attribute);
185:
186: super .visitCustom_attribute(attribute);
187: }
188:
189: public void visitInstruction(Instruction helper) {
190: visitedInstructions.add(helper);
191:
192: super .visitInstruction(helper);
193: }
194:
195: public void visitExceptionHandler(ExceptionHandler helper) {
196: visitedExceptionHandlers.add(helper);
197:
198: super .visitExceptionHandler(helper);
199: }
200:
201: public void visitInnerClass(InnerClass helper) {
202: visitedInnerClasses.add(helper);
203:
204: super .visitInnerClass(helper);
205: }
206:
207: public void visitLineNumber(LineNumber helper) {
208: visitedLineNumbers.add(helper);
209:
210: super .visitLineNumber(helper);
211: }
212:
213: public void visitLocalVariable(LocalVariable helper) {
214: visitedLocalVariables.add(helper);
215:
216: super .visitLocalVariable(helper);
217: }
218:
219: public void reset() {
220: visitedClassfiles.clear();
221: visitedConstantValue_attributes.clear();
222: visitedCode_attributes.clear();
223: visitedExceptions_attributes.clear();
224: visitedInnerClasses_attributes.clear();
225: visitedSynthetic_attributes.clear();
226: visitedSourceFile_attributes.clear();
227: visitedLineNumberTable_attributes.clear();
228: visitedLocalVariableTable_attributes.clear();
229: visitedDeprecated_attributes.clear();
230: visitedCustom_attributes.clear();
231: visitedInstructions.clear();
232: visitedExceptionHandlers.clear();
233: visitedInnerClasses.clear();
234: visitedLineNumbers.clear();
235: visitedLocalVariables.clear();
236: }
237: }
|