Cleanup of javadocs

This commit is contained in:
Ziver Koc 2020-10-02 00:49:47 +02:00
parent c8f382a4eb
commit 8cdd25b262
8 changed files with 133 additions and 118 deletions

View file

@ -33,6 +33,8 @@ public class LevenshteinDistance {
* Calculates the Levenshtein Distance(Number of character * Calculates the Levenshtein Distance(Number of character
* changes to equalize the two strings) for two Strings. * changes to equalize the two strings) for two Strings.
* *
* @param str1 first String to be compared
* @param str2 second string to be compared
* @return The number of changes needed to equalize the two Strings * @return The number of changes needed to equalize the two Strings
*/ */
public static int getDistance(String str1, String str2) { public static int getDistance(String str1, String str2) {
@ -44,6 +46,8 @@ public class LevenshteinDistance {
* Calculates the Levenshtein Distance(Number of character * Calculates the Levenshtein Distance(Number of character
* changes to equalize the two strings) for two Strings. * changes to equalize the two strings) for two Strings.
* *
* @param str1 first String to be compared
* @param str2 second string to be compared
* @param matrix is a int matrix that will be used for the dynamic programing algorithm. * @param matrix is a int matrix that will be used for the dynamic programing algorithm.
* NOTE: matrix must be 1 larger than the largest string * NOTE: matrix must be 1 larger than the largest string
* @return The number of changes needed to equalize the two Strings * @return The number of changes needed to equalize the two Strings

View file

@ -60,6 +60,7 @@ public abstract class AbstractChart extends JPanel{
* *
* @param g2 is the Graphics object that will paint the chart * @param g2 is the Graphics object that will paint the chart
* @param bound is the bounds of the axis, the drawing should not exceed this bound * @param bound is the bounds of the axis, the drawing should not exceed this bound
* @return a Rectangle object specifying the drawn are of the axis
*/ */
protected abstract Rectangle drawAxis(Graphics2D g2, Rectangle bound); protected abstract Rectangle drawAxis(Graphics2D g2, Rectangle bound);

View file

@ -62,7 +62,7 @@ public class DBConnectionPool extends TimerTask implements Closeable{
} }
// The pool // The pool
private LinkedList<PoolItem> inusePool; private LinkedList<PoolItem> inUsePool;
private LinkedList<PoolItem> readyPool; private LinkedList<PoolItem> readyPool;
/** /**
@ -81,7 +81,7 @@ public class DBConnectionPool extends TimerTask implements Closeable{
this.user = user; this.user = user;
this.password = password; this.password = password;
inusePool = new LinkedList<>(); inUsePool = new LinkedList<>();
readyPool = new LinkedList<>(); readyPool = new LinkedList<>();
this.setTimeout(DEFAULT_TIMEOUT); this.setTimeout(DEFAULT_TIMEOUT);
@ -105,7 +105,7 @@ public class DBConnectionPool extends TimerTask implements Closeable{
* @param conn is the connection to remove * @param conn is the connection to remove
*/ */
protected void removeConnection(DBConnection conn) { protected void removeConnection(DBConnection conn) {
inusePool.remove(conn); inUsePool.remove(conn);
readyPool.remove(conn); readyPool.remove(conn);
} }
@ -113,6 +113,7 @@ public class DBConnectionPool extends TimerTask implements Closeable{
* Lease one connection from the pool * Lease one connection from the pool
* *
* @return an DB connection or null if the pool is empty * @return an DB connection or null if the pool is empty
* @throws Exception will be thrown if there is any issue instantiating a DBConnection
*/ */
public synchronized DBConnection getConnection() throws Exception { public synchronized DBConnection getConnection() throws Exception {
if (readyPool.isEmpty()) { if (readyPool.isEmpty()) {
@ -123,10 +124,9 @@ public class DBConnectionPool extends TimerTask implements Closeable{
return conn; return conn;
} }
return null; return null;
} } else {
else{
PoolItem item = readyPool.poll(); PoolItem item = readyPool.poll();
inusePool.addLast(item); inUsePool.addLast(item);
item.timestamp = System.currentTimeMillis(); item.timestamp = System.currentTimeMillis();
return item.conn; return item.conn;
} }
@ -138,8 +138,8 @@ public class DBConnectionPool extends TimerTask implements Closeable{
* @param conn is the connection that is not used anymore * @param conn is the connection that is not used anymore
*/ */
protected synchronized void releaseConnection(DBConnection conn) { protected synchronized void releaseConnection(DBConnection conn) {
int index = inusePool.indexOf(conn); int index = inUsePool.indexOf(conn);
PoolItem item = inusePool.remove(index); PoolItem item = inUsePool.remove(index);
readyPool.addLast(item); readyPool.addLast(item);
} }
@ -147,17 +147,18 @@ public class DBConnectionPool extends TimerTask implements Closeable{
* @return the current size of the pool * @return the current size of the pool
*/ */
public int size() { public int size() {
return inusePool.size() + readyPool.size(); return inUsePool.size() + readyPool.size();
} }
/** /**
* Closes all the connections * Closes all the connections
*/ */
public synchronized void close() { public synchronized void close() {
for( PoolItem item : inusePool ){ for (PoolItem item : inUsePool) {
item.conn.forceClose(); item.conn.forceClose();
} }
inusePool.clear(); inUsePool.clear();
for (PoolItem item : readyPool) { for (PoolItem item : readyPool) {
item.conn.forceClose(); item.conn.forceClose();
} }
@ -166,6 +167,8 @@ public class DBConnectionPool extends TimerTask implements Closeable{
/** /**
* Set the max size of the pool * Set the max size of the pool
*
* @param max the new maximum size of the pool
*/ */
public void setMaxSize(int max) { public void setMaxSize(int max) {
this.max_conn = max; this.max_conn = max;
@ -173,9 +176,12 @@ public class DBConnectionPool extends TimerTask implements Closeable{
/** /**
* Sets the timeout of the Connections * Sets the timeout of the Connections
*
* @param timeout the new timeout value in milliseconds
*/ */
public synchronized void setTimeout(long timeout) { public synchronized void setTimeout(long timeout) {
this.timeout = timeout; this.timeout = timeout;
if (timeout_timer != null) if (timeout_timer != null)
timeout_timer.cancel(); timeout_timer.cancel();
timeout_timer = new Timer(); timeout_timer = new Timer();
@ -188,7 +194,7 @@ public class DBConnectionPool extends TimerTask implements Closeable{
public void run() { public void run() {
long stale = System.currentTimeMillis() - timeout; long stale = System.currentTimeMillis() - timeout;
for(PoolItem item : inusePool){ for (PoolItem item : inUsePool) {
if (!item.conn.valid() && stale > item.timestamp) { if (!item.conn.valid() && stale > item.timestamp) {
removeConnection(item.conn); removeConnection(item.conn);
item.conn.forceClose(); item.conn.forceClose();

View file

@ -34,6 +34,8 @@ public interface SQLResultHandler<T> {
* *
* @param stmt is the query * @param stmt is the query
* @param result is the ResultSet * @param result is the ResultSet
* @return a value based on the result handler description
* @throws SQLException if there is any database related issues
*/ */
T handleQueryResult(Statement stmt, ResultSet result) throws SQLException; T handleQueryResult(Statement stmt, ResultSet result) throws SQLException;
} }

View file

@ -10,13 +10,12 @@ import java.sql.SQLException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
* A intermediate class for loading Objects of generic Classes. * A intermediate class for loading Objects of generic Classes.
* The extending class must set the "superBean" parameter to true in {@link DBBean.DBTable}. * The extending class must set the "superBean" parameter to true in {@link DBBean.DBTable}.
* The Object that is stored must use Configurator to define what fields that should be stored. * The Object that is stored must use Configurator to define what fields that should be stored.
* *
* This class needs to fields in DB: * This class needs two fields in DB:
* <ul> * <ul>
* <li>String type: defining the class name</li> * <li>String type: defining the class name</li>
* <li>Text config: the object configuration is stored as JSON</li> * <li>Text config: the object configuration is stored as JSON</li>
@ -74,6 +73,8 @@ public abstract class DBBeanObjectDSO<T> extends DBBean{
/** /**
* Will replace the current object. * Will replace the current object.
*
* @param obj is the object to set or null to reset the DSO
*/ */
public void setObject(T obj){ public void setObject(T obj){
if(obj != null) { if(obj != null) {

View file

@ -48,10 +48,10 @@ public class DBBeanSQLResultHandler<T> implements SQLResultHandler<T>{
private boolean list; private boolean list;
/** /**
* Creates a new instance of this class that returns only one bean * Creates a new instance of this class that returns only one bean
* *
* @param <C> is the class type that should be instantiated
* @param cl is the DBBean class that will be parsed from the SQL result * @param cl is the DBBean class that will be parsed from the SQL result
* @return a new instance of this class * @return a new instance of this class
*/ */
@ -62,6 +62,7 @@ public class DBBeanSQLResultHandler<T> implements SQLResultHandler<T>{
/** /**
* Creates a new instance of this class that returns a bean with all its containing beans * Creates a new instance of this class that returns a bean with all its containing beans
* *
* @param <C> is the class type that should be instantiated
* @param cl is the DBBean class that will be parsed from the SQL result * @param cl is the DBBean class that will be parsed from the SQL result
* @param db is the DB connection for loading internal beans * @param db is the DB connection for loading internal beans
* @return a new instance of this class * @return a new instance of this class
@ -73,6 +74,7 @@ public class DBBeanSQLResultHandler<T> implements SQLResultHandler<T>{
/** /**
* Creates a new instance of this class that returns a list of beans * Creates a new instance of this class that returns a list of beans
* *
* @param <C> is the class type that should be instantiated
* @param cl is the DBBean class that will be parsed from the SQL result * @param cl is the DBBean class that will be parsed from the SQL result
* @return a new instance of this class * @return a new instance of this class
*/ */
@ -83,6 +85,7 @@ public class DBBeanSQLResultHandler<T> implements SQLResultHandler<T>{
/** /**
* Creates a new instance of this class that returns a list of beans with all the internal beans * Creates a new instance of this class that returns a list of beans with all the internal beans
* *
* @param <C> is the class type that should be instantiated
* @param cl is the DBBean class that will be parsed from the SQL result * @param cl is the DBBean class that will be parsed from the SQL result
* @param db is the DB connection for loading internal beans * @param db is the DB connection for loading internal beans
* @return a new instance of this class * @return a new instance of this class
@ -122,8 +125,7 @@ public class DBBeanSQLResultHandler<T> implements SQLResultHandler<T>{
bean_list.add(obj); bean_list.add(obj);
} }
return (T) bean_list; return (T) bean_list;
} } else {
else{
if (result.next()) { if (result.next()) {
return (T) createBean(result); return (T) createBean(result);
} }
@ -150,8 +152,7 @@ public class DBBeanSQLResultHandler<T> implements SQLResultHandler<T>{
obj = beanClass.newInstance(); obj = beanClass.newInstance();
obj.setId(id); obj.setId(id);
updateBean(result, obj); updateBean(result, obj);
} } else if (DBBeanCache.isOutDated(obj)) {
else if (DBBeanCache.isOutDated(obj)){
// Update fields // Update fields
logger.finer("Bean(" + beanClass.getName() + ") cache to old for id: " + id); logger.finer("Bean(" + beanClass.getName() + ") cache to old for id: " + id);
updateBean(result, obj); updateBean(result, obj);

View file

@ -49,6 +49,8 @@ public class ThreadedUDPNetwork extends Thread{
/** /**
* Creates a new unicast Client instance of the class * Creates a new unicast Client instance of the class
*
* @throws SocketException if there is any issue creating the new socket
*/ */
public ThreadedUDPNetwork() throws SocketException{ public ThreadedUDPNetwork() throws SocketException{
this.type = UDPType.UNICAST; this.type = UDPType.UNICAST;
@ -61,6 +63,7 @@ public class ThreadedUDPNetwork extends Thread{
* Creates a new unicast Server instance of the class * Creates a new unicast Server instance of the class
* *
* @param port is the port that the server should listen to * @param port is the port that the server should listen to
* @throws SocketException if there is any issue creating the new socket
*/ */
public ThreadedUDPNetwork(int port) throws SocketException{ public ThreadedUDPNetwork(int port) throws SocketException{
this.type = UDPType.UNICAST; this.type = UDPType.UNICAST;

View file

@ -145,21 +145,20 @@ public class ProcDiskstats {
return devName; return devName;
} }
/** /**
* This values increment when an I/O request completes. * @return number of completed I/O requests.
*/ */
public long getReadIO() { public long getReadIO() {
return readIO; return readIO;
} }
/** /**
* This value increment when an I/O request is merged with an * @return number of merged I/O requests with an already-queued I/O request.
* already-queued I/O request.
*/ */
public long getReadMerges() { public long getReadMerges() {
return readMerges; return readMerges;
} }
/** /**
* This value count the number of sectors read from to this * @return the number of sectors read from to this block device.
* block device. The "sectors" in question are the standard UNIX 512-byte * The "sectors" in question are the standard UNIX 512-byte
* sectors, not any device- or filesystem-specific block size. The * sectors, not any device- or filesystem-specific block size. The
* counter is incremented when the I/O completes. * counter is incremented when the I/O completes.
*/ */
@ -167,7 +166,7 @@ public class ProcDiskstats {
return readSectors; return readSectors;
} }
/** /**
* This value count the number of milliseconds that I/O requests have * @return the number of milliseconds that I/O requests have
* waited on this block device. If there are multiple I/O requests waiting, * waited on this block device. If there are multiple I/O requests waiting,
* this value will increase at a rate greater than 1000/second; for * this value will increase at a rate greater than 1000/second; for
* example, if 60 read requests wait for an average of 30 ms, the read_ticks * example, if 60 read requests wait for an average of 30 ms, the read_ticks
@ -177,29 +176,28 @@ public class ProcDiskstats {
return readTicks; return readTicks;
} }
/** /**
* This values increment when an I/O request completes. * @return number of completed I/O requests.
*/ */
public long getWriteIO() { public long getWriteIO() {
return writeIO; return writeIO;
} }
/** /**
* This value increment when an I/O request is merged with an * @return the number of merged I/O requests with an already-queued I/O request.
* already-queued I/O request.
*/ */
public long getWriteMerges() { public long getWriteMerges() {
return writeMerges; return writeMerges;
} }
/** /**
* This value count the number of sectors written to this * @return the number of sectors written to this block device.
* block device. The "sectors" in question are the standard UNIX 512-byte * The "sectors" in question are the standard UNIX 512-byte
* sectors, not any device- or filesystem-specific block size. The * sectors, not any device- or filesystem-specific block size.
* counter is incremented when the I/O completes. * The counter is incremented when the I/O completes.
*/ */
public long getWriteSectors() { public long getWriteSectors() {
return writeSectors; return writeSectors;
} }
/** /**
* This value count the number of milliseconds that I/O requests have * @return the number of milliseconds that I/O requests have
* waited on this block device. If there are multiple I/O requests waiting, * waited on this block device. If there are multiple I/O requests waiting,
* this value will increase at a rate greater than 1000/second; for * this value will increase at a rate greater than 1000/second; for
* example, if 60 write requests wait for an average of 30 ms, the write_ticks * example, if 60 write requests wait for an average of 30 ms, the write_ticks
@ -209,7 +207,7 @@ public class ProcDiskstats {
return writeTicks; return writeTicks;
} }
/** /**
* This value counts the number of I/O requests that have been issued to * @return the number of I/O requests that have been issued to
* the device driver but have not yet completed. It does not include I/O * the device driver but have not yet completed. It does not include I/O
* requests that are in the queue but not yet issued to the device driver. * requests that are in the queue but not yet issued to the device driver.
*/ */
@ -217,14 +215,13 @@ public class ProcDiskstats {
return inFlight; return inFlight;
} }
/** /**
* This value counts the number of milliseconds during which the device has * @return the number of milliseconds during which the device has had I/O requests queued.
* had I/O requests queued.
*/ */
public long getIoTicks() { public long getIoTicks() {
return ioTicks; return ioTicks;
} }
/** /**
* This value counts the number of milliseconds that I/O requests have waited * @return the number of milliseconds that I/O requests have waited
* on this block device. If there are multiple I/O requests waiting, this * on this block device. If there are multiple I/O requests waiting, this
* value will increase as the product of the number of milliseconds times the * value will increase as the product of the number of milliseconds times the
* number of requests waiting (see "read ticks" above for an example). * number of requests waiting (see "read ticks" above for an example).