Home > blackberry_utils

blackberry_utils

Blackberry_utils is a project mainly written in Java, it's free.

This is a bunch of useful utilities for Java BlackBerry development

== DESCRIPTION

This is a bunch of useful utils for Java BlackBerry development.

=== StringUtils

Provides convenient String manipulation methods:

  • boolean isBlank(String str)
  • boolean isNotBlank(String str)
  • String safe(String str)
  • String safe(String str, String defaultValue)
  • int linesCount(String str)
  • String removeBefore(String str, String substrToDelete)
  • String replaceAll(String source, String pattern, String replacement)
  • String join(String delimiter, Object[] tokens)
  • String join(String delimiter, Enumeration tokens)
  • String[] split(String str, String delimiter)
  • String arrayToString(Object[] array)
  • String toHumanReadableString(Object obj)
  • String getStringFromStream(InputStream in) throws IOException
  • String getStringFromStream(InputStream in, String encoding) throws IOException

=== MathUtils

Provides convenient math rounding methods the RIM API 4.5 does not provide:

  • int round(float x)
  • long round(double x)

IMPORTANT: for API 4.6.0+ use net.rim.device.api.util.MathUtilities class instead.

=== FontUtils

Provides convenient methods to set/get the default font for the application:

  • void setApplicationDefaultFont()
  • Font getApplicationDefaultFont()

=== IOUtils

Provides convenient methods for file IO manipulations:

  • void safelyCloseStream(InputStream stream)
  • void safelyCloseStream(OutputStream stream)
  • void safelyCloseStream(FileConnection stream)
  • void safelyCloseStream(OutputStreamWriter stream)
  • void delete(String url) throws IOException
  • void rename(String url, String newName) throws IOException
  • void copyFile(String sourceFileUrl, String destinationFileUrl) throws IOException
  • void copyFileForTorchHack(String sourceFileUrl, String destinationFileUrl) throws IOException
  • void saveDataToFile(String url, byte[] data) throws IOException
  • void saveDataToFile(String url, InputStream is) throws IOException
  • byte[] getFileData(String url) throws IOException
  • void createDir(String url) throws IOException
  • void createDirIncludingAncestors(String url) throws IOException
  • boolean isDirectory(String url) throws IOException
  • void deleteDir(String url) throws IOException
  • String removeEncExtension(String url)
  • long getFileSize(String url) throws IOException
  • boolean isPresent(String url) throws IOException
  • boolean isSDCardAccessible()
  • boolean isDeviceMemoryAccessible()
  • long getDirectorySize(String url, boolean includeSubDirs) throws IOException
  • long getAvailableFileSystemSize(String url) throws IOException
  • String getFileIOExceptionInfo(FileIOException e)
  • long getTotalFileSystemSize(String url) throws IOException
  • long getUsedFileSystemSize(String url) throws IOException
  • long getUsedDeviceMemory() throws IOException
  • long getAvailableDeviceMemory() throws IOException
  • long getTotalDeviceMemory() throws IOException
  • long getUsedSDCardSize() throws IOException
  • long getAvailableSDCardSize() throws IOException
  • long getTotalSDCardSize() throws IOException
  • boolean isFileSystemFullException(Throwable e)
  • boolean isSDCardEncryptionEnabled() throws IOException

=== ImageUtils

Provides convenient methods for image manipulations:

  • EncodedImage resize(EncodedImage eImage, int toWidth, int toHeight, boolean keepAspectRatio)
  • EncodedImage getResizedImage(String imgUrl, int toWidth, int toHeight) throws IOException

=== Logger

A simple file logging facility.

  • void debug(Object o, String msg)
  • void debug(String msg)

See details on Logger usage here: http://github.com/cleverua/blackberry_logger

=== SoftwareVersionUtils

Provides OsVersion class that has convenient methods for OS (Sotfware) Version manipulations:

  • isEqualTo(OsVersion other)
  • isGreaterThan(OsVersion other)
  • isGreaterThanOrEquals(OsVersion other)
  • isLessThan(OsVersion other)
  • isLessThanOrEquals(OsVersion other)
  • isEqualTo(OsVersion other, int precision)
  • isGreaterThan(OsVersion other, int precision)
  • isGreaterThanOrEquals(OsVersion other, int precision)
  • isLessThan(OsVersion other, int precision)
  • isLessThanOrEquals(OsVersion other, int precision)

== EXAMPLES

Examples are not present. Though the source code contains UtilsTestingApplication it is not a demo/sample application. The application was created just to test the utils during development.