From e9c6f1b027819d22075388154fe50c7fd4f6254e Mon Sep 17 00:00:00 2001 From: Rogiel Date: Sat, 14 May 2011 01:51:40 -0300 Subject: [PATCH] Written javadoc for many classes Signed-off-by: Rogiel --- .../java/com/l2jserver/GameServerModule.java | 6 + .../com/l2jserver/GeneralConfiguration.java | 5 + src/main/java/com/l2jserver/L2JConstants.java | 5 + .../java/com/l2jserver/L2JGameServer.java | 13 ++ .../java/com/l2jserver/ProtocolVersion.java | 22 ++- .../game/net/Lineage2Connection.java | 31 +++ .../game/net/Lineage2CryptographyKey.java | 38 +++- .../game/net/Lineage2PipelineFactory.java | 9 + .../l2jserver/game/net/Lineage2Session.java | 34 ++++ .../game/net/codec/Lineage2Decrypter.java | 25 +++ .../game/net/codec/Lineage2Encrypter.java | 26 +++ .../game/net/codec/Lineage2FrameDecoder.java | 6 + .../game/net/codec/Lineage2FrameEncoder.java | 6 + .../game/net/codec/Lineage2PacketReader.java | 42 ++++ .../game/net/codec/Lineage2PacketWriter.java | 16 ++ .../net/handler/Lineage2PacketHandler.java | 10 + .../game/net/packet/AbstractClientPacket.java | 6 + .../game/net/packet/AbstractServerPacket.java | 6 + .../game/net/packet/ClientPacket.java | 5 + .../game/net/packet/ClientPacketModule.java | 6 + .../com/l2jserver/game/net/packet/Packet.java | 6 + .../game/net/packet/PacketModule.java | 6 + .../game/net/packet/ServerPacket.java | 5 + .../game/net/packet/ServerPacketModule.java | 6 + .../java/com/l2jserver/model/id/ObjectID.java | 11 ++ .../com/l2jserver/model/id/TemplateID.java | 12 +- .../model/id/factory/IDFactoryModule.java | 6 + .../l2jserver/model/id/object/ActorID.java | 7 + .../model/id/object/CharacterID.java | 6 + .../com/l2jserver/model/id/object/ClanID.java | 5 + .../com/l2jserver/model/id/object/ItemID.java | 5 + .../com/l2jserver/model/id/object/PetID.java | 6 + .../object/allocator/BitSetIDAllocator.java | 14 ++ .../allocator/IDAllocatorException.java | 5 + .../object/iterator/WorldObjectIterable.java | 9 + .../object/iterator/WorldObjectIterator.java | 15 ++ .../id/template/CharacterTemplateID.java | 9 + .../model/id/template/ItemTemplateID.java | 9 + .../model/id/template/SkillTemplateID.java | 9 + .../factory/CharacterTemplateIDFactory.java | 5 + .../factory/ItemTemplateIDFactory.java | 5 + .../factory/SkillTemplateIDFactory.java | 5 + .../template/factory/TemplateIDFactory.java | 8 + .../model/template/AbstractTemplate.java | 18 +- .../model/template/ArmorTemplate.java | 6 + .../model/template/CharacterTemplate.java | 5 + .../model/template/ConsumableTemplate.java | 6 + .../model/template/ItemTemplate.java | 5 + .../model/template/PotionTemplate.java | 6 + .../model/template/SkillTemplate.java | 5 + .../l2jserver/model/template/Template.java | 21 ++ .../model/template/WeaponTemplate.java | 6 + .../character/CharacterBaseAttributes.java | 26 ++- .../l2jserver/service/AbstractService.java | 5 + .../java/com/l2jserver/service/Service.java | 6 + .../l2jserver/service/ServiceException.java | 5 + .../com/l2jserver/service/ServiceManager.java | 8 +- .../com/l2jserver/service/ServiceModule.java | 8 +- .../service/ServiceRestartException.java | 6 + .../service/ServiceStartException.java | 5 + .../service/ServiceStopException.java | 5 + .../l2jserver/service/cache/CacheService.java | 11 ++ .../l2jserver/service/cache/Cacheable.java | 8 + .../service/cache/SimpleCacheService.java | 6 + .../service/configuration/Configuration.java | 50 ++++- .../configuration/ConfigurationService.java | 16 ++ .../ProxyConfigurationService.java | 98 +++++++++- .../service/database/AbstractDAO.java | 14 ++ .../database/DB4ODatabaseConfiguration.java | 5 + .../service/database/DB4ODatabaseService.java | 7 + .../database/DatabaseConfiguration.java | 6 + .../service/database/DatabaseService.java | 6 + .../database/MySQLDatabaseConfiguration.java | 5 + .../database/MySQLDatabaseService.java | 182 +++++++++++++++++- .../service/game/world/WorldServiceImpl.java | 14 ++ .../world/event/WorldEventDispatcherImpl.java | 2 +- .../service/logging/Log4JLoggingService.java | 5 + .../service/network/NettyNetworkService.java | 5 + .../service/network/NetworkConfiguration.java | 5 + .../service/network/NetworkService.java | 6 + .../com/l2jserver/util/ArrayIterator.java | 20 ++ .../java/com/l2jserver/util/BufferUtils.java | 20 ++ .../java/com/l2jserver/util/Coordinate.java | 54 ++++++ .../java/com/l2jserver/util/RGBColor.java | 24 +++ .../util/transformer/TransformerFactory.java | 19 +- 85 files changed, 1205 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/l2jserver/GameServerModule.java b/src/main/java/com/l2jserver/GameServerModule.java index 6325c44b7..92f867ef0 100644 --- a/src/main/java/com/l2jserver/GameServerModule.java +++ b/src/main/java/com/l2jserver/GameServerModule.java @@ -1,11 +1,17 @@ package com.l2jserver; import com.google.inject.AbstractModule; +import com.google.inject.Module; import com.l2jserver.db.dao.DAOModuleMySQL5; import com.l2jserver.model.id.factory.IDFactoryModule; import com.l2jserver.routines.GameServerInitializationRoutine; import com.l2jserver.service.ServiceModule; +/** + * The game server Google Guice {@link Module}. + * + * @author Rogiel + */ public class GameServerModule extends AbstractModule { @Override protected void configure() { diff --git a/src/main/java/com/l2jserver/GeneralConfiguration.java b/src/main/java/com/l2jserver/GeneralConfiguration.java index 9d50484a2..accbbebc6 100644 --- a/src/main/java/com/l2jserver/GeneralConfiguration.java +++ b/src/main/java/com/l2jserver/GeneralConfiguration.java @@ -2,5 +2,10 @@ package com.l2jserver; import com.l2jserver.service.configuration.Configuration; +/** + * General configuration interface + * + * @author Rogiel + */ public interface GeneralConfiguration extends Configuration { } diff --git a/src/main/java/com/l2jserver/L2JConstants.java b/src/main/java/com/l2jserver/L2JConstants.java index 6c6a25de7..f064e6e45 100644 --- a/src/main/java/com/l2jserver/L2JConstants.java +++ b/src/main/java/com/l2jserver/L2JConstants.java @@ -1,5 +1,10 @@ package com.l2jserver; +/** + * Constant values for this L2J compilation + * + * @author Rogiel + */ public class L2JConstants { /** * Indicated the supported protocol for this compilation. diff --git a/src/main/java/com/l2jserver/L2JGameServer.java b/src/main/java/com/l2jserver/L2JGameServer.java index 80338d014..fd2559613 100644 --- a/src/main/java/com/l2jserver/L2JGameServer.java +++ b/src/main/java/com/l2jserver/L2JGameServer.java @@ -3,10 +3,23 @@ package com.l2jserver; import com.google.inject.Guice; import com.google.inject.Injector; +/** + * The L2JGameServer class + * + * @author Rogiel + */ public class L2JGameServer { + /** + * The server injector + */ private final Injector injector = Guice .createInjector(new GameServerModule()); + /** + * Get the injector + * + * @return the injector + */ public Injector getInjector() { return injector; } diff --git a/src/main/java/com/l2jserver/ProtocolVersion.java b/src/main/java/com/l2jserver/ProtocolVersion.java index 2c8156d9e..99733ece9 100644 --- a/src/main/java/com/l2jserver/ProtocolVersion.java +++ b/src/main/java/com/l2jserver/ProtocolVersion.java @@ -6,8 +6,18 @@ package com.l2jserver; * @author Rogiel */ public enum ProtocolVersion { - RELEASE(0), //UNK ID - FREYA(216); + /** + * Release version + */ + RELEASE(0), + /** + * Freya(216) + */ + FREYA(216, RELEASE), + /** + * High5(217) + */ + HIGH5(217, FREYA); public final ProtocolVersion parent; public final int version; @@ -15,20 +25,20 @@ public enum ProtocolVersion { ProtocolVersion(int version) { this(version, null); } - + ProtocolVersion(int version, ProtocolVersion parent) { this.version = version; this.parent = parent; } public boolean supports(ProtocolVersion version) { - if(this == version) + if (this == version) return true; - if(this.parent == null) + if (this.parent == null) return false; return this.parent.supports(version); } - + public static ProtocolVersion fromVersion(int version) { for (ProtocolVersion v : values()) { if (v.version == version) diff --git a/src/main/java/com/l2jserver/game/net/Lineage2Connection.java b/src/main/java/com/l2jserver/game/net/Lineage2Connection.java index 05d10fa21..722c437e2 100644 --- a/src/main/java/com/l2jserver/game/net/Lineage2Connection.java +++ b/src/main/java/com/l2jserver/game/net/Lineage2Connection.java @@ -18,17 +18,44 @@ import com.l2jserver.model.world.L2Character; * @author Rogiel */ public class Lineage2Connection { + /** + * The connection channel + */ private final Channel channel; + /** + * The character object + */ private L2Character character; + /** + * The Lineage 2 session + */ private Lineage2Session session; + /** + * The connection state + */ private ConnectionState state = ConnectionState.CONNECTED; + /** + * Each connection is represented by an state: connected, authenticated and + * in-game. + * + * @author Rogiel + */ public enum ConnectionState { CONNECTED, AUTHENTICATED, IN_GAME; } + /** + * The client supported protocol version + */ private ProtocolVersion version; + /** + * Creates a new instance + * + * @param channel + * the channel + */ public Lineage2Connection(Channel channel) { this.channel = channel; } @@ -116,6 +143,10 @@ public class Lineage2Connection { return version.supports(version); } + /** + * Get the channel + * @return the channel + */ public Channel getChannel() { return channel; } diff --git a/src/main/java/com/l2jserver/game/net/Lineage2CryptographyKey.java b/src/main/java/com/l2jserver/game/net/Lineage2CryptographyKey.java index 0e91e4d4e..56b479dcf 100644 --- a/src/main/java/com/l2jserver/game/net/Lineage2CryptographyKey.java +++ b/src/main/java/com/l2jserver/game/net/Lineage2CryptographyKey.java @@ -1,16 +1,39 @@ package com.l2jserver.game.net; +import java.util.Arrays; + import com.l2jserver.util.BlowFishKeygen; +/** + * Manages the cryptography key used to write/read packets. This class also + * updates the key once data has been sent/received. + * + * @author Rogiel + */ public class Lineage2CryptographyKey implements Cloneable { + /** + * The raw key + */ public final byte[] key; + /** + * Creates a new instance + * + * @param key + * the raw key + */ public Lineage2CryptographyKey(byte[] key) { this.key = key; } + /** + * Crates a new random key + * + * @return the random created key + */ public static Lineage2CryptographyKey createRandomKey() { - return new Lineage2CryptographyKey(BlowFishKeygen.getRandomKey()); + return new Lineage2CryptographyKey(Arrays.copyOf( + BlowFishKeygen.getRandomKey(), 16)); } /** @@ -20,10 +43,23 @@ public class Lineage2CryptographyKey implements Cloneable { return key; } + /** + * Get the key value for byte index i + * + * @param i + * the index i + * @return the key byte + */ public byte get(int i) { return key[i & 15]; } + /** + * Updates this key once data has been sent/received. + * + * @param size + * the data size + */ public void update(int size) { int old = key[8] & 0xff; old |= key[9] << 8 & 0xff00; diff --git a/src/main/java/com/l2jserver/game/net/Lineage2PipelineFactory.java b/src/main/java/com/l2jserver/game/net/Lineage2PipelineFactory.java index c3e8610b9..c21963fea 100644 --- a/src/main/java/com/l2jserver/game/net/Lineage2PipelineFactory.java +++ b/src/main/java/com/l2jserver/game/net/Lineage2PipelineFactory.java @@ -17,7 +17,16 @@ import com.l2jserver.game.net.codec.Lineage2PacketReader; import com.l2jserver.game.net.codec.Lineage2PacketWriter; import com.l2jserver.game.net.handler.Lineage2PacketHandler; +/** + * This class creates a new instance of {@link ChannelPipeline} and attaches all + * handlers and codecs. + * + * @author Rogiel + */ public class Lineage2PipelineFactory implements ChannelPipelineFactory { + /** + * The Google Guice {@link Injector}. + */ private final Injector injector; @Inject diff --git a/src/main/java/com/l2jserver/game/net/Lineage2Session.java b/src/main/java/com/l2jserver/game/net/Lineage2Session.java index 9abe65d2c..e5f6913c0 100644 --- a/src/main/java/com/l2jserver/game/net/Lineage2Session.java +++ b/src/main/java/com/l2jserver/game/net/Lineage2Session.java @@ -1,14 +1,48 @@ package com.l2jserver.game.net; +/** + * Lineage 2 session with the username and loginserver keys + * + * @author Rogiel + */ public class Lineage2Session { + /** + * The username + */ private final String username; + /** + * The play key, part 1 + */ private final int playKey1; + /** + * The play key, part 2 + */ private final int playKey2; + /** + * The login key, part 1 + */ private final int loginKey1; + /** + * The login key, part 2 + */ private final int loginKey2; + /** + * Creates a new instance + * + * @param username + * the username + * @param playOK1 + * the play key, part 1 + * @param playOK2 + * the play key, part 2 + * @param loginOK1 + * the login key, part 1 + * @param loginOK2 + * the login key, part 2 + */ public Lineage2Session(String username, int playOK1, int playOK2, int loginOK1, int loginOK2) { this.username = username; diff --git a/src/main/java/com/l2jserver/game/net/codec/Lineage2Decrypter.java b/src/main/java/com/l2jserver/game/net/codec/Lineage2Decrypter.java index 6e0975240..227a75c4b 100644 --- a/src/main/java/com/l2jserver/game/net/codec/Lineage2Decrypter.java +++ b/src/main/java/com/l2jserver/game/net/codec/Lineage2Decrypter.java @@ -7,10 +7,24 @@ import org.jboss.netty.handler.codec.oneone.OneToOneDecoder; import com.l2jserver.game.net.Lineage2CryptographyKey; +/** + * Decrypts encrypted Lineage II packets + * + * @author Rogiel + */ public class Lineage2Decrypter extends OneToOneDecoder { + /** + * The handler name + */ public static final String HANDLER_NAME = "crypto.decoder"; + /** + * Enabled state + */ private boolean enabled = false; + /** + * Crypto key + */ private Lineage2CryptographyKey key; @Override @@ -37,6 +51,11 @@ public class Lineage2Decrypter extends OneToOneDecoder { return buffer; } + /** + * Creates a random key and enables descrypting + * + * @return the generated key + */ public Lineage2CryptographyKey enable() { Lineage2CryptographyKey key = Lineage2CryptographyKey.createRandomKey(); this.setKey(key); @@ -44,6 +63,12 @@ public class Lineage2Decrypter extends OneToOneDecoder { return key; } + /** + * Set this decrypter key. The key can only be set once. + * + * @param key + * the key + */ public void setKey(Lineage2CryptographyKey key) { if (this.key != null) throw new IllegalStateException("Key is already set"); diff --git a/src/main/java/com/l2jserver/game/net/codec/Lineage2Encrypter.java b/src/main/java/com/l2jserver/game/net/codec/Lineage2Encrypter.java index ac66c541d..72279d826 100644 --- a/src/main/java/com/l2jserver/game/net/codec/Lineage2Encrypter.java +++ b/src/main/java/com/l2jserver/game/net/codec/Lineage2Encrypter.java @@ -7,10 +7,24 @@ import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; import com.l2jserver.game.net.Lineage2CryptographyKey; +/** + * Encrypts Lineage II packets + * + * @author Rogiel + */ public class Lineage2Encrypter extends OneToOneEncoder { + /** + * The handler name + */ public static final String HANDLER_NAME = "crypto.encoder"; + /** + * Enabled state + */ private boolean enabled = false; + /** + * Crypto key + */ private Lineage2CryptographyKey key; @Override @@ -37,11 +51,23 @@ public class Lineage2Encrypter extends OneToOneEncoder { return msg; } + /** + * Enables this encrypter with the given key + * + * @param key + * the key + */ public void enable(Lineage2CryptographyKey key) { this.setKey(key); this.setEnabled(true); } + /** + * Set this decrypter key. The key can only be set once. + * + * @param key + * the key + */ public void setKey(Lineage2CryptographyKey key) { if (this.key != null) throw new IllegalStateException("Key is already set"); diff --git a/src/main/java/com/l2jserver/game/net/codec/Lineage2FrameDecoder.java b/src/main/java/com/l2jserver/game/net/codec/Lineage2FrameDecoder.java index a9d5f96c6..aaaa61ae4 100644 --- a/src/main/java/com/l2jserver/game/net/codec/Lineage2FrameDecoder.java +++ b/src/main/java/com/l2jserver/game/net/codec/Lineage2FrameDecoder.java @@ -10,6 +10,12 @@ import org.jboss.netty.handler.codec.frame.FrameDecoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * This decoder parses Lineage II frames. Each frame is has a header of 2 bytes + * unsigned short. + * + * @author Rogiel + */ public class Lineage2FrameDecoder extends FrameDecoder { private static final int HEADER_SIZE = 2; diff --git a/src/main/java/com/l2jserver/game/net/codec/Lineage2FrameEncoder.java b/src/main/java/com/l2jserver/game/net/codec/Lineage2FrameEncoder.java index 6bb9b03e7..c480bd1e0 100644 --- a/src/main/java/com/l2jserver/game/net/codec/Lineage2FrameEncoder.java +++ b/src/main/java/com/l2jserver/game/net/codec/Lineage2FrameEncoder.java @@ -5,6 +5,12 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; +/** + * This encoder creates Lineage II frames. Each frame is has a header of 2 bytes + * unsigned short. + * + * @author Rogiel + */ public class Lineage2FrameEncoder extends OneToOneEncoder { @Override protected Object encode(ChannelHandlerContext ctx, Channel channel, diff --git a/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketReader.java b/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketReader.java index 3484ade1c..7dd90ebea 100644 --- a/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketReader.java +++ b/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketReader.java @@ -21,15 +21,43 @@ import com.l2jserver.game.net.packet.client.RequestGotoLobby; import com.l2jserver.game.net.packet.client.RequestKeyMapping; import com.l2jserver.game.net.packet.client.RequestManorList; +/** + * This decoder reads an frame and decodes the packet in it. Each packet has an + * fixed single opcode byte. Once the packet has been identified, reading is + * done by the {@link ClientPacket} class. + *

+ * Note that some packets have an additional opcode. This class also handle + * those cases. + * + * @author Rogiel + */ public class Lineage2PacketReader extends OneToOneDecoder { + /** + * The handler name + */ public static final String HANDLER_NAME = "packet.reader"; + /** + * The Google Guice {@link Injector} + */ private final Injector injector; + /** + * The logger + */ private final Logger logger = LoggerFactory .getLogger(Lineage2PacketReader.class); + /** + * The active Lineage 2 connection + */ private Lineage2Connection connection; + /** + * Creates a new instance + * + * @param injector + * the injector + */ @Inject public Lineage2PacketReader(Injector injector) { this.injector = injector; @@ -48,12 +76,26 @@ public class Lineage2PacketReader extends OneToOneDecoder { return packet; } + /** + * Crates a new instance of the packet type + * + * @param type + * the packet type + * @return the created packet + */ private ClientPacket createPacket(Class type) { if (type == null) return null; return injector.getInstance(type); } + /** + * Discovers the packet type + * + * @param buffer + * the buffer + * @return the packet class + */ private Class getPacketClass(ChannelBuffer buffer) { final short opcode = buffer.readUnsignedByte(); switch (opcode) { diff --git a/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketWriter.java b/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketWriter.java index 7483909e7..f39505e6b 100644 --- a/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketWriter.java +++ b/src/main/java/com/l2jserver/game/net/codec/Lineage2PacketWriter.java @@ -13,12 +13,28 @@ import org.slf4j.LoggerFactory; import com.l2jserver.game.net.Lineage2Connection; import com.l2jserver.game.net.packet.ServerPacket; +/** + * This encoder writes the frame content and encodes the packet in it. Each + * packet has an fixed single opcode byte. Once the packet opcode has been + * written, packet data is written by the {@link ServerPacket} class. + * + * @author Rogiel + */ public class Lineage2PacketWriter extends OneToOneEncoder { + /** + * The handler name + */ public static final String HANDLER_NAME = "packet.writer"; + /** + * The logger + */ private static final Logger log = LoggerFactory .getLogger(Lineage2PacketWriter.class); + /** + * The active Lineage 2 connection + */ private Lineage2Connection connection; @Override diff --git a/src/main/java/com/l2jserver/game/net/handler/Lineage2PacketHandler.java b/src/main/java/com/l2jserver/game/net/handler/Lineage2PacketHandler.java index 69936de64..da9fd3c1a 100644 --- a/src/main/java/com/l2jserver/game/net/handler/Lineage2PacketHandler.java +++ b/src/main/java/com/l2jserver/game/net/handler/Lineage2PacketHandler.java @@ -8,7 +8,17 @@ import org.jboss.netty.channel.SimpleChannelHandler; import com.l2jserver.game.net.Lineage2Connection; import com.l2jserver.game.net.packet.ClientPacket; +/** + * This handler dispatches the {@link ClientPacket#process(Lineage2Connection)} + * method and creates a new {@link Lineage2Connection} once a new channel is + * open. + * + * @author Rogiel + */ public class Lineage2PacketHandler extends SimpleChannelHandler { + /** + * The Lineage 2 connection + */ private Lineage2Connection connection; @Override diff --git a/src/main/java/com/l2jserver/game/net/packet/AbstractClientPacket.java b/src/main/java/com/l2jserver/game/net/packet/AbstractClientPacket.java index cd9090819..f2d86183b 100644 --- a/src/main/java/com/l2jserver/game/net/packet/AbstractClientPacket.java +++ b/src/main/java/com/l2jserver/game/net/packet/AbstractClientPacket.java @@ -1,4 +1,10 @@ package com.l2jserver.game.net.packet; +/** + * An abstract {@link ClientPacket} + * + * @author Rogiel + * @see ClientPacket + */ public abstract class AbstractClientPacket implements ClientPacket { } diff --git a/src/main/java/com/l2jserver/game/net/packet/AbstractServerPacket.java b/src/main/java/com/l2jserver/game/net/packet/AbstractServerPacket.java index 8dc2e8d63..f4836d391 100644 --- a/src/main/java/com/l2jserver/game/net/packet/AbstractServerPacket.java +++ b/src/main/java/com/l2jserver/game/net/packet/AbstractServerPacket.java @@ -1,5 +1,11 @@ package com.l2jserver.game.net.packet; +/** + * An abstract {@link ServerPacket} + * + * @author Rogiel + * @see ServerPacket + */ public abstract class AbstractServerPacket implements ServerPacket { private final int opcode; diff --git a/src/main/java/com/l2jserver/game/net/packet/ClientPacket.java b/src/main/java/com/l2jserver/game/net/packet/ClientPacket.java index 442b690b6..7de1135e4 100644 --- a/src/main/java/com/l2jserver/game/net/packet/ClientPacket.java +++ b/src/main/java/com/l2jserver/game/net/packet/ClientPacket.java @@ -4,6 +4,11 @@ import org.jboss.netty.buffer.ChannelBuffer; import com.l2jserver.game.net.Lineage2Connection; +/** + * Each implementation is an packet sent by the game client. + * + * @author Rogiel + */ public interface ClientPacket extends Packet { /** * Read binary data in the {@link ChannelBuffer}. diff --git a/src/main/java/com/l2jserver/game/net/packet/ClientPacketModule.java b/src/main/java/com/l2jserver/game/net/packet/ClientPacketModule.java index 23c58d40b..ed3019f46 100644 --- a/src/main/java/com/l2jserver/game/net/packet/ClientPacketModule.java +++ b/src/main/java/com/l2jserver/game/net/packet/ClientPacketModule.java @@ -1,8 +1,14 @@ package com.l2jserver.game.net.packet; import com.google.inject.AbstractModule; +import com.google.inject.Module; import com.l2jserver.game.net.packet.client.ProtocolVersionPacket; +/** + * Google Guice {@link Module} for client packets + * + * @author Rogiel + */ public class ClientPacketModule extends AbstractModule { @Override protected void configure() { diff --git a/src/main/java/com/l2jserver/game/net/packet/Packet.java b/src/main/java/com/l2jserver/game/net/packet/Packet.java index 0bf4786a5..f525231c2 100644 --- a/src/main/java/com/l2jserver/game/net/packet/Packet.java +++ b/src/main/java/com/l2jserver/game/net/packet/Packet.java @@ -1,4 +1,10 @@ package com.l2jserver.game.net.packet; +/** + * An simple packet. This must not be used directly, use {@link ClientPacket} or + * {@link ServerPacket} instead. + * + * @author Rogiel + */ public interface Packet { } diff --git a/src/main/java/com/l2jserver/game/net/packet/PacketModule.java b/src/main/java/com/l2jserver/game/net/packet/PacketModule.java index 4daee8c01..549dc76e4 100644 --- a/src/main/java/com/l2jserver/game/net/packet/PacketModule.java +++ b/src/main/java/com/l2jserver/game/net/packet/PacketModule.java @@ -1,7 +1,13 @@ package com.l2jserver.game.net.packet; import com.google.inject.AbstractModule; +import com.google.inject.Module; +/** + * Google Guice {@link Module} for packets + * + * @author Rogiel + */ public class PacketModule extends AbstractModule { @Override protected void configure() { diff --git a/src/main/java/com/l2jserver/game/net/packet/ServerPacket.java b/src/main/java/com/l2jserver/game/net/packet/ServerPacket.java index ae7fb9f80..484013945 100644 --- a/src/main/java/com/l2jserver/game/net/packet/ServerPacket.java +++ b/src/main/java/com/l2jserver/game/net/packet/ServerPacket.java @@ -4,6 +4,11 @@ import org.jboss.netty.buffer.ChannelBuffer; import com.l2jserver.game.net.Lineage2Connection; +/** + * Each implementation is an packet sent by the game server. + * + * @author Rogiel + */ public interface ServerPacket extends Packet { /** * Writes this packet binary data. diff --git a/src/main/java/com/l2jserver/game/net/packet/ServerPacketModule.java b/src/main/java/com/l2jserver/game/net/packet/ServerPacketModule.java index c41e58cfe..cc9b3ebca 100644 --- a/src/main/java/com/l2jserver/game/net/packet/ServerPacketModule.java +++ b/src/main/java/com/l2jserver/game/net/packet/ServerPacketModule.java @@ -1,8 +1,14 @@ package com.l2jserver.game.net.packet; import com.google.inject.AbstractModule; +import com.google.inject.Module; import com.l2jserver.game.net.packet.client.ProtocolVersionPacket; +/** + * Google Guice {@link Module} for server packets + * + * @author Rogiel + */ public class ServerPacketModule extends AbstractModule { @Override protected void configure() { diff --git a/src/main/java/com/l2jserver/model/id/ObjectID.java b/src/main/java/com/l2jserver/model/id/ObjectID.java index 73149e7e1..42959bceb 100644 --- a/src/main/java/com/l2jserver/model/id/ObjectID.java +++ b/src/main/java/com/l2jserver/model/id/ObjectID.java @@ -15,9 +15,20 @@ import com.l2jserver.model.world.WorldObject; * the {@link WorldObject} type */ public abstract class ObjectID extends ID { + /** + * Creates a new instance + * + * @param id + * the raw id + */ protected ObjectID(int id) { super(id); } + /** + * Returns the {@link WorldObject} associated with this {@link ID} + * + * @return the {@link WorldObject} if existent, null otherwise + */ public abstract T getObject(); } diff --git a/src/main/java/com/l2jserver/model/id/TemplateID.java b/src/main/java/com/l2jserver/model/id/TemplateID.java index 894f84953..be66578c5 100644 --- a/src/main/java/com/l2jserver/model/id/TemplateID.java +++ b/src/main/java/com/l2jserver/model/id/TemplateID.java @@ -7,12 +7,22 @@ import com.l2jserver.model.template.Template; * defined in the template class. * * @author Rogiel - * */ public abstract class TemplateID> extends ID { + /** + * Creates a new instance + * + * @param id + * the raw id + */ public TemplateID(int id) { super(id); } + /** + * Returns the {@link Template} associated with this {@link ID} + * + * @return the {@link Template} if existent, null otherwise + */ public abstract T getTemplate(); } diff --git a/src/main/java/com/l2jserver/model/id/factory/IDFactoryModule.java b/src/main/java/com/l2jserver/model/id/factory/IDFactoryModule.java index 307c00838..76445ccf4 100644 --- a/src/main/java/com/l2jserver/model/id/factory/IDFactoryModule.java +++ b/src/main/java/com/l2jserver/model/id/factory/IDFactoryModule.java @@ -1,6 +1,7 @@ package com.l2jserver.model.id.factory; import com.google.inject.AbstractModule; +import com.google.inject.Module; import com.google.inject.Scopes; import com.google.inject.assistedinject.FactoryModuleBuilder; import com.l2jserver.model.id.object.allocator.BitSetIDAllocator; @@ -13,6 +14,11 @@ import com.l2jserver.model.id.template.factory.CharacterTemplateIDFactory; import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory; import com.l2jserver.model.id.template.factory.SkillTemplateIDFactory; +/** + * Google Guice {@link IDFactory} {@link Module} + * + * @author Rogiel + */ public class IDFactoryModule extends AbstractModule { @Override protected void configure() { diff --git a/src/main/java/com/l2jserver/model/id/object/ActorID.java b/src/main/java/com/l2jserver/model/id/object/ActorID.java index aa48d0f3f..d84f7e67c 100644 --- a/src/main/java/com/l2jserver/model/id/object/ActorID.java +++ b/src/main/java/com/l2jserver/model/id/object/ActorID.java @@ -5,6 +5,13 @@ import com.google.inject.assistedinject.Assisted; import com.l2jserver.model.id.ObjectID; import com.l2jserver.model.world.capability.Actor; +/** + * An {@link ObjectID} instance representing an {@link Actor} object + * + * @author Rogiel + * @param + * the actor subclass + */ public abstract class ActorID extends ObjectID { @Inject public ActorID(@Assisted int id) { diff --git a/src/main/java/com/l2jserver/model/id/object/CharacterID.java b/src/main/java/com/l2jserver/model/id/object/CharacterID.java index 820cc89e5..83d97d27d 100644 --- a/src/main/java/com/l2jserver/model/id/object/CharacterID.java +++ b/src/main/java/com/l2jserver/model/id/object/CharacterID.java @@ -3,8 +3,14 @@ package com.l2jserver.model.id.object; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import com.l2jserver.db.dao.CharacterDAO; +import com.l2jserver.model.id.ObjectID; import com.l2jserver.model.world.L2Character; +/** + * An {@link ObjectID} instance representing an {@link L2Character} object + * + * @author Rogiel + */ public final class CharacterID extends ActorID { /** * Data Access Object (DAO) for characters diff --git a/src/main/java/com/l2jserver/model/id/object/ClanID.java b/src/main/java/com/l2jserver/model/id/object/ClanID.java index 8b0ed28f9..a3ebdf214 100644 --- a/src/main/java/com/l2jserver/model/id/object/ClanID.java +++ b/src/main/java/com/l2jserver/model/id/object/ClanID.java @@ -5,6 +5,11 @@ import com.l2jserver.db.dao.ClanDAO; import com.l2jserver.model.id.ObjectID; import com.l2jserver.model.world.Clan; +/** + * An {@link ObjectID} instance representing an {@link Clan} object + * + * @author Rogiel + */ public final class ClanID extends ObjectID { /** * Data Access Object (DAO) for clans diff --git a/src/main/java/com/l2jserver/model/id/object/ItemID.java b/src/main/java/com/l2jserver/model/id/object/ItemID.java index 13ac353cd..06172c633 100644 --- a/src/main/java/com/l2jserver/model/id/object/ItemID.java +++ b/src/main/java/com/l2jserver/model/id/object/ItemID.java @@ -6,6 +6,11 @@ import com.l2jserver.db.dao.ItemDAO; import com.l2jserver.model.id.ObjectID; import com.l2jserver.model.world.Item; +/** + * An {@link ObjectID} instance representing an {@link Item} object + * + * @author Rogiel + */ public final class ItemID extends ObjectID { /** * Data Access Object (DAO) for items diff --git a/src/main/java/com/l2jserver/model/id/object/PetID.java b/src/main/java/com/l2jserver/model/id/object/PetID.java index b7f67803d..9ebd35596 100644 --- a/src/main/java/com/l2jserver/model/id/object/PetID.java +++ b/src/main/java/com/l2jserver/model/id/object/PetID.java @@ -2,8 +2,14 @@ package com.l2jserver.model.id.object; import com.google.inject.Inject; import com.l2jserver.db.dao.PetDAO; +import com.l2jserver.model.id.ObjectID; import com.l2jserver.model.world.Pet; +/** + * An {@link ObjectID} instance representing an {@link Pet} object + * + * @author Rogiel + */ public final class PetID extends ActorID { /** * Data Access Object (DAO) for pets diff --git a/src/main/java/com/l2jserver/model/id/object/allocator/BitSetIDAllocator.java b/src/main/java/com/l2jserver/model/id/object/allocator/BitSetIDAllocator.java index 7f7e7be24..ef8778f5b 100644 --- a/src/main/java/com/l2jserver/model/id/object/allocator/BitSetIDAllocator.java +++ b/src/main/java/com/l2jserver/model/id/object/allocator/BitSetIDAllocator.java @@ -10,7 +10,15 @@ import org.slf4j.LoggerFactory; import com.l2jserver.util.PrimeFinder; +/** + * The {@link BitSet} id allocator allocates new IDs backed by an {@link BitSet} + * + * @author Rogiel + */ public class BitSetIDAllocator implements IDAllocator { + /** + * The logger + */ private static final Logger log = LoggerFactory .getLogger(BitSetIDAllocator.class); @@ -32,6 +40,9 @@ public class BitSetIDAllocator implements IDAllocator { */ private AtomicInteger nextId = new AtomicInteger(); + /** + * Initializes this allocator + */ public void init() { ids = new BitSet(PrimeFinder.nextPrime(100000)); ids.clear(); @@ -108,6 +119,9 @@ public class BitSetIDAllocator implements IDAllocator { } } + /** + * Increases the {@link BitSet} capacity + */ private void increaseBitSetCapacity() { log.debug("Increasing BitSet capacity from {}", ids.size()); BitSet newBitSet = new BitSet( diff --git a/src/main/java/com/l2jserver/model/id/object/allocator/IDAllocatorException.java b/src/main/java/com/l2jserver/model/id/object/allocator/IDAllocatorException.java index 2a97693b7..044e431e4 100644 --- a/src/main/java/com/l2jserver/model/id/object/allocator/IDAllocatorException.java +++ b/src/main/java/com/l2jserver/model/id/object/allocator/IDAllocatorException.java @@ -1,5 +1,10 @@ package com.l2jserver.model.id.object.allocator; +/** + * Exception thrown by an {@link IDAllocator}. + * + * @author Rogiel + */ public class IDAllocatorException extends RuntimeException { private static final long serialVersionUID = 111195059766878062L; diff --git a/src/main/java/com/l2jserver/model/id/object/iterator/WorldObjectIterable.java b/src/main/java/com/l2jserver/model/id/object/iterator/WorldObjectIterable.java index 557fb7445..fc7dc9663 100644 --- a/src/main/java/com/l2jserver/model/id/object/iterator/WorldObjectIterable.java +++ b/src/main/java/com/l2jserver/model/id/object/iterator/WorldObjectIterable.java @@ -13,8 +13,17 @@ import com.l2jserver.model.world.WorldObject; * the return object type */ public class WorldObjectIterable implements Iterable { + /** + * The {@link Iterator} + */ private final Iterator iterator; + /** + * Creates a new instance + * + * @param iterator + * the iterator + */ public WorldObjectIterable(Iterator iterator) { this.iterator = iterator; } diff --git a/src/main/java/com/l2jserver/model/id/object/iterator/WorldObjectIterator.java b/src/main/java/com/l2jserver/model/id/object/iterator/WorldObjectIterator.java index dc9dbd46e..3d6d23b42 100644 --- a/src/main/java/com/l2jserver/model/id/object/iterator/WorldObjectIterator.java +++ b/src/main/java/com/l2jserver/model/id/object/iterator/WorldObjectIterator.java @@ -17,12 +17,27 @@ import com.l2jserver.util.ArrayIterator; * the object type */ public class WorldObjectIterator implements Iterator { + /** + * The {@link ObjectID} iterator + */ private final Iterator> ids; + /** + * Creates a new instance + * + * @param ids + * the {@link ObjectID} var-arg + */ public WorldObjectIterator(ObjectID... ids) { this(new ArrayIterator>(ids)); } + /** + * Creates a new instance + * + * @param ids + * the {@link ObjectID} iterator + */ public WorldObjectIterator(Iterator> ids) { this.ids = ids; } diff --git a/src/main/java/com/l2jserver/model/id/template/CharacterTemplateID.java b/src/main/java/com/l2jserver/model/id/template/CharacterTemplateID.java index 036473103..0f580d275 100644 --- a/src/main/java/com/l2jserver/model/id/template/CharacterTemplateID.java +++ b/src/main/java/com/l2jserver/model/id/template/CharacterTemplateID.java @@ -6,7 +6,16 @@ import com.l2jserver.model.id.TemplateID; import com.l2jserver.model.template.CharacterTemplate; import com.l2jserver.service.game.template.TemplateService; +/** + * An {@link TemplateID} instance representing an {@link CharacterTemplate} + * object + * + * @author Rogiel + */ public class CharacterTemplateID extends TemplateID { + /** + * The template service + */ private final TemplateService templateService; @Inject diff --git a/src/main/java/com/l2jserver/model/id/template/ItemTemplateID.java b/src/main/java/com/l2jserver/model/id/template/ItemTemplateID.java index fd1baf6a3..4add4462c 100644 --- a/src/main/java/com/l2jserver/model/id/template/ItemTemplateID.java +++ b/src/main/java/com/l2jserver/model/id/template/ItemTemplateID.java @@ -6,7 +6,16 @@ import com.l2jserver.model.id.TemplateID; import com.l2jserver.model.template.ItemTemplate; import com.l2jserver.service.game.template.TemplateService; +/** + * An {@link TemplateID} instance representing an {@link ItemTemplate} + * object + * + * @author Rogiel + */ public class ItemTemplateID extends TemplateID { + /** + * The template service + */ private final TemplateService templateService; @Inject diff --git a/src/main/java/com/l2jserver/model/id/template/SkillTemplateID.java b/src/main/java/com/l2jserver/model/id/template/SkillTemplateID.java index 1c238b2cf..0d42adcfc 100644 --- a/src/main/java/com/l2jserver/model/id/template/SkillTemplateID.java +++ b/src/main/java/com/l2jserver/model/id/template/SkillTemplateID.java @@ -6,7 +6,16 @@ import com.l2jserver.model.id.TemplateID; import com.l2jserver.model.template.SkillTemplate; import com.l2jserver.service.game.template.TemplateService; +/** + * An {@link TemplateID} instance representing an {@link SkillTemplate} + * object + * + * @author Rogiel + */ public class SkillTemplateID extends TemplateID { + /** + * The template service + */ private final TemplateService templateService; @Inject diff --git a/src/main/java/com/l2jserver/model/id/template/factory/CharacterTemplateIDFactory.java b/src/main/java/com/l2jserver/model/id/template/factory/CharacterTemplateIDFactory.java index 32e41a769..0698ad937 100644 --- a/src/main/java/com/l2jserver/model/id/template/factory/CharacterTemplateIDFactory.java +++ b/src/main/java/com/l2jserver/model/id/template/factory/CharacterTemplateIDFactory.java @@ -2,6 +2,11 @@ package com.l2jserver.model.id.template.factory; import com.l2jserver.model.id.template.CharacterTemplateID; +/** + * Creates new {@link CharacterTemplateID} instances + * + * @author Rogiel + */ public interface CharacterTemplateIDFactory extends TemplateIDFactory { } diff --git a/src/main/java/com/l2jserver/model/id/template/factory/ItemTemplateIDFactory.java b/src/main/java/com/l2jserver/model/id/template/factory/ItemTemplateIDFactory.java index 17bdea7dd..d93eb75b5 100644 --- a/src/main/java/com/l2jserver/model/id/template/factory/ItemTemplateIDFactory.java +++ b/src/main/java/com/l2jserver/model/id/template/factory/ItemTemplateIDFactory.java @@ -2,6 +2,11 @@ package com.l2jserver.model.id.template.factory; import com.l2jserver.model.id.template.ItemTemplateID; +/** + * Creates new {@link ItemTemplateID} instances + * + * @author Rogiel + */ public interface ItemTemplateIDFactory extends TemplateIDFactory { } diff --git a/src/main/java/com/l2jserver/model/id/template/factory/SkillTemplateIDFactory.java b/src/main/java/com/l2jserver/model/id/template/factory/SkillTemplateIDFactory.java index 902f0a8f3..322ce04e6 100644 --- a/src/main/java/com/l2jserver/model/id/template/factory/SkillTemplateIDFactory.java +++ b/src/main/java/com/l2jserver/model/id/template/factory/SkillTemplateIDFactory.java @@ -2,6 +2,11 @@ package com.l2jserver.model.id.template.factory; import com.l2jserver.model.id.template.SkillTemplateID; +/** + * Creates new {@link SkillTemplateID} instances + * + * @author Rogiel + */ public interface SkillTemplateIDFactory extends TemplateIDFactory { } diff --git a/src/main/java/com/l2jserver/model/id/template/factory/TemplateIDFactory.java b/src/main/java/com/l2jserver/model/id/template/factory/TemplateIDFactory.java index 30d7f2c12..d48cf3766 100644 --- a/src/main/java/com/l2jserver/model/id/template/factory/TemplateIDFactory.java +++ b/src/main/java/com/l2jserver/model/id/template/factory/TemplateIDFactory.java @@ -3,6 +3,14 @@ package com.l2jserver.model.id.template.factory; import com.l2jserver.model.id.TemplateID; import com.l2jserver.model.id.factory.IDFactory; +/** + * Creates a new {@link TemplateID} + * + * @author Rogiel + * + * @param + * the subclass of {@link TemplateID} that will be createdF + */ public interface TemplateIDFactory> extends IDFactory { } diff --git a/src/main/java/com/l2jserver/model/template/AbstractTemplate.java b/src/main/java/com/l2jserver/model/template/AbstractTemplate.java index 4c4ed73c4..24ccb9b34 100644 --- a/src/main/java/com/l2jserver/model/template/AbstractTemplate.java +++ b/src/main/java/com/l2jserver/model/template/AbstractTemplate.java @@ -2,11 +2,25 @@ package com.l2jserver.model.template; import com.l2jserver.model.id.TemplateID; +/** + * An abstract {@link Template} + * + * @author Rogiel + * + * @param + * the type of object created by this template + */ public abstract class AbstractTemplate implements Template { + /** + * The {@link TemplateID}F + */ private final TemplateID id; - public AbstractTemplate(TemplateID id) { - super(); + /** + * Creates a new instance + * @param id + */ + protected AbstractTemplate(TemplateID id) { this.id = id; } diff --git a/src/main/java/com/l2jserver/model/template/ArmorTemplate.java b/src/main/java/com/l2jserver/model/template/ArmorTemplate.java index 5cbecfaa8..89c16916f 100644 --- a/src/main/java/com/l2jserver/model/template/ArmorTemplate.java +++ b/src/main/java/com/l2jserver/model/template/ArmorTemplate.java @@ -3,7 +3,13 @@ package com.l2jserver.model.template; import com.l2jserver.model.id.template.ItemTemplateID; import com.l2jserver.model.template.capability.Defendable; import com.l2jserver.model.template.capability.IncomingDamageIntercept; +import com.l2jserver.model.world.Item; +/** + * Template for Armor {@link Item} + * + * @author Rogiel + */ public abstract class ArmorTemplate extends ItemTemplate implements Defendable, IncomingDamageIntercept { public ArmorTemplate(ItemTemplateID id) { diff --git a/src/main/java/com/l2jserver/model/template/CharacterTemplate.java b/src/main/java/com/l2jserver/model/template/CharacterTemplate.java index b74629e3c..0df05c138 100644 --- a/src/main/java/com/l2jserver/model/template/CharacterTemplate.java +++ b/src/main/java/com/l2jserver/model/template/CharacterTemplate.java @@ -10,6 +10,11 @@ import com.l2jserver.model.world.character.CharacterBaseAttributes; import com.l2jserver.model.world.character.CharacterClass; import com.l2jserver.util.Coordinate; +/** + * Template for {@link L2Character} + * + * @author Rogiel + */ public abstract class CharacterTemplate extends AbstractTemplate { /** * The logger diff --git a/src/main/java/com/l2jserver/model/template/ConsumableTemplate.java b/src/main/java/com/l2jserver/model/template/ConsumableTemplate.java index 2d1d752c5..f0b5a442a 100644 --- a/src/main/java/com/l2jserver/model/template/ConsumableTemplate.java +++ b/src/main/java/com/l2jserver/model/template/ConsumableTemplate.java @@ -2,7 +2,13 @@ package com.l2jserver.model.template; import com.l2jserver.model.id.template.ItemTemplateID; import com.l2jserver.model.template.capability.Consumable; +import com.l2jserver.model.world.Item; +/** + * Template for consumable {@link Item} + * + * @author Rogiel + */ public abstract class ConsumableTemplate extends ItemTemplate implements Consumable { public ConsumableTemplate(ItemTemplateID id) { diff --git a/src/main/java/com/l2jserver/model/template/ItemTemplate.java b/src/main/java/com/l2jserver/model/template/ItemTemplate.java index 4335a42d8..0f17d3c6c 100644 --- a/src/main/java/com/l2jserver/model/template/ItemTemplate.java +++ b/src/main/java/com/l2jserver/model/template/ItemTemplate.java @@ -6,6 +6,11 @@ import org.slf4j.LoggerFactory; import com.l2jserver.model.id.template.ItemTemplateID; import com.l2jserver.model.world.Item; +/** + * Template for an {@link Item} + * + * @author Rogiel + */ public abstract class ItemTemplate extends AbstractTemplate { /** * The logger diff --git a/src/main/java/com/l2jserver/model/template/PotionTemplate.java b/src/main/java/com/l2jserver/model/template/PotionTemplate.java index 445ae46fc..bdae4899f 100644 --- a/src/main/java/com/l2jserver/model/template/PotionTemplate.java +++ b/src/main/java/com/l2jserver/model/template/PotionTemplate.java @@ -1,7 +1,13 @@ package com.l2jserver.model.template; import com.l2jserver.model.id.template.ItemTemplateID; +import com.l2jserver.model.world.Item; +/** + * Template for Potion {@link Item} + * + * @author Rogiel + */ public abstract class PotionTemplate extends ConsumableTemplate { public PotionTemplate(ItemTemplateID id) { super(id); diff --git a/src/main/java/com/l2jserver/model/template/SkillTemplate.java b/src/main/java/com/l2jserver/model/template/SkillTemplate.java index dcd9c8e0b..16da515c3 100644 --- a/src/main/java/com/l2jserver/model/template/SkillTemplate.java +++ b/src/main/java/com/l2jserver/model/template/SkillTemplate.java @@ -4,6 +4,11 @@ import com.l2jserver.model.id.template.SkillTemplateID; import com.l2jserver.model.template.capability.Castable; import com.l2jserver.model.world.character.CharacterClass; +/** + * Template for skill + * + * @author Rogiel + */ public abstract class SkillTemplate extends AbstractTemplate implements Castable { public SkillTemplate(SkillTemplateID id) { diff --git a/src/main/java/com/l2jserver/model/template/Template.java b/src/main/java/com/l2jserver/model/template/Template.java index ebc459e0c..3f9f79fce 100644 --- a/src/main/java/com/l2jserver/model/template/Template.java +++ b/src/main/java/com/l2jserver/model/template/Template.java @@ -1,9 +1,30 @@ package com.l2jserver.model.template; import com.l2jserver.model.id.TemplateID; +import com.l2jserver.model.world.WorldObject; +/** + * An template is like a base for an {@link WorldObject}. Normally, instead of + * manually creating the object this can be done through templates, that easy + * the need of setting the new objects parameters. + * + * @author Rogiel + * + * @param + * the {@link WorldObject} type + */ public interface Template { + /** + * Create a new {@link WorldObject} + * + * @return the created object + */ T create(); + /** + * Return this {@link TemplateID} + * + * @return the template id + */ TemplateID getID(); } diff --git a/src/main/java/com/l2jserver/model/template/WeaponTemplate.java b/src/main/java/com/l2jserver/model/template/WeaponTemplate.java index b43e6148d..17d125a29 100644 --- a/src/main/java/com/l2jserver/model/template/WeaponTemplate.java +++ b/src/main/java/com/l2jserver/model/template/WeaponTemplate.java @@ -2,7 +2,13 @@ package com.l2jserver.model.template; import com.l2jserver.model.id.template.ItemTemplateID; import com.l2jserver.model.template.capability.Attackable; +import com.l2jserver.model.world.Item; +/** + * Template for Weapon {@link Item} + * + * @author Rogiel + */ public abstract class WeaponTemplate extends ItemTemplate implements Attackable { public WeaponTemplate(ItemTemplateID id) { super(id); diff --git a/src/main/java/com/l2jserver/model/world/character/CharacterBaseAttributes.java b/src/main/java/com/l2jserver/model/world/character/CharacterBaseAttributes.java index c53b62d6b..c7444b63e 100644 --- a/src/main/java/com/l2jserver/model/world/character/CharacterBaseAttributes.java +++ b/src/main/java/com/l2jserver/model/world/character/CharacterBaseAttributes.java @@ -23,7 +23,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { */ private final int mentality; /** - * The character dextry + * The character dexterity */ private final int dexterity; /** @@ -93,8 +93,8 @@ public class CharacterBaseAttributes implements CharacterAttributes { * the concentration * @param mentality * the mentality - * @param dextry - * the dextry + * @param dexterity + * the dexterity * @param witness * the witness * @param physicalAttack @@ -151,6 +151,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the intelligence */ + @Override public int getIntelligence() { return intelligence; } @@ -158,6 +159,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the strength */ + @Override public int getStrength() { return strength; } @@ -165,6 +167,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the concentration */ + @Override public int getConcentration() { return concentration; } @@ -172,13 +175,15 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the mentality */ + @Override public int getMentality() { return mentality; } /** - * @return the dextry + * @return the dexterity */ + @Override public int getDexterity() { return dexterity; } @@ -186,6 +191,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the witness */ + @Override public int getWitness() { return witness; } @@ -193,6 +199,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the physicalAttack */ + @Override public int getPhysicalAttack() { return physicalAttack; } @@ -200,6 +207,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the magicalAttack */ + @Override public int getMagicalAttack() { return magicalAttack; } @@ -207,6 +215,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the physicalDefense */ + @Override public int getPhysicalDefense() { return physicalDefense; } @@ -214,6 +223,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the magicalDefense */ + @Override public int getMagicalDefense() { return magicalDefense; } @@ -221,6 +231,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the attackSpeed */ + @Override public int getAttackSpeed() { return attackSpeed; } @@ -228,6 +239,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the castSpeed */ + @Override public int getCastSpeed() { return castSpeed; } @@ -235,6 +247,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the accuracy */ + @Override public int getAccuracy() { return accuracy; } @@ -242,6 +255,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the criticalChance */ + @Override public int getCriticalChance() { return criticalChance; } @@ -249,6 +263,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the evasionChance */ + @Override public int getEvasionChance() { return evasionChance; } @@ -256,6 +271,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the moveSpeed */ + @Override public int getMoveSpeed() { return moveSpeed; } @@ -263,6 +279,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the maxWeigth */ + @Override public int getMaxWeigth() { return maxWeigth; } @@ -270,6 +287,7 @@ public class CharacterBaseAttributes implements CharacterAttributes { /** * @return the craft */ + @Override public boolean canCraft() { return craft; } diff --git a/src/main/java/com/l2jserver/service/AbstractService.java b/src/main/java/com/l2jserver/service/AbstractService.java index f47ac1752..dbc8f5a75 100644 --- a/src/main/java/com/l2jserver/service/AbstractService.java +++ b/src/main/java/com/l2jserver/service/AbstractService.java @@ -1,5 +1,10 @@ package com.l2jserver.service; +/** + * An abstract service implementing basic life-cycle methods. + * + * @author Rogiel + */ public class AbstractService implements Service { @Override public void start() throws ServiceStartException { diff --git a/src/main/java/com/l2jserver/service/Service.java b/src/main/java/com/l2jserver/service/Service.java index 115bcd4b8..000ba88ab 100644 --- a/src/main/java/com/l2jserver/service/Service.java +++ b/src/main/java/com/l2jserver/service/Service.java @@ -1,5 +1,11 @@ package com.l2jserver.service; +/** + * Each Service is a provider of a given feature. Most services will want to + * implement {@link AbstractService} class instead of this interface. + * + * @author Rogiel + */ public interface Service { /** * Start this service diff --git a/src/main/java/com/l2jserver/service/ServiceException.java b/src/main/java/com/l2jserver/service/ServiceException.java index cd4ca7c39..d6ad26a5e 100644 --- a/src/main/java/com/l2jserver/service/ServiceException.java +++ b/src/main/java/com/l2jserver/service/ServiceException.java @@ -1,5 +1,10 @@ package com.l2jserver.service; +/** + * Exception for an {@link Service} + * + * @author Rogiel + */ public class ServiceException extends Exception { private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/l2jserver/service/ServiceManager.java b/src/main/java/com/l2jserver/service/ServiceManager.java index fac8dcb96..1d6be6489 100644 --- a/src/main/java/com/l2jserver/service/ServiceManager.java +++ b/src/main/java/com/l2jserver/service/ServiceManager.java @@ -7,6 +7,11 @@ import com.google.inject.Inject; import com.google.inject.Injector; import com.l2jserver.service.logging.LoggingService; +/** + * The {@link ServiceManager} is responsible for starting and stopping services + * + * @author Rogiel + */ public class ServiceManager { /** * The logger @@ -39,8 +44,7 @@ public class ServiceManager { logger.info("{}: Starting service...", serviceClass.getCanonicalName()); service.start(); - logger.info("{}: Service started!", - serviceClass.getCanonicalName()); + logger.info("{}: Service started!", serviceClass.getCanonicalName()); return service; } catch (ServiceStartException e) { logger.error("{}: Error starting service: {}", diff --git a/src/main/java/com/l2jserver/service/ServiceModule.java b/src/main/java/com/l2jserver/service/ServiceModule.java index 03e053948..0a49fdab6 100644 --- a/src/main/java/com/l2jserver/service/ServiceModule.java +++ b/src/main/java/com/l2jserver/service/ServiceModule.java @@ -1,6 +1,7 @@ package com.l2jserver.service; import com.google.inject.AbstractModule; +import com.google.inject.Module; import com.google.inject.Scopes; import com.l2jserver.service.configuration.ConfigurationService; import com.l2jserver.service.configuration.ProxyConfigurationService; @@ -19,6 +20,11 @@ import com.l2jserver.service.logging.LoggingService; import com.l2jserver.service.network.NettyNetworkService; import com.l2jserver.service.network.NetworkService; +/** + * Google Guice {@link Module} for services + * + * @author Rogiel + */ public class ServiceModule extends AbstractModule { @Override protected void configure() { @@ -29,7 +35,7 @@ public class ServiceModule extends AbstractModule { .in(Scopes.SINGLETON); bind(DatabaseService.class).to(MySQLDatabaseService.class).in( Scopes.SINGLETON); - + bind(NetworkService.class).to(NettyNetworkService.class).in( Scopes.SINGLETON); bind(ScriptingService.class).to(ScriptingServiceImpl.class).in( diff --git a/src/main/java/com/l2jserver/service/ServiceRestartException.java b/src/main/java/com/l2jserver/service/ServiceRestartException.java index 68d0bf8c1..ca59c5eed 100644 --- a/src/main/java/com/l2jserver/service/ServiceRestartException.java +++ b/src/main/java/com/l2jserver/service/ServiceRestartException.java @@ -1,5 +1,11 @@ package com.l2jserver.service; +/** + * Thrown when an service failed to restart. It's cause can be an + * {@link ServiceStartException} or {@link ServiceStopException}. + * + * @author Rogiel + */ public class ServiceRestartException extends ServiceException { private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/l2jserver/service/ServiceStartException.java b/src/main/java/com/l2jserver/service/ServiceStartException.java index 9ff9cd53a..2db27f433 100644 --- a/src/main/java/com/l2jserver/service/ServiceStartException.java +++ b/src/main/java/com/l2jserver/service/ServiceStartException.java @@ -1,5 +1,10 @@ package com.l2jserver.service; +/** + * Exception thrown when a service failed to start. + * + * @author Rogiel + */ public class ServiceStartException extends ServiceException { private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/l2jserver/service/ServiceStopException.java b/src/main/java/com/l2jserver/service/ServiceStopException.java index df856da15..3f61c1edd 100644 --- a/src/main/java/com/l2jserver/service/ServiceStopException.java +++ b/src/main/java/com/l2jserver/service/ServiceStopException.java @@ -1,5 +1,10 @@ package com.l2jserver.service; +/** + * Exception thrown when a service failed to stop + * + * @author Rogiel + */ public class ServiceStopException extends ServiceException { private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/l2jserver/service/cache/CacheService.java b/src/main/java/com/l2jserver/service/cache/CacheService.java index dd4d3dc43..a52e801a1 100644 --- a/src/main/java/com/l2jserver/service/cache/CacheService.java +++ b/src/main/java/com/l2jserver/service/cache/CacheService.java @@ -16,5 +16,16 @@ import com.l2jserver.service.Service; * */ public interface CacheService extends Service { + /** + * Decores the instance with the cache + * + * @param + * the instance type + * @param interfaceType + * the interface type + * @param instance + * the instance + * @return the cache-decorated object + */ T decorate(Class interfaceType, T instance); } diff --git a/src/main/java/com/l2jserver/service/cache/Cacheable.java b/src/main/java/com/l2jserver/service/cache/Cacheable.java index 7c310a54e..fcdccecc6 100644 --- a/src/main/java/com/l2jserver/service/cache/Cacheable.java +++ b/src/main/java/com/l2jserver/service/cache/Cacheable.java @@ -1,5 +1,13 @@ package com.l2jserver.service.cache; +/** + * Flags an interface that is capable of caching. + *

+ * Note: only interfaces can be cached! + * + * @author Rogiel + * + */ public interface Cacheable { } diff --git a/src/main/java/com/l2jserver/service/cache/SimpleCacheService.java b/src/main/java/com/l2jserver/service/cache/SimpleCacheService.java index a5275517d..e1e3e11de 100644 --- a/src/main/java/com/l2jserver/service/cache/SimpleCacheService.java +++ b/src/main/java/com/l2jserver/service/cache/SimpleCacheService.java @@ -5,10 +5,16 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Arrays; import java.util.Map; +import java.util.WeakHashMap; import com.l2jserver.service.AbstractService; import com.l2jserver.util.factory.CollectionFactory; +/** + * Simple cache that stores invocation results in a {@link WeakHashMap}. + * + * @author Rogiel + */ public class SimpleCacheService extends AbstractService implements CacheService { private final Map cache = CollectionFactory .newWeakMap(MethodInvocation.class, Object.class); diff --git a/src/main/java/com/l2jserver/service/configuration/Configuration.java b/src/main/java/com/l2jserver/service/configuration/Configuration.java index 7b0213d20..3688022e2 100644 --- a/src/main/java/com/l2jserver/service/configuration/Configuration.java +++ b/src/main/java/com/l2jserver/service/configuration/Configuration.java @@ -6,24 +6,70 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Configuration interface + *

+ * Each service desiring to use the configuration system must extend the + * interface and define methods for getters and setters. Each method must be + * annotated either with {@link ConfigurationPropertyGetter} or + * {@link ConfigurationPropertySetter} + *

+ * Each interface may optionally be annotated with {@link ConfigurationName}. + * + * @author Rogiel + */ public interface Configuration { + /** + * Each configuration can define the name of its configuration. This will be + * used by implementations to look for the configuration. + * + * @author Rogiel + * + */ @Retention(RetentionPolicy.RUNTIME) @Documented @Target(value = ElementType.TYPE) public @interface ConfigurationName { + /** + * @return the configuration name + */ String value(); } - + + /** + * The getter method for an configuration property + *

+ * The method must have no arguments. + * + * @author Rogiel + */ @Retention(RetentionPolicy.RUNTIME) @Target(value = ElementType.METHOD) public @interface ConfigurationPropertyGetter { + /** + * @return the property name + */ String name(); + + /** + * @return the default value to be used + */ String defaultValue() default ""; } - + + /** + * The setter method for an configuration property. + *

+ * The method must have a single argument and return type void. + * + * @author Rogiel + */ @Retention(RetentionPolicy.RUNTIME) @Target(value = ElementType.METHOD) public @interface ConfigurationPropertySetter { + /** + * @return the property name + */ String name(); } } diff --git a/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java b/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java index be9e9241d..27faa6628 100644 --- a/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java +++ b/src/main/java/com/l2jserver/service/configuration/ConfigurationService.java @@ -2,6 +2,22 @@ package com.l2jserver.service.configuration; import com.l2jserver.service.Service; +/** + * The configuration service is responsible for reading and writing in + * configuration storage. Each configuration is represented by an interface. + * Implementations of this interface are implementaion specific. + * + * @author Rogiel + */ public interface ConfigurationService extends Service { + /** + * Get the configuration object for config + * + * @param + * the configuration type + * @param config + * the configuration interface class + * @return the configuration object + */ C get(Class config); } diff --git a/src/main/java/com/l2jserver/service/configuration/ProxyConfigurationService.java b/src/main/java/com/l2jserver/service/configuration/ProxyConfigurationService.java index 4baa6bb4e..555914890 100644 --- a/src/main/java/com/l2jserver/service/configuration/ProxyConfigurationService.java +++ b/src/main/java/com/l2jserver/service/configuration/ProxyConfigurationService.java @@ -23,12 +23,27 @@ import com.l2jserver.service.configuration.Configuration.ConfigurationPropertySe import com.l2jserver.util.transformer.Transformer; import com.l2jserver.util.transformer.TransformerFactory; +/** + * Creates {@link Configuration} object through Java {@link Proxy}. Uses the + * annotations in the interface to retrieve and store values. + * + * @author Rogiel + */ public class ProxyConfigurationService extends AbstractService implements ConfigurationService { + /** + * The directory in which configuration files are stored + */ private File directory = new File("./config"); + /** + * The logger + */ private final Logger logger = LoggerFactory .getLogger(ProxyConfigurationService.class); + /** + * The cache of configuration objects + */ private Map, Object> cache = new WeakHashMap, Object>(); @Override @@ -59,6 +74,11 @@ public class ProxyConfigurationService extends AbstractService implements return proxy; } + /** + * The invocation handler for configuration interfaces + * + * @author Rogiel + */ private class ConfigInvocationHandler implements InvocationHandler { private final Properties properties; private Map cache = new WeakHashMap(); @@ -70,7 +90,8 @@ public class ProxyConfigurationService extends AbstractService implements @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - logger.debug("Configuration service, method invoked: {}", method.getName()); + logger.debug("Configuration service, method invoked: {}", + method.getName()); if (args == null || args.length == 0) { final ConfigurationPropertyGetter getter = method .getAnnotation(ConfigurationPropertyGetter.class); @@ -87,6 +108,15 @@ public class ProxyConfigurationService extends AbstractService implements return null; } + /** + * Get the untransformed value of an property + * + * @param getter + * the getter annotation + * @param type + * the transformed type + * @return the untransformed property + */ private Object get(ConfigurationPropertyGetter getter, Class type) { if (cache.containsKey(getter.name())) return cache.get(getter.name()); @@ -96,6 +126,16 @@ public class ProxyConfigurationService extends AbstractService implements return o; } + /** + * Set the transformed value of an property + * + * @param setter + * the setter annotation + * @param value + * the untransformed value + * @param type + * the transformed type + */ private void set(ConfigurationPropertySetter setter, Object value, Class type) { if (value != null) { @@ -108,6 +148,15 @@ public class ProxyConfigurationService extends AbstractService implements } } + /** + * Untransforms an value + * + * @param value + * the raw value + * @param type + * the output type + * @return the untransformed value + */ private Object untransform(String value, Class type) { if (value == null) return null; @@ -120,6 +169,15 @@ public class ProxyConfigurationService extends AbstractService implements return transformer.untransform(value); } + /** + * Transforms an value + * + * @param value + * the raw typed value + * @param type + * the input type + * @return the string representing value + */ @SuppressWarnings({ "rawtypes", "unchecked" }) private String transform(Object value, Class type) { if (value == null) @@ -133,6 +191,15 @@ public class ProxyConfigurationService extends AbstractService implements return transformer.transform(value); } + /** + * Retrieve the raw value from the property file + * + * @param key + * the key + * @param defaultValue + * the default value + * @return the value found or default value + */ private String getRaw(String key, String defaultValue) { if (properties == null) return defaultValue; @@ -143,6 +210,15 @@ public class ProxyConfigurationService extends AbstractService implements } } + /** + * Tries to locate an .properties file + * + * @param clazz + * configuration interface class + * @return the found property + * @throws IOException + * if any i/o error occur + */ private Properties findProperties(Class clazz) throws IOException { ConfigurationName config = findAnnotation(ConfigurationName.class, clazz); @@ -159,6 +235,17 @@ public class ProxyConfigurationService extends AbstractService implements return prop; } + /** + * Tries to find an annotation in the class or any parent-class. + * + * @param + * the annotation type + * @param annotationClass + * the annotation class + * @param clazz + * the class to look for annotations + * @return the annotation found + */ private T findAnnotation(Class annotationClass, Class clazz) { T ann = clazz.getAnnotation(annotationClass); @@ -175,10 +262,19 @@ public class ProxyConfigurationService extends AbstractService implements return null; } + /** + * @return the configuration store directory + */ public File getDirectory() { return directory; } + /** + * Set the configuration store directory + * + * @param directory + * the directory + */ public void setDirectory(File directory) { this.directory = directory; } diff --git a/src/main/java/com/l2jserver/service/database/AbstractDAO.java b/src/main/java/com/l2jserver/service/database/AbstractDAO.java index 8ea589c3e..da541ded7 100644 --- a/src/main/java/com/l2jserver/service/database/AbstractDAO.java +++ b/src/main/java/com/l2jserver/service/database/AbstractDAO.java @@ -2,7 +2,18 @@ package com.l2jserver.service.database; import com.google.inject.Inject; +/** + * Abstract DAO implementations. Store an instance of {@link DatabaseService}. + * + * @author Rogiel + * + * @param + * the dao object type + */ public abstract class AbstractDAO implements DataAccessObject { + /** + * The database service instance + */ protected final DatabaseService database; @Inject @@ -10,6 +21,9 @@ public abstract class AbstractDAO implements DataAccessObject { this.database = database; } + /** + * @return the database service + */ public DatabaseService getDatabase() { return database; } diff --git a/src/main/java/com/l2jserver/service/database/DB4ODatabaseConfiguration.java b/src/main/java/com/l2jserver/service/database/DB4ODatabaseConfiguration.java index d5dc918a2..b3d8f1b73 100644 --- a/src/main/java/com/l2jserver/service/database/DB4ODatabaseConfiguration.java +++ b/src/main/java/com/l2jserver/service/database/DB4ODatabaseConfiguration.java @@ -4,6 +4,11 @@ import java.io.File; import com.l2jserver.service.configuration.Configuration.ConfigurationName; +/** + * Configuration for DB4O Database Service + * + * @author Rogiel + */ @ConfigurationName("db4o") public interface DB4ODatabaseConfiguration extends DatabaseConfiguration { /** diff --git a/src/main/java/com/l2jserver/service/database/DB4ODatabaseService.java b/src/main/java/com/l2jserver/service/database/DB4ODatabaseService.java index 6193580b3..3784d54c7 100644 --- a/src/main/java/com/l2jserver/service/database/DB4ODatabaseService.java +++ b/src/main/java/com/l2jserver/service/database/DB4ODatabaseService.java @@ -2,6 +2,13 @@ package com.l2jserver.service.database; import com.l2jserver.service.AbstractService; +/** + * Database service implementation for DB4O database engine. + *

+ * Note that this is not implemented yet! + * + * @author Rogiel + */ public class DB4ODatabaseService extends AbstractService implements DatabaseService { } diff --git a/src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java b/src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java index fc941b327..252c8b85f 100644 --- a/src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java +++ b/src/main/java/com/l2jserver/service/database/DatabaseConfiguration.java @@ -3,6 +3,12 @@ package com.l2jserver.service.database; import com.l2jserver.service.configuration.Configuration; import com.l2jserver.service.configuration.Configuration.ConfigurationName; +/** + * Database service configuration + * + * @author Rogiel + * @see Configuration + */ @ConfigurationName("database") public interface DatabaseConfiguration extends Configuration { diff --git a/src/main/java/com/l2jserver/service/database/DatabaseService.java b/src/main/java/com/l2jserver/service/database/DatabaseService.java index b38f85a4c..0b0a205ac 100644 --- a/src/main/java/com/l2jserver/service/database/DatabaseService.java +++ b/src/main/java/com/l2jserver/service/database/DatabaseService.java @@ -2,6 +2,12 @@ package com.l2jserver.service.database; import com.l2jserver.service.Service; +/** + * The database service manages connection between the {@link DataAccessObject} + * implementation and the database. + * + * @author Rogiel + */ public interface DatabaseService extends Service { } diff --git a/src/main/java/com/l2jserver/service/database/MySQLDatabaseConfiguration.java b/src/main/java/com/l2jserver/service/database/MySQLDatabaseConfiguration.java index 2db0539ab..a9ce289e9 100644 --- a/src/main/java/com/l2jserver/service/database/MySQLDatabaseConfiguration.java +++ b/src/main/java/com/l2jserver/service/database/MySQLDatabaseConfiguration.java @@ -1,5 +1,10 @@ package com.l2jserver.service.database; +/** + * Configuration interface for {@link MySQLDatabaseService}. + * + * @author Rogiel + */ public interface MySQLDatabaseConfiguration extends DatabaseConfiguration { /** * @return the jdbc url diff --git a/src/main/java/com/l2jserver/service/database/MySQLDatabaseService.java b/src/main/java/com/l2jserver/service/database/MySQLDatabaseService.java index 82997b84c..6484f9776 100644 --- a/src/main/java/com/l2jserver/service/database/MySQLDatabaseService.java +++ b/src/main/java/com/l2jserver/service/database/MySQLDatabaseService.java @@ -7,6 +7,8 @@ import java.sql.SQLException; import java.util.Iterator; import java.util.List; +import javax.sql.DataSource; + import org.apache.commons.dbcp.ConnectionFactory; import org.apache.commons.dbcp.DriverManagerConnectionFactory; import org.apache.commons.dbcp.PoolableConnectionFactory; @@ -24,16 +26,39 @@ import com.l2jserver.service.configuration.ConfigurationService; import com.l2jserver.util.ArrayIterator; import com.l2jserver.util.factory.CollectionFactory; +/** + * The database service implementation for MySQL database + * + * @author Rogiel + */ public class MySQLDatabaseService extends AbstractService implements DatabaseService { + /** + * The configuration object + */ private final MySQLDatabaseConfiguration config; + /** + * The logger + */ private final Logger logger = LoggerFactory .getLogger(MySQLDatabaseService.class); + /** + * The database connection pool + */ private ObjectPool connectionPool; + /** + * The dayabase connection factory + */ private ConnectionFactory connectionFactory; + /** + * The poolable connection factory + */ @SuppressWarnings("unused") private PoolableConnectionFactory poolableConnectionFactory; + /** + * The connection {@link DataSource}. + */ private PoolingDataSource dataSource; @Inject @@ -51,6 +76,15 @@ public class MySQLDatabaseService extends AbstractService implements dataSource = new PoolingDataSource(connectionPool); } + /** + * Executes an query in the database. + * + * @param + * the query return type + * @param query + * the query + * @return an instance of T + */ public T query(Query query) { try { final Connection conn = dataSource.getConnection(); @@ -84,17 +118,59 @@ public class MySQLDatabaseService extends AbstractService implements } } + /** + * The query interface. The query will receive an connection an will be + * executed. The can return return a value if required. + * + * @author Rogiel + * + * @param + * the return type + */ public interface Query { + /** + * Execute the query in conn + * + * @param conn + * the connection + * @return the query return value + * @throws SQLException + */ R query(Connection conn) throws SQLException; } + /** + * This query is used for the following statements: + *

+ * + * @author Rogiel + * + * @param + * the query return type + */ public static abstract class InsertUpdateQuery implements Query { private final Iterator iterator; + /** + * Creates a new query for objects + * + * @param objects + * the object list + */ public InsertUpdateQuery(T... objects) { this(new ArrayIterator(objects)); } + /** + * Create a new query for objects in iterator + * + * @param iterator + * the object iterator + */ public InsertUpdateQuery(Iterator iterator) { this.iterator = iterator; } @@ -118,16 +194,46 @@ public class MySQLDatabaseService extends AbstractService implements return rows; } + /** + * Creates the prepared query for execution + * + * @return the prepared query + */ protected abstract String query(); + /** + * Set the parameters for in statement for object + * + * @param st + * the prepared statement + * @param object + * the object + * @throws SQLException + */ protected abstract void parametize(PreparedStatement st, T object) throws SQLException; + /** + * Return the key mapper. Can be null if no generated keys are used or + * are not important. + * + * @param object + * the object + * @return the key mapper + */ protected Mapper keyMapper(T object) { return null; } } + /** + * An select query that returns a list of objects of type T + * + * @author Rogiel + * + * @param + * the query return type + */ public static abstract class SelectListQuery implements Query> { @Override public List query(Connection conn) throws SQLException { @@ -142,14 +248,46 @@ public class MySQLDatabaseService extends AbstractService implements return list; } + /** + * Creates the prepared query for execution + * + * @return the prepared query + */ protected abstract String query(); + /** + * Set the parameters for in statement for object + * + * @param st + * the prepared statement + * @param object + * the object + * @throws SQLException + */ protected void parametize(PreparedStatement st) throws SQLException { } + /** + * Return the mapper that will bind {@link ResultSet} objects into an + * T object instance. The mapper will need to create the object + * instance. + *

+ * Note: This method will be called for each row, an thus is a + * good idea to create a new instance on each call! + * + * @return the mapper instance + */ protected abstract Mapper mapper(); } + /** + * An select query that returns a single object of type T + * + * @author Rogiel + * + * @param + * the query return type + */ public static abstract class SelectSingleQuery implements Query { @Override public T query(Connection conn) throws SQLException { @@ -163,15 +301,55 @@ public class MySQLDatabaseService extends AbstractService implements return null; } + /** + * Creates the prepared query for execution + * + * @return the prepared query + */ protected abstract String query(); - protected abstract void parametize(PreparedStatement st) - throws SQLException; + /** + * Set the parameters for in statement for object + * + * @param st + * the prepared statement + * @param object + * the object + * @throws SQLException + */ + protected void parametize(PreparedStatement st) throws SQLException { + } + /** + * Return the mapper that will bind {@link ResultSet} objects into an + * T object instance. The mapper will need to create the object + * instance. + * + * @return the mapper + */ protected abstract Mapper mapper(); } + /** + * The {@link Mapper} maps an {@link ResultSet} into an object T + * + * @author Rogiel + * + * @param + * the object type + */ public interface Mapper { + /** + * Map the result set value into an object. + *

+ * Note: it is required to call {@link ResultSet#next()}, since + * it is called by the {@link Query}. + * + * @param rs + * the result set + * @return the created instance + * @throws SQLException + */ T map(ResultSet rs) throws SQLException; } } diff --git a/src/main/java/com/l2jserver/service/game/world/WorldServiceImpl.java b/src/main/java/com/l2jserver/service/game/world/WorldServiceImpl.java index 825100339..78645aba9 100644 --- a/src/main/java/com/l2jserver/service/game/world/WorldServiceImpl.java +++ b/src/main/java/com/l2jserver/service/game/world/WorldServiceImpl.java @@ -18,12 +18,26 @@ import com.l2jserver.service.ServiceStopException; import com.l2jserver.service.game.world.event.WorldEventDispatcher; import com.l2jserver.util.factory.CollectionFactory; +/** + * Default implementation for {@link WorldService}. + * + * @author Rogiel + */ public class WorldServiceImpl extends AbstractService implements WorldService { + /** + * The logger + */ private static final Logger log = LoggerFactory .getLogger(WorldServiceImpl.class); + /** + * The set of all objects registered in the world + */ private final Set objects = CollectionFactory .newSet(WorldObject.class); + /** + * The world event dispatcher + */ private final WorldEventDispatcher dispatcher; @Inject diff --git a/src/main/java/com/l2jserver/service/game/world/event/WorldEventDispatcherImpl.java b/src/main/java/com/l2jserver/service/game/world/event/WorldEventDispatcherImpl.java index bbf50d3ea..56e2a04c0 100644 --- a/src/main/java/com/l2jserver/service/game/world/event/WorldEventDispatcherImpl.java +++ b/src/main/java/com/l2jserver/service/game/world/event/WorldEventDispatcherImpl.java @@ -14,7 +14,7 @@ import com.l2jserver.model.world.event.WorldListener; import com.l2jserver.util.factory.CollectionFactory; /** - * {@link WorldEventDispatcher} implementation + * Default {@link WorldEventDispatcher} implementation * * @author Rogiel */ diff --git a/src/main/java/com/l2jserver/service/logging/Log4JLoggingService.java b/src/main/java/com/l2jserver/service/logging/Log4JLoggingService.java index 79ecb2be6..30e08f26d 100644 --- a/src/main/java/com/l2jserver/service/logging/Log4JLoggingService.java +++ b/src/main/java/com/l2jserver/service/logging/Log4JLoggingService.java @@ -5,6 +5,11 @@ import org.apache.log4j.BasicConfigurator; import com.l2jserver.service.AbstractService; import com.l2jserver.service.ServiceStopException; +/** + * Logging service implementation for Log4J + * + * @author Rogiel + */ public class Log4JLoggingService extends AbstractService implements LoggingService { @Override diff --git a/src/main/java/com/l2jserver/service/network/NettyNetworkService.java b/src/main/java/com/l2jserver/service/network/NettyNetworkService.java index 4aa0e16ae..418d6eb58 100644 --- a/src/main/java/com/l2jserver/service/network/NettyNetworkService.java +++ b/src/main/java/com/l2jserver/service/network/NettyNetworkService.java @@ -14,6 +14,11 @@ import com.l2jserver.game.net.Lineage2PipelineFactory; import com.l2jserver.service.AbstractService; import com.l2jserver.service.configuration.ConfigurationService; +/** + * Netty network service implementation + * + * @author Rogiel + */ public class NettyNetworkService extends AbstractService implements NetworkService { private final NetworkConfiguration config; diff --git a/src/main/java/com/l2jserver/service/network/NetworkConfiguration.java b/src/main/java/com/l2jserver/service/network/NetworkConfiguration.java index 18c63d0a5..ca4747a56 100644 --- a/src/main/java/com/l2jserver/service/network/NetworkConfiguration.java +++ b/src/main/java/com/l2jserver/service/network/NetworkConfiguration.java @@ -5,6 +5,11 @@ import java.net.InetSocketAddress; import com.l2jserver.service.configuration.Configuration; import com.l2jserver.service.configuration.Configuration.ConfigurationName; +/** + * The network {@link Configuration} + * + * @author Rogiel + */ @ConfigurationName("network") public interface NetworkConfiguration extends Configuration { // TODO set default value diff --git a/src/main/java/com/l2jserver/service/network/NetworkService.java b/src/main/java/com/l2jserver/service/network/NetworkService.java index 584f2e69b..6e01567c7 100644 --- a/src/main/java/com/l2jserver/service/network/NetworkService.java +++ b/src/main/java/com/l2jserver/service/network/NetworkService.java @@ -2,5 +2,11 @@ package com.l2jserver.service.network; import com.l2jserver.service.Service; +/** + * The network service is responsible for communicating the server and the game + * client. You can see more details in each implementation. + * + * @author Rogiel + */ public interface NetworkService extends Service { } diff --git a/src/main/java/com/l2jserver/util/ArrayIterator.java b/src/main/java/com/l2jserver/util/ArrayIterator.java index 6d1a36df6..c60f1f27c 100644 --- a/src/main/java/com/l2jserver/util/ArrayIterator.java +++ b/src/main/java/com/l2jserver/util/ArrayIterator.java @@ -3,10 +3,30 @@ package com.l2jserver.util; import java.util.Iterator; import java.util.NoSuchElementException; +/** + * This {@link Iterator} takes an array as input and iterate over it. + * + * @author Rogiel + * + * @param + * the array type + */ public class ArrayIterator implements Iterator { + /** + * The objects + */ private final T[] objects; + /** + * the iterator index + */ private int i = 0; + /** + * Creates a new iterator instance + * + * @param objects + * the objects + */ public ArrayIterator(T... objects) { this.objects = objects; } diff --git a/src/main/java/com/l2jserver/util/BufferUtils.java b/src/main/java/com/l2jserver/util/BufferUtils.java index e6ba9d8e4..1f9123238 100644 --- a/src/main/java/com/l2jserver/util/BufferUtils.java +++ b/src/main/java/com/l2jserver/util/BufferUtils.java @@ -4,7 +4,19 @@ import java.util.Arrays; import org.jboss.netty.buffer.ChannelBuffer; +/** + * This is an Netty {@link ChannelBuffer} utility class. + * + * @author Rogiel + */ public class BufferUtils { + /** + * Reads an unicode string from the buffer + * + * @param buffer + * the buffer + * @return the read unicode string + */ public static final String readString(ChannelBuffer buffer) { char[] str = new char[buffer.readableBytes()]; int index = 0; @@ -15,6 +27,14 @@ public class BufferUtils { return String.valueOf(Arrays.copyOfRange(str, 0, index)); } + /** + * Writes an unicode string to the buffer + * + * @param buffer + * the buffer + * @param str + * the string + */ public static final void writeString(ChannelBuffer buffer, String str) { if (str != null) { final int len = str.length(); diff --git a/src/main/java/com/l2jserver/util/Coordinate.java b/src/main/java/com/l2jserver/util/Coordinate.java index 657a59868..b0737f048 100644 --- a/src/main/java/com/l2jserver/util/Coordinate.java +++ b/src/main/java/com/l2jserver/util/Coordinate.java @@ -1,33 +1,87 @@ package com.l2jserver.util; +/** + * Represents an coordinate in the game world. + *

+ * Each coordinate has 3 points: x, y and z. + * + * @author Rogiel + */ public class Coordinate { + /** + * The X point + */ private final int x; + /** + * The Y point + */ private final int y; + /** + * The Z point + */ private final int z; + /** + * Creates a new coordinate + * + * @param x + * the x point + * @param y + * the y point + * @param z + * the z point + */ protected Coordinate(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } + /** + * @return the x point + */ public int getX() { return x; } + /** + * @return the y point + */ public int getY() { return y; } + /** + * @return the z point + */ public int getZ() { return z; } + /** + * Calculates the distance between this coordinate and + * other + * + * @param other + * the other coodinate + * @return the computed distance + */ public int getDistance(Coordinate other) { // TODO calculation return x + y + z; } + /** + * Creates a new instance from the 3 points + * + * @param x + * the x point + * @param y + * the y point + * @param z + * the z point + * @return the new {@link Coordinate} object created + */ public static Coordinate fromXYZ(int x, int y, int z) { return new Coordinate(x, y, z); } diff --git a/src/main/java/com/l2jserver/util/RGBColor.java b/src/main/java/com/l2jserver/util/RGBColor.java index 3b070329b..18d68920a 100644 --- a/src/main/java/com/l2jserver/util/RGBColor.java +++ b/src/main/java/com/l2jserver/util/RGBColor.java @@ -1,8 +1,22 @@ package com.l2jserver.util; +/** + * An RED-GREEN-BLUE color + * + * @author Rogiel + */ public class RGBColor { + /** + * The red value + */ private final byte red; + /** + * The green value + */ private final byte green; + /** + * The blue value + */ private final byte blue; protected RGBColor(byte r, byte g, byte b) { @@ -32,10 +46,20 @@ public class RGBColor { return blue; } + /** + * Converts to an byte array + * + * @return an byte array of this color + */ public byte[] toByteArray() { return new byte[] { red, green, blue }; } + /** + * Convers this color into an integer + * + * @return the color integer + */ public int toInteger() { return red + green >> 8 + blue >> 16; } diff --git a/src/main/java/com/l2jserver/util/transformer/TransformerFactory.java b/src/main/java/com/l2jserver/util/transformer/TransformerFactory.java index 4660e625e..b95773596 100644 --- a/src/main/java/com/l2jserver/util/transformer/TransformerFactory.java +++ b/src/main/java/com/l2jserver/util/transformer/TransformerFactory.java @@ -14,7 +14,20 @@ import com.l2jserver.util.transformer.impl.IntegerTransformer; import com.l2jserver.util.transformer.impl.LongTransformer; import com.l2jserver.util.transformer.impl.ShortTransformer; +/** + * The {@link TransformerFactory} return the transformer instance for any given + * type. + * + * @author Rogiel + */ public class TransformerFactory { + /** + * return the transformer instance the given type. + * + * @param type + * the type + * @return the transformer + */ public static final Transformer getTransfromer(Class type) { if (type == Byte.class || type == Byte.TYPE) { return ByteTransformer.SHARED_INSTANCE; @@ -30,11 +43,11 @@ public class TransformerFactory { return DoubleTransformer.SHARED_INSTANCE; } else if (type == Boolean.class || type == Boolean.TYPE) { return BooleanTransformer.SHARED_INSTANCE; - } else if(type == InetSocketAddress.class) { + } else if (type == InetSocketAddress.class) { return InetSocketAddressTransformer.SHARED_INSTANCE; - } else if(type == File.class) { + } else if (type == File.class) { return FileTransformer.SHARED_INSTANCE; - }else if(type == Class.class) { + } else if (type == Class.class) { return ClassTransformer.SHARED_INSTANCE; } return null;