1 16 package org.apache.cocoon.components.flow.javascript.fom; 17 18 import org.mozilla.javascript.Scriptable; 19 import org.mozilla.javascript.ScriptableObject; 20 21 24 public class PageLocalImpl extends ScriptableObject implements PageLocal { 25 26 private PageLocalScope scope; private String id; 28 29 public PageLocalImpl() { 30 this.id = String.valueOf(System.identityHashCode(this)); 31 } 32 33 public void setPageLocalScope(PageLocalScope scope) { 34 this.scope = scope; 35 } 36 37 public Object getId() { 38 return id; 39 } 40 41 public String getClassName() { 42 return "PageLocal"; 43 } 44 45 public boolean has(String name, Scriptable start) { 46 if (scope == null) { 47 return super.has(name, start); 48 } 49 return scope.has(this, name); 50 } 51 52 public boolean has(int index, Scriptable start) { 53 if (scope == null) { 54 return super.has(index, start); 55 } 56 return scope.has(this, index); 57 } 58 59 public void put(String name, Scriptable start, Object value) { 60 if (scope == null) { 61 super.put(name, start, value); 62 } else { 63 scope.put(this, name, value); 64 } 65 } 66 67 public void put(int index, Scriptable start, Object value) { 68 if (scope == null) { 69 super.put(index, start, value); 70 } else { 71 scope.put(this, index, value); 72 } 73 } 74 75 public Object get(String name, Scriptable start) { 76 if (scope == null) { 77 return super.get(name, start); 78 } 79 return scope.get(this, name); 80 } 81 82 public Object get(int index, Scriptable start) { 83 if (scope == null) { 84 return super.get(index, start); 85 } 86 return scope.get(this, index); 87 } 88 89 public void delete(int index) { 90 if (scope == null) { 91 super.delete(index); 92 } else { 93 scope.delete(this, index); 94 } 95 } 96 97 public void delete(String name) { 98 if (scope == null) { 99 super.delete(name); 100 } else { 101 scope.delete(this, name); 102 } 103 } 104 105 public Object [] getIds() { 106 if (scope == null) { 107 return super.getIds(); 108 } 109 return scope.getIds(this); 110 } 111 112 public Object getDefaultValue(Class hint) { 113 if (scope == null) { 114 return super.getDefaultValue(hint); 115 } 116 return scope.getDefaultValue(this, hint); 117 } 118 119 } 120 | Popular Tags |