// See if there are character ranges (eg [0-9]) which are legal in
// Forte but not in java
m = optionalCharacters.matcher(aBuffer.toString());
if (m.find()) {
_log.debug("Java templates have no equivalent to character ranges in Forte (" + m.group(2) + " entered)");
UsageException errorVar = new UsageException("Java templates have no equivalent to character ranges in Forte (" + m.group(2) + " entered)");
ErrorMgr.addError(errorVar);
throw errorVar;
}
// Look for any unescaped brackets
m = repititionCount.matcher(aBuffer.toString());
while (m.find()) {
int count = Integer.parseInt(m.group(2));
int end = m.end(2);
char c = aBuffer.charAt(end + 1);
char[] repeatingChar = new char[count];
for (int i = 0; i < count; i++) {
repeatingChar[i] = c;
}
aBuffer.replace(m.start(2) - 1, end + 2, new String(repeatingChar));
m = repititionCount.matcher(aBuffer.toString());
}
// Now search through the string, looking for characters to
// translate and removing escapre characters
for (index = 0; index < aBuffer.length(); index++) {
switch (aBuffer.charAt(index)) {
case '\\':
// If the next character doesn't need escaping in the new
// mask then remove
// the escaping, else replace with the java escape character
// (')
switch (aBuffer.charAt(index + 1)) {
case '\\':
case 'a':
case '@':
case ')':
case '(':
case 'k':
case 'n':
case 'N':
case '&':
case '!':
aBuffer.deleteCharAt(index);
break;
default:
aBuffer.setCharAt(index, '\'');
}
break;
case '?':
aBuffer.setCharAt(index, '*');
break;
case 'a':
aBuffer.setCharAt(index, 'L');
break;
case 'A':
aBuffer.setCharAt(index, 'U');
break;
case '@':
aBuffer.setCharAt(index, '?');
break;
case '&':
aBuffer.setCharAt(index, 'A');
break;
case 'k':
UsageException errorVar = new UsageException("Java templates have no equivalent to the 'k' template character in Forte");
ErrorMgr.addError(errorVar);
throw errorVar;
case 'n':
// n isn't really an A, but it's pretty close