KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonicsystems > jarjar > StringReader


1 /*
2   Jar Jar Links - A utility to repackage and embed Java libraries
3   Copyright (C) 2004 Tonic Systems, Inc.
4
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 2 of the License, or
8   (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   GNU General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with this program; see the file COPYING. if not, write to
17   the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18   Boston, MA 02111-1307 USA
19 */

20
21 package com.tonicsystems.jarjar;
22
23 import com.tonicsystems.jarjar.util.*;
24 import org.objectweb.asm.*;
25 import org.objectweb.asm.commons.EmptyVisitor;
26
27 class StringReader extends EmptyVisitor
28 {
29     private StringVisitor sv;
30     private int line = -1;
31
32     public StringReader(StringVisitor sv) {
33         this.sv = sv;
34     }
35
36     private void handleObject(Object JavaDoc value) {
37         if (value instanceof String JavaDoc)
38             sv.visitString((String JavaDoc)value, line);
39     }
40
41     public void visit(String JavaDoc name, Object JavaDoc value) {
42         handleObject(value);
43     }
44     
45     public void visitEnum(String JavaDoc name, String JavaDoc desc, String JavaDoc value) {
46         handleObject(value);
47     }
48     
49     public void visit(int version, int access, String JavaDoc name, String JavaDoc signature, String JavaDoc superName, String JavaDoc[] interfaces) {
50         line = -1;
51         sv.visitStart(name);
52     }
53
54     public void visitEnd() {
55         sv.visitEnd();
56     }
57
58     public FieldVisitor visitField(int access, String JavaDoc name, String JavaDoc desc, String JavaDoc signature, Object JavaDoc value) {
59         handleObject(value);
60         return this;
61     }
62
63     public void visitLdcInsn(Object JavaDoc cst) {
64         handleObject(cst);
65     }
66     
67     public void visitLineNumber(int line, Label start) {
68         StringReader.this.line = line;
69     }
70 }
71
Popular Tags