KickJava   Java API By Example, From Geeks To Geeks.

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


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.web.core.jsploader;
21
22 import java.io.IOException JavaDoc;
23 import org.openide.filesystems.FileObject;
24 import org.openide.loaders.DataObjectExistsException;
25 import org.openide.loaders.MultiDataObject;
26 import org.openide.loaders.UniFileLoader;
27 import org.openide.util.NbBundle;
28
29 /**
30 * Loader for JSPs.
31 *
32 * @author Petr Jiricka
33 */

34 public class JspLoader extends UniFileLoader {
35
36     /** serialVersionUID */
37     private static final long serialVersionUID = 1549250022027438942L;
38
39     /** Extension for JSP files */
40     public static final String JavaDoc JSP_EXTENSION = "jsp"; // NOI18N
41
/** Recommended extension for JSP fragments */
42     public static final String JavaDoc JSPF_EXTENSION = "jspf"; // NOI18N
43
/** Recommended extension for JSP fragments */
44     public static final String JavaDoc JSF_EXTENSION = "jsf"; // NOI18N
45

46     /** Recommended extension for JSP pages in XML syntax */
47     public static final String JavaDoc JSPX_EXTENSION = "jspx"; // NOI18N
48
/** Extension for tag files */
49     public static final String JavaDoc TAG_FILE_EXTENSION = "tag"; // NOI18N
50
/** Recommended extension for tag file fragments */
51     public static final String JavaDoc TAGF_FILE_EXTENSION = "tagf"; // NOI18N
52
/** Recommended extension for tag files in XML syntax */
53     public static final String JavaDoc TAGX_FILE_EXTENSION = "tagx"; // NOI18N
54

55     public static final String JavaDoc JSP_MIME_TYPE = "text/x-jsp"; // NOI18N
56

57     public static final String JavaDoc TAG_MIME_TYPE = "text/x-tag"; // NOI18N
58

59     public static String JavaDoc getMimeType(JspDataObject data) {
60         if ((data == null) || !(data instanceof JspDataObject)) {
61             return ""; // NOI18N
62
}
63         String JavaDoc ext = data.getPrimaryFile().getExt();
64         if (ext.equals(TAG_FILE_EXTENSION) || ext.equals(TAGF_FILE_EXTENSION)
65             || ext.equals(TAGX_FILE_EXTENSION)) {
66             return TAG_MIME_TYPE;
67         } else {
68             return JSP_MIME_TYPE;
69         }
70     }
71     
72     protected void initialize () {
73         super.initialize();
74         getExtensions().addMimeType(JSP_MIME_TYPE);
75         getExtensions().addMimeType(TAG_MIME_TYPE);
76
77     }
78
79     /** Get the default display name of this loader.
80      * @return default display name
81      */

82     protected String JavaDoc defaultDisplayName () {
83         return NbBundle.getBundle(JspLoader.class).getString("PROP_JspLoader_Name");
84     }
85     
86     protected String JavaDoc actionsContext() {
87         return "Loaders/text/x-jsp/Actions/"; // NOI18N
88
}
89     
90     public JspLoader() {
91         super ("org.netbeans.modules.web.core.jsploader.JspDataObject"); // NOI18N
92
}
93
94     /** For subclasses. */
95     protected JspLoader(String JavaDoc str) {
96         super (str);
97     }
98     
99     protected JspDataObject createJspObject(FileObject pf, final UniFileLoader l)
100         throws DataObjectExistsException {
101         return new JspDataObject (pf, l);
102     }
103
104
105     protected MultiDataObject createMultiObject (final FileObject primaryFile)
106     throws DataObjectExistsException, IOException JavaDoc {
107         JspDataObject obj = createJspObject(primaryFile, this);
108         // [PENDING] add these from JspDataObject, not from the loader
109
obj.getCookieSet0 ().add (new TagLibParseSupport(primaryFile));
110         return obj;
111     }
112
113 }
114
Popular Tags