Add static utility methods to StringIdItem and TypeIdItem for getting their string representations

This commit is contained in:
Ben Gruver
2012-06-06 11:09:46 -07:00
parent f7dfb272f3
commit 58e4b792b8
2 changed files with 24 additions and 0 deletions

View File

@ -32,6 +32,8 @@ import org.jf.dexlib.Util.AnnotatedOutput;
import org.jf.dexlib.Util.Input;
import org.jf.dexlib.Util.Utf8Utils;
import javax.annotation.Nullable;
public class StringIdItem extends Item<StringIdItem> {
private StringDataItem stringDataItem;
@ -133,6 +135,16 @@ public class StringIdItem extends Item<StringIdItem> {
return stringDataItem.getStringValue();
}
/**
* Get the <code>String</code> value that the given <code>StringIdItem</code> represents
* @param stringIdItem The <code>StringIdItem</code> to get the string value of
* @return the <code>String</code> value that the given <code>StringIdItem</code> represents
*/
@Nullable
public static String getStringValue(@Nullable StringIdItem stringIdItem) {
return stringIdItem==null?null:stringIdItem.getStringValue();
}
/**
* Get the <code>StringDataItem</code> that this <code>StringIdItem</code> references
* @return the <code>StringDataItem</code> that this <code>StringIdItem</code> references

View File

@ -31,6 +31,8 @@ package org.jf.dexlib;
import org.jf.dexlib.Util.AnnotatedOutput;
import org.jf.dexlib.Util.Input;
import javax.annotation.Nullable;
public class TypeIdItem extends Item<TypeIdItem> {
private StringIdItem typeDescriptor;
@ -146,6 +148,16 @@ public class TypeIdItem extends Item<TypeIdItem> {
return typeDescriptor.getStringValue();
}
/**
* Returns the type descriptor as a <code>String</code> for the given type
* @param typeIdItem The <code>TypeIdItem</code> to get the type descriptor of
* @return the type descriptor as a <code>String</code> for the gvien type
*/
@Nullable
public static String getTypeDescriptor(@Nullable TypeIdItem typeIdItem) {
return typeIdItem==null?null:typeIdItem.getTypeDescriptor();
}
/**
* Returns the "shorty" representation of this type, used to create the shorty prototype string for a method
* @return the "shorty" representation of this type, used to create the shorty prototype string for a method