Skip to content

Commit 18eebd3

Browse files
committed
Fixed Logger bug
1 parent e06a529 commit 18eebd3

4 files changed

Lines changed: 83 additions & 7 deletions

File tree

src/main/java/io/github/intisy/utils/custom/Database.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.intisy.utils.custom;
22

3-
import com.github.WildePizza.EmptyLogger;
4-
import com.github.WildePizza.SimpleLogger;
3+
import io.github.intisy.simple.logger.EmptyLogger;
4+
import io.github.intisy.simple.logger.SimpleLogger;
55

66
import java.sql.*;
77
import java.util.ArrayList;

src/main/java/io/github/intisy/utils/utils/BufferUtils.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
@SuppressWarnings("unused")
66
public class BufferUtils {
7+
/**
8+
* Prints the content of the given ShortBuffer.
9+
*
10+
* @param buffer The ShortBuffer to be printed.
11+
*/
712
public static void printBuffer(ShortBuffer buffer) {
813
System.out.print("Buffer content: ");
914
while (buffer.hasRemaining()) {
@@ -12,6 +17,14 @@ public static void printBuffer(ShortBuffer buffer) {
1217
System.out.println();
1318
buffer.flip();
1419
}
20+
21+
/**
22+
* Finds the middle value between two ShortBuffers and returns a new ShortBuffer containing these middle values.
23+
*
24+
* @param buffer1 The first ShortBuffer.
25+
* @param buffer2 The second ShortBuffer.
26+
* @return A new ShortBuffer containing the middle values.
27+
*/
1528
public static ShortBuffer findMiddleValue(ShortBuffer buffer1, ShortBuffer buffer2) {
1629
// Calculate the number of elements to be written to the middle buffer
1730
int writeCount = Math.min(buffer1.remaining(), buffer2.remaining());
@@ -34,6 +47,14 @@ public static ShortBuffer findMiddleValue(ShortBuffer buffer1, ShortBuffer buffe
3447
buffer2.flip(); // Prepare the buffer for reading
3548
return middleBuffer;
3649
}
50+
51+
/**
52+
* Combines two ShortBuffers into a new one, where each element is the sum of the corresponding elements in the input buffers.
53+
*
54+
* @param buffer1 The first ShortBuffer.
55+
* @param buffer2 The second ShortBuffer.
56+
* @return A new ShortBuffer containing the combined values.
57+
*/
3758
public static ShortBuffer combineValue(ShortBuffer buffer1, ShortBuffer buffer2) {
3859
int combinedSize = buffer1.remaining() + buffer2.remaining();
3960
ShortBuffer combinedBuffer = ShortBuffer.allocate(combinedSize);
@@ -57,6 +78,14 @@ public static ShortBuffer combineValue(ShortBuffer buffer1, ShortBuffer buffer2)
5778
combinedBuffer.flip(); // Prepare the buffer for reading
5879
return combinedBuffer;
5980
}
81+
82+
/**
83+
* Divides each element in the given ShortBuffer by a factor and returns a new ShortBuffer containing the result.
84+
*
85+
* @param buffer The ShortBuffer to be divided.
86+
* @param factor The factor by which each element will be divided.
87+
* @return A new ShortBuffer containing the divided values.
88+
*/
6089
public static ShortBuffer divideBuffer(ShortBuffer buffer, double factor) {
6190
int writeCount = buffer.remaining();
6291
ShortBuffer middleBuffer = ShortBuffer.allocate(writeCount);
@@ -67,6 +96,15 @@ public static ShortBuffer divideBuffer(ShortBuffer buffer, double factor) {
6796
middleBuffer.flip(); // Prepare the buffer for reading
6897
return middleBuffer;
6998
}
99+
100+
/**
101+
* Multiplies each element in the given ShortBuffer by a factor and returns a new ShortBuffer containing the result.
102+
* The result is clamped to the range of a short value.
103+
*
104+
* @param buffer The ShortBuffer to be multiplied.
105+
* @param factor The factor by which each element will be multiplied.
106+
* @return A new ShortBuffer containing the multiplied values.
107+
*/
70108
public static ShortBuffer multiplyBuffer(ShortBuffer buffer, double factor) {
71109
int writeCount = buffer.remaining();
72110
ShortBuffer middleBuffer = ShortBuffer.allocate(writeCount);

src/main/java/io/github/intisy/utils/utils/ClipboardUtils.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,20 @@
55
import java.awt.datatransfer.StringSelection;
66

77
public class ClipboardUtils {
8-
public static void copyToClipboard(String text) {
9-
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
10-
StringSelection selection = new StringSelection(text);
11-
clipboard.setContents(selection, null);
12-
}
8+
/**
9+
* Copies the given text to the system clipboard.
10+
*
11+
* @param text The text to be copied to the clipboard.
12+
*
13+
* @throws SecurityException If a security manager exists and its
14+
* {@code checkPermission} method doesn't allow
15+
* {@code AWTPermission("accessClipboard")} to be granted.
16+
* @throws IllegalStateException If the system clipboard is unavailable.
17+
* @throws NullPointerException If the given text is {@code null}.
18+
*/
19+
public static void copyToClipboard(String text) {
20+
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
21+
StringSelection selection = new StringSelection(text);
22+
clipboard.setContents(selection, null);
23+
}
1324
}

src/main/java/io/github/intisy/utils/utils/ConnectionUtils.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@
55
import java.io.InputStreamReader;
66
import java.net.HttpURLConnection;
77

8+
/**
9+
* This class provides utility methods for handling HTTP connections.
10+
*/
811
public class ConnectionUtils {
12+
13+
/**
14+
* Generates a curl command based on the provided HTTP connection, token, and payload.
15+
*
16+
* @param connection The HTTP connection to be used.
17+
* @param token The authorization token to be included in the curl command. If null, no token will be included.
18+
* @param payload The payload to be sent in the curl command.
19+
* @return A curl command as a string.
20+
*/
921
public static String curl(HttpURLConnection connection, String token, String payload) {
1022
StringBuilder curl = new StringBuilder();
1123
if (token != null)
@@ -17,6 +29,14 @@ public static String curl(HttpURLConnection connection, String token, String pay
1729
System.out.println(connection.getRequestProperties());
1830
return curl.toString();
1931
}
32+
33+
/**
34+
* Retrieves the output from the error stream of the provided HTTP connection.
35+
*
36+
* @param connection The HTTP connection to be used.
37+
* @return The output from the error stream as a string.
38+
* @throws IOException If an I/O error occurs while reading from the error stream.
39+
*/
2040
public static String getOutput(HttpURLConnection connection) throws IOException {
2141
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
2242
StringBuilder response = new StringBuilder();
@@ -27,6 +47,13 @@ public static String getOutput(HttpURLConnection connection) throws IOException
2747
br.close();
2848
return response.toString();
2949
}
50+
51+
/**
52+
* Prints the output from the error stream of the provided HTTP connection.
53+
*
54+
* @param connection The HTTP connection to be used.
55+
* @throws IOException If an I/O error occurs while reading from the error stream.
56+
*/
3057
public static void printOutput(HttpURLConnection connection) throws IOException {
3158
System.out.println(getOutput(connection));
3259
}

0 commit comments

Comments
 (0)