diff options
| author | njames <njames@us.ibm.com> | 2015-02-20 21:24:49 -0600 |
|---|---|---|
| committer | njames <njames@us.ibm.com> | 2015-02-20 21:24:49 -0600 |
| commit | 679c2de95cccdfb1e286537c59122b926924b6d3 (patch) | |
| tree | 9a832f9a8285dd3dc337e968dfb654f98682da22 /src | |
| parent | 68a30ab92ea9c927f6462cbd87549443f8523fc7 (diff) | |
| download | serverwiz-679c2de95cccdfb1e286537c59122b926924b6d3.tar.gz serverwiz-679c2de95cccdfb1e286537c59122b926924b6d3.zip | |
full project
Diffstat (limited to 'src')
| -rw-r--r-- | src/com/ibm/ServerWizard2/AttributeValidator.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/com/ibm/ServerWizard2/AttributeValidator.java b/src/com/ibm/ServerWizard2/AttributeValidator.java new file mode 100644 index 0000000..0a2ff0e --- /dev/null +++ b/src/com/ibm/ServerWizard2/AttributeValidator.java @@ -0,0 +1,41 @@ +package com.ibm.ServerWizard2; + +import org.eclipse.jface.viewers.ICellEditorValidator; + +public class AttributeValidator implements ICellEditorValidator { + Field f; + public AttributeValidator(Field f) { + this.f=f; + } + + public String isValid(Object arg0) { + String s = (String)arg0; + String rtn=null; + if (f.type.equals("uint8_t")) { + if (!this.isValidByte(s)) { + rtn="Invalid number format for uint8_t"; + } + } else if (f.type.equals("uint32_t") || f.type.equals("uint16_t")) { + if (!this.isValidInt(s)) { + rtn="Invalid number format for uint16_t or uint32_t"; + } + } + return rtn; + } + private boolean isValidByte(String s) { +/* try { + Byte.decode(s); + } catch (Exception e) { + return false; + }*/ + return true; + } + private boolean isValidInt(String s) { + try { + Integer.decode(s); + } catch (Exception e) { + return false; + } + return true; + } +} |

