1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 package com.ohos.hapsigntool.zip; 17 18 import java.io.IOException; 19 import java.nio.ByteBuffer; 20 21 /** 22 * ZipDataInput interface 23 * 24 * @since 2021/12/20 25 */ 26 public interface ZipDataInput { 27 /** 28 * Get how many bytes are contained in this data input. 29 * 30 * @return this data input size 31 */ size()32 long size(); 33 34 /** 35 * Copy the specified data block into the destination ZipDataOutput 36 * 37 * @param offset offset index at the ZipDataInput 38 * @param size size of the data block 39 * @param output the destination ZipDataOutput 40 * @throws IOException when IO error occurred 41 */ copyTo(long offset, long size, ZipDataOutput output)42 void copyTo(long offset, long size, ZipDataOutput output) throws IOException; 43 44 /** 45 * Copy the specified data block into the destination ZipDataOutput 46 * 47 * @param offset offset index at the ZipDataInput 48 * @param size size of the data block 49 * @param buffer the destination ZipDataOutput 50 * @throws IOException when IO error occurred 51 */ copyTo(long offset, int size, ByteBuffer buffer)52 void copyTo(long offset, int size, ByteBuffer buffer) throws IOException; 53 54 /** 55 * Create a ByteBuffer which contain the specified data block from this ZipDataInput 56 * 57 * @param offset offset index at the ZipDataInput 58 * @param size size of the data block 59 * @return a ByteBuffer 60 * @throws IOException when IO error occurred 61 */ createByteBuffer(long offset, int size)62 ByteBuffer createByteBuffer(long offset, int size) throws IOException; 63 64 /** 65 * Create a new ZipDataInput whose content is shared by this ZipDataInput 66 * 67 * @param offset offset index at the ZipDataInput 68 * @param size size of the data block 69 * @return new ZipDataInput 70 */ slice(long offset, long size)71 ZipDataInput slice(long offset, long size); 72 } 73