001: /*
002: * @(#)MemberDependenceNode.java 1.12 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027:
028: package dependenceAnalyzer;
029:
030: import util.Set;
031: import java.util.*;
032: import util.EmptyEnumeration;
033:
034: public class MemberDependenceNode extends DependenceNode {
035:
036: /*
037: * Flag values.
038: */
039: public static final int EXCLUDED = 1;
040: public static final int REQUIRED = 2;
041:
042: public static final int STATIC = 4;
043: public static final int PRIVATE = 8;
044: public static final int METHOD = 16;
045: public static final int FIELD = 32;
046: public static final int INIT = 64;
047: public static final int CLINIT = 128;
048: public static final int OVERRIDDEN = 256;
049: public static final int IMPUTED = 512;
050: public static final int NATIVE = 1024;
051:
052: // a mask
053: public static final int NO_OVERRIDING = STATIC | PRIVATE | FIELD
054: | INIT | CLINIT;
055:
056: /*
057: * Constructor.
058: */
059: public MemberDependenceNode(Object nm, int flagval) {
060: super (nm);
061: flags = flagval;
062: }
063:
064: /*
065: * Public methods.
066: */
067: public Enumeration overrides() {
068: if (memberOverrides == null)
069: return EmptyEnumeration.instance;
070: return memberOverrides.elements();
071: }
072:
073: public Enumeration overriddenBy() {
074: if (memberOverriddenBy == null)
075: return EmptyEnumeration.instance;
076: return memberOverriddenBy.elements();
077: }
078:
079: /*
080: * These are all package-visible parts of the implementation.
081: */
082: Set memberOverriddenBy;
083: Set memberOverrides;
084:
085: public void dump(java.io.PrintStream o) {
086: for (int j = 0; j < 16; j++) {
087: switch (flags & (1 << j)) {
088: case EXCLUDED:
089: o.print("Excluded ");
090: break;
091: case REQUIRED:
092: o.print("Required ");
093: break;
094: case STATIC:
095: o.print("static ");
096: break;
097: case PRIVATE:
098: o.print("private ");
099: break;
100: case METHOD:
101: o.print("method ");
102: break;
103: case FIELD:
104: o.print("field ");
105: break;
106: case INIT:
107: o.print("constructor ");
108: break;
109: case CLINIT:
110: o.print("static initializer ");
111: break;
112: case OVERRIDDEN:
113: o.print("overridden ");
114: break;
115: case IMPUTED:
116: o.print("imputed ");
117: break;
118: case NATIVE:
119: o.print("native ");
120: break;
121: }
122: }
123: o.println(nodeName.toString());
124: if (memberOverriddenBy != null) {
125: o.println(" is overridden " + memberOverriddenBy.size()
126: + " times");
127: }
128: }
129:
130: }
|