⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 item.java

📁 OBPM是一个开源
💻 JAVA
字号:
// Source file:
// C:\\Java\\workspace\\SmartWeb3\\src\\com\\cyberway\\dynaform\\document\\ejb\\Item.java

package cn.myapps.core.dynaform.document.ejb;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;

import cn.myapps.base.action.BlobFileObject;
import cn.myapps.util.DateUtil;
import cn.myapps.util.StringList;
import cn.myapps.util.StringUtil;

/**
 * @hibernate.class table="T_ITEM"
 * 
 */
public class Item {
	public static final String VALUE_TYPE_VARCHAR = "VALUE_TYPE_VARCHAR";

	public static final String VALUE_TYPE_NUMBER = "VALUE_TYPE_NUMBER";

	public static final String VALUE_TYPE_DATE = "VALUE_TYPE_DATE";

	public static final String VALUE_TYPE_BLOB = "VALUE_TYPE_BLOB";

	public static final String VALUE_TYPE_TEXT = "VALUE_TYPE_TEXT";

	public static final String VALUE_TYPE_STRINGLIST = "VALUE_TYPE_STRINGLIST";

	public static final String VALUE_TYPE_INCLUDE = "VALUE_TYPE_INCLUDE";

	public static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat(
			"00000000000000000000.000000");

	public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
			"yyyy-MM-dd hh:mm:ss");
	
	public static final SimpleDateFormat DATE_FORMAT_SHORT = new SimpleDateFormat(
	"yyyy-MM-dd hh:mm:ss");

	private Document document;

	private String id;

	private Date lastModified;

	private boolean isHidden;

	/**
	 * 字段名称
	 */
	private String name;

	private String type;

	private boolean isbrief;

	private int orderno;

	private String formname;

	private boolean issubformvalue;

	private String varcharvalue;

	private Double numbervalue;

	private BlobFileObject blobvalue;

	private String textvalue;

	private Date datevalue;

	private boolean isChanged;

	public boolean isChanged() {
		return isChanged;
	}

	public void setChanged(boolean isChanged) {
		this.isChanged = isChanged;
	}

	/**
	 * @hibernate.property column="TYPE"
	 * @return
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param valuetype
	 *            The valuetype to set.
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @hibernate.component class="cn.myapps.base.action.BlobFileObject"
	 *                      prefix="CONTENT"
	 */
	public BlobFileObject getBlobvalue() {
		return blobvalue;
	}

	/**
	 * @param blobvalue
	 *            The blobvalue to set.
	 */
	public void setBlobvalue(BlobFileObject blobvalue) {
		this.blobvalue = blobvalue;
	}

	/**
	 * @hibernate.property column="NUMBERVALUE"
	 * @return Returns the numbervalue.
	 */
	public Double getNumbervalue() {
		if (getType().equals(VALUE_TYPE_NUMBER)) {
			return numbervalue;
		} else {
			String tmp = null;
			if (getType().equals(VALUE_TYPE_VARCHAR)) {
				tmp = varcharvalue;
			} else if (getType().equals(VALUE_TYPE_TEXT)) {
				tmp = textvalue;
			}
			if (tmp != null) {
				try {
					return Double.valueOf(tmp);
				} catch (Exception e) {
				}
			}
		}
		return null;
	}

	/**
	 * @param numbervalue
	 *            The numbervalue to set.
	 */
	public void setNumbervalue(Double numbervalue) {
		this.numbervalue = numbervalue;
	}

	/**
	 * @hibernate.property column="VARCHARVALUE"
	 * @return Returns the numbervalue.
	 */
	public String getVarcharvalue() {
		if (getType().equals(VALUE_TYPE_VARCHAR)) {
			if (varcharvalue != null && varcharvalue.length() > 255) {
				return varcharvalue.substring(0, 255);
			} else {
				return varcharvalue;
			}

		} else if (getType().equals(VALUE_TYPE_NUMBER)) {
			Double num = getNumbervalue();
			return num != null ? DECIMAL_FORMAT.format(num) : "";
		} else if (getType().equals(VALUE_TYPE_DATE)) {
			Date dt = getDatevalue();
			if (dt != null) {
				return DATE_FORMAT.format(dt);
			}
		} else if (getType().equals(VALUE_TYPE_TEXT)) {
			String text = getTextvalue();
			if (text != null && text.length() > 255) {
				return text.substring(0, 255);
			} else {
				return text;
			}

		} else if (getType().equals(VALUE_TYPE_BLOB)) {
			BlobFileObject bv = getBlobvalue();
			if (bv != null) {
				return bv.toString();
			}
		}
		return null;
	}

	/**
	 * @param varcharvalue
	 *            The varcharvalue to set.
	 */
	public void setVarcharvalue(String varcharvalue) {
		this.varcharvalue = varcharvalue;
	}

	/**
	 * @hibernate.property column="TEXTVALUE" type="text"
	 * @return
	 */
	public String getTextvalue() {
		if (getType().equals(VALUE_TYPE_TEXT)) {
			return textvalue;
		} else {
			return getVarcharvalue();
		}
	}

	/**
	 * @param varcharvalue
	 *            The varcharvalue to set.
	 */
	public void setTextvalue(String textvalue) {
		this.textvalue = textvalue;
	}

	/**
	 * @roseuid 41ECB656005D
	 */
	public Item() {
		type = VALUE_TYPE_VARCHAR;
	}

	public Object getValue() {
		if (getType().equals(VALUE_TYPE_VARCHAR)) {
			return getVarcharvalue();
		} else if (getType().equals(VALUE_TYPE_NUMBER)) {
			return getNumbervalue();
		} else if (getType().equals(VALUE_TYPE_DATE)) {
			return getDatevalue();
		} else if (getType().equals(VALUE_TYPE_TEXT)) {
			return getTextvalue();
		} else if (getType().equals(VALUE_TYPE_BLOB)) {
			return getBlobvalue();
		}
		return null;
	}

	/**
	 * @hibernate.many-to-one column="DOC_ID"
	 *                        class="cn.myapps.core.dynaform.document.ejb.Document"
	 * 
	 */
	public Document getDocument() {
		return document;
	}

	public void setDocument(Document document) {
		this.document = document;
	}

	/**
	 * @hibernate.id column="ID" generator-class="assigned"
	 */
	public String getId() {
		return id;
	}

	/**
	 * @param id
	 *            The id to set.
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @hibernate.property column="LASTMODIFIED"
	 * @return
	 */
	public Date getLastModified() {
		return lastModified;
	}

	/**
	 * @param lastModified
	 *            The lastModified to set.
	 */
	public void setLastModified(Date lastModified) {
		this.lastModified = lastModified;
	}

	/**
	 * @hibernate.property column="NAME"
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            The name to set.
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @hibernate.property column="DATEVALUE"
	 * @return Returns the datevalue.
	 */
	public Date getDatevalue() {
		if (getType().equals(VALUE_TYPE_DATE)) {
			return datevalue;
		} else {
			String tmp = null;
			if (getType().equals(VALUE_TYPE_VARCHAR)) {
				tmp = varcharvalue;
			} else if (getType().equals(VALUE_TYPE_TEXT)) {
				tmp = textvalue;
			}
			if (tmp != null) {
				try {
					return new Date(DATE_FORMAT.parse(tmp).getTime());
				} catch (Exception e) {
					try {
						return new Date(DATE_FORMAT_SHORT.parse(tmp).getTime());
					} catch (Exception e2) {
					}
				}
			}
		}
		return null;
	}

	/**
	 * @param datevalue
	 *            The datevalue to set.
	 */
	public void setDatevalue(Date datevalue) {
		this.datevalue = datevalue;
	}

	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("<name>");
		sb.append(name);
		sb.append("<value>");
		sb.append(getValue() + "");
		return sb.toString();
	}

	/**
	 * @hibernate.property column="ISBRIEF"
	 * @return
	 */
	public boolean getIsbrief() {
		return isbrief;
	}

	/**
	 * @param isbrief
	 *            The isbrief to set.
	 */
	public void setIsbrief(boolean isbrief) {
		this.isbrief = isbrief;
	}

	/**
	 * @hibernate.property column="ISSUBFORMVALUE"
	 * @return
	 */
	public boolean getIssubformvalue() {
		return issubformvalue;
	}

	/**
	 * @param issubformvalue
	 *            The issubformvalue to set.
	 */
	public void setIssubformvalue(boolean issubformvalue) {
		this.issubformvalue = issubformvalue;
	}

	/**
	 * @hibernate.property column="ORDERNO"
	 * @return
	 */
	public int getOrderno() {
		return orderno;
	}

	/**
	 * @param orderno
	 *            The orderno to set.
	 */
	public void setOrderno(int orderno) {
		this.orderno = orderno;
	}

	/**
	 * @param value
	 *            The value to set.
	 */
	public void setValue(Object value) {// 存在问题
		if (value == null) {
			// Nothing to do
		} else if (this.getType().equals(Item.VALUE_TYPE_VARCHAR)) {
			this.setVarcharvalue(value + "");
		} else if (this.getType().equals(Item.VALUE_TYPE_TEXT)) {
			this.setTextvalue(value + "");
		} else if (value != null && this.getType().equals(Item.VALUE_TYPE_DATE)) {
			if (value instanceof Date) {
				this.setDatevalue((Date) value);
			} else if (value instanceof String) {
				try {
					this.setDatevalue(new Date(DateUtil.parseDate(
							(String) value).getTime()));
				} catch (Exception e) {
					this.setDatevalue(null);
				}
			}
		} else if (value != null && this.getType().equals(Item.VALUE_TYPE_BLOB)) {
			if (value instanceof byte[]) {
				this.setBlobvalue((BlobFileObject) value);
			}
		} else if (value != null
				&& this.getType().equals(Item.VALUE_TYPE_NUMBER)) {
			Double d = new Double(0.0);
			if (value instanceof Number) {
				d = new Double(((Number) value).doubleValue());
			} else if (value instanceof String) {
				if (StringUtil.isNumber((String) value)) {
					d = Double.valueOf((String) value);
				}
			}
			this.setNumbervalue(d);
		}
	}

	/**
	 * @hibernate.property column="FORMNAME"
	 * @return
	 */
	public String getFormname() {
		return formname;
	}

	/**
	 * @param formname
	 *            The formname to set.
	 */
	public void setFormname(String formname) {
		this.formname = formname;
	}

	public Object[] getValueArray() {
		// if (true) {
		// return new String[]{"1","2","3"};
		// }
		if (this.getIssubformvalue() && this.getVarcharvalue() != null) {
			if (this.getVarcharvalue().length() == 0) {
				return new Object[0];
			}

			StringList sl = new StringList(this.getVarcharvalue());
			Collection vc = sl.toCollection();

			Object[] rtn = new Object[vc.size()];
			Iterator iter = vc.iterator();
			int i = 0;
			while (iter.hasNext()) {
				String v = (String) iter.next();
				if (type.equals(VALUE_TYPE_VARCHAR)) {
					rtn[i] = v;
				} else if (type.equals(VALUE_TYPE_NUMBER)) {
					try {
						rtn[i] = Double.valueOf(v);
					} catch (Exception e) {
						rtn[i] = new Double(0.0);
					}
				} else if (type.equals(VALUE_TYPE_DATE)) {
					try {
						rtn[i] = DateUtil.parseDate(v);
					} catch (Exception e) {
					}
				} else if (type.equals(VALUE_TYPE_TEXT)) {
					rtn[i] = v;
				}
				i++;
			}

			return rtn;

		} else {
			return null;
		}

	}

	public boolean isHidden() {
		return isHidden;
	}

	public void setHidden(boolean isHidden) {
		this.isHidden = isHidden;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -