org.jace.parser.constant.StringConstant Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jace-core-java Show documentation
Show all versions of jace-core-java Show documentation
Jace core module, Java source-code
package org.jace.parser.constant;
import java.io.DataOutputStream;
import java.io.IOException;
import org.jace.parser.ConstantPool;
public class StringConstant implements Constant
{
private final int index;
private final ConstantPool pool;
public StringConstant(ConstantPool pool, int index)
{
this.pool = pool;
this.index = index;
}
@Override
public int getSize()
{
return 1;
}
@Override
public Object getValue()
{
UTF8Constant c = (UTF8Constant) pool.getConstantAt(index);
return c.getValue();
}
@Override
public String toString()
{
return "A StringConstant pointing to a UTF8Constant at index " + index;
}
@Override
public void write(DataOutputStream output) throws IOException
{
output.writeByte(new StringConstantReader().getTag());
output.writeShort(index);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy