Class MagicMimeEntry

java.lang.Object
com.jk.core.mime.MagicMimeEntry

public class MagicMimeEntry extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static 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

    Constructors
    Constructor
    Description
    This method constructs a new MagicMimeEntry with the provided sub-entries.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    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
    This method gets the numeric value that represents this entry type.
    void
    This method prints the sub-entries content and separate them with a tab.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • STRING_TYPE

      public static final int STRING_TYPE
      Represents the string type identifier.
      See Also:
    • BELONG_TYPE

      public static final int BELONG_TYPE
      Represents the belong type.
      See Also:
    • SHORT_TYPE

      public static final int SHORT_TYPE
      Represents the short type.
      See Also:
    • LELONG_TYPE

      public static final int LELONG_TYPE
      Represents the lelong type.
      See Also:
    • BESHORT_TYPE

      public static final int BESHORT_TYPE
      Represents the beshort type.
      See Also:
    • LESHORT_TYPE

      public static final int LESHORT_TYPE
      Represents the leshort type.
      See Also:
    • BYTE_TYPE

      public static final int BYTE_TYPE
      Represents the byte type.
      See Also:
    • UNKNOWN_TYPE

      public static final int UNKNOWN_TYPE
      Represents the unknown type.
      See Also:
  • Constructor Details

  • Method Details

    • getCheckBytesFrom

      public int getCheckBytesFrom()
      This method gets the check bytes from.
      Returns:
      the check bytes from.
    • getContent

      public String getContent()
      This method gets the entry content.
      Returns:
      the entry content.
    • getMatch

      public String getMatch(byte[] content) throws IOException
      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

      public String 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

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      string representation of the object.
    • traverseAndPrint

      public void traverseAndPrint(String tabs)
      This method prints the sub-entries content and separate them with a tab.
      Parameters:
      tabs - Specifies the entry content.