Package org.cyclos.server.utils
Enum ServerImageHelper.ImageType
- java.lang.Object
-
- java.lang.Enum<ServerImageHelper.ImageType>
-
- org.cyclos.server.utils.ServerImageHelper.ImageType
-
- All Implemented Interfaces:
Serializable,Comparable<ServerImageHelper.ImageType>
- Enclosing class:
- ServerImageHelper
public static enum ServerImageHelper.ImageType extends Enum<ServerImageHelper.ImageType>
Contains the known image types
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ServerImageHelper.ImageTypegetByContent(byte[] firstBytes)Try to identify a file type given the first content bytesstatic ServerImageHelper.ImageTypegetByContent(File file)Try to identify a file type by reading it's contentstatic ServerImageHelper.ImageTypegetByContentType(String contentType)Try to identify a file type given a MIME content typestatic ServerImageHelper.ImageTypegetByFileName(String filename)Try to identify a file type given a file name, using the extensionStringgetContentType()String[]getContentTypes()StringgetExtension()String[]getExtensions()byte[]getSignature()static booleanhasImageExtension(String filename)static ServerImageHelper.ImageTypevalueOf(String name)Returns the enum constant of this type with the specified name.static ServerImageHelper.ImageType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
GIF
public static final ServerImageHelper.ImageType GIF
-
JPEG
public static final ServerImageHelper.ImageType JPEG
-
PNG
public static final ServerImageHelper.ImageType PNG
-
WEBP
public static final ServerImageHelper.ImageType WEBP
-
-
Method Detail
-
values
public static ServerImageHelper.ImageType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ServerImageHelper.ImageType c : ServerImageHelper.ImageType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ServerImageHelper.ImageType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
getByContent
public static ServerImageHelper.ImageType getByContent(byte[] firstBytes) throws IllegalArgumentException
Try to identify a file type given the first content bytes- Throws:
IllegalArgumentException- When the content is not an image
-
getByContent
public static ServerImageHelper.ImageType getByContent(File file) throws IOException, IllegalArgumentException
Try to identify a file type by reading it's content- Throws:
IOException- Error reading fileIllegalArgumentException- When the file is not an image
-
getByContentType
public static ServerImageHelper.ImageType getByContentType(String contentType) throws IllegalArgumentException
Try to identify a file type given a MIME content type- Throws:
IllegalArgumentException- When the content type is not an image
-
getByFileName
public static ServerImageHelper.ImageType getByFileName(String filename) throws IllegalArgumentException
Try to identify a file type given a file name, using the extension- Throws:
IllegalArgumentException- When the fileName is not an image
-
hasImageExtension
public static boolean hasImageExtension(String filename)
-
getContentType
public String getContentType()
-
getContentTypes
public String[] getContentTypes()
-
getExtension
public String getExtension()
-
getExtensions
public String[] getExtensions()
-
getSignature
public byte[] getSignature()
-
-