Files
Brainstorm/Class File Services/src/com/de22/javabytecode/Interface.java
2014-05-30 10:31:51 -07:00

83 lines
2.4 KiB
Java

package com.de22.javabytecode;
import java.io.IOException;
/**
* Copyright Wynne Crisman 1999,2006<p>
*/
public class Interface extends Component {
private short interfaceIndex = 0; //The index in the constant table of the interface constant.//
/**
* Interface constructor.
*/
protected Interface(Type type) {
super(type);
}//Interface()//
/**
* Interface constructor.
*/
public Interface(Type type, short interfaceIndex) {
super(type);
this.interfaceIndex = interfaceIndex;
}//Interface()//
/**
* Gets the index of the interface class reference in the constant pool.
* @return The constant pool index of the interface class.
*/
public short getClassIndex() {
return interfaceIndex;
}//getClassIndex()//
/**
* Sets the index of the interface class reference in the constant pool.
* @param classIndex The constant pool index of the interface class.
*/
public void setClassIndex(short classIndex) {
this.interfaceIndex = classIndex;
}//setClassIndex()//
/**
* Gets the size in number of bytes of the component and all subcomponents.
* @return The number of bytes required to represent the component and all subcomponents.
*/
public int getSize() {
return 0;
}//getSize()//
/**
* Reads this object from the given stream.
* @param in The input stream to read this object from.
*/
public void readExternal(java.io.ObjectInput in) throws IOException, ClassNotFoundException {
interfaceIndex = in.readShort();
}//readExternal()//
/**
* Reads a interface from the given stream.
* @param type The type object that the interface will belong to.
* @param in The input stream to read the interface from.
*/
protected static Interface readInterface(Type type, java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException {
Interface interfaze = new Interface(type);
interfaze.readExternal(in);
return interfaze;
}//readInterface()//
/**
* @see Component.toString(StringBuffer, int)
*/
public void toString(StringBuffer buffer, int tabCount) {
appendTabs(buffer, tabCount);
buffer.append("Interface (interfaceIndex=");
buffer.append(interfaceIndex);
buffer.append(" name='");
buffer.append(getType().getConstant(interfaceIndex));
buffer.append("')");
appendEndOfLine(buffer);
}//toString()//
/**
* Writes this object to the given stream.
* @param out The output stream to write this object to.
*/
public void writeExternal(java.io.ObjectOutput out) throws IOException {
out.writeShort(interfaceIndex);
}//writeExternal()//
}//Interface//