001: /*
002: * @(#)DependenceNode.java 1.13 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 java.util.Enumeration;
031: import util.Set;
032:
033: /*
034: * A DependenceNode represents an element in the dependence graph.
035: * It will be extended by a more specific node type, depending on
036: * whether we are doing class-level or class-member-level
037: * dependence analysis.
038: */
039: public abstract class DependenceNode {
040: /*
041: * A DependenceNode is in one of three states:
042: * UNANALYZED -- it has a name and may have a list of dependents.
043: * it cannot have a dependence list. Intuitively,
044: * we haven't looked at any class file yet, so don't
045: * even know if it exists!
046: * ANALYZED -- a class file has been found and analyzed. The
047: * dependence list is complete.
048: * ERROR -- tried to analyze. Could not. Generally, could not
049: * find an appropriate class file.
050: * PRIMITIVE -- primitive type
051: */
052: public static final int UNANALYZED = 0;
053: public static final int ANALYZED = 1;
054: public static final int ERROR = 2;
055: public static final int PRIMITIVE = 3;
056:
057: public int state() {
058: return nodeState;
059: }
060:
061: /*
062: * The meaning of a node's name depends on the level of analysis
063: * we're doing. It will be either a fully-qualified class name,
064: * or it will be a member-name-with-signature using the usual
065: * conventions.
066: */
067: public Object name() {
068: return nodeName;
069: }
070:
071: /*
072: * The dependence lists are Enumerations yielding
073: * DependenceArc's. See below.
074: */
075: public Enumeration dependsOn() {
076: return nodeDependsOn.elements();
077: }
078:
079: public Enumeration dependedOn() {
080: return nodeDependedOn.elements();
081: }
082:
083: /*
084: * The following word is for use of clients.
085: * Flags such as "must load" or "must exclude" can be
086: * put here.
087: */
088: public int flags = 0;
089:
090: /*
091: * Actual state. Package scope. Manipulated by dependenceAnalyzer.
092: */
093: int nodeState = UNANALYZED;
094: Object nodeName;
095: Set nodeDependsOn;
096: Set nodeDependedOn;
097:
098: protected DependenceNode(Object myName) {
099: nodeName = myName;
100: nodeDependsOn = new Set();
101: nodeDependedOn = new Set();
102: }
103:
104: }
|