Package org.apache.poi.poifs.filesystem
Enum FileMagic
- All Implemented Interfaces:
Serializable,Comparable<FileMagic>,java.lang.constant.Constable
The file magic number, i.e. the file identification based on the first bytes
of the file
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionBIFF2 raw stream - for Excel 2BIFF3 raw stream - for Excel 3BIFF4 raw stream - for Excel 4BMP imageEMF imageGIF imageSome different HTML documentsJPEG imageOld MS Write raw streamOLE2 / BIFF8+ stream used for Office 97 and higher documentsOOXML / ZIP stream - The first 4 bytes of an OOXML file, used in detectionPDF documentPNG ImageRTF documentTIFF ImageUNKNOWN magicWMF image with a placeable headerXML file - The first 5 bytes of a raw XML file, used in detection -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamprepareToCheckMagic(InputStream stream) Checks if anInputStreamcan be reset (i.e.static FileMagicvalueOf(byte[] magic) Returns the enum constant of this type with the specified name.static FileMagicGet the file magic of the suppliedFilestatic FileMagicvalueOf(InputStream inp) Get the file magic of the supplied InputStream (which MUST support mark and reset).static FileMagicReturns the enum constant of this type with the specified name.static FileMagic[]values()Returns an array containing the constants of this enum type, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
OLE2
OLE2 / BIFF8+ stream used for Office 97 and higher documents -
OOXML
OOXML / ZIP stream - The first 4 bytes of an OOXML file, used in detection -
XML
XML file - The first 5 bytes of a raw XML file, used in detection -
BIFF2
BIFF2 raw stream - for Excel 2 -
BIFF3
BIFF3 raw stream - for Excel 3 -
BIFF4
BIFF4 raw stream - for Excel 4 -
MSWRITE
Old MS Write raw stream -
RTF
RTF document -
PDF
PDF document -
HTML
Some different HTML documents -
WORD2
-
JPEG
JPEG image -
GIF
GIF image -
PNG
PNG Image -
TIFF
TIFF Image -
WMF
WMF image with a placeable header -
EMF
EMF image -
BMP
BMP image -
UNKNOWN
UNKNOWN magic
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
magic- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
valueOf
Get the file magic of the suppliedFileEven if this method returns
UNKNOWNit could potentially mean, that the ZIP stream has leading junk bytes- Parameters:
inp- a file to be identified- Throws:
IOException
-
valueOf
Get the file magic of the supplied InputStream (which MUST support mark and reset).If unsure if your InputStream does support mark / reset, use
prepareToCheckMagic(InputStream)to wrap it and make sure to always use that, and not the original!Even if this method returns
UNKNOWNit could potentially mean, that the ZIP stream has leading junk bytes- Parameters:
inp- An InputStream which supports either mark/reset- Throws:
IOException
-
prepareToCheckMagic
Checks if anInputStreamcan be reset (i.e. used for checking the header magic) and wraps it if not- Parameters:
stream- stream to be checked for wrapping- Returns:
- a mark enabled stream
-