Framework Utilities (Aspire 2)

From wiki.searchtechnologies.com
Jump to: navigation, search

For Information on Aspire 3.1 Click Here

The Aspire Framework Utilities Package contains a number of useful utilities for Aspire component programmers.

Inside this package, you will find a number of useful Java classes for doing all sorts of interesting things. All of these classes have static methods which you can use at any time.

Base32Utilities

Encode data to and decode data from Base32.

Base64Utilities

Encode data to and decode data from Base64.

DateTimeUtilities

Utilities to convert to and from ISO8601 format (the official date format used within Aspire).

Also utilities such as DateTimeUtilities.HOURS(n), DateTimeUtilities.MINUTES(n), and DateTimeUtilities.SECONDS(n) which produce the number of milliseconds required for the specified time duration (since ms is the standard method for specifying timeouts throughout Aspire).

DBUtilities

Currently only has a single method to load the JDBC driver jar.

FileUtilities

Methods include:

  • Copying data from one stream to another, or from an input stream to a file
    • Implements a nested loop which reads buffers of bytes from the input and writes them to the output
  • Deleting directories and all of their sub-directories and sub-files
  • Converting byte counts to KILOBYTES and MEGABYTES

PropertyUtilities

Mostly property conversions from different formats (Maps, AspireObject, and XML W3C DOM Element objects).

SecurityUtilities

Methods for encrypting and decrypting passwords.

StringUtilities

Contains:

  • Null-safe string methods (such as equals, default string, empty string)
  • Checking strings for all digits, alphas, punctuation, lower-case letters, or upper-case letters
  • Joining lists of strings together, each one separated with a separator
  • HTML escaping
  • String to MD5

Utilities

Other utilities which don't fit into the other categories already identified. Including:

  • getApplication() - Fetch the AspireApplication, only available when running inside an Aspire Server
  • getApplicationFromClass() - Fetch an AspireApplication, also works inside of Unit Tests
  • Fetching the Aspire settings.xml and properties from this file
  • Information about the hardware environment (isWindows(), is64Bit())
  • Methods for updating the auto-start portion of the settings.xml file

XMLUtilities

Methods for checking for illegal XML characters (from character streams and for single-characters), so they can be removed from XML streams before they are parsed with SAX.

These methods allow for parsing of dirty files with SAX parsers and the like.