org.walluck.oscar
Class AIMUtil

java.lang.Object
  extended by org.walluck.oscar.AIMUtil

public class AIMUtil
extends Object

AIM utilities.

Since:
1.0
Version:
1.0
Author:
David Walluck

Constructor Summary
AIMUtil()
           
 
Method Summary
static String about()
          Print about information.
static byte[] byteArrayFromHexString(String s)
          Turn a hex string into the corresponding byte array.
static String byteArrayToHexString(byte[] b)
          Turn a byte array into the corresponding string.
static String charsetAOLToJava(int charset)
          Given a short value indicating the charset code, return the corresponding Java string indicating the charset.
static String charsetAOLToJava(String charset)
          Given a string indicating the charset, return the corresponding Java string indicating the charset.
static String convertHTMLToOSCAR(String str)
          Convert from HTML to OSCAR markup
static String convertOSCARToHTML(String str)
          Convert from OSCAR markup to HTML
static String dirAOLToSys(String name)
          Convert an AOL style directory name to system.
static String dirSysToAOL(String name)
          Convert a system style directory name to AOL.
static String extractRoomName(String s)
          Extract the name from a Chat name.
static String flapChannelToString(int channel)
          Print the plain-text description of a FLAP channel.
static String getLibraryDate()
          Get the library date.
static String getLibraryVersion()
          Get the library version.
static String hexdump(byte[] data)
          Returns a string representing a hex dump of the given byte array.
static String memInfo()
          Print Java runtime memory information before and after garbage collection.
static String normalize(String sn)
          Normalizes a screenname (removes spaces and lowercases all letters).
static String parseProfileEncoding(String enc)
          Parse a profile encoding string.
static String prettyPrintTime(long time)
          Convert the time elapsed in milliseconds to a pretty string.
static String snacErrorToString(int error)
          Return the plain-text description of a SNAC error.
static String snacToString(int family, int subtype)
          Return the plain-text description of a SNAC given a family and subtype.
static boolean snCmp(String sn1, String sn2)
          Checks two given screennames for equality.
static int snLen(String sn)
          Return the length of the given screenname (ignoring spaces).
static byte[] uuidToByteArray(String uuid)
          This lets us turn a UUID (Universally Uninque Identifier) string into a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AIMUtil

public AIMUtil()
Method Detail

getLibraryVersion

public static String getLibraryVersion()
Get the library version.

Returns:
the library version

getLibraryDate

public static String getLibraryDate()
Get the library date.

Returns:
the library date

snLen

public static int snLen(String sn)
Return the length of the given screenname (ignoring spaces).

Parameters:
sn - the screenname
Returns:
the length of the screenname

normalize

public static String normalize(String sn)
Normalizes a screenname (removes spaces and lowercases all letters).

Parameters:
sn - the non-normalized screenname
Returns:
the screenname after it has been normalized

snCmp

public static boolean snCmp(String sn1,
                            String sn2)
Checks two given screennames for equality.

Parameters:
sn1 - the first screenname
sn2 - the second screenname
Returns:
true if the screennames are equal, false if the screennames are not equal

byteArrayFromHexString

public static byte[] byteArrayFromHexString(String s)
Turn a hex string into the corresponding byte array.

Parameters:
s - the hex string to convert
Returns:
a byte array

byteArrayToHexString

public static String byteArrayToHexString(byte[] b)
Turn a byte array into the corresponding string.

Parameters:
b - the byte array to convert
Returns:
a string

uuidToByteArray

public static byte[] uuidToByteArray(String uuid)
This lets us turn a UUID (Universally Uninque Identifier) string into a byte array.

Parameters:
uuid - the UUID string
Returns:
the corresponding byte array

about

public static String about()
Print about information.

Returns:
about information

memInfo

public static String memInfo()
Print Java runtime memory information before and after garbage collection.

Returns:
memory information

flapChannelToString

public static String flapChannelToString(int channel)
Print the plain-text description of a FLAP channel.

Parameters:
channel - the FLAP channel
Returns:
a String value

snacToString

public static String snacToString(int family,
                                  int subtype)
Return the plain-text description of a SNAC given a family and subtype.

Parameters:
family - the SNAC family
subtype - the SNAC subtype
Returns:
the SNAC description

snacErrorToString

public static String snacErrorToString(int error)
Return the plain-text description of a SNAC error.

Parameters:
error - the error code
Returns:
the SNAC error

extractRoomName

public static String extractRoomName(String s)
Extract the name from a Chat name. Looks like "!aol://number:number-number-name".

Parameters:
s - the Chat name
Returns:
the extracted name

dirAOLToSys

public static String dirAOLToSys(String name)
Convert an AOL style directory name to system.

Parameters:
name - the filename
Returns:
the directory with system separators

dirSysToAOL

public static String dirSysToAOL(String name)
Convert a system style directory name to AOL.

Parameters:
name - the filename
Returns:
the directory with AOL separators (0x01)

prettyPrintTime

public static String prettyPrintTime(long time)
Convert the time elapsed in milliseconds to a pretty string.

Parameters:
time - the time elapsed in milliseconds
Returns:
the pretty string

hexdump

public static String hexdump(byte[] data)
Returns a string representing a hex dump of the given byte array.

Parameters:
data - the byte array of the data you want to hex dump
Returns:
a string representing the hex dump of the given byte array

convertHTMLToOSCAR

public static String convertHTMLToOSCAR(String str)
Convert from HTML to OSCAR markup

Parameters:
str - the string to convert
Returns:
OSCAR markup

convertOSCARToHTML

public static String convertOSCARToHTML(String str)
Convert from OSCAR markup to HTML

Parameters:
str - the string to convert
Returns:
valid HTML

parseProfileEncoding

public static String parseProfileEncoding(String enc)
Parse a profile encoding string. For example, 'aol-rtf; charset="us-ascii"'.

Parameters:
enc - the profile encoding
Returns:
the AOL text encoding string, or "us-ascii" if none is found

charsetAOLToJava

public static String charsetAOLToJava(int charset)
                               throws UnsupportedEncodingException
Given a short value indicating the charset code, return the corresponding Java string indicating the charset.

Parameters:
charset - the short value indicating the charset
Returns:
the string representing the corresponding Java charset
Throws:
UnsupportedEncodingException - if an error occurs

charsetAOLToJava

public static String charsetAOLToJava(String charset)
                               throws UnsupportedEncodingException
Given a string indicating the charset, return the corresponding Java string indicating the charset.

Parameters:
charset - the string indicating the charset
Returns:
the string representing the corresponding Java charset
Throws:
UnsupportedEncodingException - if an error occurs