当前位置: 首页>>代码示例>>Java>>正文


Java ByteArray.makeDataInputStream方法代码示例

本文整理汇总了Java中com.android.dx.util.ByteArray.makeDataInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java ByteArray.makeDataInputStream方法的具体用法?Java ByteArray.makeDataInputStream怎么用?Java ByteArray.makeDataInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.dx.util.ByteArray的用法示例。


在下文中一共展示了ByteArray.makeDataInputStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseLocalVariables

import com.android.dx.util.ByteArray; //导入方法依赖的package包/类
/**
 * Parse the table part of either a {@code LocalVariableTable}
 * or a {@code LocalVariableTypeTable}.
 *
 * @param bytes {@code non-null;} bytes to parse, which should <i>only</i>
 * contain the table data (no header)
 * @param pool {@code non-null;} constant pool to use
 * @param count {@code >= 0;} the number of entries
 * @param typeTable {@code true} iff this is for a type table
 * @return {@code non-null;} the constructed list
 */
private LocalVariableList parseLocalVariables(ByteArray bytes,
        ConstantPool pool, ParseObserver observer, int count,
        boolean typeTable) {
    if (bytes.size() != (count * 10)) {
        // "+ 2" is for the count.
        throwBadLength((count * 10) + 2);
    }

    ByteArray.MyDataInputStream in = bytes.makeDataInputStream();
    LocalVariableList list = new LocalVariableList(count);

    try {
        for (int i = 0; i < count; i++) {
            int startPc = in.readUnsignedShort();
            int length = in.readUnsignedShort();
            int nameIdx = in.readUnsignedShort();
            int typeIdx = in.readUnsignedShort();
            int index = in.readUnsignedShort();
            CstString name = (CstString) pool.get(nameIdx);
            CstString type = (CstString) pool.get(typeIdx);
            CstString descriptor = null;
            CstString signature = null;

            if (typeTable) {
                signature = type;
            } else {
                descriptor = type;
            }

            list.set(i, startPc, length, name,
                    descriptor, signature, index);

            if (observer != null) {
                observer.parsed(bytes, i * 10, 10, Hex.u2(startPc) +
                        ".." + Hex.u2(startPc + length) + " " +
                        Hex.u2(index) + " " + name.toHuman() + " " +
                        type.toHuman());
            }
        }
    } catch (IOException ex) {
        throw new RuntimeException("shouldn't happen", ex);
    }

    list.setImmutable();
    return list;
}
 
开发者ID:JLLK,项目名称:multidex-maker,代码行数:58,代码来源:StdAttributeFactory.java


注:本文中的com.android.dx.util.ByteArray.makeDataInputStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。