View Javadoc
1   /**
2    * SpamSchutz - simple way to protect your mail addresses from naïve spammers
3    * Copyright (C) 2011, Aiki IT
4    * <p/>
5    * This program is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU 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    * <p/>
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 General Public License for more details.
14   * <p/>
15   * You should have received a copy of the GNU General Public License
16   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  package de.aikiit.spamprotector.converter;
19  
20  import lombok.Getter;
21  
22  /**
23   * Encapsulates the character conversion logics.
24   * Each changeable character is represented by an enumeration instance and
25   * allows conversion from/to the encoded value.
26   */
27  @Getter
28  public enum CharacterConverter {
29  
30      /** Space */
31      SPACE(" ", "&nbsp;"), //
32      /** Exclamation mark */
33      EXCLAMATION_MARK("!", "&#33;"), //
34      /** Quotation */
35      QUOTE("\"", "&#34;"), //
36      /** Hash */
37      HASH("#", "&#35;"), //
38      /** Dollar sign */
39      DOLLAR("$", "&#36;"), //
40      /** Percent */
41      PERCENT("%", "&#37;"), //
42      /** Ampersand */
43      AMPERSAND("&", "&amp;"), //
44      /** Single quotation */
45      SINGLE_QUOTE("\'", "&#39;"), //
46      /** Left bracket */
47      LEFT_BRACKET("(", "&#40;"), //
48      /** Right bracket */
49      RIGHT_BRACKET(")", "&#41;"), //
50      /** Asterisk */
51      ASTERISK("*", "&#42;"), //
52      /** Plus sign */
53      PLUS("+", "&#43;"), //
54      /** Comma */
55      COMMA(",", "&#44;"), //
56      /** Minus sign */
57      MINUS("-", "&#45;"), //
58      /** Plain dot */
59      DOT(".", "&#46;"), //
60      /** Single slash */
61      SLASH("/", "&#47;"), //
62      /** Number 0 */
63      ZERO("0", "&#48;"), //
64      /** Number 1 */
65      ONE("1", "&#49;"), //
66      /** Number 2 */
67      TWO("2", "&#50;"), //
68      /** Number 3 */
69      THREE("3", "&#51;"), //
70      /** Number 4 */
71      FOUR("4", "&#52;"), //
72      /** Number 5 */
73      FIVE("5", "&#53;"), //
74      /** Number 6 */
75      SIX("6", "&#54;"), //
76      /** Number 7 */
77      SEVEN("7", "&#55;"), //
78      /** Number 8 */
79      EIGHT("8", "&#56;"), //
80      /** Number 9 */
81      NINE("9", "&#57;"), //
82      /** Colon */
83      COLON(":", "&#58;"), //
84      /** Semicolon */
85      SEMICOLON(";", "&#59;"), //
86      /** Less than */
87      LT("<", "&#60;"), //
88      /** Equal sign */
89      EQUAL("=", "&#61;"), //
90      /** Greater than */
91      GT(">", "&#62;"), //
92      /** Question mark */
93      QUESTION_MARK("?", "&#63;"), //
94      /** AT sign */
95      AT("@", "&#64;"), //
96      /** A */
97      CAPITAL_A("A", "&#65;"), //
98      /** B */
99      CAPITAL_B("B", "&#66;"), //
100     /** C */
101     CAPITAL_C("C", "&#67;"), //
102     /** D */
103     CAPITAL_D("D", "&#68;"), //
104     /** E */
105     CAPITAL_E("E", "&#69;"), //
106     /** F */
107     CAPITAL_F("F", "&#70;"), //
108     /** G */
109     CAPITAL_G("G", "&#71;"), //
110     /** H */
111     CAPITAL_H("H", "&#72;"), //
112     /** I */
113     CAPITAL_I("I", "&#73;"), //
114     /** J */
115     CAPITAL_J("J", "&#74;"), //
116     /** K */
117     CAPITAL_K("K", "&#75;"), //
118     /** L */
119     CAPITAL_L("L", "&#76;"), //
120     /** M */
121     CAPITAL_M("M", "&#77;"), //
122     /** N */
123     CAPITAL_N("N", "&#78;"), //
124     /** O */
125     CAPITAL_O("O", "&#79;"), //
126     /** P */
127     CAPITAL_P("P", "&#80;"), //
128     /** Q */
129     CAPITAL_Q("Q", "&#81;"), //
130     /** R */
131     CAPITAL_R("R", "&#82;"), //
132     /** S */
133     CAPITAL_S("S", "&#83;"), //
134     /** T */
135     CAPITAL_T("T", "&#84;"), //
136     /** U */
137     CAPITAL_U("U", "&#85;"), //
138     /** V */
139     CAPITAL_V("V", "&#86;"), //
140     /** W */
141     CAPITAL_W("W", "&#87;"), //
142     /** X */
143     CAPITAL_X("X", "&#88;"), //
144     /** Y */
145     CAPITAL_Y("Y", "&#89;"), //
146     /** Z */
147     CAPITAL_Z("Z", "&#90;"), //
148     /** [ */
149     LEFT_SQUARE_BRACKET("[", "&#91;"), //
150     /** Backslash */
151     BACKSLASH("\\", "&#92;"), //
152     /** ] */
153     RIGHT_SQUARE_BRACKET("]", "&#93;"), //
154     /** Circumflex */
155     CIRCUMFLEX("^", "&#94;"), //
156     /** Underscore */
157     UNDERSCORE("_", "&#95;"), //
158     /** Tick */
159     TICK("`", "&#96;"), //
160     /** a */
161     A("a", "&#97;"), //
162     /** b */
163     B("b", "&#98;"), //
164     /** c */
165     C("c", "&#99;"), //
166     /** d */
167     D("d", "&#100;"), //
168     /** e */
169     E("e", "&#101;"), //
170     /** f */
171     F("f", "&#102;"), //
172     /** g */
173     G("g", "&#103;"), //
174     /** h */
175     H("h", "&#104;"), //
176     /** i */
177     I("i", "&#105;"), //
178     /** j */
179     J("j", "&#106;"), //
180     /** k */
181     K("k", "&#107;"), //
182     /** l */
183     L("l", "&#108;"), //
184     /** m */
185     M("m", "&#109;"), //
186     /** n */
187     N("n", "&#110;"), //
188     /** o */
189     O("o", "&#111;"), //
190     /** p */
191     P("p", "&#112;"), //
192     /** q */
193     Q("q", "&#113;"), //
194     /** r */
195     R("r", "&#114;"), //
196     /** s */
197     S("s", "&#115;"), //
198     /** t */
199     T("t", "&#116;"), //
200     /** u */
201     U("u", "&#117;"), //
202     /** v */
203     V("v", "&#118;"), //
204     /** w */
205     W("w", "&#119;"), //
206     /** x */
207     X("x", "&#120;"), //
208     /** y */
209     Y("y", "&#121;"), //
210     /** z */
211     Z("z", "&#122;"), //
212     /** { */
213     LEFT_CURLY_BRACKET("{", "&#123;"), //
214     /** Pipe */
215     PIPE("|", "&#124;"), //
216     /** } */
217     RIGHT_CURLY_BRACKET("}", "&#125;"), //
218     /** Tilde */
219     TILDE("~", "&#126;"), //
220     //
221     ;
222 
223     private final String plain;
224     private final String replacement;
225 
226     CharacterConverter(final String plain, final String placement) {
227         this.plain = plain;
228         this.replacement = placement;
229     }
230 
231 }