if (keyDef.startsWith("0x")) {
try {
this.keyCode = Integer.parseInt(keyDef.substring(2), 16);
} catch (Throwable t) {
Debug.logError(t, module);
throw new JposException(JposConst.JPOS_E_ILLEGAL, "Illegal hex code key definition [" + keyName + "]");
}
} else if (keyDef.startsWith("VK_")) {
try {
Field kef = KeyEvent.class.getField(keyDef);
this.keyCode = kef.getInt(kef);
} catch (Throwable t) {
Debug.logError(t, module);
throw new JposException(JposConst.JPOS_E_ILLEGAL, "Illegal virtual key definition [" + keyName + "]");
}
} else {
try {
this.keyCode = Integer.parseInt(keyDef);
} catch (Throwable t) {
Debug.logError(t, module);
throw new JposException(JposConst.JPOS_E_ILLEGAL, "Illegal key code definition [" + keyName + "]");
}
}
// set the key modifiers
String[] modifiers = null;
if (keyMod != null && keyMod.length() > 0) {
if (keyMod.indexOf("+") != -1) {
modifiers = keyMod.split("\\+");
} else {
modifiers = new String[1];
modifiers[0] = keyMod;
}
for (int i = 0; i < modifiers.length; i++) {
if ("SHIFT".equalsIgnoreCase(modifiers[i])) {
this.shift = true;
} else {
this.shift = false;
}
if ("CTRL".equalsIgnoreCase(modifiers[i])) {
this.ctrl = true;
} else {
this.ctrl = false;
}
if ("ALT".equalsIgnoreCase(modifiers[i])) {
this.alt = true;
this.alt = false;
}
}
}
// set the mapped value
if (UtilValidate.isNotEmpty(mappedValue)) {
try {
this.mappedCode = Integer.parseInt(mappedValue);
} catch (Throwable t) {
Debug.logError(t, module);
throw new JposException(JposConst.JPOS_E_ILLEGAL, "Illegal key code mapping [" + mappedValue + "]");
}
} else {
this.mappedCode = keyCode;
}
}