From: Svjatoslav Agejenko Date: Sun, 27 Sep 2026 13:42:25 +0000 (+0300) Subject: chore!: require Java 21, drop servlet-api and CommonPathResolver X-Git-Tag: svjatoslavcommons-2.0.0~1 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=f72e14bbc9747a5878bb90c011519c541ccd0efb;p=svjatoslav_commons.git chore!: require Java 21, drop servlet-api and CommonPathResolver Build: compiler source/target 8 to 21 (Debian 13 ships OpenJDK 21 and 25); remove the unused provided-scope servlet-api 2.5 dependency, which nothing in the tree ever imported. API: delete CommonPathResolver, a trivial System.getProperty ("user.home") wrapper; package-info and docs updated accordingly. Documentation: doc/ renamed to Documentation/ per house convention. The page gains stable CUSTOM_ID anchors on every heading and the shared style.css replaces the inline style block; the Maven quick-start section moves ahead of the feature tour, feature subsections follow a familiarity ramp, and a new building-from-source section documents the Debian 13 JDK packages and the Maven build. --- diff --git a/.gitignore b/.gitignore index 80a1eb3..6597e9e 100755 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,8 @@ /*.log /test/ -/doc/apidocs/ -/doc/graphs/ +/Documentation/apidocs/ +/Documentation/graphs/ /.classpath /.factorypath diff --git a/AGENTS.md b/AGENTS.md index 5ccf1fd..29c64ef 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,7 +16,7 @@ mvn clean install # Clean build and install to local Maven repo ## Project Info - **License:** Creative Commons Zero (CC0) -- **Java Version:** 8 +- **Java Version:** 21 - **Package:** `eu.svjatoslav.commons` ## Dependencies @@ -24,7 +24,6 @@ mvn clean install # Clean build and install to local Maven repo | Dependency | Scope | Purpose | |-----------------|----------|----------------------------| | junit 4.8.1 | test | Unit testing | -| servlet-api 2.5 | provided | Servlet support (optional) | ## Package Structure @@ -36,7 +35,6 @@ mvn clean install # Clean build and install to local Maven repo ### `eu.svjatoslav.commons.file` - **IOHelper** - File I/O utilities (recursive delete, read/write files, smart overwrite) - **FilePathParser** - Extract file extensions, names without extensions, format file sizes -- **CommonPathResolver** - Resolve common system paths (home directory) ### `eu.svjatoslav.commons.gui.dialog` - **ExceptionDialog** - Swing dialog for displaying exceptions with stack traces diff --git a/Documentation/index.org b/Documentation/index.org new file mode 100644 index 0000000..03fbcc3 --- /dev/null +++ b/Documentation/index.org @@ -0,0 +1,205 @@ +#+SETUPFILE: ~/.emacs.d/org-styles/html/darksun.theme +#+TITLE: Svjatoslav Commons - Java library of commonly used functions +#+LANGUAGE: en +#+LATEX_HEADER: \usepackage[margin=1.0in]{geometry} +#+LATEX_HEADER: \usepackage{parskip} +#+LATEX_HEADER: \usepackage[none]{hyphenat} + +#+OPTIONS: H:20 num:20 +#+OPTIONS: author:nil + +#+HTML_HEAD: + +* Introduction +:PROPERTIES: +:CUSTOM_ID: introduction +:END: + +Svjatoslav Commons is a shared Java utility library that consolidates +commonly needed functionality: reading and writing files, manipulating +strings, handling binary data, and displaying errors to users. + +The library requires Java 21 and has no runtime dependencies; only JUnit +is used, for testing. See [[#usage][How to +take library into use]] for Maven dependency configuration. The complete +API documentation is available in the [[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/][JavaDoc]]. + +* How to take library into use +:PROPERTIES: +:CUSTOM_ID: usage +:END: + +Add the *svjatoslavcommons* dependency to your Maven project: + +#+BEGIN_SRC xml + + + eu.svjatoslav + svjatoslavcommons + 1.9 + + +#+END_SRC + +Also add the repository (the library is not on Maven Central): + +#+BEGIN_SRC xml + + + svjatoslav.eu + Svjatoslav repository + https://www3.svjatoslav.eu/maven/ + + +#+END_SRC + +* Library contents +:PROPERTIES: +:CUSTOM_ID: library-contents +:END: +- See [[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/][JavaDoc]]. + +** String utilities ([[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/package-summary.html][eu.svjatoslav.commons.string]]) +:PROPERTIES: +:CUSTOM_ID: string-utilities +:END: + +The string package provides a mutable string builder optimized for +prefix and suffix operations, plus simple glob-style pattern matching. + +[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/String2.html][String2]] is a mutable string that stores characters in a list, enabling +efficient operations at both ends. It provides ~prepend()~ and ~append()~ +for adding text, ~trimPrefix()~ and ~trimSuffix()~ for removing characters, +~trimPrefixIfExists()~ and ~trimSuffixIfExists()~ for conditional removal, +~hasPrefix()~ and ~hasSuffix()~ for checking, ~repeat()~ for duplication, +and ~enforceLength()~ for padding or truncating to exact lengths. All +methods return the same instance for fluent chaining. + +[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/GlobMatcher.html][GlobMatcher]] matches strings against glob-style wildcard patterns using +~*~ (matches any sequence of characters, including empty) and ~?~ (matches +exactly one character). This is simpler than regular expressions and +useful for file name filtering, simple validation, or user-friendly +pattern input. + +** File system utilities ([[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/file/package-summary.html][eu.svjatoslav.commons.file]]) +:PROPERTIES: +:CUSTOM_ID: file-system-utilities +:END: + +The file package provides utilities for common file operations: reading +and writing files, parsing paths, and formatting file sizes. + +[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/file/IOHelper.html][IOHelper]] is the primary file I/O class. It reads and writes files as +byte arrays or UTF-8 strings, deletes files and directories +recursively (without following symbolic links, which prevents accidental +deletion of data outside the intended scope), and overwrites files only +when content actually differs, avoiding unnecessary disk writes and +preserving timestamps. + +[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/file/FilePathParser.html][FilePathParser]] extracts metadata from file paths: the file extension +(lowercase normalized), the file name without extension, and formats +file sizes using binary units (b, KiB, MiB, GiB, TiB, PiB) with +human-readable descriptions like "15 MiB". + +** Binary data utilities ([[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/data/package-summary.html][eu.svjatoslav.commons.data]]) +:PROPERTIES: +:CUSTOM_ID: binary-data-utilities +:END: + +The data package provides classes for working with binary data at the +bit level and converting it to human-readable formats. + +[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/data/BitInputStream.html][BitInputStream]] and [[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/data/BitOutputStream.html][BitOutputStream]] allow reading and writing +individual bits from streams, not just whole bytes. This is essential +for applications that work with bit-packed data formats where data is +not byte-aligned, such as custom compression algorithms, network +protocols, or binary file formats. Bits are processed from most +significant to least significant within each byte, and you can read or +write any number of bits (not just multiples of 8). + +[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/data/HexConverter.html][HexConverter]] converts byte arrays to uppercase hexadecimal strings. +Each byte becomes exactly two characters (0-9, A-F), making binary data +visible in logs, debug output, or text-based protocols. Null inputs +return null; empty arrays return empty strings. + +** Tokenizer ([[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/tokenizer/package-summary.html][eu.svjatoslav.commons.string.tokenizer]]) +:PROPERTIES: +:CUSTOM_ID: tokenizer +:END: + +The tokenizer package provides a regex-based tokenizer for parsing +structured text into tokens with lookahead and backtracking support. + +[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/tokenizer/Tokenizer.html][Tokenizer]] is the main class. You add [[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/tokenizer/Terminator.html][Terminator]] objects that define +token boundaries using regex patterns. Each terminator has a strategy: +~PRESERVE~ returns matched tokens for processing, ~DROP~ silently discards +them (useful for whitespace or comments). You can peek at the next token +without consuming it, unread tokens to backtrack, expect specific tokens +and throw exceptions on mismatch, and categorize tokens using group +names. + +[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/tokenizer/TokenizerMatch.html][TokenizerMatch]] is the result object containing the matched text, the +terminator that identified it, the regex matcher (for extracting capture +groups), and methods to check group membership. + +[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/tokenizer/InvalidSyntaxException.html][InvalidSyntaxException]] is thrown when expectations fail during parsing, +such as when expecting a specific token but finding something else. + +** Graphical dialogs ([[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/gui/dialog/package-summary.html][eu.svjatoslav.commons.gui.dialog]]) +:PROPERTIES: +:CUSTOM_ID: graphical-dialogs +:END: + +The dialog package provides Swing-based components for displaying +information to users in graphical applications. + +[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.html][ExceptionDialog]] displays exceptions with their full stack traces in a +windowed dialog. It shows the exception type, error message, cause (if +present), and complete stack trace, making it easy to debug errors in +GUI applications without requiring console output or log files. Note: +this requires a graphical environment and is not suitable for headless +or server-side applications. + +* Source code +:PROPERTIES: +:CUSTOM_ID: source-code +:ID: 978b7ea2-e246-45d0-be76-4d561308e9f3 +:END: + +*This program is free software: released under Creative Commons Zero +(CC0) license* + +*Program author:* +- Svjatoslav Agejenko +- Homepage: https://svjatoslav.eu +- Email: mailto:svjatoslav@svjatoslav.eu +- See also: [[https://www.svjatoslav.eu/projects/][Other software projects hosted at svjatoslav.eu]] + +*Getting the source code:* +- [[https://www2.svjatoslav.eu/gitweb/?p=svjatoslav_commons.git;a=snapshot;h=HEAD;sf=tgz][Download latest snapshot in TAR GZ format]] +- [[https://www2.svjatoslav.eu/gitweb/?p=svjatoslav_commons.git;a=summary][Browse Git repository online]] +- Clone Git repository using command: + : git clone https://www2.svjatoslav.eu/git/svjatoslav_commons.git + +** Building from source :gap: +:PROPERTIES: +:CUSTOM_ID: building-from-source +:ID: ceadc583-a9d8-435b-9ba8-c564d3b64ff4 +:END: + +The library builds with Maven on JDK 21 or newer (the compiler targets +Java 21). On Debian 13 install one of the packaged JDKs: + +: sudo apt install openjdk-21-jdk # or: openjdk-25-jdk + +Then clone and build: + +: git clone https://www2.svjatoslav.eu/git/svjatoslav_commons.git +: cd svjatoslav_commons +: mvn clean package + +This runs the unit tests and produces +=target/svjatoslavcommons-.jar= together with sources and +JavaDoc jars. =mvn clean install= additionally installs the library +into the local Maven repository (=~/.m2/repository=), making the +snapshot available to other projects on the same machine. diff --git a/Documentation/style.css b/Documentation/style.css new file mode 100644 index 0000000..3403e0e --- /dev/null +++ b/Documentation/style.css @@ -0,0 +1,35 @@ +.flex-center { + display: flex; + justify-content: center; +} + +.flex-center video { + width: min(90%, 1000px); + height: auto; +} + +.responsive-img { + width: min(100%, 1000px); + height: auto; +} + +/* === SVG diagram theme === */ +svg > rect:first-child { + fill: #061018; +} + +svg text[fill="#666"], +svg text[fill="#999"] { + fill: #aaa !important; +} + +svg line[stroke="#ccc"] { + stroke: #445566 !important; +} + +svg { + background-color: #061018; + border-radius: 8px; + display: block; + margin: 0 auto; +} \ No newline at end of file diff --git a/Tools/Update web site b/Tools/Update web site index 13594a3..7ee4b83 100755 --- a/Tools/Update web site +++ b/Tools/Update web site @@ -26,10 +26,10 @@ export_org_to_html() { } export_org_files_to_html() { - echo "🔍 Searching for .org files in doc/ ..." + echo "🔍 Searching for .org files in Documentation/ ..." echo "=======================================" - mapfile -t ORG_FILES < <(find doc -type f -name "*.org" | sort) + mapfile -t ORG_FILES < <(find Documentation -type f -name "*.org" | sort) if [ ${#ORG_FILES[@]} -eq 0 ]; then echo "❌ No .org files found!" @@ -64,15 +64,15 @@ export_org_files_to_html() { mvn clean package # Put generated JavaDoc HTML files to documentation directory -rm -rf doc/apidocs/ -cp -r target/apidocs/ doc/ +rm -rf Documentation/apidocs/ +cp -r target/apidocs/ Documentation/ # Publish Emacs org-mode files into HTML format export_org_files_to_html ## Upload assembled documentation to server echo "📤 Uploading to server..." -rsync -avz --delete -e 'ssh -p 10006' doc/ \ +rsync -avz --delete -e 'ssh -p 10006' Documentation/ \ n0@www3.svjatoslav.eu:/mnt/big/projects/svjatoslav_commons/ if [ $? -eq 0 ]; then diff --git a/doc/index.org b/doc/index.org deleted file mode 100644 index 733ab35..0000000 --- a/doc/index.org +++ /dev/null @@ -1,224 +0,0 @@ -#+SETUPFILE: ~/.emacs.d/org-styles/html/darksun.theme -#+TITLE: Svjatoslav Commons - Java library of commonly used functions -#+LANGUAGE: en -#+LATEX_HEADER: \usepackage[margin=1.0in]{geometry} -#+LATEX_HEADER: \usepackage{parskip} -#+LATEX_HEADER: \usepackage[none]{hyphenat} - -#+OPTIONS: H:20 num:20 -#+OPTIONS: author:nil - -#+begin_export html - -#+end_export - - -* Introduction - -Svjatoslav Commons is a shared Java utility library that consolidates -commonly needed functionality: reading and writing files, manipulating -strings, handling binary data, and displaying errors to users. - -The library requires Java 8 and has minimal dependencies: only JUnit -for testing and servlet-api (optional, provided scope). See [[#usage][How to -take library into use]] for Maven dependency configuration. The complete -API documentation is available in the [[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/][JavaDoc]]. - -* Library contents -:PROPERTIES: -:CUSTOM_ID: library-contents -:END: -- See [[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/][JavaDoc]]. - -** Binary data utilities ([[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/data/package-summary.html][eu.svjatoslav.commons.data]]) - -The data package provides classes for working with binary data at the -bit level and converting it to human-readable formats. - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/data/BitInputStream.html][BitInputStream]] and [[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/data/BitOutputStream.html][BitOutputStream]] allow reading and writing -individual bits from streams, not just whole bytes. This is essential -for applications that work with bit-packed data formats where data is -not byte-aligned, such as custom compression algorithms, network -protocols, or binary file formats. Bits are processed from most -significant to least significant within each byte, and you can read or -write any number of bits (not just multiples of 8). - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/data/HexConverter.html][HexConverter]] converts byte arrays to uppercase hexadecimal strings. -Each byte becomes exactly two characters (0-9, A-F), making binary data -visible in logs, debug output, or text-based protocols. Null inputs -return null; empty arrays return empty strings. - -** File system utilities ([[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/file/package-summary.html][eu.svjatoslav.commons.file]]) - -The file package provides utilities for common file operations: reading -and writing files, parsing paths, and resolving system directories. - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/file/IOHelper.html][IOHelper]] is the primary file I/O class. It reads and writes files as -byte arrays or UTF-8 strings, deletes files and directories -recursively (without following symbolic links, which prevents accidental -deletion of data outside the intended scope), and overwrites files only -when content actually differs, avoiding unnecessary disk writes and -preserving timestamps. - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/file/FilePathParser.html][FilePathParser]] extracts metadata from file paths: the file extension -(lowercase normalized), the file name without extension, and formats -file sizes using binary units (b, KiB, MiB, GiB, TiB, PiB) with -human-readable descriptions like "15 MiB". - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/file/CommonPathResolver.html][CommonPathResolver]] resolves common system paths. Currently it provides -the user's home directory, useful for storing application configuration -files or user-specific data. - -** Graphical dialogs ([[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/gui/dialog/package-summary.html][eu.svjatoslav.commons.gui.dialog]]) - -The dialog package provides Swing-based components for displaying -information to users in graphical applications. - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/gui/dialog/ExceptionDialog.html][ExceptionDialog]] displays exceptions with their full stack traces in a -windowed dialog. It shows the exception type, error message, cause (if -present), and complete stack trace, making it easy to debug errors in -GUI applications without requiring console output or log files. Note: -this requires a graphical environment and is not suitable for headless -or server-side applications. - -** String utilities ([[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/package-summary.html][eu.svjatoslav.commons.string]]) - -The string package provides a mutable string builder optimized for -prefix and suffix operations, plus simple glob-style pattern matching. - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/String2.html][String2]] is a mutable string that stores characters in a list, enabling -efficient operations at both ends. It provides ~prepend()~ and ~append()~ -for adding text, ~trimPrefix()~ and ~trimSuffix()~ for removing characters, -~trimPrefixIfExists()~ and ~trimSuffixIfExists()~ for conditional removal, -~hasPrefix()~ and ~hasSuffix()~ for checking, ~repeat()~ for duplication, -and ~enforceLength()~ for padding or truncating to exact lengths. All -methods return the same instance for fluent chaining. - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/GlobMatcher.html][GlobMatcher]] matches strings against glob-style wildcard patterns using -~*~ (matches any sequence of characters, including empty) and ~?~ (matches -exactly one character). This is simpler than regular expressions and -useful for file name filtering, simple validation, or user-friendly -pattern input. - -** Tokenizer ([[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/tokenizer/package-summary.html][eu.svjatoslav.commons.string.tokenizer]]) - -The tokenizer package provides a regex-based tokenizer for parsing -structured text into tokens with lookahead and backtracking support. - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/tokenizer/Tokenizer.html][Tokenizer]] is the main class. You add [[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/tokenizer/Terminator.html][Terminator]] objects that define -token boundaries using regex patterns. Each terminator has a strategy: -~PRESERVE~ returns matched tokens for processing, ~DROP~ silently discards -them (useful for whitespace or comments). You can peek at the next token -without consuming it, unread tokens to backtrack, expect specific tokens -and throw exceptions on mismatch, and categorize tokens using group -names. - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/tokenizer/TokenizerMatch.html][TokenizerMatch]] is the result object containing the matched text, the -terminator that identified it, the regex matcher (for extracting capture -groups), and methods to check group membership. - -[[https://www3.svjatoslav.eu/projects/svjatoslav_commons/apidocs/eu/svjatoslav/commons/string/tokenizer/InvalidSyntaxException.html][InvalidSyntaxException]] is thrown when expectations fail during parsing, -such as when expecting a specific token but finding something else. - -* How to take library into use -:PROPERTIES: -:CUSTOM_ID: usage -:END: - -Add the *svjatoslavcommons* dependency to your Maven project: - -#+BEGIN_SRC xml - - - eu.svjatoslav - svjatoslavcommons - 1.9 - - -#+END_SRC - -Also add the repository (the library is not on Maven Central): - -#+BEGIN_SRC xml - - - svjatoslav.eu - Svjatoslav repository - https://www3.svjatoslav.eu/maven/ - - -#+END_SRC - -* Source code -:PROPERTIES: -:CUSTOM_ID: source-code -:ID: 978b7ea2-e246-45d0-be76-4d561308e9f3 -:END: - -*This program is free software: released under Creative Commons Zero -(CC0) license* - -*Program author:* -- Svjatoslav Agejenko -- Homepage: https://svjatoslav.eu -- Email: mailto://svjatoslav@svjatoslav.eu -- See also: [[https://www.svjatoslav.eu/projects/][Other software projects hosted at svjatoslav.eu]] - -*Getting the source code:* -- [[https://www2.svjatoslav.eu/gitweb/?p=svjatoslav_commons.git;a=snapshot;h=HEAD;sf=tgz][Download latest snapshot in TAR GZ format]] -- [[https://www2.svjatoslav.eu/gitweb/?p=svjatoslav_commons.git;a=summary][Browse Git repository online]] -- Clone Git repository using command: - : git clone https://www2.svjatoslav.eu/git/svjatoslav_commons.git diff --git a/pom.xml b/pom.xml index ef82e33..abef677 100644 --- a/pom.xml +++ b/pom.xml @@ -25,8 +25,8 @@ maven-compiler-plugin 3.8.1 - 8 - 8 + 21 + 21 UTF-8 @@ -102,13 +102,6 @@ 4.8.1 test - - - javax.servlet - servlet-api - 2.5 - provided - diff --git a/src/main/java/eu/svjatoslav/commons/file/CommonPathResolver.java b/src/main/java/eu/svjatoslav/commons/file/CommonPathResolver.java deleted file mode 100755 index 0695c16..0000000 --- a/src/main/java/eu/svjatoslav/commons/file/CommonPathResolver.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Svjatoslav Commons - shared library of common functionality. Author: Svjatoslav Agejenko. - * This project is released under Creative Commons Zero (CC0) license. - */ -package eu.svjatoslav.commons.file; - -import java.io.File; - -/** - * Resolves common system paths and directories. - * - *

This utility class provides static methods to obtain common file system - * paths that are frequently needed in applications, such as the user's home - * directory, configuration directories, or temporary directories.

- * - *

Currently provides:

- *
    - *
  • User home directory - the personal directory of the current user
  • - *
- * - *

Example usage:

- *
{@code
- * File homeDir = CommonPathResolver.getHomeDirectory();
- * File configFile = new File(homeDir, ".myapp/config.properties");
- * }
- * - *

This class is designed to be extended with additional common path - * resolution methods as needed.

- * - */ -public class CommonPathResolver { - - /** - * Private constructor to prevent instantiation. - * - *

This is a utility class with only static methods. It does not need - * to be instantiated.

- */ - private CommonPathResolver() {} - - /** - * Returns the current user's home directory. - * - *

This is typically the personal directory of the logged-in user, - * such as:

- *
    - *
  • On Linux/Mac: "/home/username" or "/Users/username"
  • -*
  • On Windows: "C:\\Users\\username"
  • - *
- * - *

This is a convenient location for storing user-specific configuration - * files, documents, and application data.

- * - *

Example usage:

- *
{@code
-     * File home = CommonPathResolver.getHomeDirectory();
-     * System.out.println("Home directory: " + home.getAbsolutePath());
-     *
-     * // Create an application config directory
-     * File configDir = new File(home, ".myapp");
-     * configDir.mkdirs();
-     * }
- * - * @return a File object representing the user's home directory. - * The directory typically exists and is readable/writable - * by the current user. - */ - public static File getHomeDirectory() { - return new File(System.getProperty("user.home")); - } - -} \ No newline at end of file diff --git a/src/main/java/eu/svjatoslav/commons/file/package-info.java b/src/main/java/eu/svjatoslav/commons/file/package-info.java index d830d3a..6897c99 100644 --- a/src/main/java/eu/svjatoslav/commons/file/package-info.java +++ b/src/main/java/eu/svjatoslav/commons/file/package-info.java @@ -13,8 +13,6 @@ * reading/writing files, and smart file overwriting *
  • {@link eu.svjatoslav.commons.file.FilePathParser} - Parse file paths to extract extensions, * file names, and format file sizes
  • - *
  • {@link eu.svjatoslav.commons.file.CommonPathResolver} - Resolve common system paths - * such as user home directory
  • * * *

    These utilities simplify common file operations that would otherwise require @@ -25,6 +23,5 @@ * @since 1.0 * @see eu.svjatoslav.commons.file.IOHelper * @see eu.svjatoslav.commons.file.FilePathParser - * @see eu.svjatoslav.commons.file.CommonPathResolver */ package eu.svjatoslav.commons.file; \ No newline at end of file