IndexableFieldIdentifier.java revision 9883:903a2e023ffb
1169689Skan/*
2169689Skan * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
3169689Skan * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4169689Skan *
5169689Skan * This code is free software; you can redistribute it and/or modify it
6169689Skan * under the terms of the GNU General Public License version 2 only, as
7169689Skan * published by the Free Software Foundation.
8169689Skan *
9169689Skan * This code is distributed in the hope that it will be useful, but WITHOUT
10169689Skan * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11169689Skan * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12169689Skan * version 2 for more details (a copy is included in the LICENSE file that
13169689Skan * accompanied this code).
14169689Skan *
15169689Skan * You should have received a copy of the GNU General Public License version
16169689Skan * 2 along with this work; if not, write to the Free Software Foundation,
17169689Skan * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18169689Skan *
19169689Skan * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20169689Skan * or visit www.oracle.com if you need additional information or have any
21169689Skan * questions.
22169689Skan *
23169689Skan */
24169689Skan
25169689Skanpackage sun.jvm.hotspot.oops;
26169689Skan
27169689Skanimport sun.jvm.hotspot.*;
28169689Skanimport sun.jvm.hotspot.types.*;
29169689Skanimport java.io.*;
30169689Skan
31169689Skan// An IndexableFieldIdentifier describes a field in an Oop accessed by an index
32169689Skan
33169689Skanpublic class IndexableFieldIdentifier extends FieldIdentifier {
34169689Skan
35169689Skan  public IndexableFieldIdentifier(int index) {
36169689Skan    this.index = index;
37169689Skan  }
38169689Skan
39169689Skan  private int index;
40169689Skan
41169689Skan  public int getIndex() { return index; }
42169689Skan
43169689Skan  public String getName() { return Integer.toString(getIndex()); }
44169689Skan
45169689Skan  public void printOn(PrintStream tty) {
46169689Skan    tty.print(" - " + getIndex() + ":\t");
47169689Skan  }
48169689Skan
49169689Skan  public boolean equals(Object obj) {
50169689Skan    if (obj == null) {
51169689Skan      return false;
52169689Skan    }
53169689Skan
54169689Skan    if (!(obj instanceof IndexableFieldIdentifier)) {
55169689Skan      return false;
56169689Skan    }
57169689Skan
58169689Skan    return (((IndexableFieldIdentifier) obj).getIndex() == index);
59169689Skan  }
60169689Skan
61169689Skan  public int hashCode() {
62169689Skan    return index;
63169689Skan  }
64169689Skan};
65169689Skan