OpenAPI 1.0

com.aquafold.openapi.util
Interface AQUtil


public interface AQUtil

A utility class available in AquaScript environment. This class provides a number of convenient methods for development and debugging.

A singleton instance of this class is mapped to a global name aqua.util.


Method Summary
 String formatByteSize(double bytes, String format, int decimalPos)
          Formats size of files into something more readable.
 String formatTimeInterval(long interval)
          Formats time interval into human-readable form.
 byte[] hexDecode(String data)
          Converts an array of characters representing hexidecimal values into an array of bytes of those same values.
 String hexEncode(byte[] data)
          Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order.
 String htmlDecode(String text)
          Unescapes a string containing HTML entity escapes to a string containing the actual Unicode characters corresponding to the escapes.
 String htmlEncode(String text)
          Escapes the characters in a String using HTML entities.
 boolean isBlank(Object text)
          Returns true if argument text is empty or contains only whitespace symbols.
 Object newJavaArray(String type, int length)
          Creates a new java array with the specified component type and length.
 void sleep(int ms)
          Causes script to sleep for a specified number of milliseconds.
 String sqlEncode(String string)
          Escapes single quote characters in a string to make it safe for inclusion into a SQL query.
 String urlEncode(String string)
          Translates a string into x-www-form-urlencoded format.
 

Method Detail

sleep

void sleep(int ms)
           throws Exception
Causes script to sleep for a specified number of milliseconds.

Parameters:
ms - Delay in milliseconds.
Throws:
Exception

isBlank

boolean isBlank(Object text)
Returns true if argument text is empty or contains only whitespace symbols.

Parameters:
text - A text string or AQOpaqueObject.

formatTimeInterval

String formatTimeInterval(long interval)
Formats time interval into human-readable form. Example: "2h 46m 40s"

Parameters:
interval - Time interval in milliseconds.

formatByteSize

String formatByteSize(double bytes,
                      String format,
                      int decimalPos)
                      throws Exception
Formats size of files into something more readable. If descimalPos is not specified or is 0, the return value will be rounded up. Example: 1024 bytes; 1 KB; 0.001 MB

Parameters:
bytes - The value to be formatted.
format - Valid string values are "B", "KB", "MB", "GB", "TB"
decimalPos - Sets the maximum number of digits allowed in the fraction portion of a number.
Returns:
String representation of the formatted size.
Throws:
Exception - on error

urlEncode

String urlEncode(String string)
Translates a string into x-www-form-urlencoded format. This method uses UTF-8 encoding to obtain the bytes for unsafe characters.

Parameters:
string - A string to be encoded.

sqlEncode

String sqlEncode(String string)
Escapes single quote characters in a string to make it safe for inclusion into a SQL query.

Parameters:
string - A string to be encoded.

htmlEncode

String htmlEncode(String text)
Escapes the characters in a String using HTML entities.

Parameters:
text - Text string.

htmlDecode

String htmlDecode(String text)
Unescapes a string containing HTML entity escapes to a string containing the actual Unicode characters corresponding to the escapes.

Parameters:
text - Encoded text string.

newJavaArray

Object newJavaArray(String type,
                    int length)
                    throws Exception
Creates a new java array with the specified component type and length. Example:

aqua.util.newJavaArray('java.lang.String', 100);
aqua.util.newJavaArray('byte', 0);

Parameters:
type - Fully qualified name of a Class representing the component type of the new array.
length - The length of the new array.
Returns:
The new array.
Throws:
Exception

hexEncode

String hexEncode(byte[] data)
Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order. The returned array will be double the length of the passed array, as it takes two characters to represent any given byte.

Parameters:
data - a byte[] to convert to Hex characters.
Returns:
A char[] containing hexidecimal characters.

hexDecode

byte[] hexDecode(String data)
                 throws Exception
Converts an array of characters representing hexidecimal values into an array of bytes of those same values. The returned array will be half the length of the passed array, as it takes two characters to represent any given byte. An exception is thrown if the passed char array has an odd number of elements.

Parameters:
data - An array of characters containing hexidecimal digits
Returns:
A byte array containing binary data decoded from the supplied char array.
Throws:
Exception

OpenAPI 1.0


Copyright © 2010 AquaFold, Inc. All Rights Reserved. Use is subject to license terms.