1 19 20 package org.netbeans.modules.web.core.syntax.completion; 21 22 import java.lang.reflect.Modifier ; 23 import java.util.ArrayList ; 24 import java.util.Collection ; 25 import java.util.List ; 26 import org.netbeans.api.java.classpath.ClassPath; 27 import org.netbeans.modules.editor.NbEditorUtilities; 30 import org.netbeans.modules.web.core.syntax.JspSyntaxSupport; 31 import org.openide.loaders.DataObject; 32 33 37 38 40 public class ELImplicitObjects { 41 42 public static final int OBJECT_TYPE = 0; 43 public static final int MAP_TYPE = 1; 44 45 public static class ELImplicitObject { 46 private String name; 47 private int type; 48 private String clazz; 49 50 51 public ELImplicitObject(String name) { 52 this.name = name; 53 this.setType(MAP_TYPE); 54 } 55 56 public String getName() { 57 return name; 58 } 59 60 public int getType() { 61 return type; 62 } 63 64 public void setType(int type) { 65 this.type = type; 66 } 67 68 public String getClazz(){ 69 return clazz; 70 } 71 72 public void setClazz(String clazz){ 73 this.clazz = clazz; 74 } 75 } 76 77 public static class PageContextObject extends ELImplicitObject{ 78 public PageContextObject(String name){ 79 super(name); 80 setType(ELImplicitObjects.OBJECT_TYPE); 81 setClazz("javax.servlet.jsp.PageContext"); } 83 } 84 85 private static Collection <ELImplicitObject> implicitELObjects = null; 86 87 private static void initImplicitObjects() { 88 if (implicitELObjects == null){ 89 implicitELObjects = new ArrayList (); 90 implicitELObjects.add(new PageContextObject("pageContext")); implicitELObjects.add(new ELImplicitObject("pageScope")); implicitELObjects.add(new ELImplicitObject("requestScope")); implicitELObjects.add(new ELImplicitObject("sessionScope")); implicitELObjects.add(new ELImplicitObject("applicationScope")); implicitELObjects.add(new ELImplicitObject("param")); implicitELObjects.add(new ELImplicitObject("paramValues")); implicitELObjects.add(new ELImplicitObject("header")); implicitELObjects.add(new ELImplicitObject("headerValues")); implicitELObjects.add(new ELImplicitObject("initParam")); implicitELObjects.add(new ELImplicitObject("cookie")); } 102 } 103 104 106 public static Collection <ELImplicitObject> getELImplicitObjects(String prefix){ 107 initImplicitObjects(); 108 Collection <ELImplicitObject> filtered = implicitELObjects; 109 if (prefix != null && !prefix.equals("")){ 110 filtered = new ArrayList (); 111 for (ELImplicitObject elem : implicitELObjects) { 112 if (elem.getName().startsWith(prefix)) 113 filtered.add(elem); 114 } 115 } 116 return filtered; 117 } 118 119 public static ELImplicitObject getELImplicitObject (String expr){ 120 initImplicitObjects(); 121 ELImplicitObject obj = null; 122 if (expr != null && !expr.equals("")){ 123 int indexP = expr.indexOf('['); 124 int indexD = expr.indexOf('.'); 125 String name = null; 126 if (indexD > -1 && (indexP == -1 || indexD < indexP)) 127 name = expr.substring(0, indexD); 128 else{ 129 if (indexP > -1) 130 name = expr.substring(0, indexP); 131 else 132 name = expr; 133 } 134 name = name.trim(); 135 for (ELImplicitObject elem : implicitELObjects) { 136 if (elem.getName().equals(name)){ 137 obj = elem; 138 break; 139 } 140 } 141 } 142 return obj; 143 } 144 145 146 } 147 | Popular Tags |