Use {@link #getOSName()} to retrieve the name of current operating system. - * - * @since 1.0.0b.1 - * @see #getOSName() - */ - public enum OS { - /** - * Indicates the Windows OS. - */ - WINDOWS, - - /** - * Indicates the Linux OS. - */ - LINUX, - - /** - * Indicates the Mac OS. - */ - MAC, - - /** - * Indicates the Solaris OS. - */ - SOLARIS, - - /** - * Indicates unknown OS. - */ - OTHER - }; - - /** - * Stores the static variable of {@link OSUtils.OS}. - */ - private static OS os = null; - - /** - * Returns path separator based on operating system. - * - * @since 1.0.0b.1 - * @see File#separator - */ - public final static String sep = File.separator; - - /** - * Retrieves and returns the name of current operating system. - * - *
If the operating system name unknown, then it will returns {@code OTHER}.
- *
- * @return the name of current operating system
- *
- * @since 1.0.0b.1
- * @see System#getProperty(String)
- */
- public static OS getOSName() {
- if (os == null) {
- final String osName = System.getProperty("os.name").toLowerCase();
-
- if (osName.contains("win")) {
- os = OS.WINDOWS;
- }
- else if (osName.contains("nix") || osName.contains("nux") ||
- osName.contains("aix")) {
- os = OS.LINUX;
- }
- else if (osName.contains("mac")) {
- os = OS.MAC;
- }
- else if (osName.contains("sunos")) {
- os = OS.SOLARIS;
- }
- else {
- os = OS.OTHER; // unknown operating system
- }
- }
-
- return os;
- }
-}
From bcf1f172924d821eb3b34174d43f748089cffce8 Mon Sep 17 00:00:00 2001
From: Ryuu Mitsuki <117973493+mitsuki31@users.noreply.github.com>
Date: Sat, 16 Sep 2023 20:09:41 +0700
Subject: [PATCH 03/36] Refactor the main class
* Changed the main class to `MainClass.java`
* Introduced a new final class called `ArgumentsParser` in main class
* Added several new methods to `ArgumentsParser` class, including:
- `contains`
- `get`
- `getArguments`
- `iterator` (from `Iterable` interface)
---
pom.xml | 2 +-
src/main/java/com/mitsuki/jmatrix/Main.java | 141 ----------------
.../mitsuki/jmatrix/internal/MainClass.java | 155 ++++++++++++++++++
3 files changed, 156 insertions(+), 142 deletions(-)
delete mode 100644 src/main/java/com/mitsuki/jmatrix/Main.java
create mode 100644 src/main/java/com/mitsuki/jmatrix/internal/MainClass.java
diff --git a/pom.xml b/pom.xml
index c30ab35f..3906e555 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@
This class does not provides APIs for build the matrix, - * it's just useless class if get imported. - * - *
Usage:
- * - *- * java -jar path/to/jmatrix-<version>.jar [-h|-V|-cr] - *- * - * @author - * Ryuu Mitsuki - * @version 1.32, 19 July 2023 - * @since 1.0.0b.1 - * @see com.mitsuki.jmatrix.Matrix - */ -public class Main -{ - /** - * Stores the static object class of {@link XMLParser} class. - */ - private static XMLParser XML = new XMLParser(XMLParser.XMLType.CONFIG); - - /** - * Stores a string that represents the concatenation of: - * - *
For example: + * + *
+ * PropertiesParser parser = PropertiesParser.load("example.properties");
+ * Properties properties = parser.getProperties();
+ *
+ *
+ * Or with one variable: + * + *
+ * Properties properties = PropertiesParser.load("example.properties")
+ * .getProperties();
+ *
+ *
+ * @author Ryuu Mitsuki
+ * @version 1.0, 16 September 2023
+ * @since 1.5.0
+ * @license
+ * Apache License 2.0
+ */
public final class PropertiesParser {
+
+ /**
+ * A path to the specified property file (initialized inside constructor).
+ */
private String propertyFile;
+
+ /**
+ * Stores the properties data from the specified properties file.
+ */
private Properties properties;
+ /**
+ * A sole constructor. Users should never use this constructor to create a new
+ * instance of this class.
+ *
+ * @param inStream The (@link InputStream} object to be loaded by
+ * {@link Properties}.
+ * @param propertyPath The string path to the property file.
+ *
+ * @throws IOException
+ * If an I/O error occurs while loading the properties.
+ *
+ * @since 1.5.0
+ * @see #load(String)
+ */
private PropertiesParser(InputStream inStream,
String propertyPath) throws IOException {
this.propertyFile = propertyPath;
@@ -37,6 +85,22 @@ private PropertiesParser(InputStream inStream,
this.properties.load(inStream);
}
+ /**
+ * Loads and retrieves the properties from the specified file path.
+ *
+ * @param file The file path reference to a property file.
+ *
+ * @return A new instance of this class with parsed properties.
+ * To get the properties, users can use {@link #getProperties()}.
+ *
+ * @throws IOException
+ * If an I/O error occurs while loading the properties.
+ *
+ * @throws NullPointerException
+ * If the given file path is {@code null}.
+ *
+ * @since 1.5.0
+ */
public static PropertiesParser load(String file) throws IOException {
if (file == null) {
throw new NullPointerException("The file path cannot be null");
@@ -51,16 +115,51 @@ public static PropertiesParser load(String file) throws IOException {
return new PropertiesParser(propertyStream, file);
}
+ /**
+ * Gets the instance of {@link Properties} class with parsed properties
+ * from this class.
+ *
+ * @return The instance of {@link Properties} with parsed properties.
+ *
+ * @since 1.5.0
+ */
public Properties getProperties() {
return this.properties;
}
}
-class SetupProperties {
+/**
+ * This class provides access to get the setup properties and it is designed
+ * to be synchronized and thread-safe.
+ *
+ * The setup properties are retrieved from the file statically using + * the {@code static} block, which means that when the program starts it will + * immediately retrieve the properties from the file. + * + * @author Ryuu Mitsuki + * @version 1.0, 16 September 2023 + * @since 1.5.0 + * @license + * Apache License 2.0 + */ +final class SetupProperties { + + /** + * A string represents a file path to the setup properties stored in. + */ private static final String setupFile = "configuration/setup.properties"; + + /** + * A {@code Properties} object that stores all properties data + * from setup properties file. + */ private static Properties setupProperties; + /* Immediately search and check the setup properties file, then retrieve + * all properties data from it. Before retrieving the properties, + * it will checks whether the properties file is exist and readable. + */ static { File setupFile_FileObj = new File(setupFile); @@ -97,6 +196,14 @@ class SetupProperties { } } + /** + * Gets the synchronized setup properties from this class. + * + * @return A synchronized instance of {@link Properties} from this + * class containing all setup properties data. + * + * @since 1.5.0 + */ static Properties getSetupProperties() { return setupProperties; } From ae0eb2d6685b3900401ffe2500cf264ef5156c1e Mon Sep 17 00:00:00 2001 From: Ryuu Mitsuki <117973493+mitsuki31@users.noreply.github.com> Date: Sun, 17 Sep 2023 12:53:52 +0700 Subject: [PATCH 07/36] Temporarily deactivate the `tests` CI Decativated due to maintaining the internal code. This CI will also be improved to support with future changes. --- .github/workflows/tests.yml | 169 +++++++++++++++++------------------- 1 file changed, 80 insertions(+), 89 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 57f29ca2..2a71e80c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -61,29 +61,20 @@ jobs: # Install deps - name: Install dependencies if: ${{ steps.cache-maven.outputs.cache-hit != true && env.DEBUG != true }} - run: mvn install -DskipTests + run: mvn clean install -DskipTests - name: Install dependencies (Debug) if: ${{ steps.cache-maven.outputs.cache-hit != true && env.DEBUG == true }} - run: mvn install -DskipTests -X + run: mvn clean install -DskipTests -X - # Packaging with source files - - name: Package source + # Packaging and testing + - name: Packaging and testing if: ${{ env.DEBUG != true }} - run: mvn package -P include-src + run: mvn test package -P include-src - name: Package source (Debug) if: ${{ env.DEBUG == true }} - run: mvn package -P include-src -X - - # Test - - name: Test project - if: ${{ env.DEBUG != true }} - run: mvn test - - - name: Test project (Debug) - if: ${{ env.DEBUG == true }} - run: mvn test -X + run: mvn test package -P include-src -X # Clean up - name: Clean up the project @@ -91,77 +82,77 @@ jobs: # ::---:: Make Test ::---:: # - make-test: - name: Make Test - runs-on: ubuntu-latest - continue-on-error: true - - strategy: - matrix: - py-ver: ['3.7', '3.x'] - - env: - arch: x64 - DEPS_FILE: 'requirements.txt' - DEBUG: ${{ inputs.debug }} - - steps: - # Checkout - - name: Checkout repository - uses: actions/checkout@v3 - - # Setup Python - - name: Setup Python ${{ matrix.py-ver }} - id: setup-py - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.py-ver }} - architecture: ${{ env.arch }} - cache: 'pip' - cache-dependency-path: '**/${{ env.DEPS_FILE }}' - - # Install deps - - name: Install dependencies - if: ${{ steps.setup-py.outputs.cache-hit != true }} - run: | - if [ $DEBUG = 'true' ]; then - python -m pip install -r $DEPS_FILE --debug - else - python -m pip install -r $DEPS_FILE - fi - - # Sadly, Make cannot tests the project thoroughly due to unavailability - # of necessary packages (e.g "org.junit"), so here it just tests - # the project on compiling, packaging, and generating docs. - - # Compile - - name: Compile the project - run: | - [ -d target/classes ] && make clean - make compile VERBOSE=$DEBUG LINT=true - - # Package - - name: Packaging the project - run: | - make package VERBOSE=$DEBUG - - - name: Packaging the project (with source) - run: | - make package INCLUDE-SRC=true VERBOSE=$DEBUG - - # Build docs - - name: Build the docs - run: | - # Build docs - # For more information on debugging, we prefer to change it - # to "all" mode. - if [ $DEBUG = 'true' ]; then - make build-docs VERBOSE=all - else - make build-docs - fi - - # Clean up - - name: Clean up the project - run: | - [ -d target ] && echo "Clean the project" && make clean +# make-test: +# name: Make Test +# runs-on: ubuntu-latest +# continue-on-error: true +# +# strategy: +# matrix: +# py-ver: ['3.7', '3.x'] +# +# env: +# arch: x64 +# DEPS_FILE: 'requirements.txt' +# DEBUG: ${{ inputs.debug }} +# +# steps: +# # Checkout +# - name: Checkout repository +# uses: actions/checkout@v3 +# +# # Setup Python +# - name: Setup Python ${{ matrix.py-ver }} +# id: setup-py +# uses: actions/setup-python@v3 +# with: +# python-version: ${{ matrix.py-ver }} +# architecture: ${{ env.arch }} +# cache: 'pip' +# cache-dependency-path: '**/${{ env.DEPS_FILE }}' +# +# # Install deps +# - name: Install dependencies +# if: ${{ steps.setup-py.outputs.cache-hit != true }} +# run: | +# if [ $DEBUG = 'true' ]; then +# python -m pip install -r $DEPS_FILE --debug +# else +# python -m pip install -r $DEPS_FILE +# fi +# +# # Sadly, Make cannot tests the project thoroughly due to unavailability +# # of necessary packages (e.g "org.junit"), so here it just tests +# # the project on compiling, packaging, and generating docs. +# +# # Compile +# - name: Compile the project +# run: | +# [ -d target/classes ] && make clean +# make compile VERBOSE=$DEBUG LINT=true +# +# # Package +# - name: Packaging the project +# run: | +# make package VERBOSE=$DEBUG +# +# - name: Packaging the project (with source) +# run: | +# make package INCLUDE-SRC=true VERBOSE=$DEBUG +# +# # Build docs +# - name: Build the docs +# run: | +# # Build docs +# # For more information on debugging, we prefer to change it +# # to "all" mode. +# if [ $DEBUG = 'true' ]; then +# make build-docs VERBOSE=all +# else +# make build-docs +# fi +# +# # Clean up +# - name: Clean up the project +# run: | +# [ -d target ] && echo "Clean the project" && make clean From 7deda926dfa16e672394b07f19ef6fb96f4a2524 Mon Sep 17 00:00:00 2001 From: Ryuu Mitsuki <117973493+mitsuki31@users.noreply.github.com> Date: Sun, 17 Sep 2023 12:58:47 +0700 Subject: [PATCH 08/36] Fix several errors during compilation The errors is occurred due to missing some variables, error imports, and etc. --- src/main/java/com/mitsuki/jmatrix/Matrix.java | 100 +++++++++--------- .../jmatrix/internal/JMatrixUtils.java | 77 ++------------ .../mitsuki/jmatrix/internal/XMLParser.java | 8 +- 3 files changed, 62 insertions(+), 123 deletions(-) diff --git a/src/main/java/com/mitsuki/jmatrix/Matrix.java b/src/main/java/com/mitsuki/jmatrix/Matrix.java index beda3eee..bb65feb8 100644 --- a/src/main/java/com/mitsuki/jmatrix/Matrix.java +++ b/src/main/java/com/mitsuki/jmatrix/Matrix.java @@ -24,7 +24,7 @@ import com.mitsuki.jmatrix.exception.JMatrixBaseException; import com.mitsuki.jmatrix.exception.MatrixArrayFullException; import com.mitsuki.jmatrix.exception.NullMatrixException; -import com.mitsuki.jmatrix.util.Options; +import com.mitsuki.jmatrix.internal.JMatrixUtils; import com.mitsuki.jmatrix.core.MatrixUtils; import java.util.Arrays; @@ -228,7 +228,7 @@ public Matrix(int rows, int cols) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Copy the sizes from input parameters this.ROWS = rows; @@ -290,7 +290,7 @@ public Matrix(int rows, int cols, double val) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Copy the sizes from input parameters this.ROWS = rows; @@ -353,7 +353,7 @@ public Matrix(int rows, int cols, double val) { public Matrix(double[ ][ ] arr) { // Raise the exception immediately if given array is null if (arr == null || arr.length == 0) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Given two-dimensional array is null. Please ensure the array has valid elements.")); } @@ -425,7 +425,7 @@ public void create(int rows, int cols) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Copy the sizes from input parameters this.ROWS = rows; @@ -453,7 +453,7 @@ public void create(int rows, int cols) { public void create(double[ ][ ] arr) { // Raise the exception immediately if given array is null if (arr == null || arr.length == 0) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Given two-dimensional array is null. Please ensure the array has valid elements.")); } @@ -511,7 +511,7 @@ public void create(double[ ][ ] arr) { public static Matrix identity(int n) { // Check for negative value on input argument if (n < 1) { - Options.raiseError(new IllegalMatrixSizeException( + JMatrixUtils.raiseError(new IllegalMatrixSizeException( "Sizes of identity matrix cannot be lower than 1.")); } @@ -571,10 +571,10 @@ else if (values.length < this.COLS) { try { throw new JMatrixBaseException(iae); } catch (final JMatrixBaseException jme) { - Options.raiseError(jme); + JMatrixUtils.raiseError(jme); } } catch (final RuntimeException re) { - Options.raiseError(re); + JMatrixUtils.raiseError(re); } // Iterate values list and fill elements of matrix array @@ -619,7 +619,7 @@ else if (this.index >= this.ROWS) { "Cannot add values anymore, Matrix is already full"); } } catch (final RuntimeException re) { - Options.raiseError(re); + JMatrixUtils.raiseError(re); } // Creates list of repeated value @@ -761,7 +761,7 @@ else if (this.ROWS != m.ROWS || this.COLS != m.COLS) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create new matrix for the result double[ ][ ] result = new double[this.ROWS][m.COLS]; @@ -845,7 +845,7 @@ else if (this.ROWS != arr.length || this.COLS != arr[0].length) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create new matrix for the result double[ ][ ] result = new double[this.ROWS][arr[0].length]; @@ -932,7 +932,7 @@ else if (a.length != b.length || a[0].length != b[0].length) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create a new array for the result double[ ][ ] result = new double[a.length][b[0].length]; @@ -1020,7 +1020,7 @@ else if (a.getSize()[0] != b.getSize()[0] || a.getSize()[1] != b.getSize()[1]) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create new matrix object Matrix matrixRes = new Matrix(a.getSize()[0], b.getSize()[1]); @@ -1106,7 +1106,7 @@ else if (this.ROWS != m.ROWS || this.COLS != m.COLS) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create new matrix for the result double[ ][ ] result = new double[this.ROWS][m.COLS]; @@ -1186,7 +1186,7 @@ else if (this.ROWS != arr.length || this.COLS != arr[0].length) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create new matrix for the result double[ ][ ] result = new double[this.ROWS][arr[0].length]; @@ -1272,7 +1272,7 @@ else if (a.length != b.length || a[0].length != b[0].length) { ); } - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create a new matrix array double[ ][ ] result = new double[a.length][b[0].length]; @@ -1357,7 +1357,7 @@ else if (a.getSize()[0] != b.getSize()[0] || a.getSize()[1] != b.getSize()[1]) { ); } - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create new matrix object Matrix matrixRes = new Matrix(a.getSize()[0], b.getSize()[1]); @@ -1448,7 +1448,7 @@ else if (this.COLS != m.ROWS) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create new matrix array double[ ][ ] result = new double[this.ROWS][m.COLS]; @@ -1534,7 +1534,7 @@ else if (this.COLS != a.length) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create new matrix array double[ ][ ] result = new double[this.ROWS][a[0].length]; @@ -1620,7 +1620,7 @@ else if (a[0].length != b.length) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); double[ ][ ] result = new double[a.length][b[0].length]; @@ -1707,7 +1707,7 @@ else if (a.getSize()[1] != b.getSize()[0]) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Create new matrix object Matrix result = new Matrix(a.getSize()[0], b.getSize()[1]); @@ -1762,7 +1762,7 @@ else if (a.getSize()[1] != b.getSize()[0]) { public void mult(double x) { // Throw the exception immediately if this matrix has null entries if (this.ENTRIES == null) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "This matrix is null. " + "Please ensure the matrix are initialized before performing scalar multiplication." )); @@ -1812,7 +1812,7 @@ public void mult(double x) { public static Matrix mult(Matrix m, double x) { // Throw the exception immediately if given matrix has null entries if (m == null || m.getEntries() == null) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Given matrix is null. " + "Please ensure the matrix are initialized before performing scalar multiplication." )); @@ -1890,7 +1890,7 @@ public static Matrix mult(Matrix m, double x) { public void transpose() { // Throw the exception immediately if this matrix has null entries if (this.ENTRIES == null) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "This matrix is null. " + "Please ensure the matrix are initialized before performing transposition." )); @@ -1926,7 +1926,7 @@ public void transpose() { */ public static double[ ][ ] transpose(double[ ][ ] arr) { if (arr == null || arr.length == 0) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Given array is null. " + "Please ensure the array has valid elements before performing transposition." )); @@ -1997,7 +1997,7 @@ public void transpose() { public static Matrix transpose(Matrix m) { // Throw the exception immediately if the given matrix has null entries if (m == null || m.getEntries() == null) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Given matrix is null. " + "Please ensure the matrix are initialized before performing transposition." )); @@ -2084,7 +2084,7 @@ public boolean isSquare() { */ public static boolean isSquare(double[ ][ ] arr) { if (arr == null || arr.length == 0) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Given array is null. Please ensure the array has valid elements.")); } @@ -2111,7 +2111,7 @@ public static boolean isSquare(double[ ][ ] arr) { */ public static boolean isSquare(Matrix m) { if (m == null || m.getEntries() == null) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Matrix is null. Please ensure the matrix are initialized.")); } @@ -2164,7 +2164,7 @@ public boolean isDiagonal() { */ public static boolean isDiagonal(Matrix m) { if (!m.isSquare()) { - Options.raiseError(new IllegalMatrixSizeException( + JMatrixUtils.raiseError(new IllegalMatrixSizeException( "Matrix is non-square type. " + "Please ensure the matrix has the same number of rows and columns." )); @@ -2201,7 +2201,7 @@ public static boolean isDiagonal(Matrix m) { */ public static boolean isDiagonal(double[ ][ ] arr) { if (!Matrix.isSquare(arr)) { - Options.raiseError(new IllegalMatrixSizeException( + JMatrixUtils.raiseError(new IllegalMatrixSizeException( "Given array is non-square type. " + "Please ensure the array has the same number of rows and columns." )); @@ -2314,14 +2314,14 @@ public boolean isLowerTriangular() { */ public static boolean isLowerTriangular(Matrix m) { if (MatrixUtils.isNullEntries(m)) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Matrix is null. Please ensure the matrix have been initialized.") ); } // The matrix must be square else if (!m.isSquare()) { - Options.raiseError(new IllegalMatrixSizeException( + JMatrixUtils.raiseError(new IllegalMatrixSizeException( "Matrix is non-square type. " + "Please ensure the matrix has the same number of rows and columns." )); @@ -2383,14 +2383,14 @@ else if (!m.isSquare()) { */ public static boolean isLowerTriangular(double[ ][ ] arr) { if (arr == null || arr.length == 0) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Array is null. Please ensure the array has valid elements.") ); } // The two-dimensional array must be square else if (!Matrix.isSquare(arr)) { - Options.raiseError(new IllegalMatrixSizeException( + JMatrixUtils.raiseError(new IllegalMatrixSizeException( "Array is non-square type. " + "Please ensure the array has the same number of rows and columns." )); @@ -2503,14 +2503,14 @@ public boolean isUpperTriangular() { */ public static boolean isUpperTriangular(Matrix m) { if (MatrixUtils.isNullEntries(m)) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Matrix is null. Please ensure the matrix have been initialized.") ); } // The matrix must be square else if (!m.isSquare()) { - Options.raiseError(new IllegalMatrixSizeException( + JMatrixUtils.raiseError(new IllegalMatrixSizeException( "Matrix is non-square type. " + "Please ensure the matrix has the same number of rows and columns." )); @@ -2572,14 +2572,14 @@ else if (!m.isSquare()) { */ public static boolean isUpperTriangular(double[ ][ ] arr) { if (arr == null || arr.length == 0) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Array is null. Please ensure the array has valid elements.") ); } // The matrix must be square else if (!Matrix.isSquare(arr)) { - Options.raiseError(new IllegalMatrixSizeException( + JMatrixUtils.raiseError(new IllegalMatrixSizeException( "Array is non-square type. " + "Please ensure the array has the same number of rows and columns." )); @@ -2636,7 +2636,7 @@ public Matrix copy() { "Matrix is null. Please ensure the matrix are initialized."); } } catch (final NullMatrixException nme) { - Options.raiseError(nme); + JMatrixUtils.raiseError(nme); } // Create new and copy the matrix @@ -2724,7 +2724,7 @@ else if (index > this.ROWS - 1) { "Given index is too larger than number of rows."); } - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); this.selectedIndex = index; this.hasSelect = true; @@ -2800,7 +2800,7 @@ else if (!this.hasSelect) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Change values of matrix column with values from argument parameter for (int i = 0; i < this.COLS; i++) { @@ -2855,7 +2855,7 @@ public void change(double value) { // Check if the user have not select any index row // If user have not then it will immediately raise the exception if (!this.hasSelect) { - Options.raiseError(new InvalidIndexException( + JMatrixUtils.raiseError(new InvalidIndexException( "Selected index is null. " + "Please ensure you have already called \"select(int)\" method." )); @@ -2894,7 +2894,7 @@ public void change(double value) { */ public void clear() { if (this.ENTRIES == null) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Matrix is null. Please ensure the matrix have been initialized.")); } @@ -2924,7 +2924,7 @@ public void clear() { */ public void sort() { if (this.ENTRIES == null) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "This matrix is null. Please ensure the matrix are initialized.")); } @@ -2954,7 +2954,7 @@ public void sort() { */ public static void sort(double[ ][ ] arr) { if (arr == null || arr.length == 0) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Given array is null. Please ensure the array has valid elements.")); } @@ -2981,7 +2981,7 @@ public static void sort(double[ ][ ] arr) { public static Matrix sort(Matrix m) { // Check for matrix with null entries if (m == null || m.getEntries() == null) { - Options.raiseError(new NullMatrixException( + JMatrixUtils.raiseError(new NullMatrixException( "Given matrix is null. Please ensure the matrix are initialized.")); } @@ -3100,7 +3100,7 @@ public double get(int row, int col) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); // Check for negative index for both inputs if (row < 0) { @@ -3204,7 +3204,7 @@ else if (index > this.ROWS - 1) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); System.out.println(Arrays.toString(this.ENTRIES[index])); } else { @@ -3277,7 +3277,7 @@ final public static void display(double[ ][ ] arr, int index) { } // Throw the exception if got one - if (cause != null) Options.raiseError(cause); + if (cause != null) JMatrixUtils.raiseError(cause); System.out.println(Arrays.toString(arr[index])); } diff --git a/src/main/java/com/mitsuki/jmatrix/internal/JMatrixUtils.java b/src/main/java/com/mitsuki/jmatrix/internal/JMatrixUtils.java index fc09fea0..f102d14a 100644 --- a/src/main/java/com/mitsuki/jmatrix/internal/JMatrixUtils.java +++ b/src/main/java/com/mitsuki/jmatrix/internal/JMatrixUtils.java @@ -33,17 +33,16 @@ /** * This class provides all neccessary utilities for JMatrix library. * - * @author - * Ryuu Mitsuki + * @author Ryuu Mitsuki * @version 1.5, 16 September 2023 * @since 1.0.0b.1 - * @license + * @license * Apache License 2.0 - * - * @see com.mitsuki.jmatrix.util.XMLParser */ public class JMatrixUtils { + private static final String PROGNAME = "JMatrix"; + ///// ---------------------- ///// /// Class & Packages /// ///// ---------------------- ///// @@ -54,7 +53,7 @@ public class JMatrixUtils { *
For example:
* *
- * Options.getPackageName(MyClass.class);
+ * JMatrixUtils.getPackageName(MyClass.class);
*
*
* @param cls the {@link Class} object.
@@ -74,7 +73,7 @@ public static String getPackageName(Class> cls) {
* For example:
* *
- * Options.getClassName(MyClass.class);
+ * JMatrixUtils.getClassName(MyClass.class);
*
*
* @param cls the {@link Class} object.
@@ -242,7 +241,7 @@ public static long getLinesFile(InputStream stream) {
* @see java.io.InputStream
*/
public static InputStream getFileAsStream(String filePath) {
- return Options.class.getClassLoader().getResourceAsStream(filePath);
+ return JMatrixUtils.class.getClassLoader().getResourceAsStream(filePath);
}
/**
@@ -264,73 +263,13 @@ public static boolean writeToFile(String filePath, String[ ] contents) {
return true;
} catch (final IOException ioe) {
- Options.raiseError(new JMatrixBaseException(ioe), 0);
+ JMatrixUtils.raiseError(new JMatrixBaseException(ioe), 0);
}
return false;
}
- ///// ------------------ /////
- /// Contents ///
- ///// ------------------ /////
-
- /**
- * Returns a list containing the help message contents.
- *
- * @return the contents of help message.
- *
- * @since 1.0.0b.1
- * @see #readFile(InputStream)
- * @see #getFileAsStream(String)
- * @see #removeComment(String[])
- */
- public static String[ ] getHelpMsg() {
- return removeComment(readFile(getFileAsStream(contentsPath + "help.content")));
- }
-
- /**
- * Returns a list containing the copyright contents.
- *
- * @return the contents of copyright.
- *
- * @since 1.0.0b.1
- * @see #readFile(InputStream)
- * @see #getFileAsStream(String)
- * @see java.lang.StringBuilder
- */
- public static String[ ] getCopyright() {
- final String[ ] contents = readFile(getFileAsStream(contentsPath + "additional.content"));
- String[ ] copyright = new String[contents.length];
-
- for (int i = 0; i < contents.length; i++) {
- // Ignore the comment
- if (!contents[i].startsWith("#")) {
- StringBuilder sb = new StringBuilder();
- for (int j = 0; j < contents[i].length(); j += 2) {
- String bytes = contents[i].substring(j, j + 2);
- sb.append((char) Integer.parseInt(bytes, 16));
- }
- copyright[i] = sb.toString();
- } else {
- copyright[i] = contents[i];
- }
- }
-
- for (int i = 0; i != contents.length; i++) {
- if (copyright[i].contains("${PACKAGE_NAME}")) {
- copyright[i] = copyright[i].replace("${PACKAGE_NAME}", XML.getProperty("programName"));
- }
-
- if (copyright[i].contains("${AUTHOR}")) {
- copyright[i] = copyright[i].replace("${AUTHOR}", XML.getProperty("author"));
- }
- }
-
- return removeComment(copyright);
- }
-
-
/**
* Removes comment lines from an array of strings.
*
diff --git a/src/main/java/com/mitsuki/jmatrix/internal/XMLParser.java b/src/main/java/com/mitsuki/jmatrix/internal/XMLParser.java
index 41f03925..f6e80f94 100644
--- a/src/main/java/com/mitsuki/jmatrix/internal/XMLParser.java
+++ b/src/main/java/com/mitsuki/jmatrix/internal/XMLParser.java
@@ -119,7 +119,7 @@ static String getData(final String choice) {
break;
default:
- Options.raiseError(
+ JMatrixUtils.raiseError(
new JMatrixBaseException(
new IllegalArgumentException(
"Cannot retrieve data for input \"" + choice + "\""
@@ -143,7 +143,7 @@ static String getData(final String choice) {
* @since 1.0.0b.1
* @license
* Apache License 2.0
- * @see com.mitsuki.jmatrix.util.Options
+ * @see com.mitsuki.jmatrix.internal.JMatrixUtils
*/
public class XMLParser implements XMLData
{
@@ -187,7 +187,7 @@ public XMLParser(XMLType type) {
break;
default:
- Options.raiseError(
+ JMatrixUtils.raiseError(
new JMatrixBaseException(
new IllegalArgumentException(
"Invalid XML type: \"" + type + "\""
@@ -216,7 +216,7 @@ public XMLParser(XMLType type) {
XMLConfig.betaNum = xml.getElementsByTagName("beta_num").item(0).getTextContent().strip();
}
} catch (final Exception e) {
- Options.raiseError(new JMatrixBaseException(e), -1);
+ JMatrixUtils.raiseError(new JMatrixBaseException(e), -1);
}
}
From bd8d304e26bc2b46bdade6914f164bfab1f8f043 Mon Sep 17 00:00:00 2001
From: Ryuu Mitsuki <117973493+mitsuki31@users.noreply.github.com>
Date: Sun, 17 Sep 2023 16:47:10 +0700
Subject: [PATCH 09/36] Fix errors during properties initializer
Removed several checks from checking the setup properties file
This will only occurs error because the `File` class checks the file
from the current directory. Replaced by checking the `InputStream`
whether it is null, null is indicates that InputStream cannot found
the specified file inside JAR's directory tree.
---
.../jmatrix/internal/PropertiesParser.java | 31 +++++--------------
1 file changed, 7 insertions(+), 24 deletions(-)
diff --git a/src/main/java/com/mitsuki/jmatrix/internal/PropertiesParser.java b/src/main/java/com/mitsuki/jmatrix/internal/PropertiesParser.java
index 3552601c..5f462a27 100644
--- a/src/main/java/com/mitsuki/jmatrix/internal/PropertiesParser.java
+++ b/src/main/java/com/mitsuki/jmatrix/internal/PropertiesParser.java
@@ -19,11 +19,9 @@
package com.mitsuki.jmatrix.internal;
-import java.io.File;
+import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
-import java.io.FileNotFoundException;
-import java.nio.file.AccessDeniedException;
import java.util.Properties;
@@ -161,27 +159,6 @@ final class SetupProperties {
* it will checks whether the properties file is exist and readable.
*/
static {
- File setupFile_FileObj = new File(setupFile);
-
- // Store the exception and will be thrown later if not null
- Throwable causeException = null;
-
- if (!setupFile_FileObj.exists()) {
- causeException = new FileNotFoundException(
- String.format("Cannot found '%s' file", setupFile)
- );
- } else if (setupFile_FileObj.exists() &&
- !setupFile_FileObj.canRead()) {
- causeException = new AccessDeniedException(setupFile,
- null, "Read access is denied"
- );
- }
-
- // It is a good practice to throw occurred exception immediately,
- // especially after exiting a code block (e.g., if-else statement block)
- if (causeException != null)
- throw new ExceptionInInitializerError(causeException);
-
// Although the Properties class has been designed to be synchronized,
// the code below further ensures that it is implicitly synchronized
if (setupProperties == null) {
@@ -190,6 +167,12 @@ final class SetupProperties {
.getResourceAsStream(setupFile)) {
setupProperties = new Properties();
setupProperties.load(inStream);
+
+ if (setupProperties == null) {
+ throw new FileNotFoundException(String.format(
+ "InputStream cannot found '%s' file", setupFile
+ ));
+ }
} catch (final IOException ioe) {
throw new ExceptionInInitializerError(ioe);
}
From bcd0b0ec848997333f58c64b9276429447a40db6 Mon Sep 17 00:00:00 2001
From: Ryuu Mitsuki <117973493+mitsuki31@users.noreply.github.com>
Date: Sun, 17 Sep 2023 18:10:32 +0700
Subject: [PATCH 10/36] Enhance the setup properties parser
The setup properties parser has improved in several factors, one of which is checking the existence of the file.
---
.../jmatrix/internal/PropertiesParser.java | 24 ++++++++++++-------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/mitsuki/jmatrix/internal/PropertiesParser.java b/src/main/java/com/mitsuki/jmatrix/internal/PropertiesParser.java
index 5f462a27..004b7180 100644
--- a/src/main/java/com/mitsuki/jmatrix/internal/PropertiesParser.java
+++ b/src/main/java/com/mitsuki/jmatrix/internal/PropertiesParser.java
@@ -19,10 +19,12 @@
package com.mitsuki.jmatrix.internal;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.util.Properties;
+import java.net.URL;
/**
@@ -155,24 +157,30 @@ final class SetupProperties {
private static Properties setupProperties;
/* Immediately search and check the setup properties file, then retrieve
- * all properties data from it. Before retrieving the properties,
- * it will checks whether the properties file is exist and readable.
+ * all properties data from it. Throw IOException if I/O errors occurred.
*/
static {
// Although the Properties class has been designed to be synchronized,
// the code below further ensures that it is implicitly synchronized
if (setupProperties == null) {
- try (InputStream inStream = SetupProperties.class
+ try {
+ URL urlSetupFile = SetupProperties.class
.getClassLoader()
- .getResourceAsStream(setupFile)) {
- setupProperties = new Properties();
- setupProperties.load(inStream);
+ .getResource(setupFile);
- if (setupProperties == null) {
+ // Return an error if the resource file cannot be found
+ if (urlSetupFile == null) {
throw new FileNotFoundException(String.format(
- "InputStream cannot found '%s' file", setupFile
+ "ClassLoader cannot found '%s' file", setupFile
));
}
+
+ // Convert the URL to InputStream
+ InputStream inStream = urlSetupFile.openStream();
+
+ // Load the properties file
+ setupProperties = new Properties();
+ setupProperties.load(inStream);
} catch (final IOException ioe) {
throw new ExceptionInInitializerError(ioe);
}
From edc1672f3ffd343c0297d8a0abc24aae7814086f Mon Sep 17 00:00:00 2001
From: Ryuu Mitsuki <117973493+mitsuki31@users.noreply.github.com>
Date: Sun, 17 Sep 2023 20:15:57 +0700
Subject: [PATCH 11/36] Refactor the main method on parsing several arguments
* Added new method called `getFirstArgument` that gets the first known argument.
The known arguments in this changes (the arguments are not different with the previous ones):
"-V", "--version", "ver", "version" : Display the JMatrix version
"-cr", "--copyright", "copyright" : Display the copyright and license
* Added several necessary private members
---
.../mitsuki/jmatrix/internal/MainClass.java | 57 +++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/src/main/java/com/mitsuki/jmatrix/internal/MainClass.java b/src/main/java/com/mitsuki/jmatrix/internal/MainClass.java
index 1b22b811..ed4b41ad 100644
--- a/src/main/java/com/mitsuki/jmatrix/internal/MainClass.java
+++ b/src/main/java/com/mitsuki/jmatrix/internal/MainClass.java
@@ -25,6 +25,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.LinkedHashSet;
+import java.util.Properties;
import java.util.Set;
import java.lang.Iterable;
@@ -46,6 +47,16 @@
*/
public class MainClass {
+ private static Properties setupProperties = SetupProperties.getSetupProperties();
+
+ private static ListIf a known argument is found, it is returned as the first
+ * known argument. If none of the provided arguments match the known ones,
+ * it returns {@code null}.
+ *
+ * @param args A list of arguments to search for known arguments.
+ *
+ * @return The first known argument found, or {@code null}
+ * if none are known.
+ *
+ * @since 1.5.0
+ */
static String getFirstArgument(List The setup properties are retrieved from the file statically using
- * the {@code static} block, which means that when the program starts it will
- * immediately retrieve the properties from the file.
- *
- * @author Ryuu Mitsuki
- * @version 1.0, 16 September 2023
- * @since 1.5.0
- * @license
- * Apache License 2.0
- */
-final class SetupProperties {
-
- /**
- * A string represents a file path to the setup properties stored in.
- */
- private static final String setupFile = "configuration/setup.properties";
-
- /**
- * A {@code Properties} object that stores all properties data
- * from setup properties file.
- */
- private static Properties setupProperties;
-
- /* Immediately search and check the setup properties file, then retrieve
- * all properties data from it. Throw IOException if I/O errors occurred.
- */
- static {
- // Although the Properties class has been designed to be synchronized,
- // the code below further ensures that it is implicitly synchronized
- if (setupProperties == null) {
- try {
- URL urlSetupFile = SetupProperties.class
- .getClassLoader()
- .getResource(setupFile);
-
- // Return an error if the resource file cannot be found
- if (urlSetupFile == null) {
- throw new FileNotFoundException(String.format(
- "ClassLoader cannot found '%s' file", setupFile
- ));
- }
-
- // Convert the URL to InputStream
- InputStream inStream = urlSetupFile.openStream();
-
- // Load the properties file
- setupProperties = new Properties();
- setupProperties.load(inStream);
- } catch (final IOException ioe) {
- throw new ExceptionInInitializerError(ioe);
- }
- }
- }
-
- /**
- * Gets the synchronized setup properties from this class.
- *
- * @return A synchronized instance of {@link Properties} from this
- * class containing all setup properties data.
- *
- * @since 1.5.0
- */
- static Properties getSetupProperties() {
- return setupProperties;
- }
-}
diff --git a/src/main/java/com/mitsuki/jmatrix/internal/SetupProperties.java b/src/main/java/com/mitsuki/jmatrix/internal/SetupProperties.java
new file mode 100644
index 00000000..9ea6d881
--- /dev/null
+++ b/src/main/java/com/mitsuki/jmatrix/internal/SetupProperties.java
@@ -0,0 +1,98 @@
+// --------------------- //
+/* SetupProperties */
+// --------------------- //
+
+/* Copyright (c) 2023 Ryuu Mitsuki
+ *
+ * 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
+ *
+ * http://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.
+ */
+
+package com.mitsuki.jmatrix.internal;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.net.URL;
+
+/**
+ * This class provides access to get the setup properties and it is designed
+ * to be synchronized and thread-safe.
+ *
+ * The setup properties are retrieved from the file statically using
+ * the {@code static} block, which means that when the program starts it will
+ * immediately retrieve the properties from the file.
+ *
+ * @author Ryuu Mitsuki
+ * @version 1.1, 12 December 2023
+ * @since 1.5.0
+ * @license
+ * Apache License 2.0
+ */
+final class SetupProperties {
+
+ /**
+ * A string represents a file path to the setup properties stored in.
+ */
+ private static final String setupFile = "configuration/setup.properties";
+
+ /**
+ * A {@code Properties} object that stores all properties data
+ * from setup properties file.
+ */
+ private static Properties setupProperties;
+
+ /* Immediately search and check the setup properties file, then retrieve
+ * all properties data from it. Throw IOException if I/O errors occurred.
+ */
+ static {
+ // Although the Properties class has been designed to be synchronized,
+ // the code below further ensures that it is implicitly synchronized
+ if (setupProperties == null) {
+ try {
+ URL urlSetupFile = SetupProperties.class
+ .getClassLoader()
+ .getResource(setupFile);
+
+ // Return an error if the resource file cannot be found
+ if (urlSetupFile == null) {
+ throw new FileNotFoundException(String.format(
+ "ClassLoader cannot found '%s' file", setupFile
+ ));
+ }
+
+ // Convert the URL to InputStream
+ InputStream inStream = urlSetupFile.openStream();
+
+ // Load the properties file
+ setupProperties = new Properties();
+ setupProperties.load(inStream);
+ } catch (final IOException ioe) {
+ throw new ExceptionInInitializerError(ioe);
+ }
+ }
+ }
+
+ /**
+ * Gets the synchronized setup properties from this class.
+ *
+ * @return A synchronized instance of {@link Properties} from this
+ * class containing all setup properties data.
+ *
+ * @since 1.5.0
+ */
+ static Properties getSetupProperties() {
+ return setupProperties;
+ }
+}
From 120e58891b3c733b692ca401239acc62a08f79a7 Mon Sep 17 00:00:00 2001
From: Ryuu Mitsuki <117973493+mitsuki31@users.noreply.github.com>
Date: Tue, 12 Dec 2023 17:39:19 +0700
Subject: [PATCH 15/36] Refactor the `JMatrixUtils` class
Now it uses the SetupProperties class to get the program name instead.
In addition, we also added the Javadoc for undocumented variables.
---
.../jmatrix/internal/JMatrixUtils.java | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/mitsuki/jmatrix/internal/JMatrixUtils.java b/src/main/java/com/mitsuki/jmatrix/internal/JMatrixUtils.java
index f102d14a..cbe3c7fe 100644
--- a/src/main/java/com/mitsuki/jmatrix/internal/JMatrixUtils.java
+++ b/src/main/java/com/mitsuki/jmatrix/internal/JMatrixUtils.java
@@ -29,19 +29,28 @@
import java.io.IOException;
import java.util.List;
import java.util.Arrays;
+import java.util.Properties;
/**
* This class provides all neccessary utilities for JMatrix library.
*
* @author Ryuu Mitsuki
- * @version 1.5, 16 September 2023
+ * @version 1.6, 12 December 2023
* @since 1.0.0b.1
* @license
* Apache License 2.0
*/
public class JMatrixUtils {
- private static final String PROGNAME = "JMatrix";
+ /**
+ * A {@link Properties} object reference to synchronized setup properties.
+ */
+ private static final Properties setupProperties = SetupProperties.getSetupProperties();
+
+ /**
+ * A string variable holding the program name, retrieved from {@link SetupProperties}.
+ */
+ private static final String PROGNAME = setupProperties.getProperty("JM-Name");
///// ---------------------- /////
/// Class & Packages ///
@@ -128,9 +137,9 @@ public static Note: This method is thread-safe, but does not handle null inputs gracefully.
+ * If {@code date} or {@code formatPattern} is {@code null}, a
+ * {@code NullPointerException} will be thrown.
+ *
+ * @param date The date and time string in ISO 8601
+ * format (e.g., "2024-01-08T21:53:00Z").
+ * @param formatPattern The format pattern to use for the
+ * localized date and time string
+ * (e.g., "dd/MM/yyyy HH:mm:ss").
+ * @return The localized date and time string in
+ * the specified format.
+ *
+ * @throws DateTimeParseException If the input {@code date} string cannot be parsed
+ * using the ISO 8601 formatter.
+ * @throws NullPointerException If {@code null} are known on {@code date} or
+ * {@code formatPattern} argument.
+ *
+ * @since 1.5.0
+ * @see #dateISOToLocal(String)
*/
public static String dateISOToLocal(String date, String formatPattern) {
LocalDateTime dateTime = LocalDateTime.parse(date, DateTimeFormatter.ISO_DATE_TIME);
@@ -357,17 +372,27 @@ public static String dateISOToLocal(String date, String formatPattern) {
}
/**
- * Converts the given date with format of ISO to local format with
- * default format pattern.
+ * Converts a date and time string in ISO 8601 format to a localized string
+ * using the {@code yyyy-MM-dd HH:mm:ss} format pattern.
+ *
+ * For customizing the format pattern, use the
+ * {@link #dateISOToLocal(String, String)} method instead. The format pattern
+ * will use format {@code yyyy-MM-dd HH:mm:ss}.
+ *
+ * Note: This method is thread-safe, but does not handle null inputs gracefully.
+ * If {@code date} is {@code null}, a {@code NullPointerException} will be thrown.
*
- * For customizing the format pattern, use the
- * {@link #dateISOToLocal(String, String)} method instead.
- * The default value of format pattern is {@code "yyyy-MM-dd HH:mm:ss"}.
+ * @param date The date and time string in ISO 8601
+ * format (e.g., "2024-01-08T21:53:00Z").
+ * @return The localized date and time string in
+ * the {@code yyyy-MM-dd HH:mm:ss} format.
*
- * @param date a {@code String} representing the ISO date.
- * @return the local formatted date.
+ * @throws DateTimeParseException If the input {@code date} string cannot be parsed
+ * using the ISO 8601 formatter.
+ * @throws NullPointerException If {@code null} are known on {@code date} argument.
*
- * @since 1.5.0
+ * @since 1.5.0
*/
public static String dateISOToLocal(String date) {
return dateISOToLocal(date, "yyyy-MM-dd HH:mm:ss");
From 464f09f66457ab5b7821f55e31b5ff67fe5511a5 Mon Sep 17 00:00:00 2001
From: Ryuu Mitsuki <117973493+mitsuki31@users.noreply.github.com>
Date: Wed, 10 Jan 2024 12:20:19 +0700
Subject: [PATCH 30/36] fix: Replace absolute to relative path for imports
efficiency
---
Makefile | 17 ++++++++++-------
make/Main.mk | 2 +-
make/Setup.mk | 4 ++--
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index 3627332d..3147dc9a 100644
--- a/Makefile
+++ b/Makefile
@@ -17,13 +17,20 @@
# limitations under the License.
#
-MAKE_DIR := $(CURDIR)/make
+# It is NOT RECOMMENDED to use the absolute path, Make are ineffectively
+# handles directories and files with spaces, it will treats them as a list of values
+# rather than a single path of directory.
+MAKE_DIR := make
SETUP_MAKE := $(MAKE_DIR)/Setup.mk
MAIN_MAKE := $(MAKE_DIR)/Main.mk
MAKE_USAGE := $(addprefix docs/make/,makefile-usage.txcc makefile-usage.txt)
MKFLAGS := --no-print-directory --silent --file {FILE}
CUSTOMGOALS := $(MAKECMDGOALS)
+ifeq ($(wildcard $(MAKE_DIR)),)
+ $(error Cannot import internal modules from '$(abspath $(MAKE_DIR))')
+endif # wildcard : $(MAKE_DIR)
+
# Import: Func.mk
include $(MAKE_DIR)/Func.mk
@@ -35,12 +42,8 @@ include $(MAKE_DIR)/Func.mk
# initialization via the builder, especially crucial when users only seek
# to display the help message.
ifneq ($(words $(CUSTOMGOALS)),0)
- ifneq ($(filter $(word 1,$(CUSTOMGOALS)),help),help)
- ifneq ($(wildcard $(MAKE_DIR)),) # Check the "make" directory
- include $(SETUP_MAKE)
- else
- $(__raise_err,Fatal,Cannot import neccessary files from "$(MAKE_DIR)". No such a directory)
- endif # wildcard
+ ifneq ($(firstword $(CUSTOMGOALS)),help)
+ include $(SETUP_MAKE)
endif # filter
endif # words
diff --git a/make/Main.mk b/make/Main.mk
index 12b9f274..71c9b16e 100644
--- a/make/Main.mk
+++ b/make/Main.mk
@@ -21,7 +21,7 @@
# Import: Setup.mk
### TODO: Remove this when all necessary variables has correctly
### imported from the Makefile within the project's root directory.
-include $(or $(MAKE_DIR),$(CURDIR)/make)/Setup.mk
+include $(or $(MAKE_DIR),make)/Setup.mk
## :::::::::::::::: ##
diff --git a/make/Setup.mk b/make/Setup.mk
index 799606c4..a6a82c69 100644
--- a/make/Setup.mk
+++ b/make/Setup.mk
@@ -23,7 +23,7 @@ ifndef __MAKE_SETUP_MK
__MAKE_SETUP_MK = 1
# Import: Func.mk
-include $(or $(MAKE_DIR),$(CURDIR)/make)/Func.mk
+include $(or $(MAKE_DIR),make)/Func.mk
## :::::::::::::::: ##
## User Options ##
@@ -84,7 +84,7 @@ PY ?= $(or $(shell command -v python 2> /dev/null),\
# Import: Prop.mk
# Import this module only after the Python command checker
-include $(or $(MAKE_DIR),$(PWD)/make)/Prop.mk
+include $(or $(MAKE_DIR),make)/Prop.mk
### Flags
# Check if these constants has been defined to avoid redefine
From 533f6fe0df6e7ecf2ff3c130dbede6bb9b8284d9 Mon Sep 17 00:00:00 2001
From: Ryuu Mitsuki <117973493+mitsuki31@users.noreply.github.com>
Date: Wed, 10 Jan 2024 20:26:19 +0700
Subject: [PATCH 31/36] refactor: Update the excluded packages list
Replaced the "com.mitsuki.jmatrix.util" with "com.mitsuki.jmatrix.internal".
And also changed the assignment operator for all internal options.
---
Makefile | 23 ++++++++++++-----------
make/Setup.mk | 14 +++++++-------
2 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/Makefile b/Makefile
index 3147dc9a..20c8c3fd 100644
--- a/Makefile
+++ b/Makefile
@@ -56,21 +56,21 @@ endif # words
# It is equivalent with:
# $ make