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

📄 metadata.java

📁 利用java反射机制
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * MetaData.java * * Created on June 6, 2003, 2:53 PM */package org.julp;import javax.sql.*;import java.util.*;import java.sql.SQLException;import java.io.Serializable;import java.lang.reflect.*;import java.beans.*;/** * * @author  leonard */public class MetaData implements Serializable, Cloneable {        /**      * Populates and caches columns, tables, fields, etc info     *     */    public MetaData() {    }        protected boolean[] autoIncrement = null;    protected boolean[] caseSensitive = null;    protected boolean[] currency = null;    protected boolean[] definitelyWritable = null;    protected boolean[] readOnly = null;    protected boolean[] searchable = null;    protected boolean[] signed = null;    protected boolean[] writable = null;    protected int[] columnDisplaySize = null;    protected int[] columnType = null;    protected int[] nullable = null;    protected int[] precision = null;    protected int[] scale = null;    protected String[] catalogName = null;    protected String[] schemaName = null;    protected String[] tableName = null;    protected String[] columnClassName = null;    protected String[] columnLabel = null;    protected String[] columnName = null;    protected String[] columnTypeName = null;    protected String[] fullColumnName = null;    protected String[] fieldName = null;    protected Method[] readMethod = null;    protected Method[] writeMethod = null;    protected String[] fieldClassName = null;    protected Class[] fieldClass = null;           protected int columnCount = 0;        protected Class requestor = null;    protected Map tables = new HashMap();        /** Gets the designated column's table's catalog name.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the name of the catalog for the table in which the given column     *          appears or "" if not applicable     * @exception SQLException if a database access error occurs     *     */    public String getCatalogName(int columnIndex) throws SQLException {        return this.catalogName[columnIndex - 1];    }        /** <p>Returns the fully-qualified name of the Java class whose instances     * are manufactured if the method <code>ResultSet.getObject</code>     * is called to retrieve a value     * from the column.  <code>ResultSet.getObject</code> may return a subclass of the     * class returned by this method.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the fully-qualified name of the class in the Java programming     *         language that would be used by the method     * <code>ResultSet.getObject</code> to retrieve the value in the specified     * column. This is the class name used for custom mapping.     * @exception SQLException if a database access error occurs     * @since 1.2     *     */    public String getColumnClassName(int columnIndex) throws SQLException {        return this.columnClassName[columnIndex - 1];    }        /** Returns the number of columns in this <code>ResultSet</code> object.     *     * @return the number of columns     * @exception SQLException if a database access error occurs     *     */    public int getColumnCount() throws SQLException {        return this.columnCount;    }        /** Indicates the designated column's normal maximum width in characters.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the normal maximum number of characters allowed as the width     *          of the designated column     * @exception SQLException if a database access error occurs     *     */    public int getColumnDisplaySize(int columnIndex) throws SQLException {        return this.columnDisplaySize[columnIndex - 1];    }        /** Gets the designated column's suggested title for use in printouts and     * displays.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the suggested column title     * @exception SQLException if a database access error occurs     *     */    public String getColumnLabel(int columnIndex) throws SQLException {        return this.columnLabel[columnIndex - 1];    }        /** Get the designated column's name.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return column name     * @exception SQLException if a database access error occurs     *     */    public String getColumnName(int columnIndex) throws SQLException {        return this.columnName[columnIndex - 1];    }        /** Retrieves the designated column's SQL type.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return SQL type from java.sql.Types     * @exception SQLException if a database access error occurs     * @see java.sql.Types     *     */    public int getColumnType(int columnIndex) throws SQLException {        return this.columnType[columnIndex - 1];    }        /** Retrieves the designated column's database-specific type name.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return type name used by the database. If the column type is     * a user-defined type, then a fully-qualified type name is returned.     * @exception SQLException if a database access error occurs     *     */    public String getColumnTypeName(int columnIndex) throws SQLException {        return this.columnTypeName[columnIndex - 1];    }        /** Get the designated column's number of decimal digits.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return precision     * @exception SQLException if a database access error occurs     *     */    public int getPrecision(int columnIndex) throws SQLException {        return this.precision[columnIndex - 1];    }        /** Gets the designated column's number of digits to right of the decimal point.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return scale     * @exception SQLException if a database access error occurs     *     */    public int getScale(int columnIndex) throws SQLException {        return this.scale[columnIndex - 1];    }        /** Get the designated column's table's schema.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return schema name or "" if not applicable     * @exception SQLException if a database access error occurs     *     */    public String getSchemaName(int columnIndex) throws SQLException {        return this.schemaName[columnIndex - 1];    }        /** Gets the designated column's table name.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return table name or "" if not applicable     * @exception SQLException if a database access error occurs     *     */    public String getTableName(int columnIndex) throws SQLException {        return this.tableName[columnIndex - 1];    }        /** Indicates whether the designated column is automatically numbered, thus read-only.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     *     */    public boolean isAutoIncrement(int columnIndex) throws SQLException {        return this.autoIncrement[columnIndex - 1];    }        /** Indicates whether a column's case matters.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     *     */    public boolean isCaseSensitive(int columnIndex) throws SQLException {        return this.caseSensitive[columnIndex - 1];    }        /** Indicates whether the designated column is a cash value.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     *     */    public boolean isCurrency(int columnIndex) throws SQLException {        return this.currency[columnIndex - 1];    }        /** Indicates whether a write on the designated column will definitely succeed.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     *     */    public boolean isDefinitelyWritable(int columnIndex) throws SQLException {        return this.definitelyWritable[columnIndex - 1];    }        /** Indicates the nullability of values in the designated column.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return the nullability status of the given column; one of <code>columnNoNulls</code>,     *          <code>columnNullable</code> or <code>columnNullableUnknown</code>     * @exception SQLException if a database access error occurs     *     */    public int isNullable(int columnIndex) throws SQLException {        return this.nullable[columnIndex - 1];    }        /** Indicates whether the designated column is definitely not writable.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     *     */    public boolean isReadOnly(int columnIndex) throws SQLException {        return this.readOnly[columnIndex - 1];    }        /** Indicates whether the designated column can be used in a where clause.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     *     */    public boolean isSearchable(int columnIndex) throws SQLException {        return this.searchable[columnIndex - 1];    }        /** Indicates whether values in the designated column are signed numbers.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     *     */    public boolean isSigned(int columnIndex) throws SQLException {        return this.signed[columnIndex - 1];    }        /** Indicates whether it is possible for a write on the designated column to succeed.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     *     */    public boolean isWritable(int columnIndex) throws SQLException {        return this.writable[columnIndex - 1];    }        /** Sets whether the designated column is automatically numbered,     * and thus read-only. The default is for a <code>RowSet</code> object's     * columns not to be automatically numbered.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @param property <code>true</code> if the column is automatically     *                 numbered; <code>false</code> if it is not     *     * @exception SQLException if a database access error occurs     *     */    public void setAutoIncrement(int columnIndex, boolean property) throws SQLException {        this.autoIncrement[columnIndex - 1] = property;    }        /** Sets whether the designated column is case sensitive.     * The default is <code>false</code>.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @param property <code>true</code> if the column is case sensitive;     *                 <code>false</code> if it is not     *     * @exception SQLException if a database access error occurs     *     */    public void setCaseSensitive(int columnIndex, boolean property) throws SQLException {        this.caseSensitive[columnIndex - 1] = property;    }        /** Sets the designated column's table's catalog name, if any, to the given     * <code>String</code>.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @param catalogName the column's catalog name     * @exception SQLException if a database access error occurs     *     */    public void setCatalogName(int columnIndex, String catalogName) throws SQLException {        this.catalogName[columnIndex - 1] = catalogName;    }        /** Sets the number of columns in the <code>RowSet</code> object to     * the given number.     *     * @param columnCount the number of columns in the <code>RowSet</code> object     * @exception SQLException if a database access error occurs     *     */    public void setColumnCount(int columnCount) throws SQLException {        this.columnCount = columnCount;    }        /** Sets the designated column's normal maximum width in chars to the     * given <code>int</code>.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @param size the normal maximum number of characters for     *           the designated column     *     * @exception SQLException if a database access error occurs     *     */    public void setColumnDisplaySize(int columnIndex, int size) throws SQLException {        this.columnDisplaySize[columnIndex - 1] = size;    }        /** Sets the suggested column title for use in printouts and     * displays, if any, to the given <code>String</code>.     *     * @param columnIndex the first column is 1, the second is 2, ...     * @param label the column title     * @exception SQLException if a database access error occurs     *     */    public void setColumnLabel(int columnIndex, String label) throws SQLException {        this.columnLabel[columnIndex - 1] = label;    }        /** Sets the name of the designated column to the given <code>String</code>.     *

⌨️ 快捷键说明

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