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 {
private final static String buildmeta = "009";
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 minor = 7;
private final static int patch = 0;

View file

@ -173,7 +173,9 @@ final class EntriesMgr {
* @param history The history array.
* @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) {
if (bot.getLogger().isDebugEnabled()) {
bot.getLogger().debug("Saving the feeds...");

View file

@ -32,8 +32,7 @@
package net.thauvin.erik.mobibot;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.time.LocalDateTime;
/**
* 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;
// The creation date.
private final Date date = Calendar.getInstance().getTime();
private final LocalDateTime date = LocalDateTime.now();
private String comment = "";
private String nick = "";
@ -96,7 +95,7 @@ public class EntryComment implements Serializable {
* @return The date.
*/
@SuppressWarnings("UnusedDeclaration")
public final Date getDate() {
public final LocalDateTime getDate() {
return date;
}

View file

@ -85,7 +85,11 @@ public class EntryLink implements Serializable {
* @param channel The channel.
* @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) {
this.link = link;
this.title = title;
@ -106,7 +110,11 @@ public class EntryLink implements Serializable {
* @param date The entry date.
* @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) {
this.link = link;
this.title = title;
@ -280,44 +288,10 @@ public class EntryLink implements Serializable {
/**
* Sets the tags.
*
* @param tags The space-delimited tags.
* @param tags The tags.
*/
public final void setTags(final String 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);
}
}
}
}
}
private void setTags(final List<SyndCategory> tags) {
this.tags.addAll(tags);
}
/**
@ -372,10 +346,44 @@ public class EntryLink implements Serializable {
/**
* Sets the tags.
*
* @param tags The tags.
* @param tags The space-delimited tags.
*/
private void setTags(final List<SyndCategory> tags) {
this.tags.addAll(tags);
public final void setTags(final String 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;
}
/**
* {@inheritDoc}
*/
@Override
protected final void onAction(final String sender,
final String login,
@ -915,6 +918,9 @@ public class Mobibot extends PircBot {
}
}
/**
* {@inheritDoc}
*/
@Override
protected final void onDisconnect() {
if (Utils.isValidString(weblogUrl)) {
@ -956,11 +962,17 @@ public class Mobibot extends PircBot {
joinChannel(channel);
}
/**
* {@inheritDoc}
*/
@Override
protected void onJoin(final String channel, final String sender, final String login, final String hostname) {
tell.send(sender);
}
/**
* {@inheritDoc}
*/
@Override
protected final void onMessage(final String channel,
final String sender,
@ -1298,11 +1310,17 @@ public class Mobibot extends PircBot {
tell.send(sender, true);
}
/**
* {@inheritDoc}
*/
@Override
protected void onNickChange(final String oldNick, final String login, final String hostname, final String newNick) {
tell.send(newNick);
}
/**
* {@inheritDoc}
*/
@Override
protected final void onPrivateMessage(final String sender,
final String login,

View file

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

View file

@ -81,6 +81,9 @@ final public class CurrencyConverter extends AbstractModule {
commands.add(CURRENCY_CMD);
}
/**
* {@inheritDoc}
*/
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
synchronized (this) {
@ -92,6 +95,9 @@ final public class CurrencyConverter extends AbstractModule {
new Thread(() -> run(bot, sender, args)).start();
}
/**
* {@inheritDoc}
*/
@Override
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:");

View file

@ -92,12 +92,18 @@ final public class Dice extends AbstractModule {
}
}
/**
* {@inheritDoc}
*/
@Override
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, bot.helpIndent(bot.getNick() + ": " + DICE_CMD));
}
/**
* {@inheritDoc}
*/
@Override
public boolean isEnabled() {
return true;

View file

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

View file

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

View file

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

View file

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

View file

@ -61,6 +61,9 @@ final public class StockQuote extends AbstractModule {
commands.add(STOCK_CMD);
}
/**
* {@inheritDoc}
*/
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
if (args.length() > 0) {
@ -70,6 +73,9 @@ final public class StockQuote extends AbstractModule {
}
}
/**
* {@inheritDoc}
*/
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
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, "");
}
/**
* {@inheritDoc}
*/
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
if (isEnabled() && args.length() > 0) {
@ -75,6 +78,9 @@ final public class Twitter extends AbstractModule {
}
}
/**
* {@inheritDoc}
*/
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
if (isEnabled()) {
@ -85,6 +91,9 @@ final public class Twitter extends AbstractModule {
}
}
/**
* {@inheritDoc}
*/
@Override
public boolean isEnabled() {
return isValidProperties();

View file

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

View file

@ -66,11 +66,17 @@ final public class Weather extends AbstractModule {
commands.add(WEATHER_CMD);
}
/**
* {@inheritDoc}
*/
@Override
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
new Thread(() -> run(bot, sender, args.toUpperCase(), isPrivate)).start();
}
/**
* {@inheritDoc}
*/
@Override
public void helpResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
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);
}
/**
* {@inheritDoc}
*/
@Override
public boolean isPrivateMsgEnabled() {
return true;

View file

@ -185,6 +185,9 @@ final public class WorldTime extends AbstractModule {
}
}
/**
* {@inheritDoc}
*/
@Override
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:");
@ -206,6 +209,9 @@ final public class WorldTime extends AbstractModule {
return String.format("%c%03d", '@', beats);
}
/**
* {@inheritDoc}
*/
@Override
public boolean isPrivateMsgEnabled() {
return true;