Example: Alphanumeric Name Sequences Using Java
import java.util.Vector;
public class AlphaNum implements rsdesigner.uiextension.AlphaNumericSequence
{
public String NumberToAlpha(String format_string, int serial_num)
{
char [] map = {'0', // 0
'1', // 1
'2', // 2
'3', // 3
'4', // 4
'5', // 5
'6', // 6
'7', // 7
'8', // 8
'9', // 9
'A', // 10
'B', // 11
'C', // 12
'D', // 13
'E', // 14
'F'}; // 15
String result = "";
String alpha = "";
String password = "#key#";
int n, base = map.length;
Vector digit_list = new Vector();
if ( format_string.indexOf(password) != -1 )
{
int first_idx = -1;
for ( n = serial_num; n >= base; n /= base )
{
int m = n % base;
digit_list.insertElementAt( new Integer(m), 0 );
}
digit_list.insertElementAt( new Integer(n), 0 );
for ( int i = 0; i < digit_list.size(); i++ )
alpha += map[ ((Integer)digit_list.elementAt(i)).intValue() ];
while ( (first_idx = format_string.indexOf(password)) != -1 )
{
int end_idx = first_idx + password.length();
result = format_string.substring( 0, first_idx );
result += alpha;
result += format_string.substring( end_idx,
format_string.length() );
format_string = result;
}
}
return format_string;
}
}