Commit | Line | Data |
---|---|---|
0ffa4754 NR |
1 | package be.nikiroo.fanfix.supported; |
2 | ||
3 | import be.nikiroo.fanfix.Instance; | |
4 | import be.nikiroo.fanfix.bundles.StringId; | |
5 | ||
6 | /** | |
7 | * The supported input types for which we can get a {@link BasicSupport} object. | |
8 | * | |
9 | * @author niki | |
10 | */ | |
11 | public enum SupportType { | |
12 | /** EPUB files created with this program */ | |
13 | EPUB, | |
14 | /** Pure text file with some rules */ | |
15 | TEXT, | |
16 | /** TEXT but with associated .info file */ | |
17 | INFO_TEXT, | |
18 | /** My Little Pony fanfictions */ | |
19 | FIMFICTION, | |
20 | /** Fanfictions from a lot of different universes */ | |
21 | FANFICTION, | |
22 | /** Website with lots of Mangas */ | |
413bcc29 | 23 | MANGAHUB, |
0ffa4754 NR |
24 | /** Furry website with comics support */ |
25 | E621, | |
26 | /** Furry website with stories */ | |
27 | YIFFSTAR, | |
28 | /** Comics and images groups, mostly but not only NSFW */ | |
29 | E_HENTAI, | |
af1f506f NR |
30 | /** Website with lots of Mangas, in French */ |
31 | MANGA_LEL, | |
0ffa4754 NR |
32 | /** CBZ files */ |
33 | CBZ, | |
34 | /** HTML files */ | |
35 | HTML; | |
36 | ||
37 | /** | |
727108fe NR |
38 | * The name of this support type (a short version). |
39 | * | |
40 | * @return the name | |
41 | */ | |
42 | public String getSourceName() { | |
43 | switch (this) { | |
44 | case CBZ: | |
45 | return "cbz"; | |
46 | case E621: | |
47 | return "e621.net"; | |
48 | case E_HENTAI: | |
49 | return "e-hentai.org"; | |
50 | case EPUB: | |
51 | return "epub"; | |
52 | case FANFICTION: | |
53 | return "Fanfiction.net"; | |
54 | case FIMFICTION: | |
55 | return "FimFiction.net"; | |
56 | case HTML: | |
57 | return "html"; | |
58 | case INFO_TEXT: | |
59 | return "info-text"; | |
60 | case MANGA_LEL: | |
6fc76bae | 61 | return "MangaLEL"; |
413bcc29 NR |
62 | case MANGAHUB: |
63 | return "MangaHub.io"; | |
727108fe NR |
64 | case TEXT: |
65 | return "text"; | |
66 | case YIFFSTAR: | |
67 | return "YiffStar"; | |
68 | } | |
69 | ||
70 | return ""; | |
71 | } | |
72 | ||
73 | /** | |
74 | * A description of this support type (more information than | |
75 | * {@link SupportType#getSourceName()}). | |
0ffa4754 NR |
76 | * |
77 | * @return the description | |
78 | */ | |
79 | public String getDesc() { | |
d66deb8d | 80 | String desc = Instance.getInstance().getTrans().getStringX(StringId.INPUT_DESC, this.name()); |
0ffa4754 NR |
81 | |
82 | if (desc == null) { | |
d66deb8d | 83 | desc = Instance.getInstance().getTrans().getString(StringId.INPUT_DESC, this); |
0ffa4754 NR |
84 | } |
85 | ||
86 | return desc; | |
87 | } | |
88 | ||
0ffa4754 NR |
89 | @Override |
90 | public String toString() { | |
91 | return super.toString().toLowerCase(); | |
92 | } | |
93 | ||
94 | /** | |
95 | * Call {@link SupportType#valueOf(String)} after conversion to upper case. | |
96 | * | |
97 | * @param typeName | |
98 | * the possible type name | |
99 | * | |
100 | * @return NULL or the type | |
101 | */ | |
102 | public static SupportType valueOfUC(String typeName) { | |
103 | return SupportType.valueOf(typeName == null ? null : typeName | |
104 | .toUpperCase()); | |
105 | } | |
106 | ||
107 | /** | |
108 | * Call {@link SupportType#valueOf(String)} after conversion to upper case | |
109 | * but return NULL for NULL instead of raising exception. | |
110 | * | |
111 | * @param typeName | |
112 | * the possible type name | |
113 | * | |
114 | * @return NULL or the type | |
115 | */ | |
116 | public static SupportType valueOfNullOkUC(String typeName) { | |
117 | if (typeName == null) { | |
118 | return null; | |
119 | } | |
120 | ||
121 | return SupportType.valueOfUC(typeName); | |
122 | } | |
123 | ||
124 | /** | |
125 | * Call {@link SupportType#valueOf(String)} after conversion to upper case | |
126 | * but return NULL in case of error instead of raising an exception. | |
127 | * | |
128 | * @param typeName | |
129 | * the possible type name | |
130 | * | |
131 | * @return NULL or the type | |
132 | */ | |
133 | public static SupportType valueOfAllOkUC(String typeName) { | |
134 | try { | |
135 | return SupportType.valueOfUC(typeName); | |
136 | } catch (Exception e) { | |
137 | return null; | |
138 | } | |
139 | } | |
140 | } |