net.freeutils.tnef
public class TNEFUtils extends Object
TNEFUtils
class provides utility methods used by the TNEF
processing classes.
Since: 2003-04-25
Method Summary | |
---|---|
static int | attID(int att)
Returns the ID part of a 32-bit combined attribute type and ID value.
|
static int | attribute(int atp, int id)
Returns a 32-bit value containing a combined attribute type and ID.
|
static int | attType(int att)
Returns the type part of a 32-bit combined attribute type and ID value.
|
static int | calculateChecksum(byte[] data)
Returns the checksum of a given byte array.
|
static int | calculateChecksum(byte[] data, int offset, int length)
Returns the checksum of a range of bytes within a given byte array.
|
static int | calculateChecksum(RawInputStream ris)
Returns the checksum of all the data in a given RawInputStream.
|
static int | calculateCRC32(byte[] buf, int off, int len)
Calculates the CRC32 of the given bytes.
|
static String | createString(byte[] bytes, int offset, int length)
Creates a String from a C-style null terminated byte sequence.
|
static String | createStringUnicode(byte[] bytes, int offset, int length)
Creates a String from a C-style null terminated Unicode byte sequence.
|
static byte[] | decompressRTF(byte[] src)
Decompresses compressed-RTF data.
|
static String | getConstName(Class cls, String constPrefix, long value)
Returns the name of a constant which is defined in given Class,
has a name beginning with given prefix, and has given value. |
static int | getU16(int b1, int b2)
Returns an unsigned 16-bit value from little-endian ordered bytes.
|
static int | getU16(byte[] buf, int offset)
Returns an unsigned 16-bit value from little-endian ordered bytes.
|
static long | getU32(int b1, int b2, int b3, int b4)
Returns an unsigned 32-bit value from little-endian ordered bytes.
|
static long | getU32(byte[] buf, int offset)
Returns an unsigned 32-bit value from little-endian ordered bytes.
|
static long | getU64(byte[] buf, int offset)
Returns a 64-bit value from little-endian ordered bytes.
|
static int | getU8(byte[] buf, int offset)
Returns an unsigned 8-bit value from a byte array.
|
static boolean | isTNEFMimeType(String mimeType)
Checks whether the given string contains a TNEF mime type
|
static int | read(InputStream in, byte[] b, int off, int min, int max)
Reads bytes from a stream. |
static String | removeTerminatingNulls(String s)
Removes all null characters ('\0') from the end of a given String.
|
static String | replace(String s, String search, String replace)
Replaces all occurrences of given substring within string with a replacement
string.
|
static byte[] | toGUID(String guid)
Converts a GUID string to a byte array.
|
static String | toHexString(byte[] bytes)
Creates a String containing the hexadecimal representation of the given
bytes.
|
static String | toHexString(byte[] bytes, int max)
Creates a String containing the hexadecimal representation of the given
bytes.
|
static String | toHexString(byte[] bytes, int offset, int len, int max)
Creates a String containing the hexadecimal representation of the given
bytes.
|
Parameters: att the combined attribute type and ID value
Returns: the ID part of a 32-bit combined attribute type and ID value
Parameters: atp the attribute type id the attribute ID
Returns: a 32-bit value containing a combined attribute type and ID
Parameters: att the combined attribute type and ID value
Returns: the type part of a 32-bit combined attribute type and ID value
Parameters: data the byte array on which to calculate the checksum
Returns: the checksum of a given byte array
Parameters: data the byte array on which to calculate the checksum offset the offset within the array from which to begin length the number of bytes to calculate checksum on
Returns: the checksum of a range of bytes within a given byte array
Parameters: ris the stream from which the data is read
Returns: the checksum of all the data in a given RawInputStream
Throws: IOException if an I/O error occurs
Deprecated: use CompressedRTFInputStream instead
Calculates the CRC32 of the given bytes. The CRC32 calculation is similar to the standard one as demonstrated in RFC 1952, but with the inversion (before and after the calculation) omitted.Parameters: buf the byte array to calculate CRC32 on off the offset within buf at which the CRC32 calculation will start len the number of bytes on which to calculate the CRC32
Returns: the CRC32 value
Parameters: bytes a byte array containing a C-style null terminated string offset the offset within bytes where the string begins length the length of the C-style string in bytes, which may include any number of terminating null ('\0') characters
Returns: a String containing the C-style string's characters, interpreted as ISO-8859-1 characters
Parameters: bytes a byte array containing a C-style null terminated Unicode string offset the offset within bytes where the string begins length the length of the C-style string in bytes, which may include any number of terminating null ('\0') characters
Returns: a String containing the C-style string's characters, interpreted as Unicode (UTF-16 Little Endian) characters
Deprecated: use CompressedRTFInputStream instead
Decompresses compressed-RTF data.Parameters: src the compressed-RTF data bytes
Returns: an array containing the decompressed bytes
Throws: IllegalArgumentException if src does not contain valid compressed-RTF bytes
Parameters: cls the Class containing the constant constPrefix the prefix of the constant name (used in grouping constants) value the constant's value
Returns: the name of the constant
Parameters: b1 first byte value b2 second byte value
Returns: an unsigned 16-bit value as an int
Parameters: buf a byte array from which byte values are taken offset the offset within buf from which byte values are taken
Returns: an unsigned 16-bit value as an int
Parameters: b1 first byte value b2 second byte value b3 third byte value b4 fourth byte value
Returns: an unsigned 32-bit value as a long
Parameters: buf a byte array from which byte values are taken offset the offset within buf from which byte values are taken
Returns: an unsigned 32-bit value as a long
Parameters: buf a byte array from which byte values are taken offset the offset within buf from which byte values are taken
Returns: a 64-bit value as a long
Parameters: buf a byte array from which byte value is taken offset the offset within buf from which byte value is taken
Returns: an unsigned 8-bit value as an int
Parameters: mimeType the mimeType to check
Returns: true if the given string contains a TNEF mime type, false otherwise
Parameters: in the input stream to read from b the byte array to read into off the offset within the byte array to start reading into min the minimum number of bytes to read max the maximum number of bytes to read
Returns: the number of bytes read
Throws: IOException if an error occurs or there are less than the minimum number of bytes in the stream
Parameters: s a String
Returns: a String identical to the given string, with trailing null characters removed
Parameters: s the string to be modified search the substring to search for replace the string with which to replace occurrences of the search substring
Returns: a new string consisting of the given string, with all occurrences of search string replaced by replace string. If given string or search string are empty or null, the string itself is returned.
Deprecated: use the GUID class for GUID manipulation
Converts a GUID string to a byte array. A GUID string can contain only hex digits, and optional dashes. All dashes are ignored.Parameters: guid the GUID string
Returns: the equivalent GUID byte array
Throws: IllegalArgumentException if the given string does not represent a valid GUID
Parameters: bytes a byte array whose content is to be displayed
Returns: a String containing the hexadecimal representation of the given bytes
If {@code max} is non-negative and {@code bytes.length > max}, then the first {@code max} bytes are returned, followed by a human-readable indication that there are {@code bytes.length} total bytes of data including those that are not returned.
Parameters: bytes a byte array whose content is to be displayed max the maximum number of bytes to be displayed (-1 means no limit)
Returns: a String containing the hexadecimal representation of the given bytes
If {@code max} is non-negative and {@code len > max}, then the first {@code max} bytes are returned, followed by a human-readable indication that there are {@code len} total bytes of data including those that are not returned.
In particular, {@code offset + len} can extend beyond the array boundaries, as long as {@code offset + max} is still within them, resulting in {@code max} bytes returned followed by an indication that there are {@code len} total data bytes (including those that are not returned).
Parameters: bytes a byte array whose content is to be displayed offset the offset within the byte array to start at len the number of bytes max the maximum number of bytes to be displayed (-1 means no limit)
Returns: a String containing the hexadecimal representation of the given bytes