Java Code Examples for org.apache.bcel.classfile.Utility#convertString()

The following examples show how to use org.apache.bcel.classfile.Utility#convertString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BCELFactory.java    From commons-bcel with Apache License 2.0 6 votes vote down vote up
private void createConstant( final Object value ) {
    String embed = value.toString();
    if (value instanceof String) {
        embed = '"' + Utility.convertString(embed) + '"';
    } else if (value instanceof Character) {
        embed = "(char)0x" + Integer.toHexString(((Character) value).charValue());
    } else if (value instanceof Float) {
        embed += "f";
    } else if (value instanceof Long) {
        embed += "L";
    } else if (value instanceof ObjectType) {
        final ObjectType ot = (ObjectType) value;
        embed = "new ObjectType(\""+ot.getClassName()+"\")";
    }

    _out.println("il.append(new PUSH(_cp, " + embed + "));");
}
 
Example 2
Source File: BCELFactory.java    From ApkToolPlus with Apache License 2.0 5 votes vote down vote up
private void createConstant(Object value) {
  String embed = value.toString();

  if(value instanceof String)
    embed = '"' + Utility.convertString(value.toString()) + '"';
  else if(value instanceof Character)
    embed = "(char)0x" + Integer.toHexString(((Character)value).charValue());

  _out.println("il.append(new PUSH(_cp, " + embed + "));");
}