1 cananian 1.1.2.4 // HData.java, created Wed Jul 28 13:55:51 1999 by duncan
 2 cananian 1.1.2.8 // Copyright (C) 1998 Duncan Bryce <duncan@lcs.mit.edu>
 3 cananian 1.1.2.3 // Licensed under the terms of the GNU GPL; see COPYING for details.
 4 duncan   1.1.2.1 package harpoon.ClassFile;
 5 duncan   1.1.2.1 
 6 duncan   1.1.2.1 import java.util.Iterator;
 7 duncan   1.1.2.1 import java.util.List;
 8 duncan   1.1.2.1 
 9 duncan   1.1.2.1 /**
10 duncan   1.1.2.1  * <code>HData</code> is an interface that all views of a particular
11 duncan   1.1.2.1  * class's static data should extend. 
12 cananian 1.1.2.5  * An <code>HData</code> encapsulates a data view of class data in
13 cananian 1.1.2.5  * roughly the same way that an <code>HCode</code> encapsulates a
14 cananian 1.1.2.5  * code view of method instructions.
15 cananian 1.1.2.5  * A particular implementation of <code>HData</code> correlates with
16 cananian 1.1.2.5  * "memory layout" for a particular runtime implementation.
17 cananian 1.1.2.5  * <p>
18 cananian 1.1.2.5  * It is possible (and rather recommended) for a class to have *several*
19 cananian 1.1.2.5  * <code>HData</code>s associated with it, each of which encapsulates
20 cananian 1.1.2.5  * a certain set of class data.
21 duncan   1.1.2.1  *
22 cananian 1.1.2.8  * @author  Duncan Bryce <duncan@lcs.mit.edu>
23 cananian 1.2      * @version $Id: HData.java,v 1.2 2002/02/25 21:03:03 cananian Exp $
24 duncan   1.1.2.1  */
25 cananian 1.1.2.5 public abstract class HData { 
26 duncan   1.1.2.1     
27 duncan   1.1.2.1     /** Clone this <code>HData</code>, possibly moving it to a different
28 cananian 1.1.2.5      *  <code>HClass</code>.
29 cananian 1.1.2.5      * @exception CloneNotSupportedException if it is not possible to
30 cananian 1.1.2.5      *            clone this <code>HData</code>. */
31 cananian 1.1.2.5     public HData clone(HClass cls) throws CloneNotSupportedException {
32 cananian 1.1.2.5         throw new CloneNotSupportedException();
33 cananian 1.1.2.5     }
34 duncan   1.1.2.1 
35 duncan   1.1.2.1     /** Return the <code>HClass</code> to which this <code>HData</code>
36 cananian 1.1.2.6      *  belongs. Returns <code>null</code> if this <code>HData</code>
37 cananian 1.1.2.6      *  has global, rather than class-local, data structures. */
38 cananian 1.1.2.5     public abstract HClass getHClass();
39 cananian 1.1.2.5 
40 cananian 1.1.2.5     /**
41 cananian 1.1.2.5      * Return the 'root' element of this data view.
42 cananian 1.1.2.5      * @return root of the data view, or <code>null</code> if this notion
43 cananian 1.1.2.5      *         is not applicable.
44 cananian 1.1.2.5      */
45 cananian 1.1.2.5     public abstract HDataElement getRootElement();
46 duncan   1.1.2.1 
47 duncan   1.1.2.1     /**
48 duncan   1.1.2.1      * Return an Iterator over the component objects making up this
49 duncan   1.1.2.1      * data view.  If there is a 'root' to the data view, it should
50 cananian 1.1.2.5      * be the first element enumerated.<p>
51 cananian 1.1.2.5      * <b>AT LEAST ONE OF <code>getElementsI()</code> AND
52 cananian 1.1.2.5      * <code>getElementsL()</code> MUST BE IMPLEMENTED.</b>
53 cananian 1.1.2.5      */
54 cananian 1.1.2.5     public Iterator getElementsI() { return getElementsL().iterator(); }
55 duncan   1.1.2.1     
56 duncan   1.1.2.1     /**
57 duncan   1.1.2.1      * Return an ordered <code>Collection</code> (a <code>List</code>) of
58 duncan   1.1.2.1      * the component objects making up this data view.  If there is a
59 duncan   1.1.2.1      * 'root' to the data view, it should be the first element in the
60 cananian 1.1.2.5      * List.<p>
61 cananian 1.1.2.5      * <b>AT LEAST ONE OF <code>getElementsI()</code> AND
62 cananian 1.1.2.5      * <code>getElementsL()</code> MUST BE IMPLEMENTED.</b>
63 cananian 1.1.2.5      */
64 cananian 1.1.2.5     public List getElementsL() {
65 cananian 1.1.2.5         List l = new java.util.ArrayList();
66 cananian 1.1.2.5         for (Iterator it=getElementsI(); it.hasNext(); )
67 cananian 1.1.2.5             l.add(it.next());
68 cananian 1.1.2.5         return java.util.Collections.unmodifiableList(l);
69 cananian 1.1.2.5     }
70 duncan   1.1.2.2 
71 duncan   1.1.2.2     /**
72 cananian 1.1.2.7      * Print a human-readable representation of this dataview using
73 cananian 1.1.2.7      * a null callback. */
74 cananian 1.1.2.7     public final void print(java.io.PrintWriter pw) {
75 cananian 1.1.2.7         print(pw, new HCode.PrintCallback());
76 cananian 1.1.2.7     }
77 cananian 1.1.2.7     /**
78 cananian 1.1.2.7      * Print a human-readable representation of this dataview using
79 cananian 1.1.2.7      * the specified callback. */
80 cananian 1.1.2.7     public abstract void print(java.io.PrintWriter pw,
81 cananian 1.1.2.7                                HCode.PrintCallback callback); 
82 cananian 1.2     }