Here you can find the source of colorize(String original)
Parameter | Description |
---|---|
original | Original string to be parsed against group of color names. |
String
- The parsed string after conversion.
public static String colorize(String original)
//package com.java2s; /**/*from www . j a va2 s . co m*/ * Permissions 2.x * Copyright (C) 2011 Matt 'The Yeti' Burnett <admin@theyeticave.net> * Original Credit & Copyright (C) 2010 Nijikokun <nijikokun@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Permissions Public License as published by * the Free Software Foundation, either version 2 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 Permissions Public License for more details. * * You should have received a copy of the GNU Permissions Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Converts color codes into the simoleon code. Sort of a HTML format color * code tag. * <p> * Color codes allowed: black, navy, green, teal, red, purple, gold, silver, * gray, blue, lime, aqua, rose, pink, yellow, white. * </p> * Example: <blockquote * * <pre> * Messaging.colorize("Hello <green>world!"); // returns: Hello \u00A72world! * </pre> * * </blockquote> * * @param original * Original string to be parsed against group of color names. * * @return <code>String</code> - The parsed string after conversion. */ public static String colorize(String original) { // Removed the weird character return original.replace("<black>", "\u00A70").replace("<navy>", "\u00A71").replace("<green>", "\u00A72") .replace("<teal>", "\u00A73").replace("<red>", "\u00A74").replace("<purple>", "\u00A75") .replace("<gold>", "\u00A76").replace("<silver>", "\u00A77").replace("<gray>", "\u00A78") .replace("<blue>", "\u00A79").replace("<lime>", "\u00A7a").replace("<aqua>", "\u00A7b") .replace("<rose>", "\u00A7c").replace("<pink>", "\u00A7d").replace("<yellow>", "\u00A7e") .replace("<white>", "\u00A7f"); } }