/railo-java/railo-core/src/railo/runtime/SuperComponent.java

https://github.com/grapestack/railo · Java · 668 lines · 277 code · 99 blank · 292 comment · 2 complexity · 504101b08b0ceef7424aaa3250524fcf MD5 · raw file

  1. /**
  2. *
  3. */
  4. package railo.runtime;
  5. import java.util.Iterator;
  6. import java.util.Map;
  7. import java.util.Set;
  8. import railo.commons.lang.types.RefBoolean;
  9. import railo.runtime.component.DataMember;
  10. import railo.runtime.component.Member;
  11. import railo.runtime.component.MemberSupport;
  12. import railo.runtime.component.Property;
  13. import railo.runtime.dump.DumpData;
  14. import railo.runtime.dump.DumpProperties;
  15. import railo.runtime.exp.PageException;
  16. import railo.runtime.type.Collection;
  17. import railo.runtime.type.KeyImpl;
  18. import railo.runtime.type.Sizeable;
  19. import railo.runtime.type.Struct;
  20. import railo.runtime.type.StructImpl;
  21. import railo.runtime.type.dt.DateTime;
  22. import railo.runtime.type.util.StructUtil;
  23. /**
  24. *
  25. */
  26. public class SuperComponent extends MemberSupport implements ComponentPro, Member,Sizeable {
  27. private ComponentImpl comp;
  28. private SuperComponent(ComponentImpl comp) {
  29. super(Component.ACCESS_PRIVATE);
  30. this.comp=comp;
  31. }
  32. public static Member superMember(ComponentImpl comp) {
  33. if(comp==null) return new DataMember(Component.ACCESS_PRIVATE,new StructImpl());
  34. return new SuperComponent(comp);
  35. }
  36. public static Collection superInstance(ComponentImpl comp) {
  37. if(comp==null) return new StructImpl();
  38. return new SuperComponent(comp);
  39. }
  40. /**
  41. * @see railo.runtime.component.Member#getValue()
  42. */
  43. public Object getValue() {
  44. return this;
  45. }
  46. /**
  47. *
  48. * @see railo.runtime.ComponentImpl#call(railo.runtime.PageContext, java.lang.String, java.lang.Object[])
  49. */
  50. public Object call(PageContext pc, String name, Object[] args) throws PageException {
  51. return comp._call(pc, getAccess(), KeyImpl.init(name), null, args,true);
  52. }
  53. /**
  54. *
  55. * @see railo.runtime.ComponentImpl#call(railo.runtime.PageContext, railo.runtime.type.Collection.Key, java.lang.Object[])
  56. */
  57. public Object call(PageContext pc, Key name, Object[] args) throws PageException {
  58. return comp._call(pc, getAccess(), name, null, args,true);
  59. }
  60. /**
  61. *
  62. * @see railo.runtime.ComponentImpl#callWithNamedValues(railo.runtime.PageContext, java.lang.String, railo.runtime.type.Struct)
  63. */
  64. public Object callWithNamedValues(PageContext pc, String name, Struct args) throws PageException {
  65. return comp._call(pc, getAccess(), KeyImpl.init(name), args,null,true);
  66. //return comp._call(pc,name,args,null,true);
  67. }
  68. /**
  69. *
  70. * @see railo.runtime.ComponentImpl#callWithNamedValues(railo.runtime.PageContext, railo.runtime.type.Collection.Key, railo.runtime.type.Struct)
  71. */
  72. public Object callWithNamedValues(PageContext pc, Key methodName, Struct args) throws PageException {
  73. return comp._call(pc, getAccess(), methodName, args,null,true);
  74. //return comp._call(pc,methodName,args,null,true);
  75. }
  76. /**
  77. *
  78. * @see railo.runtime.ComponentImpl#castToBooleanValue()
  79. */
  80. public boolean castToBooleanValue() throws PageException {
  81. return comp.castToBooleanValue(true);
  82. }
  83. /**
  84. * @see railo.runtime.op.Castable#castToBoolean(java.lang.Boolean)
  85. */
  86. public Boolean castToBoolean(Boolean defaultValue) {
  87. return comp.castToBoolean(true,defaultValue);
  88. }
  89. /**
  90. *
  91. * @see railo.runtime.ComponentImpl#castToDateTime()
  92. */
  93. public DateTime castToDateTime() throws PageException {
  94. return comp.castToDateTime(true);
  95. }
  96. /**
  97. * @see railo.runtime.op.Castable#castToDateTime(railo.runtime.type.dt.DateTime)
  98. */
  99. public DateTime castToDateTime(DateTime defaultValue) {
  100. return comp.castToDateTime(true,defaultValue);
  101. }
  102. /**
  103. *
  104. * @see railo.runtime.ComponentImpl#castToDoubleValue()
  105. */
  106. public double castToDoubleValue() throws PageException {
  107. return comp.castToDoubleValue(true);
  108. }
  109. /**
  110. * @see railo.runtime.op.Castable#castToDoubleValue(double)
  111. */
  112. public double castToDoubleValue(double defaultValue) {
  113. return comp.castToDoubleValue(true,defaultValue);
  114. }
  115. /**
  116. *
  117. * @see railo.runtime.ComponentImpl#castToString()
  118. */
  119. public String castToString() throws PageException {
  120. return comp.castToString(true);
  121. }
  122. /**
  123. * @see railo.runtime.op.Castable#castToString(java.lang.String)
  124. */
  125. public String castToString(String defaultValue) {
  126. return comp.castToString(true,defaultValue);
  127. }
  128. /**
  129. *
  130. * @see railo.runtime.ComponentImpl#clear()
  131. */
  132. public void clear() {
  133. comp.clear();
  134. }
  135. /**
  136. *
  137. * @see railo.runtime.Component#clone()
  138. */
  139. public Object clone() {
  140. return duplicate(true);
  141. }
  142. /**
  143. *
  144. * @see railo.runtime.ComponentImpl#compareTo(boolean)
  145. */
  146. public int compareTo(boolean b) throws PageException {
  147. return comp.compareTo(b);
  148. }
  149. /**
  150. *
  151. * @see railo.runtime.ComponentImpl#compareTo(railo.runtime.type.dt.DateTime)
  152. */
  153. public int compareTo(DateTime dt) throws PageException {
  154. return comp.compareTo(dt);
  155. }
  156. /**
  157. *
  158. * @see railo.runtime.ComponentImpl#compareTo(double)
  159. */
  160. public int compareTo(double d) throws PageException {
  161. return comp.compareTo(d);
  162. }
  163. /**
  164. *
  165. * @see railo.runtime.ComponentImpl#compareTo(java.lang.String)
  166. */
  167. public int compareTo(String str) throws PageException {
  168. return comp.compareTo(str);
  169. }
  170. /**
  171. *
  172. * @see railo.runtime.ComponentImpl#containsKey(java.lang.String)
  173. */
  174. public boolean containsKey(String name) {
  175. return comp.contains(getAccess(),(name));
  176. }
  177. /**
  178. *
  179. * @see railo.runtime.ComponentImpl#containsKey(railo.runtime.type.Collection.Key)
  180. */
  181. public boolean containsKey(Key key) {
  182. return comp.contains(getAccess(),key.getLowerString());
  183. }
  184. /**
  185. *
  186. * @see railo.runtime.ComponentImpl#duplicate(boolean)
  187. */
  188. public synchronized Collection duplicate(boolean deepCopy) {
  189. return new SuperComponent((ComponentImpl) comp.duplicate(deepCopy));
  190. }
  191. /**
  192. *
  193. * @see railo.runtime.ComponentImpl#get(railo.runtime.PageContext, java.lang.String)
  194. */
  195. public Object get(PageContext pc, String name) throws PageException {
  196. return comp.get(getAccess(), name);
  197. }
  198. /**
  199. *
  200. * @see railo.runtime.ComponentImpl#get(railo.runtime.PageContext, railo.runtime.type.Collection.Key)
  201. */
  202. public Object get(PageContext pc, Key key) throws PageException {
  203. return comp.get(getAccess(), key);
  204. }
  205. /**
  206. *
  207. * @see railo.runtime.ComponentImpl#get(railo.runtime.PageContext, java.lang.String, java.lang.Object)
  208. */
  209. public Object get(PageContext pc, String name, Object defaultValue) {
  210. return comp.get(getAccess(), name, defaultValue);
  211. }
  212. /**
  213. *
  214. * @see railo.runtime.ComponentImpl#get(railo.runtime.PageContext, railo.runtime.type.Collection.Key, java.lang.Object)
  215. */
  216. public Object get(PageContext pc, Key key, Object defaultValue) {
  217. return comp.get(getAccess(), key, defaultValue);
  218. }
  219. /**
  220. *
  221. * @see railo.runtime.ComponentImpl#get(java.lang.String)
  222. */
  223. public Object get(String name) throws PageException {
  224. return comp.get(getAccess(),name);
  225. }
  226. /**
  227. *
  228. * @see railo.runtime.ComponentImpl#get(railo.runtime.type.Collection.Key)
  229. */
  230. public Object get(Key key) throws PageException {
  231. return comp.get(getAccess(),key);
  232. }
  233. /**
  234. *
  235. * @see railo.runtime.ComponentImpl#get(java.lang.String, java.lang.Object)
  236. */
  237. public Object get(String name, Object defaultValue) {
  238. return comp.get(getAccess(),name, defaultValue);
  239. }
  240. /**
  241. *
  242. * @see railo.runtime.ComponentImpl#get(railo.runtime.type.Collection.Key, java.lang.Object)
  243. */
  244. public Object get(Key key, Object defaultValue) {
  245. return comp.get(getAccess(),key, defaultValue);
  246. }
  247. /**
  248. *
  249. * @see railo.runtime.ComponentImpl#getAbsName()
  250. */
  251. public String getAbsName() {
  252. return comp.getAbsName();
  253. }
  254. /**
  255. * @see railo.runtime.ComponentPro#getBaseAbsName()
  256. */
  257. public String getBaseAbsName() {
  258. return comp.getBaseAbsName();
  259. }
  260. public boolean isBasePeristent() {
  261. return comp.isPersistent();
  262. }
  263. /**
  264. *
  265. * @see railo.runtime.ComponentImpl#getCallName()
  266. */
  267. public String getCallName() {
  268. return comp.getCallName();
  269. }
  270. /**
  271. *
  272. * @see railo.runtime.ComponentImpl#getDisplayName()
  273. */
  274. public String getDisplayName() {
  275. return comp.getDisplayName();
  276. }
  277. /**
  278. *
  279. * @see railo.runtime.ComponentImpl#getExtends()
  280. */
  281. public String getExtends() {
  282. return comp.getExtends();
  283. }
  284. /**
  285. *
  286. * @see railo.runtime.ComponentImpl#getHint()
  287. */
  288. public String getHint() {
  289. return comp.getHint();
  290. }
  291. /**
  292. *
  293. * @see railo.runtime.ComponentImpl#getJavaAccessClass(railo.commons.lang.types.RefBoolean)
  294. */
  295. public Class getJavaAccessClass(RefBoolean isNew) throws PageException {
  296. return comp.getJavaAccessClass(isNew);
  297. }
  298. /**
  299. *
  300. * @see railo.runtime.ComponentImpl#getMetaData(railo.runtime.PageContext)
  301. */
  302. public synchronized Struct getMetaData(PageContext pc) throws PageException {
  303. return comp.getMetaData(pc);
  304. }
  305. /**
  306. *
  307. * @see railo.runtime.ComponentImpl#getName()
  308. */
  309. public String getName() {
  310. return comp.getName();
  311. }
  312. /**
  313. *
  314. * @see railo.runtime.ComponentImpl#getOutput()
  315. */
  316. public boolean getOutput() {
  317. return comp.getOutput();
  318. }
  319. /**
  320. *
  321. * @see railo.runtime.ComponentImpl#instanceOf(java.lang.String)
  322. */
  323. public boolean instanceOf(String type) {
  324. return comp.top.instanceOf(type);
  325. }
  326. /**
  327. *
  328. * @see railo.runtime.ComponentImpl#isInitalized()
  329. */
  330. public boolean isInitalized() {
  331. return comp.top.isInitalized();
  332. }
  333. /**
  334. *
  335. * @see railo.runtime.ComponentImpl#isValidAccess(int)
  336. */
  337. public boolean isValidAccess(int access) {
  338. return comp.isValidAccess(access);
  339. }
  340. /**
  341. *
  342. * @see railo.runtime.ComponentImpl#iterator()
  343. */
  344. public Iterator iterator() {
  345. return comp.iterator();
  346. }
  347. /**
  348. *
  349. * @see railo.runtime.ComponentImpl#keyIterator()
  350. */
  351. public Iterator keyIterator() {
  352. return comp.keyIterator();
  353. }
  354. /**
  355. *
  356. * @see railo.runtime.ComponentImpl#keys()
  357. */
  358. public Key[] keys() {
  359. return comp.keys(getAccess());
  360. }
  361. /**
  362. *
  363. * @see railo.runtime.ComponentImpl#keysAsString()
  364. */
  365. public String[] keysAsString() {
  366. return comp.keysAsString(getAccess());
  367. }
  368. /**
  369. *
  370. * @see railo.runtime.ComponentImpl#remove(railo.runtime.type.Collection.Key)
  371. */
  372. public Object remove(Key key) throws PageException {
  373. return comp.remove(key);
  374. }
  375. /**
  376. *
  377. * @see railo.runtime.ComponentImpl#removeEL(railo.runtime.type.Collection.Key)
  378. */
  379. public Object removeEL(Key key) {
  380. return comp.removeEL(key);
  381. }
  382. /**
  383. *
  384. * @see railo.runtime.ComponentImpl#set(railo.runtime.PageContext, java.lang.String, java.lang.Object)
  385. */
  386. public Object set(PageContext pc, String name, Object value) throws PageException {
  387. return comp.set(pc, name, value);
  388. }
  389. /**
  390. *
  391. * @see railo.runtime.ComponentImpl#set(railo.runtime.PageContext, railo.runtime.type.Collection.Key, java.lang.Object)
  392. */
  393. public Object set(PageContext pc, Key key, Object value) throws PageException {
  394. return comp.set(pc, key, value);
  395. }
  396. /**
  397. *
  398. * @see railo.runtime.ComponentImpl#set(java.lang.String, java.lang.Object)
  399. */
  400. public Object set(String name, Object value) throws PageException {
  401. return comp.set(name, value);
  402. }
  403. /**
  404. *
  405. * @see railo.runtime.ComponentImpl#set(railo.runtime.type.Collection.Key, java.lang.Object)
  406. */
  407. public Object set(Key key, Object value) throws PageException {
  408. return comp.set(key, value);
  409. }
  410. /**
  411. *
  412. * @see railo.runtime.ComponentImpl#setEL(railo.runtime.PageContext, java.lang.String, java.lang.Object)
  413. */
  414. public Object setEL(PageContext pc, String name, Object value) {
  415. return comp.setEL(pc, name, value);
  416. }
  417. /**
  418. *
  419. * @see railo.runtime.ComponentImpl#setEL(railo.runtime.PageContext, railo.runtime.type.Collection.Key, java.lang.Object)
  420. */
  421. public Object setEL(PageContext pc, Key name, Object value) {
  422. return comp.setEL(pc, name, value);
  423. }
  424. /**
  425. *
  426. * @see railo.runtime.ComponentImpl#setEL(java.lang.String, java.lang.Object)
  427. */
  428. public Object setEL(String name, Object value) {
  429. return comp.setEL(name, value);
  430. }
  431. /**
  432. *
  433. * @see railo.runtime.ComponentImpl#setEL(railo.runtime.type.Collection.Key, java.lang.Object)
  434. */
  435. public Object setEL(Key key, Object value) {
  436. return comp.setEL(key, value);
  437. }
  438. /**
  439. *
  440. * @see railo.runtime.ComponentImpl#size()
  441. */
  442. public int size() {
  443. return comp.size(getAccess());
  444. }
  445. /**
  446. *
  447. * @see railo.runtime.ComponentImpl#toDumpData(railo.runtime.PageContext, int)
  448. */
  449. public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) {
  450. return comp.top.toDumpData(pageContext, maxlevel,dp);
  451. }
  452. public Page getPage() {
  453. return comp.getPage();
  454. }
  455. /**
  456. * @see railo.runtime.ComponentPro#getPageSource()
  457. */
  458. public PageSource getPageSource() {
  459. return comp.getPageSource();
  460. }
  461. /**
  462. * @see java.util.Map#containsKey(java.lang.Object)
  463. */
  464. public boolean containsKey(Object key) {
  465. return containsKey(KeyImpl.toKey(key,null));
  466. }
  467. /**
  468. * @see java.util.Map#entrySet()
  469. */
  470. public Set entrySet() {
  471. return StructUtil.entrySet(this);
  472. }
  473. /**
  474. * @see java.util.Map#get(java.lang.Object)
  475. */
  476. public Object get(Object key) {
  477. return get(KeyImpl.toKey(key,null), null);
  478. }
  479. /**
  480. * @see java.util.Map#isEmpty()
  481. */
  482. public boolean isEmpty() {
  483. return size()==0;
  484. }
  485. /**
  486. * @see java.util.Map#keySet()
  487. */
  488. public Set keySet() {
  489. return StructUtil.keySet(this);
  490. }
  491. /**
  492. * @see java.util.Map#put(K, V)
  493. */
  494. public Object put(Object key, Object value) {
  495. return setEL(KeyImpl.toKey(key,null), value);
  496. }
  497. /**
  498. * @see java.util.Map#putAll(java.util.Map)
  499. */
  500. public void putAll(Map map) {
  501. StructUtil.putAll(this, map);
  502. }
  503. /**
  504. * @see java.util.Map#remove(java.lang.Object)
  505. */
  506. public Object remove(Object key) {
  507. return removeEL(KeyImpl.toKey(key,null));
  508. }
  509. /**
  510. * @see java.util.Map#values()
  511. */
  512. public java.util.Collection values() {
  513. return StructUtil.values(this);
  514. }
  515. /**
  516. * @see java.util.Map#containsValue(java.lang.Object)
  517. */
  518. public boolean containsValue(Object value) {
  519. return values().contains(value);
  520. }
  521. public Iterator valueIterator() {
  522. return comp.valueIterator();
  523. }
  524. /**
  525. * @see railo.runtime.ComponentPro#getProperties()
  526. */
  527. public Property[] getProperties(boolean onlyPeristent) {
  528. return comp.getProperties(onlyPeristent);
  529. }
  530. /**
  531. * @see railo.runtime.ComponentPro#getComponentScope()
  532. */
  533. public ComponentScope getComponentScope() {
  534. return comp.getComponentScope();
  535. }
  536. /**
  537. * @see railo.runtime.ComponentPro#contains(railo.runtime.PageContext, railo.runtime.type.Collection.Key)
  538. */
  539. public boolean contains(PageContext pc, Key key) {
  540. return comp.contains(getAccess(),key);
  541. }
  542. /**
  543. * @see railo.runtime.ComponentPro#getMember(int, railo.runtime.type.Collection.Key, boolean, boolean)
  544. */
  545. public Member getMember(int access, Key key, boolean dataMember,boolean superAccess) {
  546. return comp.getMember(access, key, dataMember, superAccess);
  547. }
  548. /**
  549. * @see railo.runtime.ComponentPro#setProperty(railo.runtime.component.Property)
  550. */
  551. public void setProperty(Property property) throws PageException {
  552. comp.setProperty(property);
  553. }
  554. /**
  555. * @see railo.runtime.type.Sizeable#sizeOf()
  556. */
  557. public long sizeOf() {
  558. return StructUtil.sizeOf(this);
  559. }
  560. public boolean equalTo(String type) {
  561. return comp.top.equalTo(type);
  562. }
  563. /**
  564. * @see railo.runtime.ComponentPro#getWSDLFile()
  565. */
  566. public String getWSDLFile() {
  567. return comp.getWSDLFile();
  568. }
  569. }