KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > core > jsploader > JspCompileUtil


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.web.core.jsploader;
21
22 import org.openide.filesystems.FileObject;
23 import org.openide.filesystems.FileUtil;
24
25 /** JSP compilation utilities
26 *
27 * @author Petr Jiricka
28 */

29 public class JspCompileUtil {
30
31     /** Finds a relative context path between rootFolder and relativeObject.
32      * Similar to <code>FileUtil.getRelativePath(FileObject, FileObject)</code>, only
33      * different slash '/' conventions.
34      * @return relative context path between rootFolder and relativeObject. The returned path
35      * always starts with a '/'. It ends with a '/' if the relative object is a directory.
36      * @exception IllegalArgumentException if relativeObject is not in rootFolder's tree.
37      */

38     public static String JavaDoc findRelativeContextPath(FileObject rootFolder, FileObject relativeObject) {
39         String JavaDoc result = "/" + FileUtil.getRelativePath(rootFolder, relativeObject); // NOI18N
40
return relativeObject.isFolder() ? (result + "/") : result; // NOI18N
41
}
42     
43     /** Returns whether a given file is a JSP file, or possibly a JSP segment.
44      * The recognition happens based on file extension (not on actual inclusion in other files).
45      * @param fo the file to examine
46      * @param acceptSegment whether segments should be accepted
47      */

48     public static boolean isJspFile(FileObject fo, boolean acceptSegment) {
49         String JavaDoc ext = fo.getExt().toLowerCase();
50         if ("jsp".equals(ext) || "jspx".equals(ext)) { // NOI18N
51
return true;
52         }
53         if ("jspf".equals(ext) && acceptSegment) { // NOI18N
54
return true;
55         }
56         return false;
57     }
58     
59     /** Returns whether a given file is a tag file, or possibly a tag segment.
60      * The recognition happens based on file extension (not on actual inclusion in other files).
61      * @param fo the file to examine
62      * @param acceptSegment whether segments should be accepted
63      */

64     public static boolean isTagFile(FileObject fo, boolean acceptSegment) {
65         String JavaDoc ext = fo.getExt().toLowerCase();
66         if ("tag".equals(ext) || "tagx".equals(ext)) { // NOI18N
67
return true;
68         }
69         if ("tagf".equals(ext) && acceptSegment) { // NOI18N
70
return true;
71         }
72         return false;
73     }
74     
75 }
76
77
Popular Tags