blob: 52ce1c0753664ad87e89eb426624f974f5f8c4ca [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.internal.compiler.env.IBinaryField;
/**
* @see IField
*/
/* package */ class BinaryField extends BinaryMember implements IField {
/*
* Constructs a handle to the field with the given name in the specified type.
*/
protected BinaryField(JavaElement parent, String name) {
super(parent, name);
}
public boolean equals(Object o) {
if (!(o instanceof BinaryField)) return false;
return super.equals(o);
}
/*
* @see IField
*/
public Object getConstant() throws JavaModelException {
IBinaryField info = (IBinaryField) getElementInfo();
return convertConstant(info.getConstant());
}
/*
* @see IMember
*/
public int getFlags() throws JavaModelException {
IBinaryField info = (IBinaryField) getElementInfo();
return info.getModifiers();
}
/*
* @see IJavaElement
*/
public int getElementType() {
return FIELD;
}
/*
* @see JavaElement#getHandleMemento()
*/
protected char getHandleMementoDelimiter() {
return JavaElement.JEM_FIELD;
}
/*
* @see IField
*/
public String getTypeSignature() throws JavaModelException {
IBinaryField info = (IBinaryField) getElementInfo();
return new String(ClassFile.translatedName(info.getTypeName()));
}
/*
* @private Debugging purposes
*/
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
buffer.append(this.tabString(tab));
if (info == null) {
toStringName(buffer);
buffer.append(" (not open)"); //$NON-NLS-1$
} else if (info == NO_INFO) {
toStringName(buffer);
} else {
try {
buffer.append(Signature.toString(this.getTypeSignature()));
buffer.append(" "); //$NON-NLS-1$
toStringName(buffer);
} catch (JavaModelException e) {
buffer.append("<JavaModelException in toString of " + getElementName()); //$NON-NLS-1$
}
}
}
}