1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | package com.msi.ibm; // class to handle each individual form public class XmlGuiFormField { String name; String label; String type; boolean required; String options; Object obj; // holds the ui implementation // or the EditText for example // getters & setters public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLabel() { return label; } public void setLabel(String label) { this.label = label; } public String getType() { return type; } public void setType(String type) { this.type = type; } public boolean isRequired() { return required; } public void setRequired(boolean required) { this.required = required; } public String getOptions() { return options; } public void setOptions(String options) { this.options = options; } public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Field Name: " + this.name + "\n"); sb.append("Field Label: " + this.label + "\n"); sb.append("Field Type: " + this.type + "\n"); sb.append("Required? : " + this.required + "\n"); sb.append("Options : " + this.options + "\n"); sb.append("Value : " + (String) this.getData() + "\n"); return sb.toString(); } public String getFormattedResult() { return this.name + "= [" + (String) this.getData() + "]"; } public Object getData() { if (type.equals("text") || type.equals("numeric")) { if (obj != null) { XmlGuiEditBox b = (XmlGuiEditBox) obj; return b.getValue(); } } if (type.equals("choice")) { if (obj != null) { XmlGuiPickOne po = (XmlGuiPickOne) obj; return po.getValue(); } } // You could add logic for other UI elements here return null; } } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |