www.pudn.com > dataswap0616.rar > TableConfig.java


package com.gemt.dataswap.config; 
 
import java.util.Arrays; 
import java.util.Collection; 
import java.util.HashMap; 
import java.util.Map; 
 
public class TableConfig implements java.io.Serializable { 
	 
	/** 
	 * 保存数据库表的配置信息 
	 */ 
	private static final long serialVersionUID = -2300219502577488423L; 
	 
	private String fromDb; 
	private String[] toDb; 
	private Field[] field; 
	private String condition; 
	private String insertSql; 
	private Collection FieldList; 
	 
	public Map getFieldMap() 
	{ 
		if(field != null && field.length > 0) { 
			Map tempFieldMap = new HashMap(); 
			for(int i = 0; i < field.length; i++) { 
				tempFieldMap.put(field[i].getName(), field[i]); 
			} 
			return tempFieldMap; 
		} 
		return null; 
	} 
	public Collection getFieldList() 
	{ 
		if(field != null && field.length > 0) { 
			return Arrays.asList(field); 
		} 
		return null; 
	} 
	public void setFieldList(Collection fieldList) 
	{ 
		FieldList = fieldList; 
	} 
	public String getInsertSql() 
	{ 
		return insertSql; 
	} 
	public void setInsertSql(String insertSql) 
	{ 
		this.insertSql = insertSql; 
	} 
	public String getCondition() 
	{ 
		return condition; 
	} 
	public void setCondition(String condition) 
	{ 
		this.condition = condition; 
	} 
	public Field[] getField() 
	{ 
		return field; 
	} 
	public void setField(Field[] field) 
	{ 
		this.field = field; 
	} 
	public String getFromDb() 
	{ 
		return fromDb; 
	} 
	public void setFromDb(String fromDb) 
	{ 
		this.fromDb = fromDb; 
	} 
	public String[] getToDb() 
	{ 
		return toDb; 
	} 
	public void setToDb(String[] toDb) 
	{ 
		this.toDb = toDb; 
	} 
	 
	@Override 
	public int hashCode() 
	{ 
		final int PRIME = 31; 
		int result = super.hashCode(); 
		result = PRIME * result + ((FieldList == null) ? 0 : FieldList.hashCode()); 
		result = PRIME * result + ((condition == null) ? 0 : condition.hashCode()); 
		result = PRIME * result + Arrays.hashCode(field); 
		result = PRIME * result + ((fromDb == null) ? 0 : fromDb.hashCode()); 
		result = PRIME * result + ((insertSql == null) ? 0 : insertSql.hashCode()); 
		result = PRIME * result + Arrays.hashCode(toDb); 
		return result; 
	} 
	@Override 
	public boolean equals(Object obj) 
	{ 
		if (this == obj) 
			return true; 
		if (!super.equals(obj)) 
			return false; 
		if (getClass() != obj.getClass()) 
			return false; 
		final TableConfig other = (TableConfig) obj; 
		if (FieldList == null) 
		{ 
			if (other.FieldList != null) 
				return false; 
		} 
		else if (!FieldList.equals(other.FieldList)) 
			return false; 
		if (condition == null) 
		{ 
			if (other.condition != null) 
				return false; 
		} 
		else if (!condition.equals(other.condition)) 
			return false; 
		if (!Arrays.equals(field, other.field)) 
			return false; 
		if (fromDb == null) 
		{ 
			if (other.fromDb != null) 
				return false; 
		} 
		else if (!fromDb.equals(other.fromDb)) 
			return false; 
		if (insertSql == null) 
		{ 
			if (other.insertSql != null) 
				return false; 
		} 
		else if (!insertSql.equals(other.insertSql)) 
			return false; 
		if (!Arrays.equals(toDb, other.toDb)) 
			return false; 
		return true; 
	} 
	 
	public String toString() { 
		return " TableConfig { fromDb = " + fromDb + " condition = " + condition + "}"; 
	} 
	 
	 
	 
}