All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jace.parser.constant.ClassConstant Maven / Gradle / Ivy

There is a newer version: 1.2.22
Show newest version
package org.jace.parser.constant;

import org.jace.parser.ConstantPool;
import java.io.DataOutputStream;
import java.io.IOException;

public class ClassConstant implements Constant
{
	private int nameIndex;
	private final ConstantPool pool;

	public ClassConstant(int nameIndex, ConstantPool pool)
	{
		this.nameIndex = nameIndex;
		this.pool = pool;
	}

	@Override
	public int getSize()
	{
		return 1;
	}

	public int getNameIndex()
	{
		return nameIndex;
	}

	public void setNameIndex(int index)
	{
		this.nameIndex = index;
	}

	@Override
	public Object getValue()
	{
		UTF8Constant c = (UTF8Constant) pool.getConstantAt(nameIndex);
		return c.getValue();
	}

	@Override
	public void write(DataOutputStream output) throws IOException
	{
		output.writeByte(new ClassConstantReader().getTag());
		output.writeShort(nameIndex);
	}

	@Override
	public String toString()
	{
		return (String) getValue();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy