xfelement.java
来自「j2me mobile application for upload file 」· Java 代码 · 共 182 行
JAVA
182 行
package org.celllife.clforms.api;
import java.util.Calendar;
import java.util.Date;
import org.celllife.clforms.Constants;
import de.enough.polish.util.HashMap;
public class XFElement {
//attributes
private String id;
private String label;
private String hintText;
private int dataType;
private String xpathBinding;
private Object value;
private HashMap select;
private boolean required;
private int selectedIndex;
public XFElement() {
super();
}
public XFElement(String id, String label, String hintText, int dataType, String xpathBinding, Object value, boolean required) {
super();
this.id = id;
this.label = label;
this.hintText = hintText;
this.dataType = dataType;
this.xpathBinding = xpathBinding;
this.value = value;
this.required = required;
this.selectedIndex = -1;
}
public XFElement(String id, String label, String hintText, int dataType, String xpathBinding, Object value) {
super();
this.id = id;
this.label = label;
this.hintText = hintText;
this.dataType = dataType;
this.xpathBinding = xpathBinding;
this.value = value;
this.selectedIndex = -1;
}
public int getDataType() {
return dataType;
}
public void setType(int dataType) {
this.dataType = dataType;
}
public String getHintText() {
return hintText;
}
public void setHintText(String hintText) {
this.hintText = hintText;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public String getXpathBinding() {
return xpathBinding;
}
public void setXpathBinding(String xpathBinding) {
this.xpathBinding = xpathBinding;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public HashMap getSelect() {
return select;
}
public void setSelect(HashMap select) {
// TODO check how this object passed?
this.select = new HashMap();
this.select = select;
}
public boolean isRequired() {
return required;
}
public void setRequired(boolean required) {
this.required = required;
}
public int getSelectedIndex() {
return selectedIndex;
}
public void setSelectedIndex(int selectedIndex) {
this.selectedIndex = selectedIndex;
}
public void setDataType(int dataType) {
this.dataType = dataType;
}
/**
* Returns the string value of the element.
* @return
*/
public String getStringValue() {
String stringValue = "";
if (value == null)
return stringValue;
switch (dataType) {
case Constants.DATE:
Date d = (Date) value;
Calendar cd = Calendar.getInstance();
cd.setTime(d);
String year = "" + cd.get(Calendar.YEAR);
String month = "" + cd.get(Calendar.MONTH);
String day = "" + cd.get(Calendar.DAY_OF_MONTH);
if (month.length()<2)
month = "0" + month;
if (day.length()<2)
day = "0" + day;
stringValue = year + "-" + month + "-" + day;
break;
default:
stringValue = value.toString();
}
return stringValue;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?