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

📄 bitstreamformat.java

📁 dspace 用j2ee架构的一个数字图书馆.开源程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     *      * @param context     *            DSpace context object     *      * @return the bitstream formats.     * @throws SQLException     */    public static BitstreamFormat[] findNonInternal(Context context)            throws SQLException    {        List formats = new ArrayList();        String myQuery = "SELECT * FROM bitstreamformatregistry WHERE internal='0' "                + "AND short_description NOT LIKE 'Unknown' "                + "ORDER BY support_level DESC, short_description";        TableRowIterator tri = DatabaseManager.query(context,                "bitstreamformatregistry", myQuery);        while (tri.hasNext())        {            TableRow row = tri.next();            // From cache?            BitstreamFormat fromCache = (BitstreamFormat) context.fromCache(                    BitstreamFormat.class, row                            .getIntColumn("bitstream_format_id"));            if (fromCache != null)            {                formats.add(fromCache);            }            else            {                formats.add(new BitstreamFormat(context, row));            }        }        // close the TableRowIterator to free up resources        tri.close();        // Return the formats as an array        BitstreamFormat[] formatArray = new BitstreamFormat[formats.size()];        formatArray = (BitstreamFormat[]) formats.toArray(formatArray);        return formatArray;    }    /**     * Create a new bitstream format     *      * @param context     *            DSpace context object     * @return the newly created BitstreamFormat     * @throws SQLException     * @throws AuthorizeException     */    public static BitstreamFormat create(Context context) throws SQLException,            AuthorizeException    {        // Check authorisation - only administrators can create new formats        if (!AuthorizeManager.isAdmin(context))        {            throw new AuthorizeException(                    "Only administrators can create bitstream formats");        }        // Create a table row        TableRow row = DatabaseManager.create(context,                "bitstreamformatregistry");        log.info(LogManager.getHeader(context, "create_bitstream_format",                "bitstream_format_id="                        + row.getIntColumn("bitstream_format_id")));        return new BitstreamFormat(context, row);    }    /**     * Get the internal identifier of this bitstream format     *      * @return the internal identifier     */    public int getID()    {        return bfRow.getIntColumn("bitstream_format_id");    }    /**     * Get a short (one or two word) description of this bitstream format     *      * @return the short description     */    public String getShortDescription()    {        return bfRow.getStringColumn("short_description");    }    /**     * Set the short description of the bitstream format     *      * @param s     *            the new short description     */    public void setShortDescription(String s)       throws SQLException    {        // You can not reset the unknown's registry's name        BitstreamFormat unknown = null;;		try {			unknown = findUnknown(bfContext);		} catch (IllegalStateException e) {			// No short_description='Unknown' found in bitstreamformatregistry			// table. On first load of registries this is expected because it			// hasn't been inserted yet! So, catch but ignore this runtime 			// exception thrown by method findUnknown.		}				// If the exception was thrown, unknown will == null so goahead and 		// load s. If not, check that the unknown's registry's name is not		// being reset.		if (unknown == null || unknown.getID() != getID()) {            bfRow.setColumn("short_description", s);		}    }    /**     * Get a description of this bitstream format, including full application or     * format name     *      * @return the description     */    public String getDescription()    {        return bfRow.getStringColumn("description");    }    /**     * Set the description of the bitstream format     *      * @param s     *            the new description     */    public void setDescription(String s)    {        bfRow.setColumn("description", s);    }    /**     * Get the MIME type of this bitstream format, for example     * <code>text/plain</code>     *      * @return the MIME type     */    public String getMIMEType()    {        return bfRow.getStringColumn("mimetype");    }    /**     * Set the MIME type of the bitstream format     *      * @param s     *            the new MIME type     */    public void setMIMEType(String s)    {        bfRow.setColumn("mimetype", s);    }    /**     * Get the support level for this bitstream format - one of     * <code>UNKNOWN</code>,<code>KNOWN</code> or <code>SUPPORTED</code>.     *      * @return the support level     */    public int getSupportLevel()    {        return bfRow.getIntColumn("support_level");    }    /**     * Set the support level for this bitstream format - one of     * <code>UNKNOWN</code>,<code>KNOWN</code> or <code>SUPPORTED</code>.     *      * @param sl     *            the new support level     */    public void setSupportLevel(int sl)    {        // Sanity check        if ((sl < 0) || (sl > 2))        {            throw new IllegalArgumentException("Invalid support level");        }        bfRow.setColumn("support_level", sl);    }    /**     * Find out if the bitstream format is an internal format - that is, one     * that is used to store system information, rather than the content of     * items in the system     *      * @return <code>true</code> if the bitstream format is an internal type     */    public boolean isInternal()    {        return bfRow.getBooleanColumn("internal");    }    /**     * Set whether the bitstream format is an internal format     *      * @param b     *            pass in <code>true</code> if the bitstream format is an     *            internal type     */    public void setInternal(boolean b)    {        bfRow.setColumn("internal", b);    }    /**     * Update the bitstream format metadata     *      * @throws SQLException     * @throws AuthorizeException     */    public void update() throws SQLException, AuthorizeException    {        // Check authorisation - only administrators can change formats        if (!AuthorizeManager.isAdmin(bfContext))        {            throw new AuthorizeException(                    "Only administrators can modify bitstream formats");        }        log.info(LogManager.getHeader(bfContext, "update_bitstream_format",                "bitstream_format_id=" + getID()));        // Delete extensions        DatabaseManager.updateQuery(bfContext,                "DELETE FROM fileextension WHERE bitstream_format_id="                        + getID());        // Rewrite extensions        for (int i = 0; i < extensions.size(); i++)        {            String s = (String) extensions.get(i);            TableRow r = DatabaseManager.create(bfContext, "fileextension");            r.setColumn("bitstream_format_id", getID());            r.setColumn("extension", s);            DatabaseManager.update(bfContext, r);        }        DatabaseManager.update(bfContext, bfRow);    }    /**     * Delete this bitstream format. This converts the types of any bitstreams     * that may have this type to "unknown". Use this with care!     *      * @throws SQLException     * @throws AuthorizeException     */    public void delete() throws SQLException, AuthorizeException    {        // Check authorisation - only administrators can delete formats        if (!AuthorizeManager.isAdmin(bfContext))        {            throw new AuthorizeException(                    "Only administrators can delete bitstream formats");        }        // Find "unknown" type        BitstreamFormat unknown = findUnknown(bfContext);        if (unknown.getID() == getID())	     throw new IllegalArgumentException("The Unknown bitstream format may not be deleted.");         // Remove from cache        bfContext.removeCached(this, getID());        // Set bitstreams with this format to "unknown"        int numberChanged = DatabaseManager.updateQuery(bfContext,                "UPDATE bitstream SET bitstream_format_id=" + unknown.getID()                        + " WHERE bitstream_format_id=" + getID());        // Delete extensions        DatabaseManager.updateQuery(bfContext,                "DELETE FROM fileextension WHERE bitstream_format_id="                        + getID());        // Delete this format from database        DatabaseManager.delete(bfContext, bfRow);        log.info(LogManager.getHeader(bfContext, "delete_bitstream_format",                "bitstream_format_id=" + getID() + ",bitstreams_changed="                        + numberChanged));    }    /**     * Get the filename extensions associated with this format     *      * @return the extensions     */    public String[] getExtensions()    {        String[] exts = new String[extensions.size()];        exts = (String[]) extensions.toArray(exts);        return exts;    }    /**     * Set the filename extensions associated with this format     *      * @param exts     *            String [] array of extensions     */    public void setExtensions(String[] exts)    {        extensions = new ArrayList();        for (int i = 0; i < exts.length; i++)        {            extensions.add(exts[i]);        }    }}

⌨️ 快捷键说明

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