Class ZipArchiveMagicNumber
- java.lang.Object
-
- org.arakhne.afc.inputoutput.filetype.MagicNumber
-
- org.arakhne.afc.inputoutput.filetype.ZipArchiveMagicNumber
-
- All Implemented Interfaces:
Comparable<MagicNumber>
- Direct Known Subclasses:
ZipArchiveXMLMagicNumber
public abstract class ZipArchiveMagicNumber extends MagicNumber
This class defines a set of informations that could distinguish a file content from another one. It is also known as Magic Number on several operating systems.This magic number supports zip archive of files. For a single zipped file, please use
ZipMagicNumber
. For a jar file, plase useJarMagicNumber
.- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:40
- Author:
- Stéphane GALLAND
- See Also:
ZipMagicNumber
,JarMagicNumber
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- inputoutput
-
-
Constructor Summary
Constructors Constructor Description ZipArchiveMagicNumber(javax.activation.MimeType mimeType)
Constructor.ZipArchiveMagicNumber(javax.activation.MimeType mimeType, File innerFile)
Constructor.ZipArchiveMagicNumber(javax.activation.MimeType mimeType, String formatVersion)
Constructor.ZipArchiveMagicNumber(javax.activation.MimeType mimeType, String formatVersion, File innerFile)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
doStreamEncoding(MagicNumberStream stream)
Invoked beforeMagicNumber.isContentType(MagicNumberStream)
to prepare the stream.protected abstract boolean
isContentType(ZipInputStream zipStream, ZipEntry zipEntry, InputStream zipEntryStream)
Replies if the specified stream contains data that corresponds to this magic number.protected boolean
isContentType(MagicNumberStream stream)
Replies if the specified stream contains data that corresponds to this magic number.protected void
undoStreamEncoding(MagicNumberStream stream)
Invoked beforeMagicNumber.isContentType(MagicNumberStream)
to unprepare the stream.-
Methods inherited from class org.arakhne.afc.inputoutput.filetype.MagicNumber
compareTo, getFormatVersion, getHostMimeTypes, getMimeType
-
-
-
-
Constructor Detail
-
ZipArchiveMagicNumber
public ZipArchiveMagicNumber(javax.activation.MimeType mimeType)
Constructor.- Parameters:
mimeType
- is the MIME type associated to this magic number.
-
ZipArchiveMagicNumber
public ZipArchiveMagicNumber(javax.activation.MimeType mimeType, String formatVersion, File innerFile)
Constructor.- Parameters:
mimeType
- is the MIME type associated to this magic number.formatVersion
- is the version of the supported format.innerFile
- is the file to open from the inside of the Zip archive to test the type. The filename is relative to the root of the zip file content.
-
ZipArchiveMagicNumber
public ZipArchiveMagicNumber(javax.activation.MimeType mimeType, File innerFile)
Constructor.- Parameters:
mimeType
- is the MIME type associated to this magic number.innerFile
- is the file to open from the inside of the Zip archive to test the type. The filename is relative to the root of the zip file content.
-
ZipArchiveMagicNumber
public ZipArchiveMagicNumber(javax.activation.MimeType mimeType, String formatVersion)
Constructor.- Parameters:
mimeType
- is the MIME type associated to this magic number.formatVersion
- is the version of the supported format.
-
-
Method Detail
-
doStreamEncoding
protected void doStreamEncoding(MagicNumberStream stream) throws IOException
Description copied from class:MagicNumber
Invoked beforeMagicNumber.isContentType(MagicNumberStream)
to prepare the stream.- Overrides:
doStreamEncoding
in classMagicNumber
- Parameters:
stream
- is the stream to analyse.- Throws:
IOException
- in case of IO error.
-
undoStreamEncoding
protected void undoStreamEncoding(MagicNumberStream stream) throws IOException
Description copied from class:MagicNumber
Invoked beforeMagicNumber.isContentType(MagicNumberStream)
to unprepare the stream.- Overrides:
undoStreamEncoding
in classMagicNumber
- Parameters:
stream
- is the stream to analyse.- Throws:
IOException
- in case of IO error.
-
isContentType
protected final boolean isContentType(MagicNumberStream stream)
Description copied from class:MagicNumber
Replies if the specified stream contains data that corresponds to this magic number.- Specified by:
isContentType
in classMagicNumber
- Parameters:
stream
- is the stream to analyse.- Returns:
true
if the stream is containing this magic number, otherwisefalse
-
isContentType
protected abstract boolean isContentType(ZipInputStream zipStream, ZipEntry zipEntry, InputStream zipEntryStream)
Replies if the specified stream contains data that corresponds to this magic number.- Parameters:
zipStream
- is the stream of the Zip archivezipEntry
- is the zip entry that is corresponding to the innerFile given as parameter of the constructor, ornull
not significant.zipEntryStream
- is the stream on the data of the given zip entry, ornull
not significant.- Returns:
true
if the stream is containing this magic number, otherwisefalse
-
-