org.apache.wookie.w3c.util
Class ContentTypeUtils

java.lang.Object
  extended by org.apache.wookie.w3c.util.ContentTypeUtils

public class ContentTypeUtils
extends java.lang.Object

Utils for content type sniffing


Constructor Summary
ContentTypeUtils()
           
 
Method Summary
static boolean isSupported(java.lang.String value, java.lang.String[] supportedValues)
          Checks to see if the supplied value is one of the supported values
static boolean isSupportedImageType(java.io.File file)
          Checks to see if a file is a supported image type
static boolean isSupportedImageType(java.io.InputStream inputStream)
          Checks to see if an inputstream contains a supported image type
static boolean isSupportedImageType(java.lang.String filename)
          Checks to see if a filename is a supported image type based on its file extension
protected static java.lang.String sniffContentType(java.io.File file)
          Sniffs the content type for images and other common types
protected static java.lang.String sniffContentType(java.io.InputStream inputStream)
          Sniffs the content type for images and other common types
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentTypeUtils

public ContentTypeUtils()
Method Detail

isSupportedImageType

public static boolean isSupportedImageType(java.lang.String filename)
Checks to see if a filename is a supported image type based on its file extension

Parameters:
filename - the filename to check
Returns:
true if the filename has an extension for a supported image type

isSupportedImageType

public static boolean isSupportedImageType(java.io.File file)
Checks to see if a file is a supported image type

Parameters:
file - the file to check
Returns:
true if the file is a supported image type

isSupportedImageType

public static boolean isSupportedImageType(java.io.InputStream inputStream)
                                    throws java.io.IOException
Checks to see if an inputstream contains a supported image type

Parameters:
inputStream -
Returns:
true if the file is a supported image type
Throws:
java.io.IOException

sniffContentType

protected static java.lang.String sniffContentType(java.io.File file)
                                            throws java.io.IOException
Sniffs the content type for images and other common types

Parameters:
file - the file to sniff
Returns:
the content type of the file if it matches a known signature, otherwise Null
Throws:
java.io.IOException

sniffContentType

protected static java.lang.String sniffContentType(java.io.InputStream inputStream)
                                            throws java.io.IOException
Sniffs the content type for images and other common types

Parameters:
inputStream - the inputStream to sniff
Returns:
the content type of the stream if it matches a known signature, otherwise Null
Throws:
java.io.IOException

isSupported

public static boolean isSupported(java.lang.String value,
                                  java.lang.String[] supportedValues)
Checks to see if the supplied value is one of the supported values

Parameters:
value -
supportedValues -
Returns:
true if the value is one of the supported values


2012 Apache Software Foundation.