package asandatabasebrowser.model;

import net.sourceforge.swingx.SxTextUtilities;

/**
 * 検索結果情報<<entity>>
 */
public class ResultInfo implements IColumnInfo {

	public boolean isAutoIncrement;	// 自動的に番号付けされて読み込み専用として扱われるかどうか
	public boolean isCaseSensitive;	// 列の大文字小文字が区別されるかどうか
	public boolean isSearchable;		// where 節で使用できるかどうか
	public boolean isCurrency;			// 通貨の値かどうか
	public int		isNullable;			// NULL をセットできるかどうか(columnNoNulls/columnNullable/columnNullableUnknown)
	public boolean isSigned;			// 値が符号付き数値かどうか
	public int		columnDisplaySize;	// 通常の最大幅の文字数
	public String	columnLabel;		// 印刷や表示に使用する、列の推奨タイトル
	public String  columnName;			// 列の名前
	public String	schemaName;			// テーブルのスキーマ
	public int		precision;			// 10進桁数
	public int		scale;				// 小数点以下の桁数
	public String	tableName;			// テーブル名
	public String	catalogName;		// テーブルのカタログ名
	public int		columnType;			// 列の SQL 型(java.sql.Types からの SQL 型)
	public String	columnTypeName;		// 列のデータベース固有の型名
	public boolean	isReadOnly;			// 絶対的に書き込み可能でないかどうか
	public boolean	isWritable;			// 列への書き込みを成功させることができるかどうか
	public boolean	isDefinitelyWritable;	// 列の書き込みが必ず成功するかどうか
	public String	columnClassName;	// Java クラスの完全指定された名前を返します。

	/** 検索結果情報を生成する。 */
	public ResultInfo(
				boolean isAutoIncrement,
				boolean isCaseSensitive,
				boolean isSearchable,
				boolean isCurrency,
				int isNullable,
				boolean isSigned,
				int columnDisplaySize,
				String columnLabel,
				String columnName,
				String schemaName,
				int precision,
				int scale,
				String tableName,
				String catalogName,
				int columnType,
				String columnTypeName,
				boolean isReadOnly,
				boolean isWritable,
				boolean isDefinitelyWritable,
				String columnClassName
		) {

		this.isAutoIncrement		= isAutoIncrement;
		this.isCaseSensitive		= isCaseSensitive;
		this.isSearchable			= isSearchable;
		this.isCurrency				= isCurrency;
		this.isNullable				= isNullable;
		this.isSigned				= isSigned;
		this.columnDisplaySize		= columnDisplaySize;
		this.columnLabel			= columnLabel;
		this.columnName				= columnName;
		this.schemaName				= schemaName;
		this.precision				= precision;
		this.scale					= scale;
		this.tableName				= tableName;
		this.catalogName			= catalogName;
		this.columnType				= columnType;
		this.columnTypeName			= columnTypeName;
		this.isReadOnly				= isReadOnly;
		this.isWritable				= isWritable;
		this.isDefinitelyWritable	= isDefinitelyWritable;
		this.columnClassName		= columnClassName;
	}

	public boolean equals(Object obj) {
		if ( !(obj instanceof ResultInfo)) return false;
		ResultInfo info = (ResultInfo) obj;
		if(SxTextUtilities.compareString(catalogName,    info.catalogName   )!=0) return false;
		if(SxTextUtilities.compareString(schemaName,  info.schemaName )!=0) return false;
		if(SxTextUtilities.compareString(tableName,    info.tableName   )!=0) return false;
		if(SxTextUtilities.compareString(columnName, info.columnName)!=0) return false;
		return true;
	}
	public String toString() { return columnLabel; }
	public String toDetailString() {
		return
		"isAutoIncrement		= "+isAutoIncrement+"\n"+
		"isCaseSensitive		= "+isCaseSensitive+"\n"+
		"isSearchable			= "+isSearchable+"\n"+
		"isCurrency				= "+isCurrency+"\n"+
		"isNullable				= "+isNullable+"\n"+
		"isSigned				= "+isSigned+"\n"+
		"columnDisplaySize		= "+columnDisplaySize+"\n"+
		"columnLabel			= "+columnLabel+"\n"+
		"columnName				= "+columnName+"\n"+
		"schemaName				= "+schemaName+"\n"+
		"precision				= "+precision+"\n"+
		"scale					= "+scale+"\n"+
		"tableName				= "+tableName+"\n"+
		"catalogName			= "+catalogName+"\n"+
		"columnType				= "+columnType+"\n"+
		"columnTypeName			= "+columnTypeName+"\n"+
		"isReadOnly				= "+isReadOnly+"\n"+
		"isWritable				= "+isWritable+"\n"+
		"isDefinitelyWritable	= "+isDefinitelyWritable+"\n"+
		"columnClassName		= "+columnClassName+"\n";
	}
}

