01: /*
02: * @(#)UnresolvedReferenceList.java 1.4 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26: package util;
27:
28: import components.*;
29: import java.io.PrintStream;
30: import java.util.Enumeration;
31: import java.util.Hashtable;
32:
33: /*
34: * UnresolvedReferenceList tracks ConstantObjects
35: * which could not be resolved, as well as the
36: * classes in which they occur.
37: * It can print the results in a readable form.
38: */
39: public class UnresolvedReferenceList {
40: Hashtable refs = new Hashtable();
41:
42: public boolean hasUnresolvedReferences() {
43: return !refs.isEmpty();
44: }
45:
46: public void add(ConstantObject reference, String container) {
47: Hashtable containerList;
48: containerList = (Hashtable) refs.get(reference);
49: if (containerList == null) {
50: /* not in list. Make new entry */
51: containerList = new Hashtable();
52: refs.put(reference, containerList);
53: }
54: /* put container in container list */
55: containerList.put(container, container);
56: }
57:
58: public void print(PrintStream out) {
59: if (refs.isEmpty())
60: return;
61: Enumeration missingRefs = refs.keys();
62: out.println(Localizer
63: .getString("javacodecompact.unresolved_references"));
64: while (missingRefs.hasMoreElements()) {
65: ConstantObject obj = (ConstantObject) (missingRefs
66: .nextElement());
67: out.print(" " + (obj.prettyPrint()));
68: out.println(" "
69: + Localizer.getString("javacodecompact.from"));
70: Hashtable containerList = (Hashtable) (refs.get(obj));
71: Enumeration containers = containerList.elements();
72: while (containers.hasMoreElements()) {
73: String c = (String) (containers.nextElement());
74: out.println(" " + c);
75: }
76: }
77: }
78: }
|