1 19 20 package org.netbeans.modules.web.core.syntax.spi; 21 22 import java.util.Hashtable ; 23 import javax.swing.text.Document ; 24 import java.net.URLClassLoader ; 25 import java.util.Map ; 26 27 import org.openide.filesystems.FileObject; 28 29 import org.netbeans.modules.web.jsps.parserapi.JspParserAPI; 30 import org.openide.ErrorManager; 31 import org.openide.cookies.InstanceCookie; 32 import org.openide.filesystems.Repository; 33 import org.openide.loaders.DataFolder; 34 import org.openide.loaders.DataObject; 35 import org.openide.loaders.DataObjectNotFoundException; 36 import org.openide.util.NbBundle; 38 39 53 public abstract class JspContextInfo { 54 55 56 public static final String CONTEXT_NAME = "/J2EE/JSPSyntaxColoring/"; 58 private static Hashtable <String , JspContextInfo> instances = new Hashtable (); 59 60 public static synchronized JspContextInfo getContextInfo( FileObject fo ) { 61 if (fo == null){ 62 return null; 63 } 64 JspContextInfo instance = instances.get(fo.getMIMEType()); 65 66 if (instance == null) { 67 FileObject f = Repository.getDefault().getDefaultFileSystem().findResource(CONTEXT_NAME + fo.getMIMEType()); if (f != null) { 69 try { 70 DataFolder folder = (DataFolder)DataObject.find(f).getCookie(DataFolder.class); 71 DataObject[] dobjs = folder.getChildren(); 72 73 for (int i = 0; i < dobjs.length; i ++){ 74 InstanceCookie ic = (InstanceCookie)dobjs[i].getCookie(InstanceCookie.class); 75 Object o = ic.instanceCreate(); 76 if (o instanceof JspContextInfo){ 77 instance = (JspContextInfo)o; 78 instances.put(fo.getMIMEType(), instance); 79 continue; 80 } 81 } 82 } catch (DataObjectNotFoundException ex) { 83 ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, ex); 84 } catch (java.io.IOException ex) { 85 ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, ex); 86 } catch (java.lang.ClassNotFoundException ex){ 87 ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, ex); 88 } 89 } 90 if (instance == null) { 91 ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, 92 new Exception (NbBundle.getBundle(JspContextInfo.class).getString("EXC_JspContextInfoNotInstalled"))); 93 } 94 } 95 return instance; 96 } 97 98 public abstract JSPColoringData getJSPColoringData(Document doc, FileObject fo); 99 100 public abstract JspParserAPI.ParseResult getCachedParseResult(Document doc, FileObject fo, boolean successfulOnly, boolean preferCurrent, boolean forceReload); 101 102 public abstract JspParserAPI.ParseResult getCachedParseResult(Document doc, FileObject fo, boolean successfulOnly, boolean preferCurrent); 103 104 public abstract JspParserAPI.JspOpenInfo getCachedOpenInfo(Document doc, FileObject fo, boolean preferCurrent); 105 106 public abstract URLClassLoader getModuleClassLoader(Document doc, FileObject fo); 107 108 119 public abstract FileObject guessWebModuleRoot(Document doc, FileObject fo); 120 121 124 public abstract Map getTaglibMap(Document doc, FileObject fo); 125 126 132 public abstract java.awt.Image getIcon(Document doc, FileObject fo); 133 134 } 135 | Popular Tags |