2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.io.mime;
23 import java.util.Locale;
25 import jalview.io.packed.DataProvider.JvDataType;
28 * static functions for resolving Jalview datatypes from mime types
30 * @author JimP TODO: consider making get(Mime)TypeOf functions throw exceptions
31 * rather than returning null
33 public class MimeTypes
36 * pair list {String,JvDataType} giving a mime-type followed by its associated
37 * JvDataType enumeration.
39 final public static Object[] typemap = new Object[] {
40 "application/x-align", JvDataType.ALIGNMENT,
41 "application/x-jalview-annotation", JvDataType.ANNOTATION,
42 "application/x-newick", JvDataType.TREE,
43 "application/x-new-hampshire", JvDataType.TREE,
44 "application/x-new-hampshire-extended", JvDataType.TREE,
45 "application/x-nh", JvDataType.TREE, "application/x-nhx",
46 JvDataType.TREE, "application/x-gff", JvDataType.FEATURES,
47 "application/x-gff3", JvDataType.FEATURES,
48 "application/x-jalview-feature-file", JvDataType.FEATURES,
49 "application/x-pdb", JvDataType.SEQASSOCATED };
54 * @return the associated jalview datatype or null if no mapping is available
56 public static JvDataType getTypeOf(String mimeType)
58 String mt = mimeType.toLowerCase(Locale.ROOT);
59 for (int i = 0; i < typemap.length; i += 2)
61 if (typemap[i].equals(mt))
63 return (JvDataType) typemap[i + 1];
72 * @return the primary mimetype associated with this type.
74 public static String getMimeTypeOf(JvDataType type)
76 for (int i = 1; i < typemap.length; i += 2)
78 if (typemap[i].equals(type))
80 return (String) typemap[i - 1];