public class TestUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static long |
checkSum(byte[] b,
int offset,
int length)
Calculate an OpenType checksum from the array.
|
static java.nio.channels.FileChannel |
createFileChannelForWriting(java.io.File file) |
static void |
createNewFile(java.io.File file)
Creates a new file including deleting an already existing file with the same path
and name and creating any needed directories.
|
static java.io.OutputStream |
createOutputStream(java.io.File file) |
static java.lang.String |
dumpLongAsString(int i)
Converts an integer into a 4 character string using the ASCII encoding.
|
static int |
encodeOneChar(java.nio.charset.CharsetEncoder encoder,
int uchar)
Encode a single character in UTF-16.
|
static boolean |
equals(byte[] b1,
int offset1,
byte[] b2,
int offset2,
int length)
Compare sections of two byte arrays for equality.
|
static boolean |
equals(int offset1,
ReadableFontData rfd1,
int offset2,
ReadableFontData rfd2,
int length) |
static boolean |
equalsNullOk(java.lang.Object o1,
java.lang.Object o2)
Checks that both objects are equal as defined by the object itself.
|
static java.lang.String |
extension(java.io.File file) |
static java.nio.charset.CharsetEncoder |
getEncoder(java.lang.String charsetName)
Get an encoder for the charset name.
|
static byte[] |
readFile(java.io.File file)
Read a file fully into a new byte array.
|
public static boolean equals(byte[] b1,
int offset1,
byte[] b2,
int offset2,
int length)
b1 - byte array 1offset1 - offset for comparison in byte array 1b2 - byte array 2offset2 - offset for comparison in byte array 2length - the length of the byte arrays to comparepublic static java.nio.channels.FileChannel createFileChannelForWriting(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic static void createNewFile(java.io.File file)
throws java.io.IOException
file - the file to createjava.io.IOExceptionpublic static java.io.OutputStream createOutputStream(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String dumpLongAsString(int i)
i - the value to convertpublic static long checkSum(byte[] b,
int offset,
int length)
b - the array to calculate checksum onoffset - the starting index in the arraylength - the number of bytes to check; must be a multiple of 4public static int encodeOneChar(java.nio.charset.CharsetEncoder encoder,
int uchar)
encoder - the encoder to use for the encodinguchar - the Unicode character to encodepublic static java.nio.charset.CharsetEncoder getEncoder(java.lang.String charsetName)
charsetName - the charset to get an encoder forpublic static java.lang.String extension(java.io.File file)
public static byte[] readFile(java.io.File file)
throws java.io.IOException
file - the file to readjava.io.IOExceptionpublic static boolean equals(int offset1,
ReadableFontData rfd1,
int offset2,
ReadableFontData rfd2,
int length)
offset1 - offset to start comparing the first ReadableFontData fromrfd1 - the first ReadableFontDataoffset2 - offset to start comparing the second ReadableFontData fromrfd2 - the second ReadableFontDatalength - the number of bytes to comparepublic static boolean equalsNullOk(java.lang.Object o1,
java.lang.Object o2)
o1 - first objecto2 - second object