KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > flow > javascript > fom > PageLocalImpl


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.flow.javascript.fom;
17
18 import org.mozilla.javascript.Scriptable;
19 import org.mozilla.javascript.ScriptableObject;
20
21 /**
22  * @version CVS $Id: PageLocalImpl.java 54079 2004-10-08 13:30:28Z vgritsenko $
23  */

24 public class PageLocalImpl extends ScriptableObject implements PageLocal {
25
26     private PageLocalScope scope; // null if this is the prototype
27
private String JavaDoc 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 JavaDoc getId() {
38         return id;
39     }
40
41     public String JavaDoc getClassName() {
42         return "PageLocal";
43     }
44
45     public boolean has(String JavaDoc 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 JavaDoc name, Scriptable start, Object JavaDoc 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 JavaDoc 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 JavaDoc get(String JavaDoc 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 JavaDoc 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 JavaDoc name) {
98         if (scope == null) {
99             super.delete(name);
100         } else {
101             scope.delete(this, name);
102         }
103     }
104
105     public Object JavaDoc[] getIds() {
106         if (scope == null) {
107             return super.getIds();
108         }
109         return scope.getIds(this);
110     }
111
112     public Object JavaDoc getDefaultValue(Class JavaDoc hint) {
113         if (scope == null) {
114             return super.getDefaultValue(hint);
115         }
116         return scope.getDefaultValue(this, hint);
117     }
118
119 }
120
Popular Tags