return true;\r
}\r
\r
+ /**\r
+ Check if the input data is long int and it is in the valid scope\r
+ The scope is provided by String\r
+ \r
+ @param strNumber The input string which needs validation\r
+ @param BeginNumber The left boundary of the scope\r
+ @param EndNumber The right boundary of the scope\r
+ \r
+ @retval true - The input is Int and in the scope;\r
+ @retval false - The input is not Int or not in the scope\r
+ \r
+ **/\r
+ public static boolean isLongInt(String strNumber, long BeginNumber, long EndNumber) throws Exception{\r
+ //\r
+ //Check if the input data is int first\r
+ //\r
+ if (!isInt(strNumber)) {\r
+ return false;\r
+ }\r
+ //\r
+ //And then check if the data is between the scope\r
+ //\r
+ try {\r
+ Long intTemp = new Long(strNumber);\r
+ if ((intTemp.longValue() < BeginNumber) || (intTemp.longValue() > EndNumber)) {\r
+ return false;\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ throw e;\r
+ }\r
+ \r
+ return true;\r
+ }\r
/**\r
Check if the input data is int and it is in the valid scope\r
The scope is provided by String\r
jCheckBoxFeatureFlag.isSelected(), jCheckBoxFixedAtBuild.isSelected(),\r
jCheckBoxPatchInMod.isSelected(), jCheckBoxDyn.isSelected(), jCheckBoxDynEx.isSelected(),\r
archList, modTypeList};\r
- if (!dataValidation(row)) {\r
- return;\r
- }\r
- \r
- if (tokenCNameExisted(jTextFieldToken.getText(), jTextFieldC_Name.getText())) {\r
- return;\r
- }\r
+ try {\r
+ if (!dataValidation(row)) {\r
+ return;\r
+ }\r
+\r
+ if (tokenCNameExisted(jTextFieldToken.getText(),jTextFieldC_Name.getText())) {\r
+ return;\r
+ }\r
+ } catch (Exception e) {\r
+ JOptionPane.showMessageDialog(frame, "Illegal Token:"+ e.getCause());\r
+ return;\r
+ }\r
\r
model.addRow(row);\r
jTable.changeSelection(model.getRowCount()-1, 0, false, false);\r
}\r
\r
Object[] o = {cName, token, ts, dataType, defaultVal, help};\r
- if (!dataValidation(o)){\r
- return;\r
+ try {\r
+ if (!dataValidation(o)){\r
+ return;\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ JOptionPane.showMessageDialog(frame, "Illegal Token:" + e.getCause());\r
+ return;\r
}\r
docConsole.setSaved(false);\r
sfc.updateSpdPcdDefinition(row, cName, token, dataType, usage, ts, defaultVal, help, archList, modTypeList);\r
return usage.trim();\r
}\r
\r
- private boolean tokenCNameExisted(String token, String cName) {\r
- Integer inputToken = Integer.decode(token);\r
+ private boolean tokenCNameExisted(String token, String cName) throws Exception{\r
+ Long inputToken = Long.decode(token);\r
\r
- for (int i = 0; i < jTable.getRowCount(); ++i) {\r
- if (jTable.getValueAt(i, 0).equals(cName)) {\r
+ for (int i = 0; i < model.getRowCount(); ++i) {\r
+ if (model.getValueAt(i, 0).equals(cName)) {\r
JOptionPane.showMessageDialog(frame, "C_Name already existed in table.");\r
return true;\r
}\r
- if (jTable.getValueAt(i, 1).equals(token)) {\r
+ if (model.getValueAt(i, 1).equals(token)) {\r
JOptionPane.showMessageDialog(frame, "Token already existed in table.");\r
return true;\r
}\r
- Integer tokenValue = Integer.decode(jTable.getValueAt(i, 1)+"");\r
+ Long tokenValue = Long.decode(model.getValueAt(i, 1)+"");\r
if (tokenValue.equals(inputToken)) {\r
JOptionPane.showMessageDialog(frame, "Same token value already existed in table.");\r
return true;\r
}\r
return true;\r
}\r
- private boolean dataValidation(Object[] row) {\r
+ private boolean dataValidation(Object[] row) throws Exception{\r
\r
if (!DataValidation.isC_NameType(row[0].toString())) {\r
JOptionPane.showMessageDialog(frame, "C_Name is NOT C_NameType.");\r
return false;\r
}\r
if (!DataValidation.isHexDoubleWordDataType(row[1].toString()) && \r
- !DataValidation.isInt(row[1].toString(), Integer.MIN_VALUE, Integer.MAX_VALUE)) {\r
+ !DataValidation.isLongInt(row[1].toString(), 1, Long.MAX_VALUE)) {\r
JOptionPane.showMessageDialog(frame, "Token is NOT correct.");\r
return false;\r
}\r