a class to read android axml @author Panxiaobo
| 32 | * @author <a href="mailto:pxb1988@gmail.com">Panxiaobo</a> |
| 33 | */ |
| 34 | public class AxmlParser implements ResConst { |
| 35 | |
| 36 | public static final int END_FILE = 7; |
| 37 | public static final int END_NS = 5; |
| 38 | public static final int END_TAG = 3; |
| 39 | public static final int START_FILE = 1; |
| 40 | public static final int START_NS = 4; |
| 41 | public static final int START_TAG = 2; |
| 42 | public static final int TEXT = 6; |
| 43 | // private int attrName[]; |
| 44 | // private int attrNs[]; |
| 45 | // private int attrResId[]; |
| 46 | // private int attrType[]; |
| 47 | // private Object attrValue[]; |
| 48 | |
| 49 | private int attributeCount; |
| 50 | |
| 51 | private IntBuffer attrs; |
| 52 | |
| 53 | private int classAttribute; |
| 54 | private int fileSize = -1; |
| 55 | private int idAttribute; |
| 56 | private ByteBuffer in; |
| 57 | private int lineNumber; |
| 58 | private int nameIdx; |
| 59 | private int nsIdx; |
| 60 | |
| 61 | private int prefixIdx; |
| 62 | |
| 63 | private int[] resourceIds; |
| 64 | |
| 65 | private String[] strings; |
| 66 | |
| 67 | private int styleAttribute; |
| 68 | |
| 69 | private int textIdx; |
| 70 | |
| 71 | public AxmlParser(byte[] data) { |
| 72 | this(ByteBuffer.wrap(data)); |
| 73 | } |
| 74 | |
| 75 | public AxmlParser(ByteBuffer in) { |
| 76 | super(); |
| 77 | this.in = in.order(ByteOrder.LITTLE_ENDIAN); |
| 78 | } |
| 79 | |
| 80 | public int getAttrCount() { |
| 81 | return attributeCount; |
| 82 | } |
| 83 | |
| 84 | public int getAttributeCount() { |
| 85 | return attributeCount; |
| 86 | } |
| 87 | |
| 88 | public String getAttrName(int i) { |
| 89 | int idx = attrs.get(i * 5 + 1); |
| 90 | return strings[idx]; |
| 91 |
nothing calls this directly
no outgoing calls
no test coverage detected