The Diffusion Publisher API is deprecated and will be removed in a future release.
@Deprecated public final class Utils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
UTF8
Deprecated.
The UTF-8 Character encoding which is recommended for most message
handling.
|
Modifier and Type | Method and Description |
---|---|
static String |
base64Decode(String toDecode)
Deprecated.
Decodes a Base 64 encoded string.
|
static String |
base64Encode(String toEncode)
Deprecated.
Encodes a String in Base64 notation.
|
static void |
bootstrap(ClassLoader cl,
com.pushtechnology.diffusion.manifest.ProductManifest manifest)
Deprecated.
|
static String |
byteBufferToAscii(ByteBuffer buffer)
Deprecated.
Converts the ByteBuffer in the default Character set for diagnostic
purposes from the current buffer position.
|
static String |
byteBufferToAscii(ByteBuffer buffer,
int limit)
Deprecated.
Converts the ByteBuffer in the default Character set for diagnostic
purposes from the current buffer position, up to a limit.
|
static String |
byteBufferToHex(ByteBuffer buffer)
Deprecated.
Converts the contents of a ByteBuffer to a Hexadecimal String for
diagnostic purposes.
|
static String |
byteBufferToHex(ByteBuffer buffer,
int length)
Deprecated.
Converts part of a ByteBuffer to a Hexadecimal String representation for
diagnostic purposes.
|
static int |
byteNumberConverter(String number)
Deprecated.
Converts a size into bytes.
|
static String |
bytesToHex(byte[] byteArray)
Deprecated.
Converts all or part of a byte array to hexadecimal representation for
diagnostic purposes.
|
static String |
bytesToHex(byte[] byteArray,
int offset,
int length)
Deprecated.
Converts all or part of a byte array to hexadecimal representation for
diagnostic purposes.
|
static String |
convertInputStreamToString(InputStream is)
Deprecated.
Returns the input stream as a string, read as UTF-8.
|
static String |
convertInputStreamToString(InputStream is,
String charSet)
Deprecated.
Returns the input stream as a string, using the specified charset.
|
static LineNumberReader |
createFileReader(File file)
Deprecated.
Creates a reader for a given file.
|
static LineNumberReader |
createFileReader(FileInputStream fileInputStream)
Deprecated.
Creates a reader for a given file input stream.
|
static LineNumberReader |
createFileReader(FileInputStream fileInputStream,
String charset)
Deprecated.
Creates a reader for a given file input stream.
|
static LineNumberReader |
createFileReader(File file,
String charset)
Deprecated.
Creates a reader for a given file.
|
static BufferedWriter |
createFileWriter(File file)
Deprecated.
Creates a buffered writer for a given file.
|
static BufferedWriter |
createFileWriter(FileOutputStream fileOutputStream)
Deprecated.
Creates a writer for a given file output stream.
|
static BufferedWriter |
createFileWriter(FileOutputStream fileOutputStream,
String charset)
Deprecated.
Creates a writer for a given file output stream.
|
static BufferedWriter |
createFileWriter(File file,
String charset)
Deprecated.
Creates a writer for a given file.
|
static LineNumberReader |
createResourceReader(String resourceName)
Deprecated.
Creates a reader for a named resource using UTF-8.
|
static LineNumberReader |
createResourceReader(String resourceName,
String charset)
Deprecated.
Creates a reader for a named resource.
|
static String |
formatDate(Date date)
Deprecated.
Formats a date.
|
static String |
formatDate(long millis)
Deprecated.
Formats a milliseconds date.
|
static String |
formatDateTime(Date date)
Deprecated.
Formats a date and time.
|
static String |
formatDateTime(long millis)
Deprecated.
Formats a milliseconds date and time.
|
static String |
formatElapsedTime(long millis)
Deprecated.
Formats an elapsed time in milliseconds into a display format string.
|
static String |
formatNumber(Number number)
Deprecated.
Formats a number using default decimal formatting.
|
static String |
formatTime(Date date)
Deprecated.
Formats a time value.
|
static String |
formatTime(long millis)
Deprecated.
Formats the time from a milliseconds date value.
|
static String |
formatTimeStamp(Date date)
Deprecated.
Formats a time stamp.
|
static String |
formatTimeStamp(long millis)
Deprecated.
Formats a milliseconds value into a timestamp.
|
static CharsetDecoder |
getDefaultCharsetDecoder()
Deprecated.
Get a Charset decoder based off the default charset.
|
static File |
getFile(String fileName)
Deprecated.
Gets a File object corresponding to a file that is loadable from the
system classpath.
|
static String |
getProductVersion()
Deprecated.
Returns the Diffusion Product Version.
|
static InputStream |
getResourceAsStream(String resourceName)
Deprecated.
Open for reading, a resource of the specified name from the search path
used to load classes.
|
static String |
join(List<? extends CharSequence> list,
String delimiter)
Deprecated.
Joins all of a list into a string, and returns the string.
|
static String |
join(String[] strings,
String delimiter)
Deprecated.
Joins an array of Strings to make a single string.
|
static PropertyHandler |
loadProperties(String resourceName)
Deprecated.
Load properties from a resource of the specified name from the search
path used to load classes.
|
static long |
millisNumberConverter(String time)
Deprecated.
Append the letter h or H to indicate hours, or m or M to indicate minutes
or s or S to indicate seconds.
|
static String |
padString(String string,
int length)
Deprecated.
Pads a string with spaces to the right up to a specified length.
|
static String |
readFileAsString(File file)
Deprecated.
Reads the entire contents of a file into a String using UTF-8 conversion.
|
static String |
readFileAsString(File file,
String charset)
Deprecated.
Reads the entire contents of a file into a String.
|
public static final String UTF8
public static void bootstrap(ClassLoader cl, com.pushtechnology.diffusion.manifest.ProductManifest manifest)
public static InputStream getResourceAsStream(String resourceName) throws APIException
resourceName
- for example a file name.APIException
- if the resource could not be found.public static PropertyHandler loadProperties(String resourceName) throws APIException
resourceName
- the resource name.APIException
- if unable to load properties.public static File getFile(String fileName) throws APIException
This could be used, for example, to obtain a handle for a file in the data directory.
fileName
- the file name (e.g. "myFile.txt")APIException
- if no file with the specified name could be found on
the system classpath.public static LineNumberReader createResourceReader(String resourceName) throws APIException
resourceName
- the resource name which should be the path of a
resource that can be loaded from the classpath, for example a file
from the data directory.APIException
- if the resource could not be found.public static LineNumberReader createResourceReader(String resourceName, String charset) throws APIException
resourceName
- the resource name which should be the path of a
resource that can be loaded from the classpath, for example a file
from the data directory.charset
- the character set to use for converting bytes read from
the file into characters.APIException
- if the resource could not be found.public static LineNumberReader createFileReader(File file) throws APIException
file
- the file to read.APIException
- if unable to create a reader for the file.public static LineNumberReader createFileReader(File file, String charset) throws APIException
file
- the file to read.charset
- the character set to use for converting bytes read from
the file into characters.APIException
- if unable to create a reader for the given file.public static LineNumberReader createFileReader(FileInputStream fileInputStream) throws APIException
fileInputStream
- the file input stream to read.APIException
- if unable to create a reader for the file input
stream.public static LineNumberReader createFileReader(FileInputStream fileInputStream, String charset) throws APIException
fileInputStream
- the file input stream to read.charset
- the character set to use for converting bytes read from
the file into characters.APIException
- if unable to create a reader for the given file.public static String readFileAsString(File file) throws APIException
This will only cater for files of up to 8Kb in size.
file
- the file to read.APIException
- if unable to read the file.public static String readFileAsString(File file, String charset) throws APIException
This will only cater for files of up to 8Kb in size.
file
- the file to read.charset
- the character set to use for byte to character conversion.APIException
- if unable to read the file.public static BufferedWriter createFileWriter(File file) throws APIException
file
- the file to write to.APIException
- if unable to create a writer for the file.public static BufferedWriter createFileWriter(File file, String charset) throws APIException
file
- the file to write to.charset
- the character set to use for converting characters to
bytes written to the file.APIException
- if unable to create a writer for the given file.public static BufferedWriter createFileWriter(FileOutputStream fileOutputStream) throws APIException
fileOutputStream
- the file output stream.APIException
- if unable to create a writer for the given file.public static BufferedWriter createFileWriter(FileOutputStream fileOutputStream, String charset) throws APIException
fileOutputStream
- the file output stream.charset
- the character set to use for converting characters to
bytes written.APIException
- if unable to create a writer for the given file.public static String convertInputStreamToString(InputStream is) throws APIException
is
- the input streamAPIException
- if unable to read streampublic static String convertInputStreamToString(InputStream is, String charSet) throws APIException
is
- the input streamcharSet
- the character setAPIException
- if unable to read streampublic static String formatDate(Date date)
The supplied date is formatted using the date formatting pattern specified in Server.xml.
date
- the date to formatpublic static String formatDate(long millis)
The supplied date is formatted using the date formatting pattern specified in Server.xml.
millis
- a date represented as the number of milliseconds, between a
point in time and midnight, January 1, 1970 UTC.public static String formatTime(Date date)
The time part of the supplied date is formatted using the time formatting pattern specified in Server.xml.
date
- a date object for which the time part is to be formatted.public static String formatTime(long millis)
The time part of the supplied date is formatted using the time formatting pattern specified in Server.xml.
millis
- a time represented as the number of milliseconds, between a
point in time and midnight, January 1, 1970 UTC.public static String formatDateTime(Date date)
The supplied date is formatted using the dateTime formatting pattern specified in Server.xml.
date
- the date to formatpublic static String formatDateTime(long millis)
The supplied date is formatted using the dateTime formatting pattern specified in Server.xml.
millis
- a time represented as the number of milliseconds, between a
point in time and midnight, January 1, 1970 UTC.public static String formatTimeStamp(Date date)
The supplied date is formatted using the timeStamp formatting pattern specified in Server.xml.
date
- the date to formatpublic static String formatTimeStamp(long millis)
The supplied value is formatted using the timeStamp formatting pattern specified in Server.xml.
millis
- a time represented as the number of milliseconds, between a
point in time and midnight, January 1, 1970 UTC.public static String formatElapsedTime(long millis)
For example "3 hour(s) 4 minute(s) 23 second(s)"
millis
- elapsed time in milliseconds.public static String formatNumber(Number number)
number
- the number.public static String bytesToHex(byte[] byteArray, int offset, int length)
byteArray
- the byte array.offset
- the offset within the byte array from which to start
converting to hex.length
- the number of bytes, starting from the offset to convert.public static String bytesToHex(byte[] byteArray)
byteArray
- the byte array.public static String byteBufferToHex(ByteBuffer buffer)
The content of the buffer between the start and the current limit will be converted.
buffer
- the buffer.public static String byteBufferToHex(ByteBuffer buffer, int length)
The content of the buffer between the start and the specified length (or limit if shorter) will be converted.
buffer
- the buffer.length
- the maximum number of bytes to convert.public static String byteBufferToAscii(ByteBuffer buffer)
buffer
- the bufferpublic static String byteBufferToAscii(ByteBuffer buffer, int limit)
buffer
- the bufferlimit
- of bytes to dumppublic static CharsetDecoder getDefaultCharsetDecoder()
public static long millisNumberConverter(String time) throws APIException
time
- string representation of timeAPIException
- if unable to convertpublic static int byteNumberConverter(String number) throws APIException
number
- the string representing the number of bytesAPIException
- if unable to convert string to numberpublic static String base64Encode(String toEncode)
toEncode
- the string to encodepublic static String base64Decode(String toDecode)
toDecode
- the string to decodepublic static String join(List<? extends CharSequence> list, String delimiter)
list
- of Strings to joindelimiter
- to delimit the list of Stringspublic static String join(String[] strings, String delimiter)
strings
- the stringsdelimiter
- a delimiter to separate the strings so that the
resulting string can be split again. If null is supplied then
there will be no delimiter and the strings will simply be
concatenated.public static String padString(String string, int length)
If the string is already equal to or longer than the specified length then it is left at the same length.
string
- the stringlength
- the desired length to pad topublic static String getProductVersion()
Copyright © 2020 Push Technology Ltd. All Rights Reserved.