More javadoc improvements.

This commit is contained in:
Erik C. Thauvin 2016-07-18 19:34:23 -07:00
parent 88115b6ee8
commit 80302ce179
17 changed files with 150 additions and 48 deletions

View file

@ -15,7 +15,7 @@ import java.time.*;
public final class ReleaseInfo { public final class ReleaseInfo {
private final static String buildmeta = "009"; private final static String buildmeta = "009";
private final static LocalDateTime date = private final static LocalDateTime date =
LocalDateTime.ofInstant(Instant.ofEpochMilli(1468789269982L), ZoneId.systemDefault()); LocalDateTime.ofInstant(Instant.ofEpochMilli(1468895453561L), ZoneId.systemDefault());
private final static int major = 0; private final static int major = 0;
private final static int minor = 7; private final static int minor = 7;
private final static int patch = 0; private final static int patch = 0;

View file

@ -173,7 +173,9 @@ final class EntriesMgr {
* @param history The history array. * @param history The history array.
* @param isDayBackup Set the true if the daily backup file should also be created. * @param isDayBackup Set the true if the daily backup file should also be created.
*/ */
public static void saveEntries(final Mobibot bot, final List<EntryLink> entries, final List<String> history, public static void saveEntries(final Mobibot bot,
final List<EntryLink> entries,
final List<String> history,
final boolean isDayBackup) { final boolean isDayBackup) {
if (bot.getLogger().isDebugEnabled()) { if (bot.getLogger().isDebugEnabled()) {
bot.getLogger().debug("Saving the feeds..."); bot.getLogger().debug("Saving the feeds...");

View file

@ -32,8 +32,7 @@
package net.thauvin.erik.mobibot; package net.thauvin.erik.mobibot;
import java.io.Serializable; import java.io.Serializable;
import java.util.Calendar; import java.time.LocalDateTime;
import java.util.Date;
/** /**
* The class used to store comments associated to a specific entry. * The class used to store comments associated to a specific entry.
@ -47,7 +46,7 @@ public class EntryComment implements Serializable {
static final long serialVersionUID = 6957415292233553224L; static final long serialVersionUID = 6957415292233553224L;
// The creation date. // The creation date.
private final Date date = Calendar.getInstance().getTime(); private final LocalDateTime date = LocalDateTime.now();
private String comment = ""; private String comment = "";
private String nick = ""; private String nick = "";
@ -96,7 +95,7 @@ public class EntryComment implements Serializable {
* @return The date. * @return The date.
*/ */
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
public final Date getDate() { public final LocalDateTime getDate() {
return date; return date;
} }

View file

@ -85,7 +85,11 @@ public class EntryLink implements Serializable {
* @param channel The channel. * @param channel The channel.
* @param tags The entry's tags/categories. * @param tags The entry's tags/categories.
*/ */
public EntryLink(final String link, final String title, final String nick, final String login, final String channel, public EntryLink(final String link,
final String title,
final String nick,
final String login,
final String channel,
final String tags) { final String tags) {
this.link = link; this.link = link;
this.title = title; this.title = title;
@ -106,7 +110,11 @@ public class EntryLink implements Serializable {
* @param date The entry date. * @param date The entry date.
* @param tags The entry's tags/categories. * @param tags The entry's tags/categories.
*/ */
public EntryLink(final String link, final String title, final String nick, final String channel, final Date date, public EntryLink(final String link,
final String title,
final String nick,
final String channel,
final Date date,
final List<SyndCategory> tags) { final List<SyndCategory> tags) {
this.link = link; this.link = link;
this.title = title; this.title = title;
@ -280,44 +288,10 @@ public class EntryLink implements Serializable {
/** /**
* Sets the tags. * Sets the tags.
* *
* @param tags The space-delimited tags. * @param tags The tags.
*/ */
public final void setTags(final String tags) { private void setTags(final List<SyndCategory> tags) {
if (tags != null) { this.tags.addAll(tags);
final String[] parts = tags.replaceAll(", ", " ").replaceAll(",", " ").split(" ");
SyndCategoryImpl tag;
String part;
char mod;
for (final String rawPart : parts) {
part = rawPart.trim();
if (part.length() >= 2) {
tag = new SyndCategoryImpl();
tag.setName(part.substring(1).toLowerCase());
mod = part.charAt(0);
if (mod == '-') {
// Don't remove the channel tag, if any.
if (!tag.getName().equals(channel.substring(1))) {
this.tags.remove(tag);
}
} else if (mod == '+') {
if (!this.tags.contains(tag)) {
this.tags.add(tag);
}
} else {
tag.setName(part.trim().toLowerCase());
if (!this.tags.contains(tag)) {
this.tags.add(tag);
}
}
}
}
}
} }
/** /**
@ -372,10 +346,44 @@ public class EntryLink implements Serializable {
/** /**
* Sets the tags. * Sets the tags.
* *
* @param tags The tags. * @param tags The space-delimited tags.
*/ */
private void setTags(final List<SyndCategory> tags) { public final void setTags(final String tags) {
this.tags.addAll(tags); if (tags != null) {
final String[] parts = tags.replaceAll(", ", " ").replaceAll(",", " ").split(" ");
SyndCategoryImpl tag;
String part;
char mod;
for (final String rawPart : parts) {
part = rawPart.trim();
if (part.length() >= 2) {
tag = new SyndCategoryImpl();
tag.setName(part.substring(1).toLowerCase());
mod = part.charAt(0);
if (mod == '-') {
// Don't remove the channel tag, if any.
if (!tag.getName().equals(channel.substring(1))) {
this.tags.remove(tag);
}
} else if (mod == '+') {
if (!this.tags.contains(tag)) {
this.tags.add(tag);
}
} else {
tag.setName(part.trim().toLowerCase());
if (!this.tags.contains(tag)) {
this.tags.add(tag);
}
}
}
}
}
} }
/** /**

View file

@ -904,6 +904,9 @@ public class Mobibot extends PircBot {
return false; return false;
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected final void onAction(final String sender, protected final void onAction(final String sender,
final String login, final String login,
@ -915,6 +918,9 @@ public class Mobibot extends PircBot {
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected final void onDisconnect() { protected final void onDisconnect() {
if (Utils.isValidString(weblogUrl)) { if (Utils.isValidString(weblogUrl)) {
@ -956,11 +962,17 @@ public class Mobibot extends PircBot {
joinChannel(channel); joinChannel(channel);
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected void onJoin(final String channel, final String sender, final String login, final String hostname) { protected void onJoin(final String channel, final String sender, final String login, final String hostname) {
tell.send(sender); tell.send(sender);
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected final void onMessage(final String channel, protected final void onMessage(final String channel,
final String sender, final String sender,
@ -1298,11 +1310,17 @@ public class Mobibot extends PircBot {
tell.send(sender, true); tell.send(sender, true);
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected void onNickChange(final String oldNick, final String login, final String hostname, final String newNick) { protected void onNickChange(final String oldNick, final String login, final String hostname, final String newNick) {
tell.send(newNick); tell.send(newNick);
} }
/**
* {@inheritDoc}
*/
@Override @Override
protected final void onPrivateMessage(final String sender, protected final void onPrivateMessage(final String sender,
final String login, final String login,

View file

@ -58,6 +58,9 @@ public class Calc extends AbstractModule {
commands.add(CALC_CMD); commands.add(CALC_CMD);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
if (Utils.isValidString(args)) { if (Utils.isValidString(args)) {
@ -79,6 +82,9 @@ public class Calc extends AbstractModule {
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
bot.send(sender, "To solve a mathematical calculation:"); bot.send(sender, "To solve a mathematical calculation:");

View file

@ -81,6 +81,9 @@ final public class CurrencyConverter extends AbstractModule {
commands.add(CURRENCY_CMD); commands.add(CURRENCY_CMD);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
synchronized (this) { synchronized (this) {
@ -92,6 +95,9 @@ final public class CurrencyConverter extends AbstractModule {
new Thread(() -> run(bot, sender, args)).start(); new Thread(() -> run(bot, sender, args)).start();
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
bot.send(sender, "To convert from one currency to another:"); bot.send(sender, "To convert from one currency to another:");

View file

@ -92,12 +92,18 @@ final public class Dice extends AbstractModule {
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
bot.send(sender, "To roll the dice:"); bot.send(sender, "To roll the dice:");
bot.send(sender, bot.helpIndent(bot.getNick() + ": " + DICE_CMD)); bot.send(sender, bot.helpIndent(bot.getNick() + ": " + DICE_CMD));
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean isEnabled() { public boolean isEnabled() {
return true; return true;

View file

@ -72,6 +72,9 @@ final public class GoogleSearch extends AbstractModule {
properties.put(GOOGLE_CSE_KEY_PROP, ""); properties.put(GOOGLE_CSE_KEY_PROP, "");
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
if (isEnabled() && args.length() > 0) { if (isEnabled() && args.length() > 0) {
@ -81,6 +84,9 @@ final public class GoogleSearch extends AbstractModule {
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
if (isEnabled()) { if (isEnabled()) {
@ -91,6 +97,9 @@ final public class GoogleSearch extends AbstractModule {
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean isEnabled() { public boolean isEnabled() {
return isValidProperties(); return isValidProperties();

View file

@ -64,11 +64,17 @@ final public class Joke extends AbstractModule {
commands.add(JOKE_CMD); commands.add(JOKE_CMD);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
new Thread(() -> run(bot, sender)).start(); new Thread(() -> run(bot, sender)).start();
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
bot.send(sender, "To retrieve a random joke:"); bot.send(sender, "To retrieve a random joke:");

View file

@ -185,6 +185,9 @@ final public class Lookup extends AbstractModule {
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
bot.send(sender, "To perform a DNS lookup query:"); bot.send(sender, "To perform a DNS lookup query:");

View file

@ -73,6 +73,9 @@ public class Ping extends AbstractModule {
commands.add(PING_CMD); commands.add(PING_CMD);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
final Random r = new Random(); final Random r = new Random();
@ -80,6 +83,9 @@ public class Ping extends AbstractModule {
bot.action(PINGS.get(r.nextInt(PINGS.size()))); bot.action(PINGS.get(r.nextInt(PINGS.size())));
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
bot.send(sender, "To ping the bot:"); bot.send(sender, "To ping the bot:");

View file

@ -61,6 +61,9 @@ final public class StockQuote extends AbstractModule {
commands.add(STOCK_CMD); commands.add(STOCK_CMD);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
if (args.length() > 0) { if (args.length() > 0) {
@ -70,6 +73,9 @@ final public class StockQuote extends AbstractModule {
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
bot.send(sender, "To retrieve a stock quote:"); bot.send(sender, "To retrieve a stock quote:");

View file

@ -66,6 +66,9 @@ final public class Twitter extends AbstractModule {
properties.put(TOKEN_SECRET_PROP, ""); properties.put(TOKEN_SECRET_PROP, "");
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
if (isEnabled() && args.length() > 0) { if (isEnabled() && args.length() > 0) {
@ -75,6 +78,9 @@ final public class Twitter extends AbstractModule {
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
if (isEnabled()) { if (isEnabled()) {
@ -85,6 +91,9 @@ final public class Twitter extends AbstractModule {
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean isEnabled() { public boolean isEnabled() {
return isValidProperties(); return isValidProperties();

View file

@ -100,6 +100,9 @@ final public class War extends AbstractModule {
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
bot.send(sender, "To play war:"); bot.send(sender, "To play war:");

View file

@ -66,11 +66,17 @@ final public class Weather extends AbstractModule {
commands.add(WEATHER_CMD); commands.add(WEATHER_CMD);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
new Thread(() -> run(bot, sender, args.toUpperCase(), isPrivate)).start(); new Thread(() -> run(bot, sender, args.toUpperCase(), isPrivate)).start();
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
bot.send(sender, "To display weather information:"); bot.send(sender, "To display weather information:");
@ -78,6 +84,9 @@ final public class Weather extends AbstractModule {
bot.send(sender, "For a listing of the ICAO station IDs, please visit: " + STATIONS_URL); bot.send(sender, "For a listing of the ICAO station IDs, please visit: " + STATIONS_URL);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean isPrivateMsgEnabled() { public boolean isPrivateMsgEnabled() {
return true; return true;

View file

@ -185,6 +185,9 @@ final public class WorldTime extends AbstractModule {
} }
} }
/**
* {@inheritDoc}
*/
@Override @Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) { public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
bot.send(sender, "To display a country's current date/time:"); bot.send(sender, "To display a country's current date/time:");
@ -206,6 +209,9 @@ final public class WorldTime extends AbstractModule {
return String.format("%c%03d", '@', beats); return String.format("%c%03d", '@', beats);
} }
/**
* {@inheritDoc}
*/
@Override @Override
public boolean isPrivateMsgEnabled() { public boolean isPrivateMsgEnabled() {
return true; return true;