`

dhtmlx的pojo

 
阅读更多

 

Grid

 

public class DhtmlxGridRow {
	Object id;
	Object data;
	public Object getId() {
		return id;
	}
	public void setId(Object id) {
		this.id = id;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
	
	
	
	
}

 

 

 

import java.util.ArrayList;
import java.util.List;

public class DhtmlxGridTable {
	List<DhtmlxGridRow> rows;
	int total_count;
	int pos;

	public int getPos() {
		return pos;
	}

	public void setPos(int pos) {
		this.pos = pos;
	}

	public int getTotal_count() {
		return total_count;
	}

	public void setTotal_count(int total_count) {
		this.total_count = total_count;
	}

	public List<DhtmlxGridRow> getRows() {
	  if(rows ==null){
	    rows = new ArrayList<DhtmlxGridRow>();
	  }
		return rows;
	}

	public void setRows(List<DhtmlxGridRow> rows) {
		this.rows = rows;
	}
}

 

 

Tree

 

import java.io.Serializable;
import java.util.List;

/**
 * @Description:DhtmlxTree节点类
 * 
 * 
 * @Version: 1.0
 * 
 */
public class DhtmlxTreeItem implements Serializable {
	/**
	 * 2011-8-2
	 */
	private static final long serialVersionUID = 1L;
	public static Long ROOTID = 0L;// 要求树的根的id为0
	public static final String[] INCLUDE_SIMPLE = { "id", "text", "item" };
	public static final String[] INCLUDE_CHECKED = { "id", "text", "item",
			"checked" };
	public static final String[] INCLUDE_OPEN = { "id", "text", "item", "open" };
	public static final String[] INCLUDE_OPEN_CHECKED = { "id", "text", "item",
			"open", "checked" };
	public static final String[] INCLUDE_ALL = { "id", "text", "item", "open",
			"checked", "child", "im0", "im1", "im2", "aCol", "sCol", "style",
			"select", "call", "tooltip", "nocheckbox", "radio", "imheight",
			"imwidth", "topoffset" };

	private String id;// id of the node
	private String text;// label of the node
	private String im0;// image for a node without child items (tree will get
						// images from the path specified in setImagePath()
						// method)
	private String im1;// image for an expanded node with child items
	private String im2;// image for a collapsed node with child items
	private String aCol;// colour of an item that is not selected
	private String sCol;// colour of a selected item
	private String style;// text style of a node
	private String open;// show a node opened (any value)
	private String select;// select a node on load (any value)
	private String call;// call function on select(any value)
	private String tooltip;// tooltip of the node
	private String checked;// check checkbox if exists (in case of 3-state
							// checkboxes values can be 1 - checked or -1 -
							// unsure)
	private String nocheckbox;// instruct component, to not render checkbox for
								// related item, optional
	private String child;// specifies whether a node has child items (1) or not
							// (0)
	private String radio;// if not empty, child items of this node will have
							// radio buttons
	private int imheight;// height of the icon
	private int imwidth;// width of the icon
	private int topoffset;// offset of the item from the node above

	private List<DhtmlxTreeItem> item;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getIm0() {
		return im0;
	}

	public void setIm0(String im0) {
		this.im0 = im0;
	}

	public String getIm1() {
		return im1;
	}

	public void setIm1(String im1) {
		this.im1 = im1;
	}

	public String getIm2() {
		return im2;
	}

	public void setIm2(String im2) {
		this.im2 = im2;
	}

	public List<DhtmlxTreeItem> getItem() {
		return item;
	}

	public void setItem(List<DhtmlxTreeItem> item) {
		this.item = item;
	}

	public String getOpen() {
		return open;
	}

	public void setOpen(String open) {
		this.open = open;
	}

	public String getSelect() {
		return select;
	}

	public void setSelect(String select) {
		this.select = select;
	}

	public String getCall() {
		return call;
	}

	public void setCall(String call) {
		this.call = call;
	}

	public String getTooltip() {
		return tooltip;
	}

	public void setTooltip(String tooltip) {
		this.tooltip = tooltip;
	}

	public String getaCol() {
		return aCol;
	}

	public void setaCol(String aCol) {
		this.aCol = aCol;
	}

	public String getsCol() {
		return sCol;
	}

	public void setsCol(String sCol) {
		this.sCol = sCol;
	}

	public String getStyle() {
		return style;
	}

	public void setStyle(String style) {
		this.style = style;
	}

	public String getChecked() {
		return checked;
	}

	public void setChecked(String checked) {
		this.checked = checked;
	}

	public String getNocheckbox() {
		return nocheckbox;
	}

	public void setNocheckbox(String nocheckbox) {
		this.nocheckbox = nocheckbox;
	}

	public String getChild() {
		return child;
	}

	public void setChild(String child) {
		this.child = child;
	}

	public String getRadio() {
		return radio;
	}

	public void setRadio(String radio) {
		this.radio = radio;
	}

	public int getImheight() {
		return imheight;
	}

	public void setImheight(int imheight) {
		this.imheight = imheight;
	}

	public int getImwidth() {
		return imwidth;
	}

	public void setImwidth(int imwidth) {
		this.imwidth = imwidth;
	}

	public int getTopoffset() {
		return topoffset;
	}

	public void setTopoffset(int topoffset) {
		this.topoffset = topoffset;
	}

}
 

 

import java.util.ArrayList;
import java.util.List;

public class DhtmlxTreeGridRow {
  Object id;
  Object data;
  String xmlkids;
  List<DhtmlxTreeGridRow> rows;
  public Object getId() {
      return id;
  }
  public void setId(Object id) {
      this.id = id;
  }
  public Object getData() {
      return data;
  }
  public void setData(Object data) {
      this.data = data;
  }
  public List<DhtmlxTreeGridRow> getRows() {
    if(rows==null){
      rows = new ArrayList<DhtmlxTreeGridRow>();
    }
    return rows;
  }
  public void setRows(List<DhtmlxTreeGridRow> rows) {
    this.rows = rows;
  }
  public String getXmlkids() {
    return xmlkids;
  }
  public void setXmlkids(String xmlkids) {
    this.xmlkids = xmlkids;
  }
  
}
 

 

 

 

import java.util.ArrayList;
import java.util.List;

public class DhtmlxTreeGridTable {
  int total_count;
  int pos;
  List<DhtmlxTreeGridRow> rows;
  
  
  public int getTotal_count() {
    return total_count;
  }
  public void setTotal_count(int total_count) {
    this.total_count = total_count;
  }
  public int getPos() {
    return pos;
  }
  public void setPos(int pos) {
    this.pos = pos;
  }
  public List<DhtmlxTreeGridRow> getRows() {
    if(rows==null){
      rows = new ArrayList<DhtmlxTreeGridRow>();
    }
    return rows;
  }
  public void setRows(List<DhtmlxTreeGridRow> rows) {
    this.rows = rows;
  }
  
}
 

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

import org.apache.commons.lang.StringUtils;

import com.mogenesis.mobileadplatform.web.util.ArrayUtil;

/**
 * 
 * @Description: dhtmxTree JSON输出构建类,使用方法见
 *               
 * 
 * @Date: 2011-8-3 下午10:57:19
 * @Version: 1.0
 * 
 */
public class DhtmlxTreeBuilder {
	/**
	 * 递归构建json字符串
	 * 
	 * @param <T>
	 * @param root
	 * @param cb
	 * @return
	 */
	public static <T> String buildRecursiveJson(T root,
			DhtmlxTreeBuildCallback<T> cb) {
		DhtmlxTreeItem d = buildRecursive(root, cb);
		if (d == null) {
			return "{}";
		}
		String[] includeProperties = cb.includeProperties();
		String[] excludeProperties = cb.excludeProperties();
		Set<String> includes = null;
		if ((includeProperties != null) && (includeProperties.length > 0)) {
			includes = new TreeSet<String>();
			for (String property : includeProperties) {
				if (StringUtils.isNotEmpty(property)) {
					includes.add(property);
				}
			}
			if (includes.size() == 0)
				includes = null;
		}
		Set<String> excludes = null;
		if ((excludeProperties != null) && (excludeProperties.length > 0)) {
			excludes = new TreeSet<String>();
			for (String property : excludeProperties) {
				if (StringUtils.isNotEmpty(property)) {
					excludes.add(property);
				}
			}
			if (excludes.size() == 0) {
				excludes = null;
			}
		}
		JsonConfig config = null;
		if ((excludes == null) && (includes == null)) {
			return JSONObject.fromObject(d).toString();
		}
		Set<String> ex;
		if (includes != null) {
			ex = new HashSet<String>();
			for (String s : DhtmlxTreeItem.INCLUDE_ALL) {
				if (!(includes.contains(s)))
					ex.add(s);
			}
			if (ex.size() > 0) {
				config = new JsonConfig();
				config.setExcludes((String[]) ArrayUtil.toArray(ex));
			}
		}
		if (excludes != null) {
			config = new JsonConfig();
			config.setExcludes((String[]) ArrayUtil.toArray(excludes));
		}
		if ((excludes != null) && (includes != null)) {
			ex = new HashSet<String>();
			for (String s : DhtmlxTreeItem.INCLUDE_ALL) {
				if (excludes.contains(s))
					ex.add(s);
				else if (!(includes.contains(s)))
					ex.add(s);
			}
			if (ex.size() > 0) {
				config = new JsonConfig();
				config.setExcludes((String[]) ArrayUtil.toArray(ex));
			}
		}
		return ((String) JSONObject.fromObject(d, config).toString());
	}

	public static <T> DhtmlxTreeItem buildRecursive(T root,
			DhtmlxTreeBuildCallback<T> cb) {
		if ((root == null) || (cb == null)) {
			return null;
		}
		DhtmlxTreeItem dRoot = cb.getDhtmlxTreeItem(root);
		if (dRoot != null)
			buildRecursiveJson(root, dRoot, cb);
		return dRoot;
	}

	private static <T> void buildRecursiveJson(T t, DhtmlxTreeItem dT,
			DhtmlxTreeBuildCallback<T> cb) {
		T[] nodes = cb.getChildren(t);
		if ((nodes == null) || (nodes.length == 0))
			return;
		List<DhtmlxTreeItem> children = dT.getItem();
		if (children == null) {
			children = new ArrayList<DhtmlxTreeItem>();
			dT.setItem(children);
		}
		for (int i = 0; i < nodes.length; ++i) {
			T node = nodes[i];
			if (node == null) {
				continue;
			}
			DhtmlxTreeItem o = cb.getDhtmlxTreeItem(node);
			buildRecursiveJson(node, o, cb);

			children.add(o);
		}
	}
}
 

 

 

import java.io.StringWriter;
import java.text.SimpleDateFormat;

import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.annotate.JsonSerialize;

public class PojoMapper {
	private static final ObjectMapper objectMapper = new ObjectMapper();
	private static final JsonFactory jsonFactory = new JsonFactory();
	private static final String JSON_DATE_FROMATE = "yyyy-MM-dd HH:mm:ss";
	static{
		SimpleDateFormat dateFormate = new SimpleDateFormat(JSON_DATE_FROMATE);
		objectMapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
		objectMapper.getSerializationConfig().setDateFormat(dateFormate);//the withDateFormate method can not effect
		objectMapper.getDeserializationConfig().setDateFormat(dateFormate);
		objectMapper.getSerializationConfig().set(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
	}
    /**
     * deserializea a json string  to an object
     *  
     * @param <T>
     * @param jsonAsString
     * @param pojoClass
     * @return
     * @throws Exception
     */
	public static <T> T fromJson(String jsonAsString, Class<T> pojoClass)
			throws Exception {
		return (T)objectMapper.readValue(jsonAsString, pojoClass);
	}
	/**
	 * serializea an object  to  a json string
	 * @param pojo
	 * @param prettyPrint  if true,enabling pretty-printing using the default pretty printer
	 * @return
	 * @throws Exception
	 */
	public static String toJson(Object pojo, boolean prettyPrint)
			throws Exception {
		StringWriter sw = new StringWriter();
		JsonGenerator jg = jsonFactory.createJsonGenerator(sw);
		if (prettyPrint) {
			jg.useDefaultPrettyPrinter();
		}
		objectMapper.writeValue(jg, pojo);
		return sw.toString();
	}
	
	
	public static String toJson(Object pojo) throws Exception{
	  return toJson(pojo, false);
	}

}
 

 

分享到:
评论

相关推荐

    dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档

    dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档

    DHTMLX中文API开发手册

    DHTMLX中文API开发手册, dhtmlx技术使用总结与介绍中文手册 DHTMLX入门教程 DHTMLX

    dhtmlx中文手册+dhtmlx.js+dhtmlx.css

    压缩包包含dhtmlx中文操作手册,dhtmlx.js、dhtmlx.cc三个文件,刚解决关于dhtmlx关于calendar一个问题,格外兴奋,分享下

    DHtmlx 4.5破解版(绝对真实)

    grid.setImagePath("assets/dhtmlx/imgs/"); grid.setHeader("姓名,性别"); grid.setEditable(false); grid.init(); grid.enablePaging(true, 10, 3, "pagingArea"); grid.setPagingSkin("toolbar"); ...

    DHTMLX 使用手册

    DHTMLX 使用手册 DHTMLX 使用手册

    dhtmlxGantt.doc

    自己项目中用到了dhtmlxGantt,所以结合自己的项目使用实例写的应用文档,从引入到应用,一步步来可实现相应效果,如有问题可私信讨论。

    dhtmlx 帮助文档 (中文版)

    dhtmlx 非常详细的帮助文档 (中文版的) 组件 布局和数据容器 dhtmlxLayout 布局 dhtmlxAccordion dhtlmxTabbar 标签 dhtmlxWindows 窗口 dhtmlxForm 表单 数据演示 dhtmlxGrid dhtmlxTree dhtmlxTreeGrid...

    dhtmlx 日历

    dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历dhtmlx 日历

    免费版的全套DHTMLX

    dhtmlx一个不错的组件,里面有很多控件,相对专业版的来说有部分控件受限制

    dhtmlxGrid介绍及使用手册(中文版)

    文档主要对dhtmlxGrid 实现的功能进行介绍,以及API操作中文手册。 文档大致目录如下: 一、 dhtmlxGrid 介绍 7 1. 自定义XML: 7 2. 支持多行表头、表尾展现 7 3. 移动、添加、删除列 8 4. 处理大型数据集-支持分页 ...

    dhtmlxGantt.rar

    dhtmlxGantt最新版本,web端甘特图,示例,源码,使用手册。例子比较齐全。从官网打包下载。

    《DHTMLX中文使用手册》PDF

    《DHTMLX中文使用手册》PDF 下载

    DhtmlxGrid 分页的自定义,DhtmlxGrid复选框多选整行

    DhtmlxGrid的自定义的分页样式,不是他们内部的三种皮肤分页; 本篇还有dhtmlxgird没有的复选框选中整行的效果,dhtmlxgrid多行选中使用的是 [Ctrl+鼠标]、[Shift+鼠标],在国内大部分的体验操作都是第一列放复选框的...

    DHTMLX,EXT实例

    DHTMLX实例。DHTMLX结合EXT的使用,很不错的效果..

    2018 最新 dhtmlxGantt 官网甘特图示例

    2018 最新 dhtmlxGantt 官网甘特图示例。 该资源是从官网下载的标准版的免费版本的 dhtmlxGantt示例,官网下载比较麻烦,这是最新的,可点击下载参考学习。 dhtmlxGantt 甘特图

    dhtmlxGrid取一列方法

    dhtmlxGrid取一列方法dhtmlxGrid取一列方法dhtmlxGrid取一列方法dhtmlxGrid取一列方法dhtmlxGrid取一列方法dhtmlxGrid取一列方法dhtmlxGrid取一列方法dhtmlxGrid取一列方法dhtmlxGrid取一列方法

    DHTMLX API

    dhtmlx API 全集 包括 dhtmlxgrid dhtmlxtree

    dhtmlxGantt_v4.0.0

    甘特图(dhtmlxgantt)的资源文件,具体代码请访问https://blog.csdn.net/qq_27339781/article/details/79869584

    DHTMLX中文帮助文档

    前端web开发,DHTMLX对做管理系统是一个不错的UI,所以提供此帮助文档

Global site tag (gtag.js) - Google Analytics