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

📄 webhelper.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /**     * Get JS index path.     * @param jsgName JS group name     * @param browserType browser type     * @param jsDir optional parent dir     * @return File     */    public static final File getJSIndexPath( String jsgName,                                             String browserType,                                             String jsDir ) {        if( jsgName == null ) {            throw new NullPointerException( "JS group is NULL" );        }        if( browserType == null ) {            throw new NullPointerException( "Browser type is NULL" );        }        if( jsDir != null ) {            return new File( jsDir,                             SCRIPT_PROD_CORE + "/" +                             browserType + "/" +                             jsgName + INDEX_SUFFIX );        } else {            return new File( SCRIPT_PROD_CORE + "/" +                             browserType + "/" +                             jsgName + INDEX_SUFFIX );        }    }    /**     * Get JS URL.     * @param jsgName JS group name     * @param browserType browser type     * @return String     */    public static final String getJSURL( String jsgName, String browserType ) {        return            SCRIPT_PROD_CORE + "/" +            browserType + "/" +            jsgName +            SCRIPT_SUFFIX;    }        /**     * Get JS absolute URL.     * @param jsgName not-compiled JS group name     * @param jsPath JS relative path     * @return String     */    public static final String getNCJSURL( String jsgName, String jsPath ) {        return            SCRIPT_PROD_CORE + "/" +            jsgName + "/" +            jsPath;    }        /**     * Get JS relative URL.     * @param jsgName not-compiled JS group name     * @param jsPath JS relative path     * @return String     */    public static final String getNCJSRelativeURL( String jsgName, String jsPath ) {        // Need to insert SCRIPT_PROD_CORE value into the jsPath string         // Example:         // ../js/modules/focus/mainmenu.js should become  ../jsclasses/2.6.0.45/all/js/modules/focus/mainmenu.js        if (jsPath != null) {            int insertPoint = jsPath.lastIndexOf ("../");            if (insertPoint == -1) {                return                    SCRIPT_PROD_CORE + "/" +                    jsgName + "/" +                    jsPath;            } else {                return                     jsPath.substring (0, insertPoint + 2) +                    SCRIPT_PROD_CORE + "/" +                     jsgName + "/" +                    jsPath.substring (insertPoint + 3, jsPath.length());                }        } else {            return                SCRIPT_PROD_CORE + "/" +                jsgName + "/";        }    }    /**     * Get JS index file relative URL.     * @param jsgName JS group name     * @param browserType browser type     * @return String     */    public static final String getJSIndexURL( String jsgName, String browserType ) {        return            SCRIPT_PROD_CORE + "/" +            browserType + "/" +            jsgName +            INDEX_SUFFIX;    }    /**     * Get JS original URL.     * @param file JS file     * @param jsDir optional parent dir     * @return String     */    public static final String getJSURL( File file, File jsDir ) {        if( file == null ) {            throw new NullPointerException( "File is NULL" );        }        // Get file postfix.        String filePostfix;        if( jsDir != null ) {            try {                String fileName = file.getCanonicalPath();                String dirPath = jsDir.getCanonicalPath();                int pos = fileName.indexOf( dirPath );                if( pos == 0 ) {                    filePostfix = fileName.substring( dirPath.length() );                } else {                    filePostfix = fileName;                }            } catch( IOException ex ) {                throw new GenericSystemException( "IO exception: " + ex.getMessage(), ex );            }        } else {            filePostfix = file.toString();        }        // Replace file separator.        String url = filePostfix.replace( File.separatorChar, '/' );        // Ok.        return url;    }    /**     * Get implementation of the file <code>f</code> for the browser type     * <code>browserType</code>.     * @param f File object     * @param browserType browser type     * @return File object     */    public static final File getImplementation( File f, String browserType ) {        if( f == null || browserType == null ) {            throw new IllegalStateException();        }        // Get impl URL for file name only.        File dir = f.getParentFile();        String fileName = f.getName();        String implFileName = getImplUrl( fileName, browserType );        // Construct impl file.        return new File( dir, implFileName );    }    /**     * Get relative implementation URL of the file name <code>fileName</code>     * for the browser type <code>browserType</code>.     * @param filePath path to file     * @param browserType browser type     * @return String     */    public static final String getImplUrl( String filePath, String browserType ) {        if( filePath == null || browserType == null ) {            throw new IllegalStateException();        }        File file = new File( filePath );        File dir = file.getParentFile();        String fileName = file.getName();        int scriptSuffixPos = fileName.indexOf( SCRIPT_SUFFIX );        if( scriptSuffixPos <= 0 ) {            throw new IllegalStateException( "Invalid file: " + filePath );        }        // Build impl dir object.        File implDir;        if( dir == null ) {            implDir = new File( SCRIPT_IMPL_DIR );        } else {            implDir = new File( dir, SCRIPT_IMPL_DIR );        }        // Construct implementation name.        String implFileName = fileName.substring( 0, scriptSuffixPos ) +            getBrowserSuffix( browserType ) + SCRIPT_SUFFIX;        // Build impl file object.        File implFile = new File( implDir, implFileName );        // Replace file separator.        String implUrl = implFile.toString().replace( File.separatorChar, '/' );        // Ok.        return implUrl;    }    // ----------------------------------------------------- private static methods    // Get script suffix.    private static final String getScriptSuffix( String scriptExt ) {        return "." + scriptExt;    }    // Get browser suffix.    private static final String getBrowserSuffix( String browserType ) {        return "." + browserType;    }    // Parse coma-separated broser types.    private static final List parseBroserTypes( String s ) {        List ret = new ArrayList();        if( StringHelper.isEmpty( s ) ) {            return ret;        }        StringTokenizer st = new StringTokenizer( s, ",;" );        while( st.hasMoreTokens() ) {            ret.add( st.nextToken().trim() );        }        return ret;    }    // ----------------------------------------------------- inner class    /**     * <p>JS URL structure</p>     * @author [ALB] Baranov Andrey     * @version $Revision: 1.3 $ $Date: 2006/07/05 16:54:22 $     */    public static final class JSURLStructure {        private String jsgName;        private String jsPath;        JSURLStructure( String jsgName, String jsPath ) {            this.jsgName = jsgName;            this.jsPath = jsPath;        }        public String getJsgName() {            return jsgName;        }        public String getJsPath() {            return jsPath;        }    }}

⌨️ 快捷键说明

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