1 28 29 package com.caucho.es; 30 31 import com.caucho.server.util.CauchoSystem; 32 33 import java.util.Hashtable ; 34 35 38 class ESPackage extends ESBase { 39 ESString name; 40 Class cl; 41 Hashtable cache = new Hashtable (); 42 43 48 private ESPackage(String name) 49 { 50 this.className = "Package"; 51 this.prototype = esBase; 52 53 this.name = ESString.create(name); 54 } 55 56 59 static ESPackage create() 60 { 61 return new ESPackage(""); 62 } 63 64 public ESBase getProperty(ESString name) throws Throwable 65 { 66 ESBase value = null; 67 68 if (name == null) 69 return this; 70 71 value = (ESBase) cache.get(name); 72 73 if (value != null) 74 return value; 75 76 String subname; 77 if (this.name.equals(ESString.NULL)) 78 subname = name.toString(); 79 else 80 subname = this.name.toString() + "." + name.toString(); 81 82 try { 83 Global global = Global.getGlobalProto(); 84 ClassLoader loader = global.getParentLoader(); 85 86 Class cl = CauchoSystem.loadClass(subname, false, loader); 87 88 value = global.classWrap(cl); 89 } catch (ClassNotFoundException e) { 90 value = new ESPackage(subname); 91 } 92 93 cache.put(name, value); 94 95 return value; 96 } 97 98 public ESString toStr() { return new ESString("[Package " + name + "]"); } 99 100 public double toNum() 101 { 102 return 0.0/0.0; 103 } 104 105 109 public Object toJavaObject() 110 { 111 return null; 112 } 113 114 ESBase create(String string) 115 { 116 try { 117 return getProperty(ESString.create(string)); 118 } catch (Throwable e) { 119 return ESBase.esNull; 120 } 121 } 122 } 123 | Popular Tags |