Using StringUtils upper/lowerCase().
This commit is contained in:
parent
30b7a80c49
commit
cfdbfca0a2
7 changed files with 21 additions and 21 deletions
|
@ -102,6 +102,7 @@ import java.util.Set;
|
|||
import java.util.Timer;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.lowerCase;
|
||||
|
||||
/**
|
||||
* Implements the #mobitopia bot.
|
||||
|
@ -360,7 +361,7 @@ public class Mobibot extends PircBot {
|
|||
System.exit(1);
|
||||
}
|
||||
|
||||
final String nickname = p.getProperty("nick", Mobibot.class.getName().toLowerCase(Constants.LOCALE));
|
||||
final String nickname = p.getProperty("nick", lowerCase(Mobibot.class.getName()));
|
||||
final String channel = p.getProperty("channel");
|
||||
final String logsDir = Utils.ensureDir(p.getProperty("logs", "."), false);
|
||||
|
||||
|
@ -567,8 +568,8 @@ public class Mobibot extends PircBot {
|
|||
|
||||
for (final char c : getNick().toCharArray()) {
|
||||
if (Character.isLetter(c)) {
|
||||
buff.append('[').append(String.valueOf(c).toLowerCase(Constants.LOCALE)).append(
|
||||
String.valueOf(c).toUpperCase(Constants.LOCALE)).append(']');
|
||||
buff.append('[').append(lowerCase(String.valueOf(c))).append(StringUtils.upperCase(String.valueOf(c)))
|
||||
.append(']');
|
||||
} else {
|
||||
buff.append(c);
|
||||
}
|
||||
|
@ -697,7 +698,7 @@ public class Mobibot extends PircBot {
|
|||
if (StringUtils.isBlank(topic)) {
|
||||
helpDefault(sender, isOp, isPrivate);
|
||||
} else {
|
||||
final String lcTopic = topic.toLowerCase(Constants.LOCALE).trim();
|
||||
final String lcTopic = lowerCase(topic).trim();
|
||||
if (lcTopic.equals(getChannelName())) {
|
||||
send(sender, "To list the last 5 posts from the channel's weblog:", isPrivate);
|
||||
send(sender, Utils.helpIndent(getNick() + ": " + getChannelName()), isPrivate);
|
||||
|
@ -783,7 +784,7 @@ public class Mobibot extends PircBot {
|
|||
isCommand = true;
|
||||
|
||||
final String[] cmds = message.substring(message.indexOf(':') + 1).trim().split(" ", 2);
|
||||
final String cmd = cmds[0].toLowerCase(Constants.LOCALE);
|
||||
final String cmd = lowerCase(cmds[0]);
|
||||
|
||||
String args = "";
|
||||
|
||||
|
@ -850,7 +851,7 @@ public class Mobibot extends PircBot {
|
|||
}
|
||||
|
||||
final String[] cmds = message.split(" ", 2);
|
||||
final String cmd = cmds[0].toLowerCase(Constants.LOCALE);
|
||||
final String cmd = lowerCase(cmds[0]);
|
||||
String args = "";
|
||||
|
||||
if (cmds.length > 1) {
|
||||
|
|
|
@ -35,7 +35,7 @@ package net.thauvin.erik.mobibot;
|
|||
import net.thauvin.erik.mobibot.entries.EntryLink;
|
||||
import net.thauvin.erik.pinboard.PinboardPoster;
|
||||
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.*;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
package net.thauvin.erik.mobibot.commands.links
|
||||
|
||||
import net.thauvin.erik.mobibot.Constants
|
||||
import net.thauvin.erik.mobibot.Mobibot
|
||||
import net.thauvin.erik.mobibot.Utils
|
||||
import net.thauvin.erik.mobibot.commands.AbstractCommand
|
||||
|
@ -73,7 +72,7 @@ class View : AbstractCommand() {
|
|||
|
||||
private fun showPosts(bot: Mobibot, args: String, sender: String) {
|
||||
val max = entriesCount
|
||||
var lcArgs = args.toLowerCase(Constants.LOCALE)
|
||||
var lcArgs = args.toLowerCase()
|
||||
var i = 0
|
||||
if (lcArgs.isEmpty() && max > maxEntries) {
|
||||
i = max - maxEntries
|
||||
|
|
|
@ -35,7 +35,6 @@ package net.thauvin.erik.mobibot.entries;
|
|||
import com.rometools.rome.feed.synd.SyndCategory;
|
||||
import com.rometools.rome.feed.synd.SyndCategoryImpl;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import net.thauvin.erik.mobibot.Constants;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -361,7 +360,7 @@ public class EntryLink implements Serializable {
|
|||
|
||||
if (part.length() >= 2) {
|
||||
tag = new SyndCategoryImpl();
|
||||
tag.setName(part.substring(1).toLowerCase(Constants.LOCALE));
|
||||
tag.setName(StringUtils.lowerCase(part.substring(1)));
|
||||
|
||||
mod = part.charAt(0);
|
||||
|
||||
|
@ -375,7 +374,7 @@ public class EntryLink implements Serializable {
|
|||
this.tags.add(tag);
|
||||
}
|
||||
} else {
|
||||
tag.setName(part.trim().toLowerCase(Constants.LOCALE));
|
||||
tag.setName(StringUtils.lowerCase(part.trim()));
|
||||
|
||||
if (!this.tags.contains(tag)) {
|
||||
this.tags.add(tag);
|
||||
|
|
|
@ -55,6 +55,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.upperCase;
|
||||
|
||||
/**
|
||||
* The CurrentConverter module.
|
||||
*
|
||||
|
@ -100,8 +102,8 @@ public final class CurrencyConverter extends ThreadedModule {
|
|||
if (cmds[3].equals(cmds[1]) || "0".equals(cmds[0])) {
|
||||
return new PublicMessage("You're kidding, right?");
|
||||
} else {
|
||||
final String to = cmds[1].toUpperCase(Constants.LOCALE);
|
||||
final String from = cmds[3].toUpperCase(Constants.LOCALE);
|
||||
final String to = upperCase(cmds[1]);
|
||||
final String from = upperCase(cmds[3]);
|
||||
|
||||
if (EXCHANGE_RATES.containsKey(to) && EXCHANGE_RATES.containsKey(from)) {
|
||||
try {
|
||||
|
@ -112,13 +114,13 @@ public final class CurrencyConverter extends ThreadedModule {
|
|||
return new PublicMessage(
|
||||
NumberFormat.getCurrencyInstance(Constants.LOCALE).format(amt).substring(1)
|
||||
+ ' '
|
||||
+ cmds[1].toUpperCase(Constants.LOCALE)
|
||||
+ upperCase(cmds[1])
|
||||
+ " = "
|
||||
+ NumberFormat.getCurrencyInstance(Constants.LOCALE)
|
||||
.format((amt * doubleTo) / doubleFrom)
|
||||
.substring(1)
|
||||
+ ' '
|
||||
+ cmds[3].toUpperCase(Constants.LOCALE));
|
||||
+ upperCase(cmds[3]));
|
||||
} catch (NumberFormatException e) {
|
||||
return new ErrorMessage("Let's try with some real numbers next time, okay?");
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
package net.thauvin.erik.mobibot.modules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import net.thauvin.erik.mobibot.Constants;
|
||||
import net.thauvin.erik.mobibot.Mobibot;
|
||||
import net.thauvin.erik.mobibot.Utils;
|
||||
import net.thauvin.erik.mobibot.msg.ErrorMessage;
|
||||
import net.thauvin.erik.mobibot.msg.Message;
|
||||
import net.thauvin.erik.mobibot.msg.PublicMessage;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
@ -188,8 +188,7 @@ public final class WorldTime extends AbstractModule {
|
|||
*/
|
||||
@SuppressFBWarnings("STT_STRING_PARSING_A_FIELD")
|
||||
static Message worldTime(final String query) {
|
||||
final String tz = (COUNTRIES_MAP.get((query.substring(query.indexOf(' ') + 1).trim()
|
||||
.toUpperCase(Constants.LOCALE))));
|
||||
final String tz = (COUNTRIES_MAP.get((StringUtils.upperCase(query.substring(query.indexOf(' ') + 1).trim()))));
|
||||
final String response;
|
||||
|
||||
if (tz != null) {
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
package net.thauvin.erik.mobibot.modules;
|
||||
|
||||
import net.thauvin.erik.mobibot.Constants;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -65,7 +65,7 @@ class LocalProperties {
|
|||
}
|
||||
|
||||
private static String keyToEnv(final String key) {
|
||||
return key.replace('-', '_').toUpperCase(Constants.LOCALE);
|
||||
return StringUtils.upperCase(key.replace('-', '_'));
|
||||
}
|
||||
|
||||
@BeforeSuite(alwaysRun = true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue