org.foray.common
Class WKConstants

java.lang.Object
  extended by org.foray.common.WKConstants

public final class WKConstants
extends Object

Class containing well-known or commonly-used constants and conversions.


Field Summary
static byte BITS_PER_BYTE
          The number of bits in a byte, that is, 8.
static byte BITS_PER_NIBBLE
          The number of bits in a nibble, that is, 4.
static byte BYTES_PER_INT
          The number of bytes in an int, that is, 4.
static short BYTES_PER_KILOBYTE
          The number of bytes per kilobyte, that is, 1024.
static byte BYTES_PER_LONG
          The number of bytes in a long, that is, 8.
static byte BYTES_PER_SHORT
          The number of bytes in a short, that is, 2.
static byte CARRIAGE_RETURN
          The carriage-return character, cast as a byte.
static float CM_PER_INCH
          The number of centimeters per inch.
static int DECIPOINTS_PER_POINT
          The number of decipoints per point, that is, 10.
static short DEGREES_PER_CIRCLE
          The number of degrees in a circle, that is, 360.
static String EMPTY_STRING
          An empty String useful for return values that might return "null", but could return this more safely.
static short GRADS_PER_CIRCLE
          The number of grads in a circle, that is, 400.
static char INVALID_UNICODE_CHARACTER
          Constant defining an invalid character value.
static short KILOBYTES_PER_MEGABYTE
          The number of kilobytes per megabytes, that is, 1024.
static byte LINEFEED
          The linefeed character, cast as a byte.
static String LINEFEED_STRING
          The linefeed character, cast as a 1-character String.
static int MAX_16_BIT_UNSIGNED_VALUES
          The maximum number of values that can be stored in 16 bits, that is, 65,536.
static int MAX_32_BIT_UNSIGNED_INT
          The maximum unsigned 32-bit value, cast as an int.
static byte MAX_4_BIT_UNSIGNED_BYTE
          The maximum 4-bit value, cast as a byte, that is 0xF.
static byte MAX_4_BIT_UNSIGNED_VALUES
          The maximum number of values that can be stored in 4 bits, that is, 16.
static short MAX_7_BIT_UNSIGNED_VALUES
          The maximum number of values that can be stored in 7 bits, that is, 128.
static byte MAX_8_BIT_UNSIGNED_BYTE
          The maximum unsigned 8-bit value, cast as a byte.
static int MAX_8_BIT_UNSIGNED_INT
          The maximum unsigned 8-bit value, cast as an int, that is 255 or 0xFF.
static short MAX_8_BIT_UNSIGNED_VALUES
          The maximum number of values that can be stored in 8 bits, that is, 256.
static short MAXIMUM_INTEGRAL_COLOR_VALUE
          Constant defining the largest integral color value, that is, 255.
static int MILLIPOINTS_PER_POINT
          The number of millipoints per point, that is, 1000.
static short MILLIUNITS_PER_UNIT
          The number of milli-units (thousandths of a unit) per unit, that is, 1000.
static float MM_PER_CM
          The number of millimeters per centimeter.
static byte PERCENT_CONVERSION
          The conversion factor between a percentage value and its decimal equivalent, that is, 100.
static int PICAS_PER_INCH
          The number of picas per inch, that is, 6.
static int POINTS_PER_INCH
          The number of points per inch, that is 72.
static byte RADIX_BASE_10
          The radix for base-10 numbers, that is, 10.
static byte RADIX_BASE_16
          The radix for base-16 numbers, that is, 16.
static byte RADIX_BASE_2
          The radix for base-2 numbers, that is, 2.
static byte RADIX_BASE_8
          The radix for base-8 numbers, that is, 8.
static byte SHIFT_1_BYTE
          The number of bits to shift for a one-byte shift.
static byte SHIFT_2_BYTES
          The number of bits to shift for a two-byte shift.
static byte SHIFT_3_BYTES
          The number of bits to shift for a three-byte shift.
static byte SHIFT_4_BYTES
          The number of bits to shift for a four-byte shift.
 
Method Summary
static float millipointsToPoints(int millipoints)
          Converts millipoints to points.
static int unsignedBytesToInt(byte byte1, byte byte2)
          Converts two unsigned bytes to an int.
static int unsignedBytesToIntBE(byte[] byteArray, int start)
          Converts two unsigned big-endian bytes from an array of bytes to an int.
static int unsignedBytesToIntLE(byte[] byteArray, int start)
          Converts two unsigned little-endian bytes from an array of bytes to an int.
static long unsignedBytesToLong(byte byte1, byte byte2, byte byte3, byte byte4)
          Converts four unsigned bytes to a long.
static long unsignedBytesToLongBE(byte[] byteArray, int start)
          Converts four unsigned big-endian bytes from an array of bytes to a long.
static long unsignedBytesToLongLE(byte[] byteArray, int start)
          Converts four unsigned little-endian bytes from an array of bytes to a long.
static int unsignedByteToInt(byte unsignedByte)
          Converts one unsigned byte to its integer equivalent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_8_BIT_UNSIGNED_BYTE

public static final byte MAX_8_BIT_UNSIGNED_BYTE
The maximum unsigned 8-bit value, cast as a byte.

See Also:
Constant Field Values

MAX_8_BIT_UNSIGNED_INT

public static final int MAX_8_BIT_UNSIGNED_INT
The maximum unsigned 8-bit value, cast as an int, that is 255 or 0xFF.

See Also:
Constant Field Values

MAX_4_BIT_UNSIGNED_BYTE

public static final byte MAX_4_BIT_UNSIGNED_BYTE
The maximum 4-bit value, cast as a byte, that is 0xF.

See Also:
Constant Field Values

MAX_32_BIT_UNSIGNED_INT

public static final int MAX_32_BIT_UNSIGNED_INT
The maximum unsigned 32-bit value, cast as an int.

See Also:
Constant Field Values

MAX_4_BIT_UNSIGNED_VALUES

public static final byte MAX_4_BIT_UNSIGNED_VALUES
The maximum number of values that can be stored in 4 bits, that is, 16.

See Also:
Constant Field Values

MAX_8_BIT_UNSIGNED_VALUES

public static final short MAX_8_BIT_UNSIGNED_VALUES
The maximum number of values that can be stored in 8 bits, that is, 256.

See Also:
Constant Field Values

MAX_7_BIT_UNSIGNED_VALUES

public static final short MAX_7_BIT_UNSIGNED_VALUES
The maximum number of values that can be stored in 7 bits, that is, 128.

See Also:
Constant Field Values

MAX_16_BIT_UNSIGNED_VALUES

public static final int MAX_16_BIT_UNSIGNED_VALUES
The maximum number of values that can be stored in 16 bits, that is, 65,536.

See Also:
Constant Field Values

BYTES_PER_LONG

public static final byte BYTES_PER_LONG
The number of bytes in a long, that is, 8.

See Also:
Constant Field Values

BYTES_PER_INT

public static final byte BYTES_PER_INT
The number of bytes in an int, that is, 4.

See Also:
Constant Field Values

BYTES_PER_SHORT

public static final byte BYTES_PER_SHORT
The number of bytes in a short, that is, 2.

See Also:
Constant Field Values

BITS_PER_BYTE

public static final byte BITS_PER_BYTE
The number of bits in a byte, that is, 8.

See Also:
Constant Field Values

BITS_PER_NIBBLE

public static final byte BITS_PER_NIBBLE
The number of bits in a nibble, that is, 4.

See Also:
Constant Field Values

SHIFT_1_BYTE

public static final byte SHIFT_1_BYTE
The number of bits to shift for a one-byte shift.

See Also:
Constant Field Values

SHIFT_2_BYTES

public static final byte SHIFT_2_BYTES
The number of bits to shift for a two-byte shift.

See Also:
Constant Field Values

SHIFT_3_BYTES

public static final byte SHIFT_3_BYTES
The number of bits to shift for a three-byte shift.

See Also:
Constant Field Values

SHIFT_4_BYTES

public static final byte SHIFT_4_BYTES
The number of bits to shift for a four-byte shift.

See Also:
Constant Field Values

CM_PER_INCH

public static final float CM_PER_INCH
The number of centimeters per inch.

See Also:
Constant Field Values

MM_PER_CM

public static final float MM_PER_CM
The number of millimeters per centimeter.

See Also:
Constant Field Values

POINTS_PER_INCH

public static final int POINTS_PER_INCH
The number of points per inch, that is 72. A "point" is a somewhat nebulous term, but here we use the term as standardized by Adobe in their concept of text space units.

See Also:
Constant Field Values

PICAS_PER_INCH

public static final int PICAS_PER_INCH
The number of picas per inch, that is, 6.

See Also:
Constant Field Values

MILLIPOINTS_PER_POINT

public static final int MILLIPOINTS_PER_POINT
The number of millipoints per point, that is, 1000.

See Also:
Constant Field Values

DECIPOINTS_PER_POINT

public static final int DECIPOINTS_PER_POINT
The number of decipoints per point, that is, 10.

See Also:
Constant Field Values

CARRIAGE_RETURN

public static final byte CARRIAGE_RETURN
The carriage-return character, cast as a byte.

See Also:
Constant Field Values

LINEFEED

public static final byte LINEFEED
The linefeed character, cast as a byte.

See Also:
Constant Field Values

LINEFEED_STRING

public static final String LINEFEED_STRING
The linefeed character, cast as a 1-character String.

See Also:
Constant Field Values

BYTES_PER_KILOBYTE

public static final short BYTES_PER_KILOBYTE
The number of bytes per kilobyte, that is, 1024.

See Also:
Constant Field Values

KILOBYTES_PER_MEGABYTE

public static final short KILOBYTES_PER_MEGABYTE
The number of kilobytes per megabytes, that is, 1024.

See Also:
Constant Field Values

PERCENT_CONVERSION

public static final byte PERCENT_CONVERSION
The conversion factor between a percentage value and its decimal equivalent, that is, 100.

See Also:
Constant Field Values

RADIX_BASE_2

public static final byte RADIX_BASE_2
The radix for base-2 numbers, that is, 2.

See Also:
Constant Field Values

RADIX_BASE_8

public static final byte RADIX_BASE_8
The radix for base-8 numbers, that is, 8.

See Also:
Constant Field Values

RADIX_BASE_10

public static final byte RADIX_BASE_10
The radix for base-10 numbers, that is, 10.

See Also:
Constant Field Values

RADIX_BASE_16

public static final byte RADIX_BASE_16
The radix for base-16 numbers, that is, 16.

See Also:
Constant Field Values

DEGREES_PER_CIRCLE

public static final short DEGREES_PER_CIRCLE
The number of degrees in a circle, that is, 360.

See Also:
Constant Field Values

GRADS_PER_CIRCLE

public static final short GRADS_PER_CIRCLE
The number of grads in a circle, that is, 400.

See Also:
Constant Field Values

MILLIUNITS_PER_UNIT

public static final short MILLIUNITS_PER_UNIT
The number of milli-units (thousandths of a unit) per unit, that is, 1000.

See Also:
Constant Field Values

EMPTY_STRING

public static final String EMPTY_STRING
An empty String useful for return values that might return "null", but could return this more safely. Using this constant in such cases is entirely safe as String instances are immutable.

See Also:
Constant Field Values

INVALID_UNICODE_CHARACTER

public static final char INVALID_UNICODE_CHARACTER
Constant defining an invalid character value.

See Also:
Constant Field Values

MAXIMUM_INTEGRAL_COLOR_VALUE

public static final short MAXIMUM_INTEGRAL_COLOR_VALUE
Constant defining the largest integral color value, that is, 255.

See Also:
Constant Field Values
Method Detail

unsignedBytesToLong

public static long unsignedBytesToLong(byte byte1,
                                       byte byte2,
                                       byte byte3,
                                       byte byte4)
Converts four unsigned bytes to a long. (It must be converted to a long because the Java int is signed).

Parameters:
byte1 - The high-order byte.
byte2 - The second highest-order byte.
byte3 - The third highest-order byte.
byte4 - The low-order byte.
Returns:
The long represented by the four bytes.

unsignedByteToInt

public static int unsignedByteToInt(byte unsignedByte)
Converts one unsigned byte to its integer equivalent.

Parameters:
unsignedByte - The byte to be converted.
Returns:
The integer equivalent of unsignedByte.

unsignedBytesToLongBE

public static long unsignedBytesToLongBE(byte[] byteArray,
                                         int start)
Converts four unsigned big-endian bytes from an array of bytes to a long. (It must be converted to a long because the Java int is signed).

Parameters:
byteArray - The array of bytes containing the bytes to be converted.
start - The index to the first byte in the array to be converted. This is the high-order byte of the 4 bytes. The second byte will be indexed at start + 1, the third byte at start + 2, and the fourth byte at start + 3.
Returns:
The long represented by the four bytes.

unsignedBytesToLongLE

public static long unsignedBytesToLongLE(byte[] byteArray,
                                         int start)
Converts four unsigned little-endian bytes from an array of bytes to a long. (It must be converted to a long because the Java int is signed).

Parameters:
byteArray - The array of bytes containing the bytes to be converted.
start - The index to the first byte in the array to be converted. This is the low-order byte of the 4 bytes. The second byte will be indexed at start + 1, the third byte at start + 2, and the fourth byte (the high-order byte) at start + 3.
Returns:
The long represented by the four bytes.

unsignedBytesToInt

public static int unsignedBytesToInt(byte byte1,
                                     byte byte2)
Converts two unsigned bytes to an int. (It must be converted to an int because the Java short is signed).

Parameters:
byte1 - The high-order byte.
byte2 - The low-order byte.
Returns:
The int represented by the two bytes.

unsignedBytesToIntBE

public static int unsignedBytesToIntBE(byte[] byteArray,
                                       int start)
Converts two unsigned big-endian bytes from an array of bytes to an int. (It must be converted to an int because the Java short is signed).

Parameters:
byteArray - The array of bytes containing the bytes to be converted.
start - The index to the first byte in the array to be converted. This is the high-order byte of the 2 bytes. The second byte (the low-order byte) will be indexed at start + 1.
Returns:
The int represented by the two bytes.

unsignedBytesToIntLE

public static int unsignedBytesToIntLE(byte[] byteArray,
                                       int start)
Converts two unsigned little-endian bytes from an array of bytes to an int. (It must be converted to an int because the Java short is signed).

Parameters:
byteArray - The array of bytes containing the bytes to be converted.
start - The index to the first byte in the array to be converted. This is the low-order byte of the 4 bytes. The second byte (the high-order byte) at start + 1.
Returns:
The int represented by the two bytes.

millipointsToPoints

public static float millipointsToPoints(int millipoints)
Converts millipoints to points.

Parameters:
millipoints - The millipoint value to be converted.
Returns:
The points equivalent of millipoints.


Copyright © 2017. All rights reserved.