Java tutorial
package be.roots.taconic.pricingguide.util; /** * This file is part of the Taconic Pricing Guide generator. This code will * generate a full featured PDF Pricing Guide by using using iText * (http://www.itextpdf.com) based on JSON files. * * Copyright (C) 2015 Roots nv * Authors: Koen Dehaen (koen.dehaen@roots.be) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * For more information, please contact Roots nv at this address: support@roots.be * */ import org.springframework.util.StringUtils; import java.util.Arrays; import java.util.List; public class GreekAlphabet { /** * Based on data provided at http://symbolcodes.tlt.psu.edu/bylanguage/greekchart.html */ public static List<String[]> getAlphabet() { return Arrays.asList(new String[] { "α", "a", "\u03B1" }, new String[] { "β", "b", "\u03B2" }, new String[] { "χ", "c", "\u03C7" }, new String[] { "δ", "d", "\u03B4" }, new String[] { "ε", "e", "\u03B5" }, new String[] { "γ", "g", "\u03B3" }, new String[] { "η", "h", "\u03B7" }, new String[] { "ι", "i", "\u03B9" }, new String[] { "φ", "j", "\u03C6" }, new String[] { "κ", "k", "\u03BA" }, new String[] { "λ", "l", "\u03BB" }, new String[] { "μ", "m", "\u03BC" }, new String[] { "ν", "n", "\u03BD" }, new String[] { "ο", "o", "\u03BF" }, new String[] { "π", "p", "\u03C0" }, new String[] { "θ", "q", "\u03B8" }, new String[] { "ρ", "r", "\u03C1" }, new String[] { "σ", "s", "\u03C3" }, new String[] { "τ", "t", "\u03C4" }, new String[] { "υ", "u", "\u03C5" }, new String[] { "ω", "w", "\u03C9" }, new String[] { "ξ", "x", "\u03BE" }, new String[] { "ψ", "y", "\u03C8" }, new String[] { "ζ", "z", "\u03B6" }); } public static char getReplacement(String greekSymbol) { for (String[] letter : getAlphabet()) { if (greekSymbol.equals(letter[0])) { return letter[1].toCharArray()[0]; } } return ' '; } public static String replaceGreekHtmlCodesWithUnicode(String text) { if (!StringUtils.isEmpty(text)) { for (String[] greekLetter : getAlphabet()) { text = text.replaceAll(greekLetter[0], greekLetter[2]); } } return text; } }