public final class Util extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Util.RandomCodePoints
Creates random valid Character Code Points (as integers).
|
| Modifier and Type | Method and Description |
|---|---|
static long |
binarySearchLongs(Memory mem,
long fromLongIndex,
long toLongIndex,
long key)
Searches a range of the specified array of longs for the specified value using the binary
search algorithm.
|
static String |
characterPad(String s,
int fieldLength,
char padChar,
boolean postpend)
Prepend or postpend the given string with the given character to fill the given field length.
|
static byte[] |
getResourceBytes(String shortFileName)
Returns a byte array of the contents of the file defined by the given resource file's
shortFileName.
|
static File |
getResourceFile(String shortFileName)
Gets the file defined by the given resource file's shortFileName.
|
static String |
getResourcePath(String shortFileName)
Gets the absolute path of the given resource file's shortName.
|
static boolean |
isAllBitsClear(long value,
long bitMask)
Return true if all the masked bits of value are zero
|
static boolean |
isAllBitsSet(long value,
long bitMask)
Return true if all the masked bits of value are one
|
static boolean |
isAnyBitsClear(long value,
long bitMask)
Return true if any the masked bits of value are zero
|
static boolean |
isAnyBitsSet(long value,
long bitMask)
Return true if any the masked bits of value are one
|
static String |
zeroPad(String s,
int fieldLength)
Prepend the given string with zeros.
|
public static long binarySearchLongs(Memory mem, long fromLongIndex, long toLongIndex, long key)
mem - the Memory to be searchedfromLongIndex - the index of the first element (inclusive) to be searchedtoLongIndex - the index of the last element (exclusive) to be searchedkey - the value to be searched forpublic static final String zeroPad(String s, int fieldLength)
s - the given stringfieldLength - desired total field length including the given stringpublic static final String characterPad(String s, int fieldLength, char padChar, boolean postpend)
s - the given stringfieldLength - the desired field lengthpadChar - the desired pad characterpostpend - if true append the pacCharacters to the end of the string.public static final boolean isAllBitsClear(long value,
long bitMask)
value - the value to be testedbitMask - defines the bits of interestpublic static final boolean isAllBitsSet(long value,
long bitMask)
value - the value to be testedbitMask - defines the bits of interestpublic static final boolean isAnyBitsClear(long value,
long bitMask)
value - the value to be testedbitMask - defines the bits of interestpublic static final boolean isAnyBitsSet(long value,
long bitMask)
value - the value to be testedbitMask - defines the bits of interestpublic static String getResourcePath(String shortFileName)
Note that the ClassLoader.getResource(shortName) returns a URL, which can have special characters, e.g., "%20" for spaces. This method obtains the URL, converts it to a URI, then does a uri.getPath(), which decodes any special characters in the URI path. This is required to make obtaining resources operating-system independent.
shortFileName - the last name in the pathname's name sequence.public static File getResourceFile(String shortFileName)
shortFileName - the last name in the pathname's name sequence.public static byte[] getResourceBytes(String shortFileName)
shortFileName - the last name in the pathname's name sequence.Copyright © 2015–2021 The Apache Software Foundation. All rights reserved.