package buzzerproxy;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import buzzerproxy.Mediatype;
/**
* @author Master
*/
public enum Filetype implements Serializable {
//*********
// Musik
//*********
MP3(Mediatype.MUSIK, "mp3"),
FLAC(Mediatype.MUSIK, "flac"), WMA(Mediatype.MUSIK, "wma"),
MIDI(Mediatype.MUSIK, "midi"), MP2(Mediatype.MUSIK, "mp2"),
WAV(Mediatype.MUSIK, "wav"), AAC(Mediatype.MUSIK, "aac"),
SMAF(Mediatype.MUSIK, "smaf"), MLD(Mediatype.MUSIK, "mld"),
OGG(Mediatype.MUSIK, "ogg"), MMF(Mediatype.MUSIK, "mmf"),
AIFF(Mediatype.MUSIK, "aiff"), RMA(Mediatype.MUSIK, "rma"),
MPC(Mediatype.MUSIK, "mpc"), APE(Mediatype.MUSIK,"ape"), // musik
//*********
// Bilder
//*********
JPG(Mediatype.BILDER, "jpg"), JPEG(Mediatype.BILDER, "jpeg"),
PNG(Mediatype.BILDER, "png"), GIF(Mediatype.BILDER, "gif"),
BMP(Mediatype.BILDER, "bmp"), TIFF(Mediatype.BILDER, "tiff"),
SVG(Mediatype.BILDER, "svg"), JPA(Mediatype.BILDER, "jpa"),
TIF(Mediatype.BILDER, "tif"), THM(Mediatype.BILDER, "thm"), // bilder
//*********
// Video
//*********
PG3(Mediatype.VIDEO, "3gp"), MPG(Mediatype.VIDEO, "mpg"),
AVI(Mediatype.VIDEO, "avi"), WMV(Mediatype.VIDEO, "wmv"),
MP4(Mediatype.VIDEO, "mp4"), MPE(Mediatype.VIDEO, "mpe"),
RM(Mediatype.VIDEO, "rm"), MPEG(Mediatype.VIDEO, "mpeg"),
MOV(Mediatype.VIDEO,"mov"), WMM(Mediatype.VIDEO, "wmm"),
WMF(Mediatype.VIDEO, "wmf"), RAM(Mediatype.VIDEO, "ram"),
OGM(Mediatype.VIDEO, "ogm"), ASX(Mediatype.VIDEO, "asx"),
FLV(Mediatype.VIDEO, "flv"), FLA(Mediatype.VIDEO, "fla"),
SWF(Mediatype.VIDEO, "swf"), F4V(Mediatype.VIDEO, "f4v"),
DIV(Mediatype.VIDEO, "div"), DIVX(Mediatype.VIDEO, "divx"),
XVID(Mediatype.VIDEO, "xvid"), MKV(Mediatype.VIDEO, "mkv"), // video
//*********
// Anwendungen
//*********
IPA(Mediatype.APPS, "ipa"), JAR(Mediatype.APPS, "jar"),
JAD(Mediatype.APPS, "jad"), CLASS(Mediatype.APPS, "class"),
SIS(Mediatype.APPS, "sis"), SISX(Mediatype.APPS, "sisx"),
APK(Mediatype.APPS, "apk"), // anwendungen
//*********
// Komprimierte Daten - Premium
//*********
RAR(Mediatype.COMPRESSED, "rar"), ZIP(Mediatype.COMPRESSED, "zip"),
GZ(Mediatype.COMPRESSED, "gz"), TAR(Mediatype.COMPRESSED, "tar"), ISO(Mediatype.COMPRESSED, "iso"), // komprimierte Dateien - premium
//*********
// Text
//*********
TXT(Mediatype.TEXT, "txt"), TEXT(Mediatype.TEXT, "text"), RTF(Mediatype.TEXT, "rtf"), // text
//*********
// Office Premium
//*********
PDF(Mediatype.OFFICE, "pdf"), DOC(Mediatype.OFFICE, "doc"),
DOCX(Mediatype.OFFICE, "docx"), PPT(Mediatype.OFFICE, "ppt"),
PPTX(Mediatype.OFFICE, "pptx"), XML(Mediatype.OFFICE, "xml"), HTM(Mediatype.OFFICE, "htm"),
ODT(Mediatype.OFFICE,"odt"), XLS(Mediatype.OFFICE, "xls"), XLSX(Mediatype.OFFICE, "xlsx"), // Office Dateien nur fuer Premium
//*********
// Premium
//*********
TEMPLATE(Mediatype.PREMIUM, ""), // premium darf dateityp selbst definieren und danach suchen
//*********
// NOT SUPPORTED
//*********
NONE(null, "");
private Mediatype type;
private String caption;
/**
* @param type
* @param caption
*/
private Filetype(Mediatype type, String caption) {
this.type = type;
this.caption = caption;
}
/**
* @return
*/
public String getCaption() {
return caption;
}
/**
* Sucht im Enum nach dem Filetype.
* Beispiel:
* filetype kann .mp3 oder mp3 sein.
* @param filetype
* @return
*/
public static Filetype getFileType(String filetype) {
for ( Filetype ft : Filetype.values() ) {
if ( ft.caption.equals( filetype ) )
return ft;
if ( filetype.startsWith( "." ) && ft.caption.equals( filetype.substring( 1, filetype.length() ) ) )
return ft;
}
return null;
}
/**
* Gibt alle Filetypen eines Mediatype zurück
* @param type
* @return
*/
public static Filetype[] getFilesTypeForMediaType(Mediatype type) {
List res = new ArrayList();
for ( Filetype ft : Filetype.values() ) {
if ( ft.type == type )
res.add( ft );
}
return res.toArray( new Filetype[0] );
}
/**
* @return
*/
public Mediatype getType() {
return type;
}
}