1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.apache.harmony.dalvik.ddmc; 18 19 import android.compat.annotation.UnsupportedAppUsage; 20 import java.nio.ByteBuffer; 21 22 /** 23 * A chunk of DDM data. This is really just meant to hold a few pieces 24 * of data together. 25 * 26 * The "offset" and "length" fields are present so handlers can over-allocate 27 * or share byte buffers. 28 * 29 * @hide 30 */ 31 @libcore.api.CorePlatformApi 32 public class Chunk { 33 34 /* 35 * Public members. Do not rename without updating the VM. 36 */ 37 @libcore.api.CorePlatformApi 38 public int type; // chunk type 39 public byte[] data; // chunk data 40 public int offset, length; // position within "data" 41 42 /** 43 * Blank constructor. Fill in your own fields. 44 */ Chunk()45 public Chunk() {} 46 47 /** 48 * Constructor with all fields. 49 */ 50 @libcore.api.CorePlatformApi Chunk(int type, byte[] data, int offset, int length)51 public Chunk(int type, byte[] data, int offset, int length) { 52 this.type = type; 53 this.data = data; 54 this.offset = offset; 55 this.length = length; 56 } 57 58 /** 59 * Construct from a ByteBuffer. The chunk is assumed to start at 60 * offset 0 and continue to the current position. 61 */ 62 @UnsupportedAppUsage 63 @libcore.api.CorePlatformApi Chunk(int type, ByteBuffer buf)64 public Chunk(int type, ByteBuffer buf) { 65 this.type = type; 66 67 this.data = buf.array(); 68 this.offset = buf.arrayOffset(); 69 this.length = buf.position(); 70 } 71 } 72