Class TextUtils
java.lang.Object
uno.anahata.asi.internal.TextUtils
A collection of general-purpose text and formatting utility methods.
- Author:
- anahata
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatBase64(byte[] data) Encodes a byte array to a Base64 string and truncates it for display.static StringformatByteArray(byte[] data) Formats a byte array into a concise string representation, showing the first and last three bytes in 0-255 format and truncating the middle.static StringformatSize(long size) Formats a byte size into a human-readable string (e.g., "1.2 KB", "5.5 MB").static StringformatValue(Object value) Formats a value for display in a summary, escaping newlines and truncating in the middle if necessary.static StringGets a unique identifier for the current device (hostname).static StringgetJvmId()Gets a unique identifier for the current JVM instance, including the PID and hostname.static StringGets the name of the current user.static booleanisNullOrEmpty(Object value) Checks if an object is null, a blank string, or an empty collection/map.static StringresolveContentString(Object value) Intelligently resolves the pure Java representation for a value.
-
Constructor Details
-
TextUtils
public TextUtils()
-
-
Method Details
-
formatSize
Formats a byte size into a human-readable string (e.g., "1.2 KB", "5.5 MB").- Parameters:
size- The size in bytes.- Returns:
- The formatted string.
-
isNullOrEmpty
Checks if an object is null, a blank string, or an empty collection/map.- Parameters:
value- The object to check.- Returns:
- true if the object is considered null or empty.
-
formatValue
-
resolveContentString
Intelligently resolves the pure Java representation for a value.Technical Purity: This method bypasses JSON serialization entirely. Collections are joined with newlines for clean multi-line display, while arrays leverage a professional bracketed comma-separated format using reflection.
- Parameters:
value- The object to represent.- Returns:
- The raw Java string representation.
-
formatByteArray
Formats a byte array into a concise string representation, showing the first and last three bytes in 0-255 format and truncating the middle.- Parameters:
data- The byte array to format.- Returns:
- A formatted string (e.g., "[12, 34, 56 ... 78, 90, 12]").
-
formatBase64
Encodes a byte array to a Base64 string and truncates it for display.- Parameters:
data- The byte array.- Returns:
- A truncated Base64 string.
-
getDeviceId
Gets a unique identifier for the current device (hostname).- Returns:
- The hostname, or "unknown-device" if it cannot be determined.
-
getJvmId
Gets a unique identifier for the current JVM instance, including the PID and hostname.- Returns:
- The JVM ID in the format "pid@hostname".
-
getUserName
-

