01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.lenya.cms.site.tree2;
19:
20: import java.util.ArrayList;
21: import java.util.Arrays;
22: import java.util.List;
23:
24: import org.apache.avalon.framework.logger.Logger;
25: import org.apache.lenya.cms.site.SiteNode;
26:
27: /**
28: * Root node.
29: */
30: public class RootNode extends TreeNodeImpl {
31:
32: private SiteTreeImpl tree;
33:
34: /**
35: * @param tree The tree.
36: * @param logger The logger.
37: */
38: public RootNode(SiteTreeImpl tree, Logger logger) {
39: super (null, "", false, logger);
40: this .tree = tree;
41: }
42:
43: public SiteTreeImpl getTree() {
44: return this .tree;
45: }
46:
47: public String getPath() {
48: return "";
49: }
50:
51: public SiteNode[] preOrder() {
52: List preOrder = new ArrayList();
53: SiteNode[] children = getChildren();
54: for (int i = 0; i < children.length; i++) {
55: TreeNode child = (TreeNode) children[i];
56: preOrder.addAll(Arrays.asList(child.preOrder()));
57: }
58: return (SiteNode[]) preOrder.toArray(new SiteNode[preOrder
59: .size()]);
60: }
61:
62: protected void deleteIfEmpty() {
63: }
64:
65: }
|