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

📄 oldrollerconfig.java

📁 这个weblogging 设计得比较精巧
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }    /**     * Sets the emailComments.     *     * @param emailComments The emailComments to set     */    public void setEmailComments( boolean emailComments )    {        this.mEmailComments = emailComments;    }    /**     * Enable linkback.     *     * @return     */    public boolean isEnableLinkback()    {        return mEnableLinkback;    }    /**     * Enable linkback.     *     * @param b     */    public void setEnableLinkback( boolean b )    {        mEnableLinkback = b;    }    /**     * @return     */    public String getSiteDescription()    {        return mSiteDescription;    }    /**     * @return     */    public String getSiteName()    {        return mSiteName;    }    /**     * @param string     */    public void setSiteDescription( String string )    {        mSiteDescription = string;    }    /**     * @param string     */    public void setSiteName( String string )    {        mSiteName = string;    }    /**     * @return     */    public String getEmailAddress()    {        return mEmailAddress;    }    /**     * @param emailAddress     */    public void setEmailAddress( String emailAddress )    {        mEmailAddress = emailAddress;    }    /**     * @return the index directory     */    public String getIndexDir()    {        return mIndexDir;    }    /**     * @param indexDir new index directory     */    public void setIndexDir( String indexDir )    {        mIndexDir = indexDir;    }    public boolean getEncryptPasswords()    {        return mEncryptPasswords;    }    public void setEncryptPasswords( boolean use )    {        mEncryptPasswords = use;    }        /**     * @return the algorithm for encrypting passwords     */    public String getAlgorithm()    {        return mAlgorithm;    }    /**     * @param algorithm, the new algorithm     */    public void setAlgorithm( String algorithm )    {        mAlgorithm = algorithm;    }        //---------------------------------------- end requisite getters & setters    /**     * Convenience method for getAdminUsers.     *     * @return     */    public String[] adminUsersArray()    {        if ( mAdminUsers == null )        {            mAdminUsers = new ArrayList();        }        return (String[]) mAdminUsers.toArray( new String[mAdminUsers.size()] );    }    /**     * Convenience method for getEditorPages.     *     * @return     */    public String[] editorPagesArray()    {        if ( mEditorPages == null )        {            mEditorPages = new ArrayList();        }        return (String[]) mEditorPages.toArray( new String[mEditorPages.size()] );    }    /**     * Convenience method for getUploadAllow.     *     * @return     */    public String[] uploadAllowArray()    {        if ( mUploadAllow == null )        {            mUploadAllow = new ArrayList();        }        return (String[]) mUploadAllow.toArray( new String[mUploadAllow.size()] );    }    /**     * Convenience method for getUploadForbid.     *     * @return     */    public String[] uploadForbidArray()    {        if ( mUploadForbid == null )        {            mUploadForbid = new ArrayList();        }        return (String[]) mUploadForbid.toArray( new String[mUploadForbid.size()] );    }    public void updateValues( OldRollerConfig child )    {        this.mAbsoluteURL = child.getAbsoluteURL();        this.mRssUseCache = child.getRssUseCache();        this.mRssCacheTime = child.getRssCacheTime();        this.mNewUserAllowed = child.getNewUserAllowed();        this.mAdminUsers = child.getAdminUsers();        this.mNewUserData = child.getNewUserData();        this.mNewUserThemes = child.getNewUserThemes();        this.mEditorPages = child.getEditorPages();        this.mEnableAggregator = child.getEnableAggregator();        this.mUploadEnabled = child.getUploadEnabled();        this.mUploadMaxDirMB = child.getUploadMaxDirMB();        this.mUploadMaxFileMB = child.getUploadMaxFileMB();        this.mUploadAllow = child.getUploadAllow();        this.mUploadForbid = child.getUploadForbid();        this.mUploadDir = child.getUploadDir();        this.uploadPath = child.getUploadPath();        this.mMemDebug = child.getMemDebug();        this.mAutoformatComments = child.getAutoformatComments();        this.mEscapeCommentHtml = child.getEscapeCommentHtml();        this.mEmailComments = child.getEmailComments();        this.mEnableLinkback = child.isEnableLinkback();        this.mSiteName = child.getSiteName();        this.mSiteDescription = child.getSiteDescription();        this.mEmailAddress = child.getEmailAddress();        this.mIndexDir = child.getIndexDir();        this.mEncryptPasswords = child.getEncryptPasswords();        this.mAlgorithm = child.getAlgorithm();    }    /**     * nice output for debugging     *     * @return     */    public String toString()    {        StringBuffer buf = new StringBuffer();        buf.append( "RollerConfig \n" );        Class clazz = getClass();        Field[] fields = clazz.getDeclaredFields();        try        {            AccessibleObject.setAccessible( fields, true );            for ( int i = 0; i < fields.length; i++ )            {                buf.append( "\t[" + fields[i].getName() + "=" +                            fields[i].get( this ) + "], \n" );            }        }        catch ( Exception e )        {            // ignored!        }        return buf.toString();    }    /**     * Read the RollerConfig from a file, as specified by a String path.     *     * @param path     *     * @return     */    public static OldRollerConfig readConfig( String path )    {        InputStream in = null;        try        {            in = new FileInputStream( path );            return OldRollerConfig.readConfig( in );        }        catch ( Exception e )        {            System.out.println( "Exception reading RollerConfig: " +                                e.getMessage() );        }        finally        {            try            {                if ( in != null )                {                    in.close();                }            }            catch ( java.io.IOException ioe )            {                System.err.println( "RollerConfig.writeConfig() unable to close InputStream" );            }        }        return new OldRollerConfig();    }    /**     * Read the RollerConfig from a file, as specified by an InputStream.     *     * @param in     *     * @return     *     * @throws RuntimeException     */    public static OldRollerConfig readConfig( InputStream in )    {        try        {            BeanReader reader = new BeanReader();            reader.setDebug(99);            reader.registerBeanClass( OldRollerConfig.class );            return (OldRollerConfig) reader.parse( in );        }        catch ( IOException e )        {            throw new RuntimeException( "FATAL ERROR reading RollerConfig inputstream.",                                        e );        }        catch ( SAXException e )        {            throw new RuntimeException( "FATAL ERROR parsing RollerConfig, file is corrupted?",                                        e );        }        catch ( IntrospectionException e )        {            throw new RuntimeException( "FATAL ERROR introspecting RollerConfig bean.",                                        e );        }    }    /**     * Write RollerConfig to file, as specified by a String path.     *     * @param path     *     * @throws RollerException     */    public void writeConfig( String path ) throws RollerException    {        FileOutputStream out = null;        try        {            out = new FileOutputStream( path );            writeConfig( out );        }        catch ( FileNotFoundException e )        {            throw new RollerException( "ERROR file not found: " + path, e );        }        finally        {            try            {                if ( out != null )                {                    out.close();                }            }            catch ( java.io.IOException ioe )            {                System.err.println( "RollerConfig.writeConfig() unable to close OutputStream" );            }        }    }    /**     * Write RollerConfig to file, as specified by an OutputStream.     *     * @param out     *     * @throws RollerException     */    public void writeConfig( OutputStream out ) throws RollerException    {        BeanWriter writer = new BeanWriter( out );        writer.enablePrettyPrint();        writer.setIndent( "    " );        writer.setWriteIDs( false );        try        {            writer.write( this );        }        catch ( IOException e )        {            throw new RollerException( "ERROR writing to roller-config.xml stream.",                                       e );        }        catch ( SAXException e )        {            throw new RollerException( "ERROR writing to roller-config.xml stream.",                                       e );        }        catch ( IntrospectionException e )        {            throw new RollerException( "ERROR introspecting RollerConfig bean.",                                       e );        }    }    /**     * test stuff     *     * @param args     */    public static void main( String[] args )    {        String basedir = System.getProperty( "basedir" );        String path = "build/roller/WEB-INF/roller-config.xml";        path = new java.io.File( basedir, path ).getAbsolutePath();        if ( ( args.length > 0 ) && args[0].equals( "read" ) )        {            OldRollerConfig.readConfig( path );        }        else if ( ( args.length > 0 ) && args[0].equals( "write" ) ) // write        {            path = "build/roller/WEB-INF/roller-config-test.xml";            path = new java.io.File( basedir, path ).getAbsolutePath();            OldRollerConfig bean = new OldRollerConfig();            try            {                bean.writeConfig( path );            }            catch ( Exception e )            {                mLogger.error( "Unexpected exception", e );            }        }        else // both        {            OldRollerConfig bean = OldRollerConfig.readConfig( path );            path = "build/roller/WEB-INF/roller-config-test.xml";            path = new java.io.File( basedir, path ).getAbsolutePath();            try            {                bean.writeConfig( path );            }            catch ( Exception e )            {                mLogger.error( "Unexpected exception", e );            }        }        System.out.println( "RollerConfig.main completed" );    }}

⌨️ 快捷键说明

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