BrightSide Workbench Full Report + Source Code
FontAwesome.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2015 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.html;
20 
21 import org.amic.util.string.Strings;
22 
27 public class FontAwesome {
28 
29  public static String getIcon(String icon) {
30  return getIcon(icon, null);
31  }
32 
33  public static String getIcon(String icon, String modifiers) {
34  return "<i class=\"fa fa-" + icon + (Strings.isBlank(modifiers) ? "" : " " + modifiers) + "\"></i>";
35  }
36 
37  public static String getMimeIcon(String type) {
38  return getIcon(getNameMimeMap(type));
39  }
40 
41  public static String getNameMimeMap(String type) {
42  switch(type.toLowerCase()) {
43  case "folder":
44  return "folder";
45  case "folder-open":
46  return "folder-open";
47  case "zip":
48  case "7z":
49  case "ace":
50  case "ar":
51  case "arj":
52  case "bz":
53  case "rar":
54  case "rpm":
55  case "deb":
56  case "tar":
57  return "file-archive-o";
58  case "ac3":
59  case "midi":
60  case "mp3":
61  case "wav":
62  return "music";
63  case "avi":
64  case "mpg":
65  case "mp4":
66  case "mkv":
67  case "rm":
68  return "film";
69  case "gif":
70  case "jpg":
71  case "png":
72  case "bmp":
73  case "odg":
74  case "svg":
75  return "picture-o";
76  case "txt":
77  return "file-text-o";
78  case "odt":
79  case "doc":
80  case "docx":
81  case "rtf":
82  case "scribus":
83  return "file-word-o";
84  case "ods":
85  case "xls":
86  case "xlsx":
87  return "file-excel-o";
88  case "odp":
89  case "ppt":
90  case "pptx":
91  return "file-powerpoint-o";
92  case "pdf":
93  return "file-pdf-o";
94  case "awk":
95  case "css":
96  case "html":
97  case "js":
98  case "make":
99  case "xml":
100  case "rss":
101  return "file-code-o";
102  case "java":
103  case "jar":
104  return "coffee";
105  case "ascii":
106  case "bin":
107  case "csv":
108  case "log":
109  return "file-o";
110  case "db":
111  case "mdb":
112  case "sql":
113  case "odb":
114  return "database";
115  case "calendar":
116  return "calendar-o";
117  case "encrypted":
118  case "pgp":
119  return "user-secret";
120  case "font":
121  case "ttf":
122  return "font";
123  case "info":
124  case "readme":
125  return "info-circle";
126  case "iso":
127  return "hdd-o";
128  case "man":
129  return "book";
130  case "odf":
131  return "superscript";
132  case "message":
133  return "envelope-o";
134  case "ps":
135  return "print";
136  case "recycled":
137  return "recycle";
138  case "tmp":
139  return "clock";
140  case "torrent":
141  return "download";
142  }
143  return "question-circle";
144  }
145 
146  private FontAwesome() {
147  }
148 
149 }
static String getIcon(String icon)
static String getNameMimeMap(String type)
static String getIcon(String icon, String modifiers)
static String getMimeIcon(String type)