📄 columninfo.java
字号:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: XELOPES Data Mining Library
* Description: The XELOPES library is an open platform-independent and data-source-independent library for Embedded Data Mining.
* Copyright: Copyright (c) 2002 Prudential Systems Software GmbH
* Company: ZSoft (www.zsoft.ru), Prudsys (www.prudsys.com)
* @author Valentine Stepanenko (valentine.stepanenko@zsoft.ru)
* @version 1.0
*/
package com.prudsys.pdm.Input.Relational;
/**
* Base class for column description.
*/
public class ColumnInfo
{
protected String name;
protected String remarks;
protected boolean nullable;
/**
* Constructor of column info from given result set of column.
*
* @param rs given result set of column
* @throws java.sql.SQLException cannot read result set
*/
ColumnInfo(java.sql.ResultSet rs) throws java.sql.SQLException {
name = rs.getString("COLUMN_NAME");
remarks = rs.getString("REMARKS");
int nl = rs.getInt("NULLABLE");
if(nl == java.sql.DatabaseMetaData.columnNullable) nullable = true;
else nullable = false;
}
/**
* Returns column name.
*
* @return column name
*/
public String getName() {
return name;
}
/**
* Returns remarks of column.
*
* @return column remark
*/
public String getRemarks() {
return remarks;
}
/**
* Allows empty values.
*
* @return allows empty values
*/
public boolean isNullable() {
return nullable;
}
/**
* Returns string representation of column info
*
* @return string representation of column info
*/
public String toString() {
return name;
}
/**
* Constructs column info from given result set.
*
* @param rs result set for obtaining column info
* @return column info obtained from given result set
* @throws java.sql.SQLException cannot obtain column info
*/
public static ColumnInfo getColumnInfo(java.sql.ResultSet rs) throws java.sql.SQLException {
ColumnInfo ci = null;
short type = rs.getShort("DATA_TYPE");
//System.out.println(type);
if(type == java.sql.Types.BIGINT||
type == java.sql.Types.DECIMAL||
type == java.sql.Types.DOUBLE||
type == java.sql.Types.FLOAT||
type == java.sql.Types.INTEGER||
type == java.sql.Types.NUMERIC||
type == java.sql.Types.REAL||
type == java.sql.Types.SMALLINT||
type == java.sql.Types.TINYINT
)
ci = new NumericColumn(rs);
else if(type == java.sql.Types.CHAR||
type == java.sql.Types.VARCHAR)
ci = new StringColumn(rs);
return ci;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -