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

📄 querycriteria.java

📁 JiveJdon 3.0 is the application of Jdon Framework 1.4 final.
💻 JAVA
字号:
/*
 * Copyright 2003-2006 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package com.jdon.jivejdon.model.query;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import com.jdon.util.UtilDateTime;
import com.jdon.util.UtilValidate;

/**
 * Query Object
   P of EAA http://www.martinfowler.com/eaaCatalog/queryObject.html
   
 * @author banq(http://www.jdon.com)
 *
 */
public class QueryCriteria {
	
    protected java.util.Date fromDate =   new Date();
    protected java.util.Date toDate =  new Date();
    
    protected ResultSort resultSort = new ResultSort();    	
	
	public java.util.Date getFromDate() {		
		return fromDate;
	}
	public String getFromDateString() {
		return UtilDateTime.toDateString(fromDate);
	}
	
	public void setFromDate(String fromYear, String fromMonth, String fromDay) {
		Date thisDate = new Date();
 	    Calendar cal = Calendar.getInstance();
	    if (UtilValidate.isEmpty(fromYear))
     	    fromYear = Integer.toString(cal.get(Calendar.YEAR));
	    if (UtilValidate.isEmpty(fromMonth)){
	    	int month = cal.get(Calendar.MONTH);
	    	if (month < 10) {
	    		fromMonth = "0" + month;
	        } else {
	        	fromMonth = "" + month;
	        }
	    }
	    if (UtilValidate.isEmpty(fromDay)){
	    	int day = cal.get(Calendar.DAY_OF_MONTH);
	    	 if (day < 10) {
	    		 fromDay = "0" + day;
		     } else {
		         fromDay = "" + day;
		     }
	    }
	    	
	    	
	    //convert MM/DD/YYYY
        String fromDate = fromMonth + "/" + fromDay + "/" + fromYear;
        this.fromDate = UtilDateTime.toDate(fromDate, "00:00");
	}
	
	
	public java.util.Date getToDate() {
		return toDate;
	}
	
	public String getToDateString() {
		return UtilDateTime.toDateString(toDate);
	}
	
	public void setToDate(String toYear, String toMonth, String toDay) {
		Date thisDate = new Date();
		Calendar cal = Calendar.getInstance();
		if (UtilValidate.isEmpty(toYear))
			toYear = Integer.toString(cal.get(Calendar.YEAR));
		if (UtilValidate.isEmpty(toMonth)){
			int month = cal.get(Calendar.MONTH);
	    	if (month < 10) {
	    		toMonth = "0" + month;
	        } else {
	        	toMonth = "" + month;
	        }
		}
			
		if (UtilValidate.isEmpty(toDay)){
			int day = cal.get(Calendar.DAY_OF_MONTH);
	    	 if (day < 10) {
	    		 toDay = "0" + day;
		     } else {
		         toDay = "" + day;
		     }
		}
	    //convert MM/DD/YYYY
        String toDate = toMonth + "/" + toDay + "/" + toYear;
        this.toDate = UtilDateTime.toDate(toDate, "00:00");
	}


	public ResultSort getResultSort() {
		return resultSort;
	}


	public void setResultSort(ResultSort resultSort) {
		this.resultSort = resultSort;
	}	

	 public String toResultSortSql(){
	    if (resultSort.getSortOrder() == ResultSort.ASCENDING)
	        return " ORDER BY "+ resultSort.getSortField() + " ASC ";
	    else
	    	return " ORDER BY "+ resultSort.getSortField() + " DESC ";
	 }

    
}
    

⌨️ 快捷键说明

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