Skip to content

Commit 26aa37d

Browse files
committed
update gradle and dependencies, add javadoc to all places with warnings about javadoc not included
1 parent 7875a35 commit 26aa37d

34 files changed

+926
-40
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
extra["gradle"] = "8.13"
2+
extra["gradle"] = "8.14.3"
33
extra["javaVersion"] = JavaVersion.VERSION_11
44
}
55

@@ -32,7 +32,7 @@ dokka {
3232
remoteUrl(project.properties["POM_URL"].toString())
3333
}
3434
perPackageOption {
35-
matchingRegex.set(".*utils.*") // will match all utils packages and sub-packages and skip javadoc for them
35+
matchingRegex.set(".*utils.*") // will match all utils packages and sub-packages and skip Javadoc for them
3636
suppress.set(true)
3737
}
3838
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
22
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
33

44
GROUP=com.pnuema.java
5-
VERSION_NAME=2.7.4
5+
VERSION_NAME=2.8.0
66
POM_ARTIFACT_ID=barcode
77

88
POM_NAME=Barcode-Java

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
vanniktech-maven-publish = "0.30.0"
2+
vanniktech-maven-publish = "0.33.0"
33
junit = "4.13.2"
44
gradleCacheFix = "3.0.1"
55
dokka = "2.0.0"

local.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# Location of the SDK. This is only used by Gradle.
55
# For customization when using a Version Control System, please read the
66
# header note.
7-
#Tue Oct 17 23:18:39 CDT 2023
8-
sdk.dir=C\:\\Users\\bradb\\AppData\\Local\\Android\\Sdk
7+
#Wed Jul 09 21:09:35 CDT 2025
8+
sdk.dir=/Users/b359923/Library/Android/sdk

settings.gradle.kts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
@file:Suppress("UnstableApiUsage")
22

3+
import java.io.IOException
4+
import java.net.Socket
5+
6+
37
pluginManagement {
48
repositories {
59
gradlePluginPortal()
@@ -9,7 +13,7 @@ pluginManagement {
913
}
1014

1115
plugins {
12-
id("com.gradle.develocity") version "3.19.2"
16+
id("com.gradle.develocity") version "4.0.2"
1317
}
1418

1519
dependencyResolutionManagement {
@@ -33,26 +37,45 @@ val cacheUrl: String? = if (System.getenv("REMOTE_CACHE_URL") == null) remoteCac
3337

3438
if (cacheUrl != null) {
3539
buildCache {
40+
local {
41+
isEnabled = true
42+
}
3643
remote<HttpBuildCache> {
3744
url = uri(cacheUrl)
38-
isEnabled = true
45+
isEnabled = isOnline()
3946
isPush = true
4047
isAllowUntrustedServer = true
4148
isAllowInsecureProtocol = false
4249
if (isEnabled) {
4350
println("Using remote build cache: $cacheUrl")
51+
} else {
52+
println("Not using remote build cache!")
4453
}
4554

4655
val remoteCacheUser: String? by extra
4756
val remoteCachePass: String? by extra
4857
credentials {
49-
username = if (System.getenv("REMOTE_CACHE_USER") == null) remoteCacheUser else System.getenv("REMOTE_CACHE_USER")
50-
password = if (System.getenv("REMOTE_CACHE_PASS") == null) remoteCachePass else System.getenv("REMOTE_CACHE_PASS")
58+
username = if (System.getenv("REMOTE_CACHE_USER") == null) remoteCacheUser as String else System.getenv("REMOTE_CACHE_USER")
59+
password = if (System.getenv("REMOTE_CACHE_PASS") == null) remoteCachePass as String else System.getenv("REMOTE_CACHE_PASS")
5160
}
5261
}
5362
}
5463
} else {
5564
println("Not using remote build cache!")
5665
}
5766

67+
private fun isOnline(): Boolean {
68+
try {
69+
// Attempt to create a socket connection to a well-known server (e.g., Cloudflare DNS)
70+
// This is a common way to check for basic internet connectivity.
71+
// Adjust the host and port as needed for your network environment.
72+
Socket("1.1.1.1", 53).close()
73+
println("Internet connection test passed")
74+
return true
75+
} catch (_: IOException) {
76+
println("Internet connection test failed, offline mode")
77+
return false
78+
}
79+
}
80+
5881
rootProject.name = "barcode"

src/main/java/com/pnuema/java/barcode/Barcode.java

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,81 @@
1818
*/
1919
@SuppressWarnings({"WeakerAccess", "unused", "DuplicatedCode"})
2020
public class Barcode {
21+
/**
22+
* Represents the types of file formats that can be used for saving files.
23+
* This enumeration includes common image file formats as well as an unspecified option.
24+
* Enum Constants:
25+
* - JPG: Represents the JPEG image format.
26+
* - BMP: Represents the BMP (Bitmap) image format.
27+
* - PNG: Represents the PNG (Portable Network Graphics) image format.
28+
* - GIF: Represents the GIF (Graphics Interchange Format) image format.
29+
* - TIFF: Represents the TIFF (Tagged Image File Format) image format.
30+
* - UNSPECIFIED: Represents an undefined or unspecified file format.
31+
*/
32+
public enum SaveTypes {
33+
/**
34+
* Represents the JPEG image file format.
35+
* Commonly used for storing and compressing digital images, particularly for photographs.
36+
*/
37+
JPG,
38+
/**
39+
* Represents the BMP (Bitmap) image file format.
40+
* BMP is a raster graphics image file format used to store bitmap digital images.
41+
* It is commonly utilized for simple and uncompressed images.
42+
*/
43+
BMP,
44+
/**
45+
* Represents the PNG (Portable Network Graphics) image file format.
46+
* PNG is a raster-graphics file format that supports lossless data compression.
47+
* It is widely used for high-quality images with support for transparency.
48+
*/
49+
PNG,
50+
/**
51+
* Represents the GIF (Graphics Interchange Format) image file format.
52+
* GIF is widely used for animated images and simple graphics with limited color palettes.
53+
*/
54+
GIF,
55+
/**
56+
* Represents the TIFF (Tagged Image File Format) image file format.
57+
* TIFF is a flexible and adaptable file format used for storing high-quality raster graphics and images.
58+
* It is commonly used in applications requiring detailed image data, such as desktop publishing and professional photography.
59+
*/
60+
TIFF,
61+
/**
62+
* Represents an undefined or unspecified file format.
63+
* This constant is used when no specific file format is selected or applicable.
64+
*/
65+
UNSPECIFIED
66+
}
2167

22-
public enum SaveTypes {JPG, BMP, PNG, GIF, TIFF, UNSPECIFIED}
23-
24-
public enum AlignmentPositions {CENTER, LEFT, RIGHT}
68+
/**
69+
* The AlignmentPositions enum represents the alignment positions
70+
* that can be used to specify the layout or positioning of elements.
71+
* It defines the following constants:
72+
* - CENTER: Represents a centered alignment.
73+
* - LEFT: Represents a left-aligned position.
74+
* - RIGHT: Represents a right-aligned position.
75+
*/
76+
public enum AlignmentPositions {
77+
/**
78+
* Represents a centered alignment position.
79+
* Typically used to specify that an element should be positioned
80+
* or aligned at the center within its container or layout.
81+
*/
82+
CENTER,
83+
/**
84+
* Represents a left-aligned position.
85+
* Typically used to specify that an element should be positioned
86+
* or aligned to the left within its container or layout.
87+
*/
88+
LEFT,
89+
/**
90+
* Represents a right-aligned position.
91+
* Typically used to specify that an element should be positioned
92+
* or aligned to the right within its container or layout.
93+
*/
94+
RIGHT
95+
}
2596

2697
private IBarcode ibarcode;
2798
private String rawData = "";

src/main/java/com/pnuema/java/barcode/BarcodeCommon.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,83 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6+
/**
7+
* Abstract base class for barcode generation.
8+
* Provides common properties and methods used across various barcode symbologies.
9+
* This class handles the validation of raw data, storage of errors, and provides
10+
* utility methods to facilitate encoding processes.
11+
*/
612
public abstract class BarcodeCommon implements IBarcode {
713
private String rawData = "";
814
private final List<String> errors = new ArrayList<>();
915

16+
/**
17+
* Default constructor for the BarcodeCommon class.
18+
* Initializes a BarcodeCommon instance, providing base functionality
19+
* for barcode generation. This constructor is protected, as it is intended
20+
* to be used only within the context of subclassing or instantiation of
21+
* derived barcode classes.
22+
*/
23+
public BarcodeCommon() {
24+
}
25+
1026
public abstract String getEncodedValue() throws BarcodeException;
1127

28+
/**
29+
* Sets the raw data to be used by the barcode instance.
30+
* This method updates the internal raw data field with the given input.
31+
*
32+
* @param rawData the raw data string to set for the barcode instance
33+
*/
1234
protected void setRawData(String rawData) {
1335
this.rawData = rawData;
1436
}
1537

38+
/**
39+
* Retrieves the raw data stored in the barcode instance.
40+
*
41+
* @return the raw data as a string
42+
*/
1643
public String getRawData() {
1744
return rawData;
1845
}
1946

47+
/**
48+
* Retrieves the list of currently stored error messages.
49+
*
50+
* @return a list of error messages encountered during processing
51+
*/
2052
@SuppressWarnings("WeakerAccess")
2153
public List<String> getErrors() {
2254
return errors;
2355
}
2456

57+
/**
58+
* Clears all error messages from the internal error list.
59+
* This method is used to reset the error state, removing
60+
* any previously stored error messages.
61+
*/
2562
public void clearErrors() {
2663
errors.clear();
2764
}
2865

66+
/**
67+
* Adds an error message to the error list and throws a {@code BarcodeException} with the specified message.
68+
*
69+
* @param ErrorMessage the error message to add and propagate as an exception
70+
* @throws BarcodeException if an error occurs in barcode processing
71+
*/
2972
protected void error(String ErrorMessage) throws BarcodeException {
3073
errors.add(ErrorMessage);
3174
throw new BarcodeException(ErrorMessage);
3275
}
3376

77+
/**
78+
* Validates whether the input string contains only numeric characters.
79+
*
80+
* @param data the string to be checked for numeric content
81+
* @return {@code true} if the input string consists solely of digits (0-9); {@code false} otherwise
82+
*/
3483
protected static boolean checkNumericOnly(String data) {
3584
return data.matches("^\\d+$");
3685
}

src/main/java/com/pnuema/java/barcode/BarcodeException.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
package com.pnuema.java.barcode;
22

3+
/**
4+
* Represents an exception thrown when an error related to barcode processing occurs.
5+
* This exception extends the {@code RuntimeException}, allowing it to be used for
6+
* unchecked exceptions.
7+
* The {@code BarcodeException} can be instantiated with a specific error message
8+
* to provide details about the cause of the exception.
9+
*/
310
public class BarcodeException extends RuntimeException {
11+
/**
12+
* Constructs a new {@code BarcodeException} with the specified error message.
13+
*
14+
* @param errorMessage the detail message explaining the reason for the exception
15+
*/
416
public BarcodeException(String errorMessage) {
517
super(errorMessage);
618
}

0 commit comments

Comments
 (0)