Package org.aspectj.apache.bcel.classfile

Examples of org.aspectj.apache.bcel.classfile.ConstantInteger


  public byte getValueByte() {
    if (type != PRIMITIVE_BYTE) {
      throw new RuntimeException("Dont call getValueByte() on a non BYTE ElementValue");
    }
    ConstantInteger c = (ConstantInteger) cpool.getConstant(idx, Constants.CONSTANT_Integer);
    return (byte) c.getIntValue();
  }
View Full Code Here


  public char getValueChar() {
    if (type != PRIMITIVE_CHAR) {
      throw new RuntimeException("Dont call getValueChar() on a non CHAR ElementValue");
    }
    ConstantInteger c = (ConstantInteger) cpool.getConstant(idx, Constants.CONSTANT_Integer);
    return (char) c.getIntValue();
  }
View Full Code Here

  public boolean getValueBoolean() {
    if (type != PRIMITIVE_BOOLEAN) {
      throw new RuntimeException("Dont call getValueBoolean() on a non BOOLEAN ElementValue");
    }
    ConstantInteger bo = (ConstantInteger) cpool.getConstant(idx);
    return (bo.getValue() != 0);
  }
View Full Code Here

  public short getValueShort() {
    if (type != PRIMITIVE_SHORT) {
      throw new RuntimeException("Dont call getValueShort() on a non SHORT ElementValue");
    }
    ConstantInteger s = (ConstantInteger) cpool.getConstant(idx);
    return (short) s.getIntValue();
  }
View Full Code Here

  public int getValueInt() {
    if (type != PRIMITIVE_INT) {
      throw new RuntimeException("Dont call getValueString() on a non STRING ElementValue");
    }
    ConstantInteger c = (ConstantInteger) cpool.getConstant(idx);
    return c.getValue();
  }
View Full Code Here

  // Whatever kind of value it is, return it as a string
  @Override
  public String stringifyValue() {
    switch (type) {
    case PRIMITIVE_INT:
      ConstantInteger c = (ConstantInteger) cpool.getConstant(idx);
      return Integer.toString(c.getValue());
    case PRIMITIVE_LONG:
      ConstantLong j = (ConstantLong) cpool.getConstant(idx);
      return Long.toString(j.getValue());
    case PRIMITIVE_DOUBLE:
      ConstantDouble d = (ConstantDouble) cpool.getConstant(idx);
      return d.getValue().toString();
    case PRIMITIVE_FLOAT:
      ConstantFloat f = (ConstantFloat) cpool.getConstant(idx);
      return Float.toString(f.getValue());
    case PRIMITIVE_SHORT:
      ConstantInteger s = (ConstantInteger) cpool.getConstant(idx);
      return Integer.toString(s.getValue());
    case PRIMITIVE_BYTE:
      ConstantInteger b = (ConstantInteger) cpool.getConstant(idx);
      return Integer.toString(b.getValue());
    case PRIMITIVE_CHAR:
      ConstantInteger ch = (ConstantInteger) cpool.getConstant(idx);
      return new Character((char) ch.getIntValue()).toString();
    case PRIMITIVE_BOOLEAN:
      ConstantInteger bo = (ConstantInteger) cpool.getConstant(idx);
      if (bo.getValue() == 0) {
        return "false";
      } else {
        return "true";
      }
    case STRING:
View Full Code Here

  @Override
  public String toString() {
    StringBuilder s = new StringBuilder();
    switch (type) {
    case PRIMITIVE_INT:
      ConstantInteger c = (ConstantInteger) cpool.getConstant(idx);
      s.append("(int)").append(Integer.toString(c.getValue()));
      break;
    case PRIMITIVE_LONG:
      ConstantLong j = (ConstantLong) cpool.getConstant(idx);
      s.append("(long)").append(Long.toString(j.getValue()));
      break;
    case PRIMITIVE_DOUBLE:
      ConstantDouble d = (ConstantDouble) cpool.getConstant(idx);
      s.append("(double)").append(d.getValue().toString());
      break;
    case PRIMITIVE_FLOAT:
      ConstantFloat f = (ConstantFloat) cpool.getConstant(idx);
      s.append("(float)").append(Float.toString(f.getValue()));
      break;
    case PRIMITIVE_SHORT:
      ConstantInteger ci = (ConstantInteger) cpool.getConstant(idx);
      s.append("(short)").append(Integer.toString(ci.getValue()));
      break;
    case PRIMITIVE_BYTE:
      ConstantInteger b = (ConstantInteger) cpool.getConstant(idx);
      s.append("(byte)").append(Integer.toString(b.getValue()));
      break;
    case PRIMITIVE_CHAR:
      ConstantInteger ch = (ConstantInteger) cpool.getConstant(idx);
      s.append("(char)").append(new Character((char) ch.getIntValue()).toString());
      break;
    case PRIMITIVE_BOOLEAN:
      ConstantInteger bo = (ConstantInteger) cpool.getConstant(idx);
      s.append("(boolean)");
      if (bo.getValue() == 0) {
        s.append("false");
      } else {
        s.append("true");
      }
      break;
View Full Code Here

  }

  public byte getValueByte() {
    if (type != PRIMITIVE_BYTE)
      throw new RuntimeException("Dont call getValueByte() on a non BYTE ElementValue");
    ConstantInteger c = (ConstantInteger) cpool.getConstant(idx, Constants.CONSTANT_Integer);
    return (byte) c.getIntValue();
  }
View Full Code Here

  }

  public char getValueChar() {
    if (type != PRIMITIVE_CHAR)
      throw new RuntimeException("Dont call getValueChar() on a non CHAR ElementValue");
    ConstantInteger c = (ConstantInteger) cpool.getConstant(idx, Constants.CONSTANT_Integer);
    return (char) c.getIntValue();
  }
View Full Code Here

  }

  public boolean getValueBoolean() {
    if (type != PRIMITIVE_BOOLEAN)
      throw new RuntimeException("Dont call getValueBoolean() on a non BOOLEAN ElementValue");
    ConstantInteger bo = (ConstantInteger) cpool.getConstant(idx);
    return (bo.getValue() != 0);
  }
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.classfile.ConstantInteger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.