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 */ | |
23 | MANGAFOX, | |
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 | /** | |
38 | * A description of this support type (more information than the | |
39 | * {@link BasicSupport#getSourceName()}). | |
40 | * | |
41 | * @return the description | |
42 | */ | |
43 | public String getDesc() { | |
44 | String desc = Instance.getTrans().getStringX(StringId.INPUT_DESC, | |
45 | this.name()); | |
46 | ||
47 | if (desc == null) { | |
48 | desc = Instance.getTrans().getString(StringId.INPUT_DESC, this); | |
49 | } | |
50 | ||
51 | return desc; | |
52 | } | |
53 | ||
54 | /** | |
55 | * The name of this support type (a short version). | |
56 | * | |
57 | * @return the name | |
58 | */ | |
59 | public String getSourceName() { | |
60 | BasicSupport support = BasicSupport.getSupport(this, null); | |
61 | if (support != null) { | |
62 | return support.getSourceName(); | |
63 | } | |
64 | ||
65 | return null; | |
66 | } | |
67 | ||
68 | @Override | |
69 | public String toString() { | |
70 | return super.toString().toLowerCase(); | |
71 | } | |
72 | ||
73 | /** | |
74 | * Call {@link SupportType#valueOf(String)} after conversion to upper case. | |
75 | * | |
76 | * @param typeName | |
77 | * the possible type name | |
78 | * | |
79 | * @return NULL or the type | |
80 | */ | |
81 | public static SupportType valueOfUC(String typeName) { | |
82 | return SupportType.valueOf(typeName == null ? null : typeName | |
83 | .toUpperCase()); | |
84 | } | |
85 | ||
86 | /** | |
87 | * Call {@link SupportType#valueOf(String)} after conversion to upper case | |
88 | * but return NULL for NULL instead of raising exception. | |
89 | * | |
90 | * @param typeName | |
91 | * the possible type name | |
92 | * | |
93 | * @return NULL or the type | |
94 | */ | |
95 | public static SupportType valueOfNullOkUC(String typeName) { | |
96 | if (typeName == null) { | |
97 | return null; | |
98 | } | |
99 | ||
100 | return SupportType.valueOfUC(typeName); | |
101 | } | |
102 | ||
103 | /** | |
104 | * Call {@link SupportType#valueOf(String)} after conversion to upper case | |
105 | * but return NULL in case of error instead of raising an exception. | |
106 | * | |
107 | * @param typeName | |
108 | * the possible type name | |
109 | * | |
110 | * @return NULL or the type | |
111 | */ | |
112 | public static SupportType valueOfAllOkUC(String typeName) { | |
113 | try { | |
114 | return SupportType.valueOfUC(typeName); | |
115 | } catch (Exception e) { | |
116 | return null; | |
117 | } | |
118 | } | |
119 | } |