Package io.aether.utils
Class RU
- java.lang.Object
-
- io.aether.utils.RU
-
public class RU extends java.lang.ObjectUtility class containing static methods for common operations such as JSON serialization, URI parsing, byte conversion, and scheduling tasks. This class does not contain instance fields or constructors.
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.concurrent.ExecutorEMPTY_EXECUTORstatic java.util.RandomRNDstatic java.security.SecureRandomSECURE_RANDOM
-
Constructor Summary
Constructors Constructor Description RU()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intavailableProcessors()static longbytesToLong(byte[] bytes, int offset)static longbytesToLongLittleEndian(byte[] bytes, int offset)static <T> Tcast(java.lang.Object t)static <T extends java.lang.Enum<T>>
java.lang.Class<java.lang.Enum<T>>castEnum(java.lang.Class<?> raw)static intceilDiv(int x, int y)static <T> T[]concatArrays(T[] v, T[] vv)static <T> T[]concatArrays(T v, T[] vv)static voidconcatStackTrace(java.lang.StackTraceElement[] st, java.lang.Throwable e)static int[]convertBytesToIntArray(byte[] bytes)static short[]convertBytesToShortArray(byte[] bytes)static byte[]convertIntToByteArray(int[] data)static byte[]convertShortToByteArray(int data)static byte[]convertShortToByteArray(short data)static byte[]convertShortToByteArray(short[] data)static java.util.concurrent.ExecutordebugExecutor(java.util.concurrent.Executor executor)static voidencodeBase64(byte[] d, int len, it.unimi.dsi.fastutil.chars.CharConsumer rs)Encodes a byte array to Base64 using the specified length and character consumer.static voidencodeBase64(byte[] d, int len, java.lang.StringBuilder rs)Encodes a byte array to Base64 using the specified length and StringBuilder.static voidencodeBase64(byte[] d, it.unimi.dsi.fastutil.chars.CharConsumer rs)Encodes a byte array to Base64 using the specified character consumer.static voidencodeBase64(byte[] d, java.lang.StringBuilder rs)Encodes a byte array to Base64 using the specified StringBuilder.static <T> Terror(java.lang.StackTraceElement[] st, java.lang.Throwable e)static <T,E extends java.lang.Throwable>
Terror(java.lang.Throwable e)static <T> TerrorUnsupported()static java.lang.Stringescape(java.lang.String s)static java.lang.Stringescape(java.lang.String chars, java.lang.String s)static voidexecuteShell(java.lang.String s)static voidexecuteShellBash(java.lang.String cmd)static voidexecuteShellBashSudo(java.lang.String password, java.lang.String cmd)static java.lang.StackTraceElement[]filterFrontAndBackStackTrace(java.lang.StackTraceElement[] ss, java.lang.Class<?>... skipClasses)static <T extends java.lang.Throwable>
TfilterFrontAndBackStackTrace(T e, java.lang.Class<?>... skipClasses)static java.lang.StackTraceElement[]filterStackTraceBack(java.lang.StackTraceElement[] ss, java.lang.Class<?>... skipClasses)static Flow<java.io.File>getAllPaths()static doublegetNetLoading()static intgetSystemLoading()static java.io.FilehomeDir()static booleanisDeclaredInClass(java.lang.reflect.Field f, java.lang.Class<?> rootClass)static voidloadLibrary(java.lang.String libraryName)static <S,T>
T[]mapArray(S[] src, java.lang.Class<T> targetType, AFunction<S,T> mapper)static longnewContextId()static CTypeI<java.lang.Object>parseType(java.lang.String s)static CTypeI<java.lang.Object>parseType(java.lang.String s, int[] i)static java.net.URIparseURI(java.lang.String s)Parses a string into a URI.static voidprintStackTrace()static <T> voidreadAll(java.util.Queue<T> q, AConsumer<T> o)static <T> T[]removeElement(T[] a, int i)static CTypeI<java.lang.Object>resolveExtend(CTypeI<?> parent, CTypeI<?> owner)static voidrunAll(java.util.Queue<ARunnable> q)static java.util.concurrent.ScheduledFuture<?>schedule(long periodMs, ARunnable t)Schedules a task to run periodically with the specified period.static java.util.concurrent.ScheduledFuture<?>scheduleAtFixedRate(long period, ARunnable t)static java.util.concurrent.ScheduledFuture<?>scheduleAtFixedRate(long period, java.util.concurrent.TimeUnit timeUnit, ARunnable t)static java.util.concurrent.ScheduledFuture<?>scheduleAtFixedRate(Destroyer resTo, long period, java.util.concurrent.TimeUnit timeUnit, ARunnable t)static java.util.concurrent.ScheduledFuture<?>scheduleAtFixedRate(Destroyer resTo, java.util.concurrent.Executor executor, int durationSeconds, ARunnable task)static java.util.concurrent.ScheduledFuture<?>scheduleAtFixedRate(java.util.concurrent.Executor executor, int durationSeconds, ARunnable t)static java.io.FileselfExecuteCmdJar()static java.lang.StringselfExecuteCmdWithoutArgs()static byte[]sha1(byte[] input)static intsizeOf(java.lang.reflect.Parameter p)static voidsleep(long ms)static java.lang.String[]splitWithQuotes(java.lang.String s)static booleanstartWith(byte[] src, int... vals)Checks if a byte array starts with specified values.static java.io.FiletempFile()static longtime()static voidtoJson(AString s, java.lang.Object val)Converts an object to a JSON string, appending the result to the provided AString.static AStringtoJson(java.lang.Object val)Converts an object to a JSON string.static java.lang.CharSequenceunescape(java.lang.CharSequence s)static java.lang.invoke.MethodHandleunreflect(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.reflect.Method method)static java.lang.invoke.VarHandleunreflect(java.lang.reflect.Field f)static <T> intupdateMax(T owner, java.util.concurrent.atomic.AtomicIntegerFieldUpdater<T> updater, int value)static <T> longupdateMax(T owner, java.util.concurrent.atomic.AtomicLongFieldUpdater<T> updater, long value)static <T> intupdateMin(T owner, java.util.concurrent.atomic.AtomicIntegerFieldUpdater<T> updater, int value)static java.io.FileworkDir()
-
-
-
Method Detail
-
loadLibrary
public static void loadLibrary(java.lang.String libraryName)
-
toJson
public static AString toJson(java.lang.Object val)
Converts an object to a JSON string.- Parameters:
val- The object to convert- Returns:
- A JSON string representation of the object
-
sha1
public static byte[] sha1(byte[] input)
-
toJson
public static void toJson(AString s, java.lang.Object val)
Converts an object to a JSON string, appending the result to the provided AString.- Parameters:
s- The AString to append the result toval- The object to convert
-
parseURI
public static java.net.URI parseURI(java.lang.String s) throws java.net.URISyntaxExceptionParses a string into a URI.- Parameters:
s- The string to parse- Returns:
- A URI object
- Throws:
java.net.URISyntaxException- If the string is not a valid URI
-
startWith
public static boolean startWith(byte[] src, int... vals)Checks if a byte array starts with specified values.- Parameters:
src- The byte array to checkvals- The expected values- Returns:
- true if the array starts with the values, false otherwise
-
encodeBase64
public static void encodeBase64(byte[] d, it.unimi.dsi.fastutil.chars.CharConsumer rs) throws java.lang.IllegalArgumentExceptionEncodes a byte array to Base64 using the specified character consumer.- Parameters:
d- The byte array to encoders- The character consumer to store the result- Throws:
java.lang.IllegalArgumentException- If the input is invalid
-
encodeBase64
public static void encodeBase64(byte[] d, int len, it.unimi.dsi.fastutil.chars.CharConsumer rs) throws java.lang.IllegalArgumentExceptionEncodes a byte array to Base64 using the specified length and character consumer.- Parameters:
d- The byte array to encodelen- The number of bytes to encoders- The character consumer to store the result- Throws:
java.lang.IllegalArgumentException- If the input is invalid
-
encodeBase64
public static void encodeBase64(byte[] d, java.lang.StringBuilder rs) throws java.lang.IllegalArgumentExceptionEncodes a byte array to Base64 using the specified StringBuilder.- Parameters:
d- The byte array to encoders- The StringBuilder to store the result- Throws:
java.lang.IllegalArgumentException- If the input is invalid
-
encodeBase64
public static void encodeBase64(byte[] d, int len, java.lang.StringBuilder rs) throws java.lang.IllegalArgumentExceptionEncodes a byte array to Base64 using the specified length and StringBuilder.- Parameters:
d- The byte array to encodelen- The number of bytes to encoders- The StringBuilder to store the result- Throws:
java.lang.IllegalArgumentException- If the input is invalid
-
schedule
public static java.util.concurrent.ScheduledFuture<?> schedule(long periodMs, ARunnable t)Schedules a task to run periodically with the specified period.- Parameters:
periodMs- The period in millisecondst- The task to schedule- Returns:
- A ScheduledFuture representing the scheduled task
-
scheduleAtFixedRate
public static java.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(Destroyer resTo, java.util.concurrent.Executor executor, int durationSeconds, ARunnable task)
-
scheduleAtFixedRate
public static java.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(java.util.concurrent.Executor executor, int durationSeconds, ARunnable t)
-
scheduleAtFixedRate
public static java.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(long period, ARunnable t)
-
scheduleAtFixedRate
public static java.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(Destroyer resTo, long period, java.util.concurrent.TimeUnit timeUnit, ARunnable t)
-
scheduleAtFixedRate
public static java.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(long period, java.util.concurrent.TimeUnit timeUnit, ARunnable t)
-
parseType
public static CTypeI<java.lang.Object> parseType(java.lang.String s)
-
filterFrontAndBackStackTrace
public static <T extends java.lang.Throwable> T filterFrontAndBackStackTrace(T e, java.lang.Class<?>... skipClasses)
-
filterFrontAndBackStackTrace
public static java.lang.StackTraceElement[] filterFrontAndBackStackTrace(java.lang.StackTraceElement[] ss, java.lang.Class<?>... skipClasses)
-
filterStackTraceBack
public static java.lang.StackTraceElement[] filterStackTraceBack(java.lang.StackTraceElement[] ss, java.lang.Class<?>... skipClasses)
-
parseType
public static CTypeI<java.lang.Object> parseType(java.lang.String s, int[] i) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
getAllPaths
public static Flow<java.io.File> getAllPaths()
-
sizeOf
public static int sizeOf(java.lang.reflect.Parameter p)
-
mapArray
public static <S,T> T[] mapArray(S[] src, java.lang.Class<T> targetType, AFunction<S,T> mapper)
-
ceilDiv
public static int ceilDiv(int x, int y)
-
resolveExtend
public static CTypeI<java.lang.Object> resolveExtend(CTypeI<?> parent, CTypeI<?> owner)
-
error
public static <T> T error(java.lang.StackTraceElement[] st, java.lang.Throwable e)
-
error
public static <T,E extends java.lang.Throwable> T error(java.lang.Throwable e) throws E extends java.lang.Throwable- Throws:
E extends java.lang.Throwable
-
availableProcessors
public static int availableProcessors()
-
sleep
public static void sleep(long ms)
-
getNetLoading
public static double getNetLoading()
-
getSystemLoading
public static int getSystemLoading()
-
concatArrays
public static <T> T[] concatArrays(T v, T[] vv)
-
cast
public static <T> T cast(java.lang.Object t)
-
concatArrays
public static <T> T[] concatArrays(T[] v, T[] vv)
-
concatStackTrace
public static void concatStackTrace(java.lang.StackTraceElement[] st, java.lang.Throwable e)
-
updateMax
public static <T> int updateMax(T owner, java.util.concurrent.atomic.AtomicIntegerFieldUpdater<T> updater, int value)
-
updateMin
public static <T> int updateMin(T owner, java.util.concurrent.atomic.AtomicIntegerFieldUpdater<T> updater, int value)
-
updateMax
public static <T> long updateMax(T owner, java.util.concurrent.atomic.AtomicLongFieldUpdater<T> updater, long value)
-
readAll
public static <T> void readAll(java.util.Queue<T> q, AConsumer<T> o)
-
runAll
public static void runAll(java.util.Queue<ARunnable> q)
-
escape
public static java.lang.String escape(java.lang.String s)
-
escape
public static java.lang.String escape(java.lang.String chars, java.lang.String s)
-
unescape
public static java.lang.CharSequence unescape(java.lang.CharSequence s)
-
convertBytesToShortArray
public static short[] convertBytesToShortArray(byte[] bytes)
-
convertBytesToIntArray
public static int[] convertBytesToIntArray(byte[] bytes)
-
convertShortToByteArray
public static byte[] convertShortToByteArray(int data)
-
convertShortToByteArray
public static byte[] convertShortToByteArray(short data)
-
convertShortToByteArray
public static byte[] convertShortToByteArray(short[] data)
-
convertIntToByteArray
public static byte[] convertIntToByteArray(int[] data)
-
time
public static long time()
-
bytesToLong
public static long bytesToLong(byte[] bytes, int offset)
-
bytesToLongLittleEndian
public static long bytesToLongLittleEndian(byte[] bytes, int offset)
-
splitWithQuotes
public static java.lang.String[] splitWithQuotes(java.lang.String s)
-
isDeclaredInClass
public static boolean isDeclaredInClass(java.lang.reflect.Field f, java.lang.Class<?> rootClass)
-
executeShellBashSudo
public static void executeShellBashSudo(java.lang.String password, java.lang.String cmd)
-
executeShellBash
public static void executeShellBash(java.lang.String cmd)
-
executeShell
public static void executeShell(java.lang.String s)
-
castEnum
public static <T extends java.lang.Enum<T>> java.lang.Class<java.lang.Enum<T>> castEnum(java.lang.Class<?> raw)
-
removeElement
public static <T> T[] removeElement(T[] a, int i)
-
unreflect
public static java.lang.invoke.MethodHandle unreflect(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.reflect.Method method)
-
unreflect
public static java.lang.invoke.VarHandle unreflect(java.lang.reflect.Field f)
-
debugExecutor
public static java.util.concurrent.Executor debugExecutor(java.util.concurrent.Executor executor)
-
errorUnsupported
public static <T> T errorUnsupported()
-
homeDir
public static java.io.File homeDir()
-
workDir
public static java.io.File workDir()
-
newContextId
public static long newContextId()
-
selfExecuteCmdJar
public static java.io.File selfExecuteCmdJar()
-
selfExecuteCmdWithoutArgs
public static java.lang.String selfExecuteCmdWithoutArgs()
-
tempFile
public static java.io.File tempFile()
-
printStackTrace
public static void printStackTrace()
-
-