com.android.dx.util.ByteArray.slice()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(191)

本文整理了Java中com.android.dx.util.ByteArray.slice()方法的一些代码示例,展示了ByteArray.slice()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteArray.slice()方法的具体详情如下:
包路径:com.android.dx.util.ByteArray
类名称:ByteArray
方法名:slice

ByteArray.slice介绍

[英]Returns a slice (that is, a sub-array) of this instance.
[中]返回此实例的切片(即子数组)。

代码示例

代码示例来源:origin: com.google.android.tools/dx

/**
 * Constructs an instance from a sub-array of a {@link ByteArray}.
 *
 * @param name {@code non-null;} attribute name
 * @param data {@code non-null;} array containing the attribute data
 * @param offset offset in {@code data} to the attribute data
 * @param length length of the attribute data, in bytes
 * @param pool {@code null-ok;} constant pool to use for cpi resolution
 */
public RawAttribute(String name, ByteArray data, int offset,
          int length, ConstantPool pool) {
  this(name, data.slice(offset, offset + length), pool);
}

代码示例来源:origin: com.android.tools.build/builder

/**
 * Constructs an instance from a sub-array of a {@link ByteArray}.
 *
 * @param name {@code non-null;} attribute name
 * @param data {@code non-null;} array containing the attribute data
 * @param offset offset in {@code data} to the attribute data
 * @param length length of the attribute data, in bytes
 * @param pool {@code null-ok;} constant pool to use for cpi resolution
 */
public RawAttribute(String name, ByteArray data, int offset,
          int length, ConstantPool pool) {
  this(name, data.slice(offset, offset + length), pool);
}

代码示例来源:origin: nikita36078/J2ME-Loader

/**
 * Constructs an instance from a sub-array of a {@link ByteArray}.
 *
 * @param name {@code non-null;} attribute name
 * @param data {@code non-null;} array containing the attribute data
 * @param offset offset in {@code data} to the attribute data
 * @param length length of the attribute data, in bytes
 * @param pool {@code null-ok;} constant pool to use for cpi resolution
 */
public RawAttribute(String name, ByteArray data, int offset,
          int length, ConstantPool pool) {
  this(name, data.slice(offset, offset + length), pool);
}

代码示例来源:origin: com.jakewharton.android.repackaged/dalvik-dx

/**
 * Constructs an instance from a sub-array of a {@link ByteArray}.
 *
 * @param name {@code non-null;} attribute name
 * @param data {@code non-null;} array containing the attribute data
 * @param offset offset in {@code data} to the attribute data
 * @param length length of the attribute data, in bytes
 * @param pool {@code null-ok;} constant pool to use for cpi resolution
 */
public RawAttribute(String name, ByteArray data, int offset,
          int length, ConstantPool pool) {
  this(name, data.slice(offset, offset + length), pool);
}

代码示例来源:origin: com.android/dx

/**
 * Constructs an instance from a sub-array of a {@link ByteArray}.
 *
 * @param name {@code non-null;} attribute name
 * @param data {@code non-null;} array containing the attribute data
 * @param offset offset in {@code data} to the attribute data
 * @param length length of the attribute data, in bytes
 * @param pool {@code null-ok;} constant pool to use for cpi resolution
 */
public RawAttribute(String name, ByteArray data, int offset,
          int length, ConstantPool pool) {
  this(name, data.slice(offset, offset + length), pool);
}

代码示例来源:origin: dragome/dragome-sdk

/**
 * Constructs an instance from a sub-array of a {@link ByteArray}.
 * 
 * @param name {@code non-null;} attribute name
 * @param data {@code non-null;} array containing the attribute data
 * @param offset offset in {@code data} to the attribute data
 * @param length length of the attribute data, in bytes
 * @param pool {@code null-ok;} constant pool to use for cpi resolution
 */
public RawAttribute(String name, ByteArray data, int offset,
          int length, ConstantPool pool) {
  this(name, data.slice(offset, offset + length), pool);
}

代码示例来源:origin: com.jakewharton.android.repackaged/dalvik-dx

/**
 * Parses a utf8 constant.
 *
 * @param at offset to the start of the constant (where the tag byte is)
 * @return {@code non-null;} the parsed value
 */
private CstString parseUtf8(int at) {
  int length = bytes.getUnsignedShort(at + 1);
  at += 3; // Skip to the data.
  ByteArray ubytes = bytes.slice(at, at + length);
  try {
    return new CstString(ubytes);
  } catch (IllegalArgumentException ex) {
    // Translate the exception
    throw new ParseException(ex);
  }
}

代码示例来源:origin: nikita36078/J2ME-Loader

/**
   * Parses a utf8 constant.
   *
   * @param at offset to the start of the constant (where the tag byte is)
   * @return {@code non-null;} the parsed value
   */
  private CstString parseUtf8(int at) {
    int length = bytes.getUnsignedShort(at + 1);

    at += 3; // Skip to the data.

    ByteArray ubytes = bytes.slice(at, at + length);

    try {
      return new CstString(ubytes);
    } catch (IllegalArgumentException ex) {
      // Translate the exception
      throw new ParseException(ex);
    }
  }
}

代码示例来源:origin: com.android.tools.build/builder

/**
   * Parses a utf8 constant.
   *
   * @param at offset to the start of the constant (where the tag byte is)
   * @return {@code non-null;} the parsed value
   */
  private CstString parseUtf8(int at) {
    int length = bytes.getUnsignedShort(at + 1);

    at += 3; // Skip to the data.

    ByteArray ubytes = bytes.slice(at, at + length);

    try {
      return new CstString(ubytes);
    } catch (IllegalArgumentException ex) {
      // Translate the exception
      throw new ParseException(ex);
    }
  }
}

代码示例来源:origin: com.android/dx

/**
   * Parses a utf8 constant.
   *
   * @param at offset to the start of the constant (where the tag byte is)
   * @return {@code non-null;} the parsed value
   */
  private CstString parseUtf8(int at) {
    int length = bytes.getUnsignedShort(at + 1);

    at += 3; // Skip to the data.

    ByteArray ubytes = bytes.slice(at, at + length);

    try {
      return new CstString(ubytes);
    } catch (IllegalArgumentException ex) {
      // Translate the exception
      throw new ParseException(ex);
    }
  }
}

代码示例来源:origin: dragome/dragome-sdk

/**
   * Parses a utf8 constant.
   * 
   * @param at offset to the start of the constant (where the tag byte is)
   * @return {@code non-null;} the parsed value
   */
  private CstUtf8 parseUtf8(int at) {
    int length = bytes.getUnsignedShort(at + 1);

    at += 3; // Skip to the data.

    ByteArray ubytes = bytes.slice(at, at + length);

    try {
      return new CstUtf8(ubytes);
    } catch (IllegalArgumentException ex) {
      // Translate the exception
      throw new ParseException(ex);
    }
  }
}

代码示例来源:origin: com.jakewharton.android.repackaged/dalvik-dx

/**
 * Parses a {@code SourceDebugExtesion} attribute.
 */
private Attribute sourceDebugExtension(DirectClassFile cf, int offset, int length,
                    ParseObserver observer) {
  ByteArray bytes = cf.getBytes().slice(offset, offset + length);
  CstString smapString = new CstString(bytes);
  Attribute result = new AttSourceDebugExtension(smapString);
  if (observer != null) {
    String decoded = smapString.getString();
    observer.parsed(bytes, offset, length, "sourceDebugExtension: " + decoded);
  }
  return result;
}

代码示例来源:origin: nikita36078/J2ME-Loader

/**
 * Parses a {@code SourceDebugExtesion} attribute.
 */
private Attribute sourceDebugExtension(DirectClassFile cf, int offset, int length,
                    ParseObserver observer) {
  ByteArray bytes = cf.getBytes().slice(offset, offset + length);
  CstString smapString = new CstString(bytes);
  Attribute result = new AttSourceDebugExtension(smapString);
  if (observer != null) {
    String decoded = smapString.getString();
    observer.parsed(bytes, offset, length, "sourceDebugExtension: " + decoded);
  }
  return result;
}

代码示例来源:origin: nikita36078/J2ME-Loader

/**
 * Parses a {@code LocalVariableTable} attribute.
 */
private Attribute localVariableTable(DirectClassFile cf, int offset,
    int length, ParseObserver observer) {
  if (length < 2) {
    return throwSeverelyTruncated();
  }
  ByteArray bytes = cf.getBytes();
  int count = bytes.getUnsignedShort(offset);
  if (observer != null) {
    observer.parsed(bytes, offset, 2,
        "local_variable_table_length: " + Hex.u2(count));
  }
  LocalVariableList list = parseLocalVariables(
      bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
      observer, count, false);
  return new AttLocalVariableTable(list);
}

代码示例来源:origin: nikita36078/J2ME-Loader

/**
 * Parses a {@code LocalVariableTypeTable} attribute.
 */
private Attribute localVariableTypeTable(DirectClassFile cf, int offset,
    int length, ParseObserver observer) {
  if (length < 2) {
    return throwSeverelyTruncated();
  }
  ByteArray bytes = cf.getBytes();
  int count = bytes.getUnsignedShort(offset);
  if (observer != null) {
    observer.parsed(bytes, offset, 2,
        "local_variable_type_table_length: " + Hex.u2(count));
  }
  LocalVariableList list = parseLocalVariables(
      bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
      observer, count, true);
  return new AttLocalVariableTypeTable(list);
}

代码示例来源:origin: com.android.tools.build/builder

/**
 * Parses a {@code LocalVariableTypeTable} attribute.
 */
private Attribute localVariableTypeTable(DirectClassFile cf, int offset,
    int length, ParseObserver observer) {
  if (length < 2) {
    return throwSeverelyTruncated();
  }
  ByteArray bytes = cf.getBytes();
  int count = bytes.getUnsignedShort(offset);
  if (observer != null) {
    observer.parsed(bytes, offset, 2,
        "local_variable_type_table_length: " + Hex.u2(count));
  }
  LocalVariableList list = parseLocalVariables(
      bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
      observer, count, true);
  return new AttLocalVariableTypeTable(list);
}

代码示例来源:origin: com.jakewharton.android.repackaged/dalvik-dx

/**
 * Parses a {@code LocalVariableTypeTable} attribute.
 */
private Attribute localVariableTypeTable(DirectClassFile cf, int offset,
    int length, ParseObserver observer) {
  if (length < 2) {
    return throwSeverelyTruncated();
  }
  ByteArray bytes = cf.getBytes();
  int count = bytes.getUnsignedShort(offset);
  if (observer != null) {
    observer.parsed(bytes, offset, 2,
        "local_variable_type_table_length: " + Hex.u2(count));
  }
  LocalVariableList list = parseLocalVariables(
      bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
      observer, count, true);
  return new AttLocalVariableTypeTable(list);
}

代码示例来源:origin: com.google.android.tools/dx

/**
 * Parses a {@code LocalVariableTable} attribute.
 */
private Attribute localVariableTable(DirectClassFile cf, int offset,
    int length, ParseObserver observer) {
  if (length < 2) {
    return throwSeverelyTruncated();
  }
  ByteArray bytes = cf.getBytes();
  int count = bytes.getUnsignedShort(offset);
  if (observer != null) {
    observer.parsed(bytes, offset, 2,
        "local_variable_table_length: " + Hex.u2(count));
  }
  LocalVariableList list = parseLocalVariables(
      bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
      observer, count, false);
  return new AttLocalVariableTable(list);
}

代码示例来源:origin: com.android/dx

/**
 * Parses a {@code LocalVariableTable} attribute.
 */
private Attribute localVariableTable(DirectClassFile cf, int offset,
    int length, ParseObserver observer) {
  if (length < 2) {
    return throwSeverelyTruncated();
  }
  ByteArray bytes = cf.getBytes();
  int count = bytes.getUnsignedShort(offset);
  if (observer != null) {
    observer.parsed(bytes, offset, 2,
        "local_variable_table_length: " + Hex.u2(count));
  }
  LocalVariableList list = parseLocalVariables(
      bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
      observer, count, false);
  return new AttLocalVariableTable(list);
}

代码示例来源:origin: com.android/dx

/**
 * Parses a {@code LocalVariableTypeTable} attribute.
 */
private Attribute localVariableTypeTable(DirectClassFile cf, int offset,
    int length, ParseObserver observer) {
  if (length < 2) {
    return throwSeverelyTruncated();
  }
  ByteArray bytes = cf.getBytes();
  int count = bytes.getUnsignedShort(offset);
  if (observer != null) {
    observer.parsed(bytes, offset, 2,
        "local_variable_type_table_length: " + Hex.u2(count));
  }
  LocalVariableList list = parseLocalVariables(
      bytes.slice(offset + 2, offset + length), cf.getConstantPool(),
      observer, count, true);
  return new AttLocalVariableTypeTable(list);
}

相关文章