001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.components.flow.javascript.fom;
018:
019: import org.mozilla.javascript.Scriptable;
020: import org.mozilla.javascript.ScriptableObject;
021:
022: /**
023: * @version CVS $Id: PageLocalImpl.java 433543 2006-08-22 06:22:54Z crossley $
024: */
025: public class PageLocalImpl extends ScriptableObject implements
026: PageLocal {
027:
028: private PageLocalScope scope; // null if this is the prototype
029: private String id;
030:
031: public PageLocalImpl() {
032: this .id = String.valueOf(System.identityHashCode(this ));
033: }
034:
035: public void setPageLocalScope(PageLocalScope scope) {
036: this .scope = scope;
037: }
038:
039: public Object getId() {
040: return id;
041: }
042:
043: public String getClassName() {
044: return "PageLocal";
045: }
046:
047: public boolean has(String name, Scriptable start) {
048: if (scope == null) {
049: return super .has(name, start);
050: }
051: return scope.has(this , name);
052: }
053:
054: public boolean has(int index, Scriptable start) {
055: if (scope == null) {
056: return super .has(index, start);
057: }
058: return scope.has(this , index);
059: }
060:
061: public void put(String name, Scriptable start, Object value) {
062: if (scope == null) {
063: super .put(name, start, value);
064: } else {
065: scope.put(this , name, value);
066: }
067: }
068:
069: public void put(int index, Scriptable start, Object value) {
070: if (scope == null) {
071: super .put(index, start, value);
072: } else {
073: scope.put(this , index, value);
074: }
075: }
076:
077: public Object get(String name, Scriptable start) {
078: if (scope == null) {
079: return super .get(name, start);
080: }
081: return scope.get(this , name);
082: }
083:
084: public Object get(int index, Scriptable start) {
085: if (scope == null) {
086: return super .get(index, start);
087: }
088: return scope.get(this , index);
089: }
090:
091: public void delete(int index) {
092: if (scope == null) {
093: super .delete(index);
094: } else {
095: scope.delete(this , index);
096: }
097: }
098:
099: public void delete(String name) {
100: if (scope == null) {
101: super .delete(name);
102: } else {
103: scope.delete(this , name);
104: }
105: }
106:
107: public Object[] getIds() {
108: if (scope == null) {
109: return super .getIds();
110: }
111: return scope.getIds(this );
112: }
113:
114: public Object getDefaultValue(Class hint) {
115: if (scope == null) {
116: return super.getDefaultValue(hint);
117: }
118: return scope.getDefaultValue(this, hint);
119: }
120:
121: }
|