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

📄 tablerow.java

📁 DSPACE的源码 dspace-1.4-source
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            int i = ((Integer) value).intValue();            if (i == 0)            {                return false; // 0 is false            }            return true; // nonzero is true        }        else        {            throw new IllegalArgumentException(                    "Value is not a boolean or an integer");        }    }    /**     * Return the date value of column.     *      * If the column's type is not a date, or the column does not exist, an     * IllegalArgumentException is thrown.     *      * @param column     *            The column name (case-insensitive)     * @return - The date value of the column, or null if the column is an SQL     *         null.     */    public java.util.Date getDateColumn(String column)    {        if (!hasColumn(column))        {            throw new IllegalArgumentException("No such column " + column);        }        String name = canonicalize(column);        if (isColumnNull(name))        {            return null;        }        Object value = data.get(name);        if (value == null)        {            throw new IllegalArgumentException("Column " + column                    + " not present");        }        if (!(value instanceof java.util.Date))        {            throw new IllegalArgumentException("Value is not a Date");        }        return (java.util.Date) value;    }    /**     * Set column to an SQL NULL.     *      * If the column does not exist, an IllegalArgumentException is thrown.     *      * @param column     *            The column name (case-insensitive)     */    public void setColumnNull(String column)    {        if (!hasColumn(column))        {            throw new IllegalArgumentException("No such column " + column);        }        setColumnNullInternal(canonicalize(column));    }    /**     * Set column to the boolean b.     *      * If the column does not exist, an IllegalArgumentException is thrown.     *      * @param column     *            The column name (case-insensitive)     * @param b     *            The boolean value     */    public void setColumn(String column, boolean b)    {        if (!hasColumn(column))        {            throw new IllegalArgumentException("No such column " + column);        }        if ("oracle".equals(ConfigurationManager.getProperty("db.name")))        {            // if oracle, use 1 or 0 for true/false            data.put(canonicalize(column), b ? new Integer(1) : new Integer(0));        }        else        {            // default to postgres true/false            data.put(canonicalize(column), b ? Boolean.TRUE : Boolean.FALSE);        }    }    /**     * Set column to the String s. If s is null, the column is set to null.     *      * If the column does not exist, an IllegalArgumentException is thrown.     *      * @param column     *            The column name (case-insensitive)     * @param s     *            The String value     */    public void setColumn(String column, String s)    {        if (!hasColumn(column))        {            throw new IllegalArgumentException("No such column " + column);        }        data.put(canonicalize(column), (s == null) ? NULL_OBJECT : s);    }    /**     * Set column to the integer i.     *      * If the column does not exist, an IllegalArgumentException is thrown.     *      * @param column     *            The column name (case-insensitive)     * @param i     *            The integer value     */    public void setColumn(String column, int i)    {        if (!hasColumn(column))        {            throw new IllegalArgumentException("No such column " + column);        }        data.put(canonicalize(column), new Integer(i));    }    /**     * Set column to the long l.     *      * If the column does not exist, an IllegalArgumentException is thrown.     *      * @param column     *            The column name (case-insensitive)     * @param l     *            The long value     */    public void setColumn(String column, long l)    {        if (!hasColumn(column))        {            throw new IllegalArgumentException("No such column " + column);        }        data.put(canonicalize(column), new Long(l));    }    /**     * Set column to the date d. If the date is null, the column is set to NULL     * as well.     *      * If the column does not exist, an IllegalArgumentException is thrown.     *      * @param column     *            The column name (case-insensitive)     * @param d     *            The date value     */    public void setColumn(String column, java.util.Date d)    {        if (!hasColumn(column))        {            throw new IllegalArgumentException("No such column " + column);        }        if (d == null)        {            setColumnNull(canonicalize(column));            return;        }        data.put(canonicalize(column), d);    }    ////////////////////////////////////////    // Utility methods    ////////////////////////////////////////    /**     * Return a String representation of this object.     *      * @return String representaton     */    public String toString()    {        final String NEWLINE = System.getProperty("line.separator");        StringBuffer result = new StringBuffer(table).append(NEWLINE);        for (Iterator iterator = data.keySet().iterator(); iterator.hasNext();)        {            String column = (String) iterator.next();            result.append("\t").append(column).append(" = ").append(                    isColumnNull(column) ? "NULL" : data.get(column)).append(                    NEWLINE);        }        return result.toString();    }    /**     * Return a hash code for this object.     *      * @return int hash of object     */    public int hashCode()    {        return toString().hashCode();    }    /**     * Return true if this object equals obj, false otherwise.     *      * @param obj     * @return true if TableRow objects are equal     */    public boolean equals(Object obj)    {        if (!(obj instanceof TableRow))        {            return false;        }        return data.equals(((TableRow) obj).data);    }    /**     * Return the canonical name for column.     *      * @param column     *            The name of the column.     * @return The canonical name of the column.     */    static String canonicalize(String column)    {        if ("oracle".equals(ConfigurationManager.getProperty("db.name")))        {            // oracle requires uppercase            return column.toUpperCase();        }        // postgres default lowercase        return column.toLowerCase();    }    /**     * Set columns to null.     *      * @param columns -     *            A list of the columns to set to null. Each element of the list     *            is a String.     */    private void nullColumns(List columns)    {        for (Iterator iterator = columns.iterator(); iterator.hasNext();)        {            setColumnNullInternal((String) iterator.next());        }    }    /**     * Internal method to set column to null. The public method ensures that     * column actually exists.     *      * @param column     */    private void setColumnNullInternal(String column)    {        data.put(canonicalize(column), NULL_OBJECT);    }}

⌨️ 快捷键说明

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