Package com.logviewer.utils
Class Utils
java.lang.Object
com.logviewer.utils.Utils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte[]static final ByteBufferstatic final int[]static final Object[]static final Stringstatic final long -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertValidTimestamp(long nano) static voidcloseQuietly(AutoCloseable closeable) static intcompareFileNames(String f1, String f2) static booleancontainsIgnoreCase(String str, String searchStr) Decodes text from a byte array.static voiddeleteContent(Path path) static LonggetFormatHash(LogFormat format) static StringgetStackTraceAsString(Throwable throwable) static Pathstatic <T> intstatic booleanstatic booleanisSubdirectory(String directory, String child) static <K,V> Map<K, V> static StringnormalizePath(String path) static RuntimeExceptionstatic voidputInt(MessageDigest digest, int x) static voidputUnencodedChars(MessageDigest digest, char c) static voidputUnencodedChars(MessageDigest digest, String s) static voidreadFully(ReadableByteChannel channel, ByteBuffer buf) static voidreadFully(ReadableByteChannel channel, ByteBuffer buf, int length) static Stringstatic <T> Tstatic voidsetLimitSafely(ByteBuffer byteBuffer, int newLimit) We cannot callByteBuffer.limit(int)directly because it doesn't work with Java 8.static voidsetPositionSafely(ByteBuffer byteBuffer, int newPosition) We cannot callByteBuffer.position(int)directly because it doesn't work with Java 8.static Stringstatic StringtoString(ByteBuffer buffer) static StringtoString(ByteBuffer buffer, Charset charsets)
-
Field Details
-
MAX_TIME_MILLIS
public static final long MAX_TIME_MILLIS- See Also:
-
EMPTY_BYTE_ARRAY
public static final byte[] EMPTY_BYTE_ARRAY -
EMPTY_INT_ARRAY
public static final int[] EMPTY_INT_ARRAY -
EMPTY_BYTE_BUFFER
-
EMPTY_OBJECTS
-
LOCAL_HOST_NAME
-
-
Method Details
-
closeQuietly
-
deleteContent
- Throws:
IOException
-
title
-
readFully
public static void readFully(ReadableByteChannel channel, ByteBuffer buf, int length) throws IOException - Throws:
IOException
-
readFully
- Throws:
IOException
-
isIdentifier
-
toString
-
toString
-
isSubdirectory
-
compareFileNames
-
containsIgnoreCase
-
indexOf
-
getFormatHash
-
safeGet
-
normalizePath
-
propagate
-
putUnencodedChars
-
putUnencodedChars
-
putInt
-
newMap
-
getStackTraceAsString
-
assertValidTimestamp
public static void assertValidTimestamp(long nano) -
getTempDir
- Throws:
IOException
-
removeAsciiColorCodes
-
decode
Decodes text from a byte array. The end of the data may be broken UTF8 sequence, skip it.- Parameters:
data- The bytes to decodeencoding- The encoding- Returns:
- A pair of the decoded text and the actual size of the text in bytes.
-
setPositionSafely
We cannot callByteBuffer.position(int)directly because it doesn't work with Java 8. In the Java 8 the return type isByteBuffer, but in Java 11 the return type isBuffer. This method calls `position(int)` onBufferclass. It works with both Java 8 and Java 11. -
setLimitSafely
We cannot callByteBuffer.limit(int)directly because it doesn't work with Java 8. In the Java 8 the return type isByteBuffer, but in Java 11 the return type isBuffer. This method calls `position(int)` onBufferclass. It works with both Java 8 and Java 11.
-