]>
git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/ajaxplorer/file/FileType.java
48d45a2774ffe5d3dcc3aac87f1413d213079edb
2 * Copyright (C) 2007-2012 Mathieu Baudier
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.
16 package org
.argeo
.slc
.web
.ajaxplorer
.file
;
20 import org
.argeo
.slc
.web
.ajaxplorer
.AjxpDriverException
;
22 public enum FileType
{
23 FOLDER("folder.png", "Directory"), UNKNOWN("mime_empty.png", "Unkown"), GIF(
24 "image.png", "GIF Picture"), JPEG("image.png", "JPEG Picture"), PNG(
25 "image.png", "PNG Picture");
27 private final String icon
;
28 private final String mimeString
;
30 FileType(String icon
, String mimeString
) {
32 this.mimeString
= mimeString
;
35 public String
getIcon() {
39 public String
getMimeString() {
43 public boolean isImage() {
44 return this == GIF
|| this == JPEG
|| this == PNG
;
47 public String
getImageType() {
56 throw new AjxpDriverException("Image type undefined for " + this);
59 public static FileType
findType(File file
) {
60 String ext
= file
.isDirectory() ?
null : file
.getName().substring(
61 file
.getName().indexOf('.') + 1);
66 * Find the type based on the extension.
69 * the extension, null for a directory
71 public static FileType
findType(String extArg
) {
75 String ext
= extArg
.toLowerCase();
76 if (ext
.equals("jpg") || ext
.equals("jpeg"))
78 else if (ext
.equals("gif"))
80 else if (ext
.equals("png"))