contactexport.java
来自「Java的框架」· Java 代码 · 共 110 行
JAVA
110 行
package mcaps.apps.prrm.roaddefect.dao.jdbc.query;
import javax.sql.DataSource;
import mcaps.apps.prrm.roaddefect.dao.util.ContactField;
import mcaps.apps.prrm.roaddefect.dao.util.RoadDefectField;
import mcap.core.base.dao.jdbc.SQLExport;
import mcap.core.base.dao.util.SortOrder;
import mcaps.apps.prrm.util.TableNameConstants;
/**
* The class that extends the SQLExport class to customize
* the export query for contact table.
*
* @author jov
* @date Sep 23, 2005
* @version 1.0.1.0
*/
public class ContactExport extends SQLExport{
/**
* The default constructor that accepts datasource and table name.
* @param ds the datasource object
* @param tableName the table in which the export operation executes upon
*/
public ContactExport(DataSource ds,String tableName) {
super(ds,tableName);
}
/**
* The constructor that accepts datasource and table name along with
* additional parameters like sort column name and sort order for
* sorting the query result.
* @param ds the datasource object
* @param tableName the table in which the export operation executes upon
* @param sortColName the name of the column used for sorting
* @param order the sort order
*/
public ContactExport(DataSource ds,String tableName,
String sortColName,SortOrder order) {
super(ds,tableName,sortColName,order);
}
/**
* The constructor that accepts datasource and table name along with
* additional parameters like sort column name array and sort order array
* for sorting the query result.
* @param ds the datasource object
* @param tableName the table in which the export operation executes upon
* @param sortColNameArray the array of the sort column name
* @param orderArray the array of the sort order based on the column name
*/
public ContactExport(DataSource ds,String tableName,
String[] sortColNameArray,SortOrder[] orderArray) {
super(ds,tableName,sortColNameArray,orderArray);
}
/**
* The constructor that accepts datasource and table name and whereclause
* to further refine the export query.
* @param ds the datasource object
* @param tableName the table in which the export operation executes upon
* @param whereClause sql where clause to refine the export query
*/
public ContactExport(DataSource ds,String fileName,String tableName,
String whereClause){
super(ds,tableName,whereClause);
}
/* (non-Javadoc)
* @see mcapss.prrm.base.dao.jdbc.SQLExport#getSelectFields()
*/
protected String getSelectFields(){
String tableName = TableNameConstants.CONTACT_TABLENAME;
StringBuffer sb = new StringBuffer();
for (int i = 0; i<ContactField.FIELDS.length; i++){
sb.append(tableName).append(".")
.append(ContactField.FIELDS[i]);
if (i >= ContactField.FIELDS.length-1){
sb.append(" ");
}else{
sb.append(", ");
}
}
return sb.toString();
}
//========================================================================
//This method shld be overriden in sub class if default select fields
//of the parent class does not work
/* (non-Javadoc)
* @see mcapss.prrm.base.dao.jdbc.SQLExport#getJoinClause()
*/
protected String getJoinClause(){
String tableA = TableNameConstants.CONTACT_TABLENAME;
String tableB = TableNameConstants.ROADDEFECT_TABLENAME;
String fieldA = ContactField.FIELDS[ContactField.ID];
String fieldB = RoadDefectField.FIELDS[RoadDefectField.CONTACTID];
StringBuffer sb = new StringBuffer();
sb.append("INNER JOIN").append(" ")
.append(tableB).append(" ")
.append("ON").append(" ")
.append(tableA).append(".").append(fieldA).append(" ")
.append("=").append(" ")
.append(tableB).append(".").append(fieldB).append(" ");
return sb.toString();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?