1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
|
/*
* Copyright 2007 - 2018 ETH Zuerich, CISD and SIS.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.hdf5.h5ar;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import ch.systemsx.cisd.base.io.IInputStream;
/**
* An interface for an HDF5 archive reader.
*
* @author Bernd Rinn
*/
public interface IHDF5ArchiveReader extends IHDF5ArchiveInfoProvider
{
/**
* Closes this object and the file referenced by this object. This object must not be used after
* being closed. Calling this method for a second time is a no-op.
*/
public void close();
/**
* Returns <code>true</code> if this archive reader has been already closed.
*/
public boolean isClosed();
//
// Verification
//
/**
* Verifies the content of the archive against the filesystem.
*
* @param fileOrDir The file or directory entry in the archive to verify. May be empty, in which
* case all entries below <var>rootDirectoryInArchive</var> are verified.
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @param rootDirectoryInArchive The root directory in the archive to start verify from. It will
* be stripped from each entry before <var>rootDirectoryOnFS</var> is added.
* @param visitor The entry visitor to call for each entry. Call {@link ArchiveEntry#isOK()} to
* check whether verification was successful.
* @param missingArchiveEntryVisitor The entry visitor to call for each file that exists on the
* filesystem, but is missing in the archive.
* @param params The parameters to determine behavior of the verification process.
* @return This archive reader.
*/
public IHDF5ArchiveReader verifyAgainstFilesystem(String fileOrDir, File rootDirectoryOnFS,
String rootDirectoryInArchive, IArchiveEntryVisitor visitor,
IArchiveEntryVisitor missingArchiveEntryVisitor, VerifyParameters params);
/**
* Verifies the content of the archive against the filesystem.
*
* @param fileOrDir The file or directory entry in the archive to verify. May be empty, in which
* case all entries below <var>rootDirectoryInArchive</var> are verified.
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @param rootDirectoryInArchive The root directory in the archive to start verify from. It will
* be stripped from each entry before <var>rootDirectoryOnFS</var> is added.
* @param visitor The entry visitor to call for each entry. Call {@link ArchiveEntry#isOK()} to
* check whether verification was successful.
* @param params The parameters to determine behavior of the verification process.
* @return This archive reader.
*/
public IHDF5ArchiveReader verifyAgainstFilesystem(String fileOrDir, File rootDirectoryOnFS,
String rootDirectoryInArchive, IArchiveEntryVisitor visitor, VerifyParameters params);
/**
* Verifies the content of the complete archive against the filesystem.
*
* @param fileOrDir The file or directory entry in the archive to verify. May be empty, in which
* case all entries below <var>rootDirectoryInArchive</var> are verified.
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @param visitor The entry visitor to call for each entry. Call {@link ArchiveEntry#isOK()} to
* check whether verification was successful.
* @param missingArchiveEntryVisitor The entry visitor to call for each file that exists on the
* filesystem, but is missing in the archive.
* @param params The parameters to determine behavior of the verification process.
* @return This archive reader.
*/
public IHDF5ArchiveReader verifyAgainstFilesystem(String fileOrDir, File rootDirectoryOnFS,
IArchiveEntryVisitor visitor, IArchiveEntryVisitor missingArchiveEntryVisitor,
VerifyParameters params);
/**
* Verifies the content of the complete archive against the filesystem.
*
* @param fileOrDir The file or directory entry in the archive to verify. May be empty, in which
* case all entries below <var>rootDirectoryInArchive</var> are verified.
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @param visitor The entry visitor to call for each entry. Call {@link ArchiveEntry#isOK()} to
* check whether verification was successful.
* @param params The parameters to determine behavior of the verification process.
* @return This archive reader.
*/
public IHDF5ArchiveReader verifyAgainstFilesystem(String fileOrDir, File rootDirectoryOnFS,
IArchiveEntryVisitor visitor, VerifyParameters params);
/**
* Verifies the content of the complete archive against the filesystem.
*
* @param fileOrDir The file or directory entry in the archive to verify. May be empty, in which
* case all entries below <var>rootDirectoryInArchive</var> are verified.
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @param visitor The entry visitor to call for each entry. Call {@link ArchiveEntry#isOK()} to
* check whether verification was successful.
* @param missingArchiveEntryVisitor The entry visitor to call for each file that exists on the
* filesystem, but is missing in the archive.
* @return This archive reader.
*/
public IHDF5ArchiveReader verifyAgainstFilesystem(String fileOrDir, File rootDirectoryOnFS,
IArchiveEntryVisitor visitor, IArchiveEntryVisitor missingArchiveEntryVisitor);
/**
* Verifies the content of the complete archive against the filesystem.
*
* @param fileOrDir The file or directory entry in the archive to verify. May be empty, in which
* case all entries below <var>rootDirectoryInArchive</var> are verified.
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @param visitor The entry visitor to call for each entry. Call {@link ArchiveEntry#isOK()} to
* check whether verification was successful.
* @return This archive reader.
*/
public IHDF5ArchiveReader verifyAgainstFilesystem(String fileOrDir, File rootDirectoryOnFS,
IArchiveEntryVisitor visitor);
/**
* Verifies the content of the archive against the filesystem.
*
* @param fileOrDir The file or directory entry in the archive to verify. May be empty, in which
* case all entries below <var>rootDirectoryInArchive</var> are verified.
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @param rootDirectoryInArchive The root directory in the archive to start verify from. It will
* be stripped from each entry before <var>rootDirectoryOnFS</var> is added.
* @param params The parameters to determine behavior of the verification process.
* @return The list of archive entries which failed verification.
*/
public List<ArchiveEntry> verifyAgainstFilesystem(String fileOrDir, File rootDirectoryOnFS,
String rootDirectoryInArchive, VerifyParameters params);
/**
* Verifies the content of the archive against the filesystem.
*
* @param fileOrDir The file or directory entry in the archive to verify. May be empty, in which
* case all entries below <var>rootDirectoryInArchive</var> are verified.
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @param params The parameters to determine behavior of the verification process.
* @return The list of archive entries which failed verification.
*/
public List<ArchiveEntry> verifyAgainstFilesystem(String fileOrDir, File rootDirectoryOnFS,
VerifyParameters params);
/**
* Verifies the content of the archive against the filesystem.
*
* @param fileOrDir The file or directory entry in the archive to verify. May be empty, in which
* case all entries below <var>rootDirectoryInArchive</var> are verified.
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @return The list of archive entries which failed verification.
*/
public List<ArchiveEntry> verifyAgainstFilesystem(String fileOrDir, File rootDirectoryOnFS);
/**
* Verifies the content of the complete archive against the filesystem.
*
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @return The list of archive entries which failed verification.
*/
public List<ArchiveEntry> verifyAgainstFilesystem(File rootDirectoryOnFS);
/**
* Verifies the content of the complete archive against the filesystem.
*
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @param params The parameters to determine behavior of the verification process.
* @return The list of archive entries which failed verification.
*/
public List<ArchiveEntry> verifyAgainstFilesystem(File rootDirectoryOnFS, VerifyParameters params);
/**
* Verifies the content of the archive against the filesystem.
*
* @param fileOrDir The file or directory entry in the archive to verify. May be empty, in which
* case all entries below <var>rootDirectoryInArchive</var> are verified.
* @param rootDirectoryOnFS The root directory on the file system that should be added to each
* entry in the archive when comparing.
* @param rootDirectoryInArchive The root directory in the archive to start verify from. It will
* be stripped from each entry before <var>rootDirectoryOnFS</var> is added.
*/
public List<ArchiveEntry> verifyAgainstFilesystem(String fileOrDir, File rootDirectoryOnFS,
String rootDirectoryInArchive);
//
// Extraction
//
/**
* Extract the content of a file in the archive to an {@link OutputStream}.
*
* @param path The path of the file to extract the content of.
* @param out The output stream to extract the content to.
* @return This archive reader.
*/
public IHDF5ArchiveReader extractFile(String path, OutputStream out);
/**
* Extract the content of a file in the archive to a byte array.
*
* @param path The path of the file to extract the content of.
* @return The byte array representing the content of the file.
*/
public byte[] extractFileAsByteArray(String path);
/**
* Extract the content of a file in the archive as an {@link IInputStream}.
*
* @param path The path of the file to extract the content of.
* @return The input stream interface. If an error occurs and the
* {@link ch.systemsx.cisd.base.exceptions.IErrorStrategy} of the archive reader does
* not re-throw the exception, the return value will be <code>null</code> on errors.
*/
public IInputStream extractFileAsIInputStream(String path);
/**
* Extract the content of a file in the archive as an {@link InputStream}.
*
* @param path The path of the file to extract the content of.
* @return The input stream. If an error occurs and the
* {@link ch.systemsx.cisd.base.exceptions.IErrorStrategy} of the archive reader does
* not re-throw the exception, the return value will be <code>null</code> on errors.
*/
public InputStream extractFileAsInputStream(String path);
/**
* Extracts the complete archive to the file system.
*
* @param rootDirectory The directory in the file system to use as root directory for the
* extracted archive path.
* @return This archive reader.
*/
public IHDF5ArchiveReader extractToFilesystem(File rootDirectory);
/**
* Extracts a path from the archive to the file system.
*
* @param rootDirectory The directory in the file system to use as root directory for the
* extracted archive path.
* @param path The path in the archive to extract. This path will be kept unchanged when
* extracted.
* @return This archive reader.
*/
public IHDF5ArchiveReader extractToFilesystem(File rootDirectory, String path);
/**
* Extracts a path from the archive to the file system.
*
* @param rootDirectory The directory in the file system to use as root directory for the
* extracted archive path.
* @param path The path in the archive to extract. This path will be kept unchanged when
* extracted.
* @param visitorOrNull The entry visitor to call for each entry. Call
* {@link ArchiveEntry#isOK()} to check whether verification was successful. May be
* <code>null</code>.
* @return This archive reader.
*/
public IHDF5ArchiveReader extractToFilesystem(File rootDirectory, String path,
IArchiveEntryVisitor visitorOrNull);
/**
* Extracts a path from the archive to the file system.
*
* @param rootDirectory The directory in the file system to use as root directory for the
* extracted archive path.
* @param path The path in the archive to extract. This path will be kept unchanged when
* extracted.
* @param strategy The strategy to determine which files and directories to extract and which
* ones to suppress.
* @param visitorOrNull The entry visitor to call for each entry. Call
* {@link ArchiveEntry#isOK()} to check whether verification was successful. May be
* <code>null</code>.
* @return This archive reader.
*/
public IHDF5ArchiveReader extractToFilesystem(File rootDirectory, String path,
ArchivingStrategy strategy, IArchiveEntryVisitor visitorOrNull);
/**
* Extracts all paths below a given directory path from the archive to the file system.
*
* @param rootDirectory The directory in the file system to use as root directory for the
* extracted archive path.
* @param rootInArchive The root path in the archive to extract. This path will be stripped when
* extracted.
* @return This archive reader.
*/
public IHDF5ArchiveReader extractToFilesystemBelowDirectory(File rootDirectory,
String rootInArchive);
/**
* Extracts all paths below a given directory path from the archive to the file system.
*
* @param rootDirectory The directory in the file system to use as root directory for the
* extracted archive path.
* @param rootInArchive The root path in the archive to extract. This path will be stripped when
* extracted.
* @param visitorOrNull The entry visitor to call for each entry. Call
* {@link ArchiveEntry#isOK()} to check whether verification was successful. May be
* <code>null</code>.
* @return This archive reader.
*/
public IHDF5ArchiveReader extractToFilesystemBelowDirectory(File rootDirectory,
String rootInArchive, IArchiveEntryVisitor visitorOrNull);
/**
* Extracts all paths below a given directory path from the archive to the file system.
*
* @param rootDirectory The directory in the file system to use as root directory for the
* extracted archive path.
* @param rootInArchive The root path in the archive to extract. This path will be stripped when
* extracted.
* @param strategy The strategy to determine which files and directories to extract and which
* ones to suppress.
* @param visitorOrNull The entry visitor to call for each entry. Call
* {@link ArchiveEntry#isOK()} to check whether verification was successful. May be
* <code>null</code>.
* @return This archive reader.
*/
public IHDF5ArchiveReader extractToFilesystemBelowDirectory(File rootDirectory,
String rootInArchive, ArchivingStrategy strategy, IArchiveEntryVisitor visitorOrNull);
/**
* Extracts a path from the archive below a given directory path to the file system.
*
* @param rootDirectory The directory in the file system to use as root directory for the
* extracted archive path.
* @param rootInArchive The root path in the archive to extract. This path will be stripped when
* extracted.
* @param path The path in the archive to extract, relative to <var>rootPathInArchive</var>.
* This path will be kept unchanged when extracted.
* @param strategy The strategy to determine which files and directories to extract and which
* ones to suppress.
* @param visitorOrNull The entry visitor to call for each entry. Call
* {@link ArchiveEntry#isOK()} to check whether verification was successful. May be
* <code>null</code>.
* @return This archive reader.
*/
public IHDF5ArchiveReader extractToFilesystemBelowDirectory(File rootDirectory,
String rootInArchive, String path, ArchivingStrategy strategy,
IArchiveEntryVisitor visitorOrNull);
}
|