com.groupdocs.parser

Interfaces

Classes

Exceptions

com.groupdocs.parser

Class MediaTypeDetector

    • Constructor Detail

      • MediaTypeDetector

        public MediaTypeDetector()
    • Method Detail

      • detect

        public String detect(InputStream stream)

        Detects the media type by the content of the stream.

        Parameters:
        stream - Stream of the document.
        Returns:
        A string with the media type if the media type is detected; otherwise, null.
        Throws:
        ArgumentNullException - stream is null.
      • detect

        public String detect(String fileName)

        Detects the media type by the fileName.

        Parameters:
        fileName - The name of the file.
        Returns:
        A string with the media type if the media type is detected; otherwise, null.
      • supports

        public boolean supports(String mediaType)

        Detects whether the mediaType is supported by the detector.

        Parameters:
        mediaType - A string with the media type.
        Returns:
        A boolean true if the media type is supported; otherwise, false.
      • detectByContent

        protected String detectByContent(InputStream stream)

        Detects the media type by the content of the stream.

        Parameters:
        stream - Stream of the document.
        Returns:
        A string with the media type if the media type is detected; otherwise, null.
      • detectByExt

        protected abstract String detectByExt(String ext)

        Detects the media type by the ext.

        Parameters:
        ext - The extension of the file in the UPPER case.
        Returns:
        A string with the media type if the media type is detected; otherwise, null.
      • checkMediaType

        protected abstract boolean checkMediaType(String mediaType)

        Detects whether the mediaType is supported by the detector.

        Parameters:
        mediaType - A string with media type in the UPPER case.
        Returns:
        A boolean true if the media type is supported; otherwise, false.