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

📄 mapcompositionlastmodifieddatecomparator.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
字号:
package com.esri.solutions.jitk.personalization.data;

import java.util.Comparator;
import java.util.Date;

/**
 * Use the Last Modified Date property value to compare two Map Compositions for
 * equality.  The {@link #setSortOrder(String)} method can be used to
 * set the desired sort order (Ascending or Descending). 
 */
public class MapCompositionLastModifiedDateComparator implements Comparator<IMapComposition> {

	/**
	 * Order to sort.  -1 to sort Descending, 1 to sort Ascending
	 */
	private int m_sortOrder;
	
	/**
	 * Sets the desired Sort Order.  If the <code>order</code> argument
	 * is ASCENDING, ASC, A, or 1, then the Sort Order is ascending.  If
	 * the <code>order</code> argument is DESCENDING, DESC, D, or -1, then
	 * the Sort Order is descending.  If the <code>order</code> argument
	 * is anything else then the Sort Order is ascending.
	 * 
	 * @param order Desired Sort Order.
	 */
	public void setSortOrder (String order) {
		if (order == null) {
			m_sortOrder = 1;
		}
		if (order.equalsIgnoreCase("ASCENDING")) {
			m_sortOrder = 1;
		} else if (order.equalsIgnoreCase("ASC")) {
			m_sortOrder = 1;
		} else if (order.equalsIgnoreCase("DESCENDING")) {
			m_sortOrder = -1;;
		} else if (order.equalsIgnoreCase("DESC")) {
			m_sortOrder = -1;
		} else if (order.equalsIgnoreCase("A")) {
			m_sortOrder = 1;
		} else if (order.equalsIgnoreCase("D")) {
			m_sortOrder = -1;
		} else if (order.equalsIgnoreCase("1")) {
			m_sortOrder = 1;
		} else if (order.equalsIgnoreCase("-1")) {
			m_sortOrder = -1;
		} else {
			m_sortOrder = 1;
		}
	}
	
	public int compare(IMapComposition o1, IMapComposition o2) {
		Date date1 = null;
		Date date2 = null;
		
		date1 = o1.getLastModifiedDate();
		date2 = o2.getLastModifiedDate();
		
		if (date1 == null) {
			date1 = new Date(0L);
		}
		if (date2 == null) {
			date2 = new Date(0L);
		}
		
		return date1.compareTo(date2) * m_sortOrder;
	}

}

⌨️ 快捷键说明

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