diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..62d4c05 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..622ab64 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..fbd7c51 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..5093609 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,104 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/zutil/algo/EuclideansAlgo.java b/src/zutil/algo/EuclideansAlgo.java index 3e53ed5..ef6afd6 100644 --- a/src/zutil/algo/EuclideansAlgo.java +++ b/src/zutil/algo/EuclideansAlgo.java @@ -38,9 +38,6 @@ import java.util.LinkedList; */ public class EuclideansAlgo { - /** - * Simple Test - */ public static void main(String[] args){ MultiPrintStream.out.println("*** Correct Answer: "); MultiPrintStream.out.println("java.util.LinkedList{0, 2, 1, 1, 1, 4, 12, 102, 1, 1, 2, 3, 2, 2, 36}"); diff --git a/src/zutil/db/SQLQuery.java b/src/zutil/db/SQLQuery.java index 6b67aeb..4583f90 100644 --- a/src/zutil/db/SQLQuery.java +++ b/src/zutil/db/SQLQuery.java @@ -54,7 +54,7 @@ public class SQLQuery { //******************************************* // Main Types /** - * + * <pre> * SELECT * [ALL | DISTINCT | DISTINCTROW ] * [FROM table_references @@ -65,7 +65,7 @@ public class SQLQuery { * [ORDER BY {col_name | expr | position} * [ASC | DESC], ...] * [LIMIT {[offset,] row_count | row_count OFFSET offset}] - * + * */ public static class SQLSelect extends SQLQueryItem{ String[] params; diff --git a/src/zutil/log/net/NetLogClient.fxml b/src/zutil/log/net/NetLogClient.fxml deleted file mode 100644 index c23a2e0..0000000 --- a/src/zutil/log/net/NetLogClient.fxml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/zutil/log/net/NetLogClient.java b/src/zutil/log/net/NetLogClient.java deleted file mode 100644 index 10c118b..0000000 --- a/src/zutil/log/net/NetLogClient.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.log.net; - -import zutil.log.LogUtil; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.logging.Level; -import java.util.logging.Logger; - - -public class NetLogClient extends Thread{ - private static final Logger logger = LogUtil.getLogger(); - - private ConcurrentLinkedQueue listeners; - private Socket s; - - public NetLogClient(String host, int port) throws IOException{ - s = new Socket(host, port); - listeners = new ConcurrentLinkedQueue<>(); - this.start(); - } - - public void addListener(NetLogListener listener){ - logger.info("Registering new NetLogListener: "+listener.getClass().getName()); - listeners.add( listener ); - } - - public void run(){ - try{ - ObjectInputStream in = new ObjectInputStream(s.getInputStream()); - while( true ){ - Object o = in.readObject(); - - for( NetLogListener listener : listeners ){ - if( o instanceof NetLogMessage ) - listener.handleLogMessage((NetLogMessage)o); - else if( o instanceof NetLogExceptionMessage ) - listener.handleExceptionMessage((NetLogExceptionMessage)o); - else if( o instanceof NetLogStatusMessage ) - listener.handleStatusMessage((NetLogStatusMessage)o); - else - logger.warning("Received unknown message: "+o.getClass().getName()); - } - } - } catch( Exception e ){ - logger.log(Level.SEVERE, null, e); - close(); - } - } - - - - public void close(){ - try{ - this.interrupt(); - s.close(); - } catch (Exception e){ - logger.log(Level.SEVERE, "Unable to close Client Socket.", e); - } - } -} diff --git a/src/zutil/log/net/NetLogClientInstance.css b/src/zutil/log/net/NetLogClientInstance.css deleted file mode 100644 index 69bf6e9..0000000 --- a/src/zutil/log/net/NetLogClientInstance.css +++ /dev/null @@ -1,35 +0,0 @@ -/* LOG LEVELS */ -.SEVERE { - -fx-control-inner-background: palevioletred; - -fx-accent: derive(-fx-control-inner-background, -40%); - -fx-cell-hover-color: derive(-fx-control-inner-background, -20%); -} -.WARNING { - -fx-control-inner-background: yellow; - -fx-accent: derive(-fx-control-inner-background, -40%); - -fx-cell-hover-color: derive(-fx-control-inner-background, -20%); -} -.INFO { } -.FINE { - -fx-control-inner-background: lavender; - -fx-accent: derive(-fx-control-inner-background, -40%); - -fx-cell-hover-color: derive(-fx-control-inner-background, -20%); -} -.FINER { - -fx-control-inner-background: lightblue ; - -fx-accent: derive(-fx-control-inner-background, -40%); - -fx-cell-hover-color: derive(-fx-control-inner-background, -20%); -} -.FINEST { - -fx-control-inner-background: skyblue; - -fx-accent: derive(-fx-control-inner-background, -40%); - -fx-cell-hover-color: derive(-fx-control-inner-background, -20%); -} - -/* Clear empty rows */ -.table-row-cell:empty { - -fx-background-color: null; -} -.table-row-cell:empty .table-cell { - -fx-border-width: 0px; -} \ No newline at end of file diff --git a/src/zutil/log/net/NetLogClientInstance.fxml b/src/zutil/log/net/NetLogClientInstance.fxml deleted file mode 100644 index 31edf82..0000000 --- a/src/zutil/log/net/NetLogClientInstance.fxml +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
diff --git a/src/zutil/log/net/NetLogExceptionMessage.java b/src/zutil/log/net/NetLogExceptionMessage.java deleted file mode 100755 index 97ceaca..0000000 --- a/src/zutil/log/net/NetLogExceptionMessage.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.log.net; - -import zutil.net.nio.message.Message; - -import java.util.logging.LogRecord; - -public class NetLogExceptionMessage implements Message { - private static final long serialVersionUID = 1L; - - private int count; - private String name; - private String message; - private String stackTrace; - - NetLogExceptionMessage(String name, String message, String stackTrace){ - this.count = 1; - this.name = name; - this.message = message; - this.stackTrace = stackTrace; - } - - public NetLogExceptionMessage(LogRecord record) { - Throwable exception = record.getThrown(); - - this.count = 1; - this.name = exception.getClass().getName(); - this.message = exception.getMessage(); - - StringBuilder str = new StringBuilder(); - for(int i=0; i() { - // public void handle(Event e) { - // handleDisconnectAction(e); - // } - //}); - } - } -} \ No newline at end of file diff --git a/src/zutil/log/net/NetLogGuiClientInstance.java b/src/zutil/log/net/NetLogGuiClientInstance.java deleted file mode 100644 index bdd9d92..0000000 --- a/src/zutil/log/net/NetLogGuiClientInstance.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.log.net; - -import javafx.application.Platform; -import javafx.event.ActionEvent; -import javafx.event.Event; -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.control.*; -import javafx.scene.control.cell.PropertyValueFactory; -import javafx.util.Callback; -import zutil.log.LogUtil; - -import java.net.URL; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class NetLogGuiClientInstance implements Initializable, NetLogListener { - private static final Logger logger = LogUtil.getLogger(); - private enum Status{RUNNING, PAUSED, DISCONNECTED} - - // Logic variables - private NetLogClient net; - private Status status; - - // UI elements - @FXML private ToggleButton pauseButton; - @FXML private Label levelLabel; - @FXML private ComboBox levelComboBox; - @FXML private Label intervalLabel; - @FXML private ComboBox intervalComboBox; - @FXML private ProgressBar progressBar; - @FXML private Label errorLabel; - @FXML private Label logCountLabel; - - @FXML private TableView logTable; - @FXML private TableColumn logTimestampColumn; - @FXML private TableColumn logLevelColumn; - @FXML private TableColumn logColumn; - - @FXML private TableView exceptionTable; - @FXML private TableColumn exCountColumn; - @FXML private TableColumn exNameColumn; - @FXML private TableColumn exMessageColumn; - @FXML private TableColumn exStackTraceColumn; - - - public void initialize(URL arg0, ResourceBundle arg1) { - // Connect to Server - try{ - net = new NetLogClient("127.0.0.1", 5050); - net.addListener( this ); - status = Status.RUNNING; - }catch(Exception e){ - logger.log(Level.SEVERE, null, e); - status = Status.DISCONNECTED; - errorLabel.setText(e.getMessage()); - } - updateStatus(); - - // Setup Gui - logTimestampColumn.setCellValueFactory(new PropertyValueFactory<>("timestamp")); - logLevelColumn.setCellValueFactory(new PropertyValueFactory<>("level")); - logLevelColumn.setCellFactory(new RowCssCellFactory(){ - public String getStyleName(String item){ - return item; - } - }); - logColumn.setCellValueFactory(new PropertyValueFactory<>("log")); - - exCountColumn.setCellValueFactory(new PropertyValueFactory<>("count")); - exNameColumn.setCellValueFactory(new PropertyValueFactory<>("name")); - exMessageColumn.setCellValueFactory(new PropertyValueFactory<>("message")); - exStackTraceColumn.setCellValueFactory(new PropertyValueFactory<>("stackTrace")); - } - - /************* NETWORK *****************/ - public void handleLogMessage(NetLogMessage msg) { - if(status == Status.RUNNING){ - logTable.getItems().add(msg); - - Platform.runLater(new Runnable() { - public void run() { - logCountLabel.setText("" + (Long.parseLong(logCountLabel.getText()) + 1)); - } - }); - } - } - - public void handleExceptionMessage(NetLogExceptionMessage msg) { - if(status == Status.RUNNING){ - exceptionTable.getItems().remove(msg); - exceptionTable.getItems().add(msg); - } - } - - public void handleStatusMessage(NetLogStatusMessage msg) { - if(status == Status.RUNNING){ - - } - } - - /*************** GUI *******************/ - @FXML - protected void handlePauseAction(ActionEvent event) { - if(status == Status.RUNNING){ - status = Status.PAUSED; - logger.info("Logging paused"); - } - else if(status == Status.PAUSED){ - status = Status.RUNNING; - logger.info("Logging Unpaused"); - } - updateStatus(); - } - - @FXML - protected void handleDisconnectAction(Event event) { - logger.info("Disconnecting from Log Server"); - net.close(); - status = Status.DISCONNECTED; - updateStatus(); - } - - @FXML - protected void handleLevelChanged(ActionEvent event) { - logger.info("Updating Log Level"); - } - - @FXML - protected void handleIntervalChanged(ActionEvent event) { - logger.info("Updating Log Interval"); - } - - private void updateStatus(){ - if(progressBar == null || pauseButton == null){ - return; - } - - if(status == Status.RUNNING){ - progressBar.setProgress(-1.0); - pauseButton.setText("Pause"); - } - else if(status == Status.PAUSED){ - progressBar.setProgress(1.0); - pauseButton.setText("Unpause"); - } - else if(status == Status.DISCONNECTED){ - pauseButton.setDisable(true); - levelLabel.setDisable(true); - levelComboBox.setDisable(true); - intervalLabel.setDisable(true); - intervalComboBox.setDisable(true); - - logTable.setDisable(true); - exceptionTable.setDisable(true); - - progressBar.setProgress(0); - logCountLabel.setDisable(true); - } - } - - /** - * http://stackoverflow.com/questions/13697115/javafx-tableview-colors - */ - public abstract class RowCssCellFactory implements Callback, TableCell> { - - public TableCell call(TableColumn p) { - TableCell cell = new TableCell() { - @Override - public void updateItem(T item, boolean empty) { - super.updateItem(item, empty); - setText(empty ? null : getString()); - setGraphic(null); - - String style = getStyleName(item); - if(style != null){ - TableRow row = getTableRow(); - row.getStyleClass().add(style); - } - } - - @Override - public void updateSelected(boolean upd){ - super.updateSelected(upd); - } - - - private String getString() { - return getItem() == null ? "NULL" : getItem().toString(); - } - }; - return cell; - } - - public abstract String getStyleName(T item); - } -} \ No newline at end of file diff --git a/src/zutil/log/net/NetLogListener.java b/src/zutil/log/net/NetLogListener.java deleted file mode 100644 index c68129e..0000000 --- a/src/zutil/log/net/NetLogListener.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.log.net; - - -public interface NetLogListener { - /** - * Handle incoming log messages - */ - void handleLogMessage(NetLogMessage log); - - /** - * Handle incoming exception messages - */ - void handleExceptionMessage(NetLogExceptionMessage exception); - - /** - * Handle incoming status messages - */ - void handleStatusMessage(NetLogStatusMessage status); -} diff --git a/src/zutil/log/net/NetLogMessage.java b/src/zutil/log/net/NetLogMessage.java deleted file mode 100755 index a6f0589..0000000 --- a/src/zutil/log/net/NetLogMessage.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.log.net; - -import zutil.net.nio.message.Message; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.LogRecord; - -public class NetLogMessage implements Message { - private static final long serialVersionUID = 1L; - private static final SimpleDateFormat dataFormat = - new SimpleDateFormat("yyyy--MM-dd HH:mm:ss"); - - private long timestamp; - private String level; - private int threadID; - private String className; - private String methodName; - private String log; - - - public NetLogMessage(String level, long timestamp, String log){ - this.level = level; - this.timestamp = timestamp; - this.log = log; - } - - public NetLogMessage( LogRecord record ){ - timestamp = record.getMillis(); - level = record.getLevel().getName(); - threadID = record.getThreadID(); - className = record.getSourceClassName(); - methodName = record.getSourceMethodName(); - log = record.getMessage(); - } - - - - public String getTimestamp() { - return dataFormat.format(new Date(timestamp)); - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getLevel() { - return level; - } - - public void setLevel(String level) { - this.level = level; - } - - public int getThreadID() { - return threadID; - } - - public void setThreadID(int threadID) { - this.threadID = threadID; - } - - public String getClassName() { - return className; - } - - public void setClassName(String className) { - this.className = className; - } - - public String getMethodName() { - return methodName; - } - - public void setMethodName(String methodName) { - this.methodName = methodName; - } - - public String getLog() { - return log; - } - - public void setLog(String log) { - this.log = log; - } - - -} diff --git a/src/zutil/log/net/NetLogServer.java b/src/zutil/log/net/NetLogServer.java deleted file mode 100755 index d61c311..0000000 --- a/src/zutil/log/net/NetLogServer.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.log.net; - -import zutil.log.LogUtil; -import zutil.net.nio.message.Message; -import zutil.net.threaded.ThreadedTCPNetworkServer; -import zutil.net.threaded.ThreadedTCPNetworkServerThread; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.net.Socket; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - - -public class NetLogServer extends Handler { - private static final Logger logger = LogUtil.getLogger(); - - private NetLogNetwork net; - private ConcurrentHashMap exceptions; - - /** - * @param port the port the server will listen on - */ - public NetLogServer(int port) { - super(); - exceptions = new ConcurrentHashMap<>(); - net = new NetLogNetwork(port); - net.start(); - } - - - public void publish(LogRecord record) { - // ensure that this log record should be logged by this Handler - if (!isLoggable(record)) - return; - - // Output the formatted data to the file - if(record.getThrown() != null){ - NetLogExceptionMessage exception = new NetLogExceptionMessage(record); - if(!exceptions.containsKey(exception)){ - logger.finest("Received new exception: "+exception); - exceptions.put(exception, exception); - net.sendMessage( exception ); - } - else{ - exception = exceptions.get(exception); - exception.addCount(1); - logger.finest("Received known exception(Count: "+exception.getCount()+"): "+exception); - net.sendMessage( exception ); - } - } - else{ - NetLogMessage log = new NetLogMessage(record); - net.sendMessage( log ); - } - } - - public void flush() {} - - public void close() { - net.close(); - } - - - class NetLogNetwork extends ThreadedTCPNetworkServer{ - private ConcurrentLinkedQueue threads; - - public NetLogNetwork(int port) { - super(port); - threads = new ConcurrentLinkedQueue<>(); - } - - public void sendMessage(Message log){ - for( NetLogServerThread thread : threads ){ - thread.sendMessage( log ); - } - } - - @Override - protected ThreadedTCPNetworkServerThread getThreadInstance(Socket s) { - try { - return new NetLogServerThread(s); - } catch (IOException e) { - logger.log(Level.SEVERE, "Unable to start Client thread", e); - } - return null; - } - - - class NetLogServerThread implements ThreadedTCPNetworkServerThread{ - private ObjectOutputStream out; - private ObjectInputStream in; - private Socket s; - - public NetLogServerThread(Socket s) throws IOException{ - this.s = s; - logger.info("Client connected: "+s.getInetAddress()); - out = new ObjectOutputStream( s.getOutputStream() ); - in = new ObjectInputStream( s.getInputStream() ); - - sendAllExceptions(); - threads.add( this ); - } - - public void sendMessage(Message msg){ - try { - out.writeObject( msg ); - out.reset(); - } catch (Exception e) { - this.close(); - logger.log(Level.SEVERE, "Unable to send message to client: "+s.getInetAddress(), e); - } - } - - public void sendAllExceptions(){ - logger.fine("Sending all exceptions to client: "+s.getInetAddress()); - for(NetLogExceptionMessage e : exceptions.values()) - sendMessage(e); - } - - public void run() { - try { - while( true ){ - in.readObject(); - } - } catch (Exception e) { - logger.log(Level.SEVERE, null, e); - } finally { - this.close(); - } - } - - - public void close(){ - try { - threads.remove(this); - logger.info("Client disconnected: "+s.getInetAddress()); - out.close(); - s.close(); - } catch (IOException e) { - logger.log(Level.SEVERE, "Unable to close Client Socket", e); - } - } - } - } -} diff --git a/src/zutil/log/net/NetLogStatusMessage.java b/src/zutil/log/net/NetLogStatusMessage.java deleted file mode 100755 index c2d41bb..0000000 --- a/src/zutil/log/net/NetLogStatusMessage.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.log.net; - -import zutil.net.nio.message.Message; - -public class NetLogStatusMessage implements Message{ - private static final long serialVersionUID = 1L; - - public long totalMemory; - public long freememory; -} diff --git a/src/zutil/ml/LinearRegression.java b/src/zutil/ml/LinearRegression.java index 2965559..8eb3262 100755 --- a/src/zutil/ml/LinearRegression.java +++ b/src/zutil/ml/LinearRegression.java @@ -25,7 +25,7 @@ public class LinearRegression { /** * Linear Regression cost method. - *

+ *


* * J(O) = 1 / (2 * m) * Σ { ( h(Xi) - Yi )^2 } *
@@ -65,11 +65,11 @@ public class LinearRegression { /** * Gradient Descent algorithm - *

+ *


* * Oj = Oj - α * (1 / m) * Σ { ( h(Xi) - Yi ) * Xij } - *
- * + * + *
* @return the theta that was found to minimize the cost function */ public static double[] gradientDescentIteration(double[][] x, double[] y, double[] theta, double alpha){ diff --git a/src/zutil/ml/neural/Perceptron.java b/src/zutil/ml/neural/Perceptron.java index 1ff6190..67ead40 100755 --- a/src/zutil/ml/neural/Perceptron.java +++ b/src/zutil/ml/neural/Perceptron.java @@ -2,9 +2,9 @@ package zutil.ml.neural; /** * This class represents one "nuron" in a neural network. - * - *

From Wikipedia: - *

+ *

+ * From Wikipedia: https://en.wikipedia.org/wiki/Perceptron + *

* The perceptron is an algorithm for supervised learning of * binary classifiers (functions that can decide whether an * input, represented by a vector of numbers, belongs to some diff --git a/src/zutil/net/mqtt/packet/MqttPacketConnect.java b/src/zutil/net/mqtt/packet/MqttPacketConnect.java index abebbe4..421d4d0 100755 --- a/src/zutil/net/mqtt/packet/MqttPacketConnect.java +++ b/src/zutil/net/mqtt/packet/MqttPacketConnect.java @@ -21,7 +21,7 @@ public class MqttPacketConnect extends MqttPacketHeader { private int protocolNameLength = 4; /** * The Protocol Name is a UTF-8 encoded string that represents - * the protocol name “MQTT”, capitalized as shown. The string, + * the protocol name "MQTT", capitalized as shown. The string, * its offset and length will not be changed by future versions * of the MQTT specification. */ diff --git a/src/zutil/parser/BBCodeParser.java b/src/zutil/parser/BBCodeParser.java index 1bdccf4..cee9d03 100755 --- a/src/zutil/parser/BBCodeParser.java +++ b/src/zutil/parser/BBCodeParser.java @@ -60,7 +60,7 @@ public class BBCodeParser { * Registers a new BBCode to the parser. Only one type of BBCode allowed. * * @param bbcode is the BBCode e.g. "b" or "url" - * @param html is the corresponding HTML e.g. "%2" + * @param html is the corresponding HTML e.g. {@code %2} * where the %x corresponds to BBCode like this: [url=%1]%2[/url] */ public void addBBCode(String bbcode, String html){ diff --git a/src/zutil/parser/Templator.java b/src/zutil/parser/Templator.java index 10b3381..e59c576 100755 --- a/src/zutil/parser/Templator.java +++ b/src/zutil/parser/Templator.java @@ -45,7 +45,7 @@ import java.util.logging.Logger; * Class for generating dynamic text/code from set data. * The syntax is similar to the javascript mustache library. * - *

+ *


* Supported tags: *

    *
  • {{key}}
    diff --git a/src/zutil/ui/Configurator.java b/src/zutil/ui/Configurator.java index 67524b7..3637f1d 100755 --- a/src/zutil/ui/Configurator.java +++ b/src/zutil/ui/Configurator.java @@ -47,15 +47,15 @@ import java.util.logging.Logger; * object the {@link Configurator#setValues(DataNode)} or {@link Configurator#setValues(Map)} * can be used to set the individual fields and finally call {@link Configurator#applyConfiguration()} * to configure the target object. - *
    + *

    * External listener can be registered to be called before or after configuration changes * by implementing {@link PreConfigurationActionListener} or {@link PostConfigurationActionListener}. * The configured object will autmatically be registered as a listener if it also implements * these interfaces. * - *
    + *

    * Supported field types: String, int, boolean, enum - *
    + *

    * Created by Ziver */ public class Configurator { diff --git a/test/zutil/log/net/NetLogServerTest.java b/test/zutil/log/net/NetLogServerTest.java deleted file mode 100755 index 99f8a5e..0000000 --- a/test/zutil/log/net/NetLogServerTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2015 Ziver Koc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package zutil.log.net; - -import zutil.log.LogUtil; - -import java.util.logging.Level; -import java.util.logging.Logger; - - -public class NetLogServerTest { - private static final Logger logger = LogUtil.getLogger(); - - public static void main(String[] args){ - LogUtil.setGlobalLevel(Level.FINEST); - LogUtil.addGlobalHandler(new NetLogServer(5050)); - - while(true){ - logger.log(Level.SEVERE, "Test Severe"); - logger.log(Level.WARNING, "Test Warning"); - logger.log(Level.INFO, "Test Info"); - logger.log(Level.FINE, "Test Fine"); - logger.log(Level.FINER, "Test Finer"); - logger.log(Level.FINEST, "Test Finest"); - - logger.log(Level.SEVERE, "Test Exception", new Exception("Test")); - - try{Thread.sleep(3000);}catch(Exception e){} - } - } -} diff --git a/test/zutil/parser/URLDecoderTest.java b/test/zutil/parser/URLDecoderTest.java index 653530b..7d81ee2 100755 --- a/test/zutil/parser/URLDecoderTest.java +++ b/test/zutil/parser/URLDecoderTest.java @@ -56,7 +56,7 @@ public class URLDecoderTest { @Test public void percentMultibyteTest() throws UnsupportedEncodingException { - assertEquals("Ängen", java.net.URLDecoder.decode("%C3%84ngen", "UTF-8")); - assertEquals("Ängen", URLDecoder.decode("%C3%84ngen")); + assertEquals("ngen", java.net.URLDecoder.decode("%C3%84ngen", "UTF-8")); + assertEquals("ngen", URLDecoder.decode("%C3%84ngen")); } }