1 package jalview.ws.io.mime;
3 import jalview.io.packed.DataProvider.JvDataType;
6 * static functions for resolving Jalview datatypes from mime types
8 * TODO: consider making get(Mime)TypeOf functions throw exceptions rather than returning null
10 public class MimeTypes
13 * pair list {String,JvDataType} giving a mime-type followed by its associated JvDataType enumeration.
15 final public static Object[] typemap = new Object[] {
16 "application/x-align",JvDataType.ALIGNMENT,
17 "application/x-jalview-annotation",JvDataType.ANNOTATION,
18 "application/x-newick",JvDataType.TREE,
19 "application/x-new-hampshire",JvDataType.TREE,
20 "application/x-new-hampshire-extended",JvDataType.TREE,
21 "application/x-nh",JvDataType.TREE,
22 "application/x-nhx",JvDataType.TREE,
23 "application/x-gff",JvDataType.FEATURES,
24 "application/x-gff3",JvDataType.FEATURES,
25 "application/x-jalview-feature-file",JvDataType.FEATURES,
26 "application/x-pdb",JvDataType.SEQASSOCATED};
30 * @return the associated jalview datatype or null if no mapping is available
32 public static JvDataType getTypeOf(String mimeType)
34 String mt = mimeType.toLowerCase();
35 for (int i=0;i<typemap.length;i+=2)
37 if (typemap[i].equals(mt))
39 return (JvDataType) typemap[i+1];
48 * @return the primary mimetype associated with this type.
50 public static String getMimeTypeOf(JvDataType type)
52 for (int i=1;i<typemap.length;i+=2)
54 if (typemap[i].equals(type))
56 return (String) typemap[i-1];