Package com.jk.core.mime
Class MagicMimeEntry
java.lang.Object
com.jk.core.mime.MagicMimeEntry
This class contains constants representing different types used in the Magic
MIME database and proper methods to interact and use them.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Represents the belong type.static final int
Represents the beshort type.static final int
Represents the byte type.static final int
Represents the lelong type.static final int
Represents the leshort type.static final int
Represents the short type.static final int
Represents the string type identifier.static final int
Represents the unknown type. -
Constructor Summary
ConstructorsConstructorDescriptionMagicMimeEntry
(ArrayList<?> entries) This method constructs a newMagicMimeEntry
with the provided sub-entries. -
Method Summary
Modifier and TypeMethodDescriptionint
This method gets the check bytes from.This method gets the entry content.getMatch
(byte[] content) This method attempts to match the provided content against the patterns and rules defined by this MagicMimeEntry.This method gets the MIME type.int
getType()
This method gets the numeric value that represents this entry type.toString()
void
traverseAndPrint
(String tabs) This method prints the sub-entries content and separate them with a tab.
-
Field Details
-
STRING_TYPE
public static final int STRING_TYPERepresents the string type identifier.- See Also:
-
BELONG_TYPE
public static final int BELONG_TYPERepresents the belong type.- See Also:
-
SHORT_TYPE
public static final int SHORT_TYPERepresents the short type.- See Also:
-
LELONG_TYPE
public static final int LELONG_TYPERepresents the lelong type.- See Also:
-
BESHORT_TYPE
public static final int BESHORT_TYPERepresents the beshort type.- See Also:
-
LESHORT_TYPE
public static final int LESHORT_TYPERepresents the leshort type.- See Also:
-
BYTE_TYPE
public static final int BYTE_TYPERepresents the byte type.- See Also:
-
UNKNOWN_TYPE
public static final int UNKNOWN_TYPERepresents the unknown type.- See Also:
-
-
Constructor Details
-
MagicMimeEntry
This method constructs a newMagicMimeEntry
with the provided sub-entries.- Parameters:
entries
- Specifies this entry sub=entries.- Throws:
InvalidMagicMimeEntryException
- if an invalid magic mime entry is encountered.
-
-
Method Details
-
getCheckBytesFrom
public int getCheckBytesFrom()This method gets the check bytes from.- Returns:
- the check bytes from.
-
getContent
This method gets the entry content.- Returns:
- the entry content.
-
getMatch
This method attempts to match the provided content against the patterns and rules defined by this MagicMimeEntry.If a match is found, this method returns the corresponding MIME type for the matched content.
- Parameters:
content
- Specifies the byte array representing the content to be matched.- Returns:
- the MIME type corresponding to the matched content, or null if no match is found.
- Throws:
IOException
- if an I/O exception has occurred.
-
getMimeType
This method gets the MIME type.- Returns:
- the MIME type.
-
getType
public int getType()This method gets the numeric value that represents this entry type.- Returns:
- the numeric value that represents this entry type.
-
toString
-
traverseAndPrint
This method prints the sub-entries content and separate them with a tab.- Parameters:
tabs
- Specifies the entry content.
-