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(" ", "&nbsp;"), //
31      EXCLAMATION_MARK("!", "&#33;"), //
32      QUOTE("\"", "&#34;"), //
33      HASH("#", "&#35;"), //
34      DOLLAR("$", "&#36;"), //
35      PERCENT("%", "&#37;"), //
36      AMPERSAND("&", "&amp;"), //
37      SINGLE_QUOTE("\'", "&#39;"), //
38      LEFT_BRACKET("(", "&#40;"), //
39      RIGHT_BRACKET(")", "&#41;"), //
40      ASTERISK("*", "&#42;"), //
41      PLUS("+", "&#43;"), //
42      COMMA(",", "&#44;"), //
43      MINUS("-", "&#45;"), //
44      DOT(".", "&#46;"), //
45      SLASH("/", "&#47;"), //
46      ZERO("0", "&#48;"), //
47      ONE("1", "&#49;"), //
48      TWO("2", "&#50;"), //
49      THREE("3", "&#51;"), //
50      FOUR("4", "&#52;"), //
51      FIVE("5", "&#53;"), //
52      SIX("6", "&#54;"), //
53      SEVEN("7", "&#55;"), //
54      EIGHT("8", "&#56;"), //
55      NINE("9", "&#57;"), //
56      COLON(":", "&#58;"), //
57      SEMICOLON(";", "&#59;"), //
58      LT("<", "&#60;"), //
59      EQUAL("=", "&#61;"), //
60      GT(">", "&#62;"), //
61      QUESTION_MARK("?", "&#63;"), //
62      AT("@", "&#64;"), //
63      CAPITAL_A("A", "&#65;"), //
64      CAPITAL_B("B", "&#66;"), //
65      CAPITAL_C("C", "&#67;"), //
66      CAPITAL_D("D", "&#68;"), //
67      CAPITAL_E("E", "&#69;"), //
68      CAPITAL_F("F", "&#70;"), //
69      CAPITAL_G("G", "&#71;"), //
70      CAPITAL_H("H", "&#72;"), //
71      CAPITAL_I("I", "&#73;"), //
72      CAPITAL_J("J", "&#74;"), //
73      CAPITAL_K("K", "&#75;"), //
74      CAPITAL_L("L", "&#76;"), //
75      CAPITAL_M("M", "&#77;"), //
76      CAPITAL_N("N", "&#78;"), //
77      CAPITAL_O("O", "&#79;"), //
78      CAPITAL_P("P", "&#80;"), //
79      CAPITAL_Q("Q", "&#81;"), //
80      CAPITAL_R("R", "&#82;"), //
81      CAPITAL_S("S", "&#83;"), //
82      CAPITAL_T("T", "&#84;"), //
83      CAPITAL_U("U", "&#85;"), //
84      CAPITAL_V("V", "&#86;"), //
85      CAPITAL_W("W", "&#87;"), //
86      CAPITAL_X("X", "&#88;"), //
87      CAPITAL_Y("Y", "&#89;"), //
88      CAPITAL_Z("Z", "&#90;"), //
89      LEFT_SQUARE_BRACKET("[", "&#91;"), //
90      BACKSLASH("\\", "&#92;"), //
91      RIGHT_SQUARE_BRACKET("]", "&#93;"), //
92      CIRCUMFLEX("^", "&#94;"), //
93      UNDERSCORE("_", "&#95;"), //
94      TICK("`", "&#96;"), //
95      A("a", "&#97;"), //
96      B("b", "&#98;"), //
97      C("c", "&#99;"), //
98      D("d", "&#100;"), //
99      E("e", "&#101;"), //
100     F("f", "&#102;"), //
101     G("g", "&#103;"), //
102     H("h", "&#104;"), //
103     I("i", "&#105;"), //
104     J("j", "&#106;"), //
105     K("k", "&#107;"), //
106     L("l", "&#108;"), //
107     M("m", "&#109;"), //
108     N("n", "&#110;"), //
109     O("o", "&#111;"), //
110     P("p", "&#112;"), //
111     Q("q", "&#113;"), //
112     R("r", "&#114;"), //
113     S("s", "&#115;"), //
114     T("t", "&#116;"), //
115     U("u", "&#117;"), //
116     V("v", "&#118;"), //
117     W("w", "&#119;"), //
118     X("x", "&#120;"), //
119     Y("y", "&#121;"), //
120     Z("z", "&#122;"), //
121     LEFT_CURLY_BRACKET("{", "&#123;"), //
122     PIPE("|", "&#124;"), //
123     RIGHT_CURLY_BRACKET("}", "&#125;"), //
124     TILDE("~", "&#126;"), //
125     //
126     ;
127 
128     private final String plain;
129     private final String replacement;
130 
131     CharacterConverter(final String plain, final String placement) {
132         this.plain = plain;
133         this.replacement = placement;
134     }
135 
136 }