1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-08 08:23:11 +00:00

Written javadoc for many classes

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-14 01:51:40 -03:00
parent 14b928cc3b
commit e9c6f1b027
85 changed files with 1205 additions and 26 deletions

View File

@@ -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 <a href="http://www.rogiel.com">Rogiel</a>
*
* @param <T>
* the array type
*/
public class ArrayIterator<T> implements Iterator<T> {
/**
* 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;
}

View File

@@ -4,7 +4,19 @@ import java.util.Arrays;
import org.jboss.netty.buffer.ChannelBuffer;
/**
* This is an Netty {@link ChannelBuffer} utility class.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
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();

View File

@@ -1,33 +1,87 @@
package com.l2jserver.util;
/**
* Represents an coordinate in the game world.
* <p>
* Each coordinate has 3 points: x, y and z.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
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 <tt>this</tt> coordinate and
* <tt>other</tt>
*
* @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);
}

View File

@@ -1,8 +1,22 @@
package com.l2jserver.util;
/**
* An RED-GREEN-BLUE color
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
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;
}

View File

@@ -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 <a href="http://www.rogiel.com">Rogiel</a>
*/
public class TransformerFactory {
/**
* return the transformer instance the given <tt>type</tt>.
*
* @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;