Class DataFormat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<UntypedData>

    public class DataFormat
    extends UntypedData
    Data type to manage MIME types.

    For MIME type definition, we make use of the Tika library package.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      DataFormat()
      construct a DataFormat object with unknown type
      DataFormat​(java.lang.String mimeType)
      Constructor for DataFormat.
    • Method Summary

      Modifier and Type Method Description
      int compareTo​(UntypedData datatype)
      java.lang.String getMimeType()
      Getter for the field mimeType.
      static DataFormat guessDataFormat​(java.io.InputStream input)
      Guess the DataFormat for a given file
      void setMimeType​(java.lang.String mimeType)
      Setter for the field mimeType.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • UNKNOWN_FORMAT

        public static final DataFormat UNKNOWN_FORMAT
        The unknown format
    • Constructor Detail

      • DataFormat

        public DataFormat()
        construct a DataFormat object with unknown type
      • DataFormat

        public DataFormat​(java.lang.String mimeType)
                   throws DataFormatException
        Constructor for DataFormat.
        Parameters:
        mimeType - the data format as MIME type in the format
         major / minor
         

        E.g. unknown is:

         application / octet - stream
         
        Throws:
        DataFormatException - if using a non valid MIME type.
    • Method Detail

      • guessDataFormat

        public static DataFormat guessDataFormat​(java.io.InputStream input)
        Guess the DataFormat for a given file
        Parameters:
        input - a InputStream object.
        Returns:
        the guessed DataFormat object; if format is not recognized then the return UNKNOWN_FORMAT
      • getMimeType

        public java.lang.String getMimeType()
        Getter for the field mimeType.
        Returns:
        the mimeType
      • setMimeType

        public void setMimeType​(java.lang.String mimeType)
        Setter for the field mimeType.
        Parameters:
        mimeType - the mimeType to set