1 /* 2 * Copyright (C) 2020 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 com.android.timezone.location.storage.block.write; 18 19 import com.android.timezone.location.storage.block.read.BlockData; 20 import com.android.timezone.location.storage.block.read.BlockInfo; 21 22 import java.io.IOException; 23 24 /** 25 * The base interface for objects that can write block data. Once {@link #close()} is called, the 26 * returned {@link ReadBack} can be used to obtain information about the block, e.g. for copying 27 * elsewhere. 28 */ 29 public interface BlockWriter { 30 31 /** 32 * Completes writing the block, and returns an object that can be used to read back the block's 33 * information, e.g. for inclusion in a block file. 34 */ close()35 ReadBack close() throws IOException; 36 37 /** Information about a written block. */ 38 interface ReadBack { 39 40 /** 41 * Returns the block's extra bytes, e.g. for inclusion in a {@link BlockInfo}. 42 * Never {@code null}, but may be empty. 43 */ getExtraBytes()44 byte[] getExtraBytes(); 45 46 /** Returns the type of the block. */ getType()47 int getType(); 48 49 /** 50 * Returns the block's data. Never {@code null} but may be empty. 51 */ getBlockData()52 BlockData getBlockData(); 53 } 54 } 55