1 /*--------------------------------------------------------------------------
2 * Copyright 2009 Taro L. Saito
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *--------------------------------------------------------------------------*/
16 //--------------------------------------
20 // Since: Feb 10, 2009 10:38:10 AM
24 //--------------------------------------
25 package org.xerial.util;
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
37 public enum FileType {
63 POWER_POINT("ppt,pptx"),
74 private static HashMap<String, FileType> fileTypeTable = new HashMap<String, FileType>();
77 for (FileType eachType : FileType.values())
79 for (String eachExt : eachType.getFileExtList())
80 fileTypeTable.put(eachExt, eachType);
84 private ArrayList<String> fileExtList;
86 private FileType(String fileExtCSV)
88 String[] fileExt = fileExtCSV.split(",\\s*");
89 assert (fileExt != null);
90 fileExtList = new ArrayList<String>(fileExt.length);
91 for (String each : fileExt)
93 fileExtList.add(each);
97 public List<String> getFileExtList()
108 public static FileType getFileType(String fileExt)
110 return fileTypeTable.get(fileExt.toLowerCase());