section.java

来自「一个免费wap站」· Java 代码 · 共 179 行

JAVA
179
字号
package com.eline.wap.common.model;

import java.util.Date;

import com.eline.wap.common.util.SerializableMap;
import com.eline.wap.common.util.SerializeData;
import com.eline.wap.common.util.StringUtils;

/**
 * 
 * @author Lucifer
 *
 * A Section is the base container for a item of catalogs / resources.
 */
public class Section implements Comparable {

	private int indexId = 0; // Unique section identifier
	// private String name = null;
	private int parentId = 0;
	private int sortOrder = 0; // Used to control sorting of item
	private boolean isActive = true; // Is the item isActive?
	private boolean isSearchable = false;
	private String searchKey = null;
	private Date dateCreated;
	private Date lastUpdate;
	
	private SerializableMap properties;

	public Section() {
		this.properties = new SerializableMap();
	}

	public Section(int sectionId) {
		this.indexId = sectionId;
		this.properties = new SerializableMap();
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	/*public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}*/

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public int getIndexId() {
		return indexId;
	}

	public void setIndexId(int indexId) {
		this.indexId = indexId;
	}

	public boolean isActive() {
		return isActive;
	}

	public void setActive(boolean isActive) {
		this.isActive = isActive;
	}

	public boolean isSearchable() {
		return isSearchable;
	}

	public void setSearchable(boolean isSearchable) {
		this.isSearchable = isSearchable;
	}

	public Date getLastUpdate() {
		return lastUpdate;
	}

	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	public int getParentId() {
		return parentId;
	}

	public void setParentId(int parentId) {
		this.parentId = parentId;
	}

	public String getSearchKey() {
		return searchKey;
	}

	public void setSearchKey(String searchKey) {
		this.searchKey = searchKey;
	}

	public int getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(int sortOrder) {
		this.sortOrder = sortOrder;
	}

	public Object getProperty(String key) {
		return this.properties.get(key);
	}

	public void setProperty(String key, String value) {
		this.properties.put(key, value);
	}

	// Convert helpers
	protected boolean getBoolean(String key, boolean defaultValue) {
		String value = (String) this.properties.get(key);
		if (value == null || value.trim().length() == 0)
			return defaultValue;
		
		return StringUtils.getBoolean(value, defaultValue);
	}

	protected void setBoolean(String key, boolean value) {
		if (key != null && key.trim().length() > 0) {
			this.properties.put(key, StringUtils.toString(value));
		}
	}
	
	protected int getInt(String key, int defaultValue) {
		String value = (String) this.properties.get(key);
		
		if (value == null || value.trim().length() == 0)
			return defaultValue;

		return StringUtils.getInt(value, defaultValue);
	}
	
	protected void setInt(String key, int value) {
		if (key != null && key.trim().length() > 0) {
			this.properties.put(key, Integer.toString(value));
		}
	}
	
	protected String getString(String key, String defaultValue) {
		String value = (String) this.properties.get(key);
		return value != null ? value : defaultValue;
	}
	
	protected void setString(String key, String value) {
		if (key != null && key.trim().length() > 0 && value != null) {
			this.properties.put(key, value);
		}
	}

	// serialize / deserialize
	public void serialize(SerializeData data) {
		this.properties.serialize(data);
	}
	
	public SerializeData deserialize() {
		return this.properties.deserialize();
	}

	// Comparable members
	/**
     * Compares this Section object to another object.
	 */
	public int compareTo(Object o) {
		if (o == null)
			return 1;
		Integer sortOrder = new Integer(this.sortOrder);
		return sortOrder.compareTo(o);
	}
}

⌨️ 快捷键说明

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