01: /**
02: * Copyright 2006-2007 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: **/package org.araneaframework.core;
16:
17: import java.util.ArrayList;
18: import java.util.Collections;
19: import java.util.List;
20: import org.araneaframework.Path;
21: import org.araneaframework.Scope;
22:
23: /**
24: * @since 1.1
25: */
26: public class StandardScope implements Scope {
27: private Object id;
28: private Scope parent;
29:
30: public StandardScope(Object id, Scope parent) {
31: this .id = id;
32: this .parent = parent;
33: }
34:
35: public Object getId() {
36: return id;
37: }
38:
39: public Scope getParent() {
40: return parent;
41: }
42:
43: public Path toPath() {
44: Scope cur = this ;
45:
46: List idlist = new ArrayList();
47:
48: while (cur != null) {
49: if (cur.getId() != null)
50: idlist.add(cur.getId().toString());
51: cur = cur.getParent();
52: }
53:
54: Collections.reverse(idlist);
55:
56: return new StandardPath(idlist);
57: }
58:
59: public String toString() {
60: return toPath().toString();
61: }
62:
63: }
|