Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.ws.io.mime

File MimeTypes.java

 

Coverage histogram

../../../../img/srcFileCovDistChart0.png
56% of files have more coverage

Code metrics

8
9
2
1
83
39
6
0.67
4.5
2
3

Classes

Class Line # Actions
MimeTypes 31 9 6 19
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.ws.io.mime;
22   
23    import jalview.io.packed.DataProvider.JvDataType;
24   
25    /**
26    * static functions for resolving Jalview datatypes from mime types
27    *
28    * @author JimP TODO: consider making get(Mime)TypeOf functions throw exceptions
29    * rather than returning null
30    */
 
31    public class MimeTypes
32    {
33    /**
34    * pair list {String,JvDataType} giving a mime-type followed by its associated
35    * JvDataType enumeration.
36    */
37    final public static Object[] typemap = new Object[] {
38    "application/x-align", JvDataType.ALIGNMENT,
39    "application/x-jalview-annotation", JvDataType.ANNOTATION,
40    "application/x-newick", JvDataType.TREE,
41    "application/x-new-hampshire", JvDataType.TREE,
42    "application/x-new-hampshire-extended", JvDataType.TREE,
43    "application/x-nh", JvDataType.TREE, "application/x-nhx",
44    JvDataType.TREE, "application/x-gff", JvDataType.FEATURES,
45    "application/x-gff3", JvDataType.FEATURES,
46    "application/x-jalview-feature-file", JvDataType.FEATURES,
47    "application/x-pdb", JvDataType.SEQASSOCATED };
48   
49    /**
50    *
51    * @param mimeType
52    * @return the associated jalview datatype or null if no mapping is available
53    */
 
54  0 toggle public static JvDataType getTypeOf(String mimeType)
55    {
56  0 String mt = mimeType.toLowerCase();
57  0 for (int i = 0; i < typemap.length; i += 2)
58    {
59  0 if (typemap[i].equals(mt))
60    {
61  0 return (JvDataType) typemap[i + 1];
62    }
63    }
64  0 return null;
65    }
66   
67    /**
68    *
69    * @param type
70    * @return the primary mimetype associated with this type.
71    */
 
72  0 toggle public static String getMimeTypeOf(JvDataType type)
73    {
74  0 for (int i = 1; i < typemap.length; i += 2)
75    {
76  0 if (typemap[i].equals(type))
77    {
78  0 return (String) typemap[i - 1];
79    }
80    }
81  0 return null;
82    }
83    }