Browse Source

BETA: Javadocs for some utils thanks FBIagent

Rumen Nikiforov 13 years ago
parent
commit
d2b224ffee

+ 4 - 2
L2J_Server_BETA/java/com/l2jserver/util/DeadLockDetector.java

@@ -28,13 +28,15 @@ import com.l2jserver.gameserver.Shutdown;
 
 
 /**
+ * Thread to check for deadlocked threads.
+ * 
  * @author -Nemesiss- L2M
- *
  */
 public class DeadLockDetector extends Thread
 {
 	private static Logger _log = Logger.getLogger(DeadLockDetector.class.getName());
-	
+
+	/** Interval to check for deadlocked threads */
 	private static final int _sleepTime = Config.DEADLOCK_CHECK_INTERVAL*1000;
 	
 	private final ThreadMXBean tmx;

+ 2 - 1
L2J_Server_BETA/java/com/l2jserver/util/L2LogManager.java

@@ -3,7 +3,8 @@ package com.l2jserver.util;
 import java.util.logging.LogManager;
 
 /**
- * Dummy class to enable logs while shutting down
+ * Specialized {@link LogManager} class.<br>
+ * Prevents log devices to close before shutdown sequence so the shutdown sequence can make logging.
  *
  */
 public class L2LogManager extends LogManager {

+ 11 - 3
L2J_Server_BETA/java/com/l2jserver/util/L2Properties.java

@@ -25,9 +25,11 @@ import java.util.Properties;
 import java.util.logging.Logger;
 
 /**
+ * Specialized {@link java.util.Properties} class.<br>
+ * Simplifies loading of property files and adds logging if a non existing property is requested.<br>
+ * 
  * @author Noctarius
  */
-
 public final class L2Properties extends Properties
 {
 	private static final long serialVersionUID = 1L;
@@ -95,7 +97,10 @@ public final class L2Properties extends Properties
 			reader.close();
 		}
 	}
-	
+
+	/**
+	 * @see Properties#getProperty(String)
+	 */
 	@Override
 	public String getProperty(String key)
 	{
@@ -110,7 +115,10 @@ public final class L2Properties extends Properties
 		
 		return property.trim();
 	}
-	
+
+	/**
+	 * @see Properties#getProperty(String,String)
+	 */
 	@Override
 	public String getProperty(String key, String defaultValue)
 	{

+ 60 - 11
L2J_Server_BETA/java/com/l2jserver/util/Util.java

@@ -23,6 +23,7 @@ package com.l2jserver.util;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 
@@ -34,12 +35,20 @@ import java.nio.ByteBuffer;
 
 public class Util
 {
-	public static boolean isInternalIP(String ipAddress)
+	/**
+	 * Checks if a host name is internal
+	 * 
+	 * @param host
+	 * 	the host name to check
+	 * @return
+	 * 	true: host name is internal<br>
+	 * 	false: host name is external
+	 */
+	public static boolean isInternalHostname(String host)
 	{
-		java.net.InetAddress addr = null;
 		try
 		{
-			addr = java.net.InetAddress.getByName(ipAddress);
+			InetAddress addr = InetAddress.getByName(host);
 			return addr.isSiteLocalAddress() || addr.isLoopbackAddress();
 		}
 		catch (UnknownHostException e)
@@ -48,7 +57,18 @@ public class Util
 		}
 		return false;
 	}
-	
+
+	/**
+	 * Method to generate the hexadecimal representation of a byte array.<br>
+	 * 16 bytes per row, while ascii chars or "." is shown at the end of the line.
+	 * 
+	 * @param data
+	 * 	the byte array to be represented in hexadecimal representation
+	 * @param len
+	 * 	the number of bytes to represent in hexadecimal representation
+	 * @return
+	 * 	byte array represented in hexadecimal format
+	 */
 	public static String printData(byte[] data, int len)
 	{
 		final StringBuilder result = new StringBuilder(len * 4);
@@ -115,7 +135,7 @@ public class Util
 		return result.toString();
 	}
 	
-	public static String fillHex(int data, int digits)
+	private static String fillHex(int data, int digits)
 	{
 		String number = Integer.toHexString(data);
 		
@@ -128,14 +148,27 @@ public class Util
 	}
 	
 	/**
-	 * @param raw
+	 * This call is equivalent to Util.printData(data, data.length)
+	 * @see Util#printData(byte[],int)
+	 * 
+	 * @param data
+	 * 	data to represent in hexadecimal
 	 * @return
+	 * 	byte array represented in hexadecimal format
 	 */
-	public static String printData(byte[] raw)
+	public static String printData(byte[] data)
 	{
-		return printData(raw, raw.length);
+		return printData(data, data.length);
 	}
-	
+
+	/**
+	 * Method to represent the remaining bytes of a ByteBuffer as hexadecimal
+	 * 
+	 * @param buf
+	 * 	ByteBuffer to represent the remaining bytes of as hexadecimal
+	 * @return
+	 * 	hexadecimal representation of remaining bytes of the ByteBuffer
+	 */
 	public static String printData(ByteBuffer buf)
 	{
 		byte[] data = new byte[buf.remaining()];
@@ -144,14 +177,30 @@ public class Util
 		buf.position(buf.position() - data.length);
 		return hex;
 	}
-	
+
+	/**
+	 * Method to generate a random sequence of bytes returned as byte array
+	 * 
+	 * @param size
+	 * 	number of random bytes to generate
+	 * @return
+	 * 	byte array with sequence of random bytes
+	 */
 	public static byte[] generateHex(int size)
 	{
 		byte[] array = new byte[size];
 		Rnd.nextBytes(array);
 		return array;
 	}
-	
+
+	/**
+	 * Method to get the stack trace of a Throwable into a String
+	 * 
+	 * @param t
+	 * 	Throwable to get the stacktrace from
+	 * @return
+	 * 	stack trace from Throwable as String
+	 */
 	public static String getStackTrace(Throwable t)
 	{
 		StringWriter sw = new StringWriter();

+ 2 - 0
L2J_Server_BETA/java/com/l2jserver/util/file/filter/XMLFilter.java

@@ -18,6 +18,8 @@ import java.io.File;
 import java.io.FileFilter;
 
 /**
+ * Specialized {@link FileFilter} class.<br>
+ * Accepts files ending with ".xml" only.
  * 
  * @author mrTJO
  */