001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: /*
027: * The contents of this file are subject to the Sun Public License
028: * Version 1.0 (the "License"); you may not use this file except in
029: * compliance with the License. A copy of the License is available at
030: * http://www.sun.com/, and in the file LICENSE.html in the
031: * doc directory.
032: *
033: * The Original Code is HAT. The Initial Developer of the
034: * Original Code is Bill Foote, with contributions from others
035: * at JavaSoft/Sun. Portions created by Bill Foote and others
036: * at Javasoft/Sun are Copyright (C) 1997-2004. All Rights Reserved.
037: *
038: * In addition to the formal license, I ask that you don't
039: * change the history or donations files without permission.
040: *
041: */
042:
043: package com.sun.tools.hat.internal.server;
044:
045: import java.util.Vector;
046:
047: import com.sun.tools.hat.internal.model.*;
048: import com.sun.tools.hat.internal.util.ArraySorter;
049: import com.sun.tools.hat.internal.util.Comparer;
050:
051: /**
052: *
053: * @version 1.4, 03/06/98 [jhat @(#)AllRootsQuery.java 1.8 07/05/05]
054: * @author Bill Foote
055: */
056:
057: class AllRootsQuery extends QueryHandler {
058:
059: public AllRootsQuery() {
060: }
061:
062: public void run() {
063: startHtml("All Members of the Rootset");
064:
065: Root[] roots = snapshot.getRootsArray();
066: ArraySorter.sort(roots, new Comparer() {
067: public int compare(Object lhs, Object rhs) {
068: Root left = (Root) lhs;
069: Root right = (Root) rhs;
070: int d = left.getType() - right.getType();
071: if (d != 0) {
072: return -d; // More interesting values are *higher*
073: }
074: return left.getDescription().compareTo(
075: right.getDescription());
076: }
077: });
078:
079: int lastType = Root.INVALID_TYPE;
080:
081: for (int i = 0; i < roots.length; i++) {
082: Root root = roots[i];
083:
084: if (root.getType() != lastType) {
085: lastType = root.getType();
086: out.print("<h2>");
087: print(root.getTypeName() + " References");
088: out.println("</h2>");
089: }
090:
091: printRoot(root);
092: if (root.getReferer() != null) {
093: out.print("<small> (from ");
094: printThingAnchorTag(root.getReferer().getId());
095: print(root.getReferer().toString());
096: out.print(")</a></small>");
097: }
098: out.print(" :<br>");
099:
100: JavaThing t = snapshot.findThing(root.getId());
101: if (t != null) { // It should always be
102: print("--> ");
103: printThing(t);
104: out.println("<br>");
105: }
106: }
107:
108: out.println("<h2>Other Queries</h2>");
109: out.println("<ul>");
110: out.println("<li>");
111: printAnchorStart();
112: out.print("\">");
113: print("Show All Classes");
114: out.println("</a>");
115: out.println("</ul>");
116:
117: endHtml();
118: }
119: }
|