Showing the changes to java/pkg/com/sun/tools/jdi/FieldImpl.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,106 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. | ||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| 4 | * | ||
| 5 | * This code is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms of the GNU General Public License version 2 only, as | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 10 | * | ||
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 14 | * version 2 for more details (a copy is included in the LICENSE file that | ||
| 15 | * accompanied this code). | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License version | ||
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, | ||
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | * | ||
| 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * questions. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package com.sun.tools.jdi; | ||
| 27 | |||
| 28 | import com.sun.jdi.*; | ||
| 29 | |||
| 30 | |||
| 31 | public class FieldImpl extends TypeComponentImpl | ||
| 32 | implements Field, ValueContainer { | ||
| 33 | |||
| 34 | FieldImpl(VirtualMachine vm, ReferenceTypeImpl declaringType, | ||
| 35 | long ref, | ||
| 36 | String name, String signature, | ||
| 37 | String genericSignature, int modifiers) { | ||
| 38 | super(vm, declaringType, ref, name, signature, | ||
| 39 | genericSignature, modifiers); | ||
| 40 | } | ||
| 41 | |||
| 42 | public boolean equals(Object obj) { | ||
| 43 | if ((obj != null) && (obj instanceof FieldImpl)) { | ||
| 44 | FieldImpl other = (FieldImpl)obj; | ||
| 45 | return (declaringType().equals(other.declaringType())) && | ||
| 46 | (ref() == other.ref()) && | ||
| 47 | super.equals(obj); | ||
| 48 | } else { | ||
| 49 | return false; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | public int hashCode() { | ||
| 54 | return (int)ref(); | ||
| 55 | } | ||
| 56 | |||
| 57 | public int compareTo(Field field) { | ||
| 58 | ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType(); | ||
| 59 | int rc = declaringType.compareTo(field.declaringType()); | ||
| 60 | if (rc == 0) { | ||
| 61 | rc = declaringType.indexOf(this) - | ||
| 62 | declaringType.indexOf(field); | ||
| 63 | } | ||
| 64 | return rc; | ||
| 65 | } | ||
| 66 | |||
| 67 | public Type type() throws ClassNotLoadedException { | ||
| 68 | return findType(signature()); | ||
| 69 | } | ||
| 70 | |||
| 71 | public Type findType(String signature) throws ClassNotLoadedException { | ||
| 72 | ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType(); | ||
| 73 | return enclosing.findType(signature); | ||
| 74 | } | ||
| 75 | |||
| 76 | /** | ||
| 77 | * @return a text representation of the declared type | ||
| 78 | * of this field. | ||
| 79 | */ | ||
| 80 | public String typeName() { | ||
| 81 | JNITypeParser parser = new JNITypeParser(signature()); | ||
| 82 | return parser.typeName(); | ||
| 83 | } | ||
| 84 | |||
| 85 | public boolean isTransient() { | ||
| 86 | return isModifierSet(VMModifiers.TRANSIENT); | ||
| 87 | } | ||
| 88 | |||
| 89 | public boolean isVolatile() { | ||
| 90 | return isModifierSet(VMModifiers.VOLATILE); | ||
| 91 | } | ||
| 92 | |||
| 93 | public boolean isEnumConstant() { | ||
| 94 | return isModifierSet(VMModifiers.ENUM_CONSTANT); | ||
| 95 | } | ||
| 96 | |||
| 97 | public String toString() { | ||
| 98 | StringBuffer buf = new StringBuffer(); | ||
| 99 | |||
| 100 | buf.append(declaringType().name()); | ||
| 101 | buf.append('.'); | ||
| 102 | buf.append(name()); | ||
| 103 | |||
| 104 | return buf.toString(); | ||
| 105 | } | ||
| 106 | } | ||