001 package railo.runtime.type.scope; 002 003 import java.util.Iterator; 004 005 import railo.runtime.PageContext; 006 import railo.runtime.dump.DumpData; 007 import railo.runtime.dump.DumpProperties; 008 import railo.runtime.exp.ExpressionException; 009 import railo.runtime.exp.PageException; 010 import railo.runtime.exp.PageRuntimeException; 011 import railo.runtime.type.Collection; 012 import railo.runtime.type.dt.DateTime; 013 import railo.runtime.type.util.StructSupport; 014 015 /** 016 * 017 */ 018 public final class LocalNotSupportedScope extends StructSupport implements Scope,Local { 019 020 private static final long serialVersionUID = 6670210379924188569L; 021 022 private static LocalNotSupportedScope instance=new LocalNotSupportedScope(); 023 private boolean bind; 024 025 private LocalNotSupportedScope(){} 026 027 public static LocalNotSupportedScope getInstance() { 028 return instance; 029 } 030 031 @Override 032 public int size() { 033 return 0; 034 } 035 036 @Override 037 public Collection.Key[] keys() { 038 return null; 039 } 040 041 @Override 042 public Object removeEL(Key key) { 043 // TODO Auto-generated method stub 044 return null; 045 } 046 047 @Override 048 public Object remove(Key key) throws PageException { 049 throw new ExpressionException("Unsupported Context for Local Scope","Can't invoke key "+key+", Local Scope can only invoked inside a Function"); 050 } 051 052 @Override 053 public void clear() { 054 } 055 @Override 056 public Object get(Collection.Key key) throws ExpressionException { 057 throw new ExpressionException("Unsupported Context for Local Scope","Can't invoke key "+key.getString()+", Local Scope can only invoked inside a Function"); 058 } 059 060 @Override 061 public Object get(Collection.Key key, Object defaultValue) { 062 return defaultValue; 063 } 064 065 @Override 066 public Object set(Key key, Object value) throws ExpressionException { 067 throw new ExpressionException("Unsupported Context for Local Scope","Can't invoke key "+key.getString()+", Local Scope can only invoked inside a Function"); 068 } 069 070 @Override 071 public Object setEL(Collection.Key key, Object value) { 072 return null; 073 } 074 075 @Override 076 public Iterator<Collection.Key> keyIterator() { 077 throw new PageRuntimeException(new ExpressionException("Unsupported Context for Local Scope","Local Scope can only invoked inside a Function")); 078 } 079 080 @Override 081 public Iterator<Entry<Key, Object>> entryIterator() { 082 throw new PageRuntimeException(new ExpressionException("Unsupported Context for Local Scope","Local Scope can only invoked inside a Function")); 083 } 084 085 086 @Override 087 public Iterator<Object> valueIterator() { 088 throw new PageRuntimeException(new ExpressionException("Unsupported Context for Local Scope","Local Scope can only invoked inside a Function")); 089 } 090 091 @Override 092 public boolean isInitalized() { 093 return false; 094 } 095 @Override 096 public void initialize(PageContext pc) { 097 } 098 099 @Override 100 public void release() { 101 } 102 @Override 103 public void release(PageContext pc) { 104 } 105 106 @Override 107 public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) { 108 throw new PageRuntimeException(new ExpressionException("Unsupported Context for Local Scope")); 109 } 110 111 @Override 112 public Collection duplicate(boolean deepCopy) { 113 return new LocalNotSupportedScope(); 114 } 115 116 117 @Override 118 public boolean containsKey(Collection.Key key) { 119 return false; 120 } 121 122 @Override 123 public boolean containsValue(Object value) { 124 return false; 125 } 126 127 @Override 128 public java.util.Collection values() { 129 return null; 130 } 131 132 @Override 133 public String castToString() throws ExpressionException { 134 throw new ExpressionException("Unsupported Context for Local Scope"); 135 } 136 137 @Override 138 public String castToString(String defaultValue) { 139 return defaultValue; 140 } 141 142 143 @Override 144 public boolean castToBooleanValue() throws ExpressionException { 145 throw new ExpressionException("Unsupported Context for Local Scope"); 146 } 147 148 @Override 149 public Boolean castToBoolean(Boolean defaultValue) { 150 return defaultValue; 151 } 152 153 154 @Override 155 public double castToDoubleValue() throws ExpressionException { 156 throw new ExpressionException("Unsupported Context for Local Scope"); 157 } 158 159 @Override 160 public double castToDoubleValue(double defaultValue) { 161 return defaultValue; 162 } 163 164 165 @Override 166 public DateTime castToDateTime() throws ExpressionException { 167 throw new ExpressionException("Unsupported Context for Local Scope"); 168 } 169 170 @Override 171 public DateTime castToDateTime(DateTime defaultValue) { 172 return defaultValue; 173 } 174 175 public int getType() { 176 return SCOPE_LOCAL; 177 } 178 public String getTypeAsString() { 179 return "local"; 180 } 181 public int compareTo(String str) throws PageException { 182 throw new ExpressionException("Unsupported Context for Local Scope"); 183 } 184 public int compareTo(boolean b) throws PageException { 185 throw new ExpressionException("Unsupported Context for Local Scope"); 186 } 187 public int compareTo(double d) throws PageException { 188 throw new ExpressionException("Unsupported Context for Local Scope"); 189 } 190 public int compareTo(DateTime dt) throws PageException { 191 throw new ExpressionException("Unsupported Context for Local Scope"); 192 } 193 @Override 194 public boolean isBind() { 195 return bind; 196 } 197 198 @Override 199 public void setBind(boolean bind) { 200 this.bind=bind; 201 } 202 }