KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > portalImpl > aggregation > navigation > Navigation


1 /*
2  * Copyright 2003,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 /*
17
18  */

19
20 package org.apache.pluto.portalImpl.aggregation.navigation;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collection JavaDoc;
24 import java.util.Iterator JavaDoc;
25
26 import org.apache.pluto.util.StringUtils;
27
28 public class Navigation
29 {
30
31     private org.apache.pluto.portalImpl.om.page.Navigation navigation = null;
32     private org.apache.pluto.portalImpl.aggregation.navigation.Navigation parent = null;
33     private org.apache.pluto.portalImpl.aggregation.Fragment linkedFragment = null;
34     private Collection JavaDoc children = new ArrayList JavaDoc();
35
36     public Navigation(org.apache.pluto.portalImpl.aggregation.navigation.Navigation parent,
37                       org.apache.pluto.portalImpl.om.page.Navigation navigation)
38     {
39         this.parent = parent;
40         this.navigation = navigation;
41         
42         if (this.parent != null)
43         {
44             this.parent.getChildren().add(this);
45         }
46     }
47
48     public boolean isRootNavigation()
49     {
50         return navigation == null;
51     }
52
53     public String JavaDoc getTitle()
54     {
55         if (isRootNavigation()) {
56             return null;
57         } else {
58             return navigation.getTitle();
59         }
60     }
61
62     public String JavaDoc getDescription()
63     {
64         if (isRootNavigation()) {
65             return null;
66         } else {
67             return navigation.getDescription();
68         }
69     }
70
71     public Navigation getParent()
72     {
73         return parent;
74     }
75
76     public Collection JavaDoc getChildren()
77     {
78         return children;
79     }
80
81     public org.apache.pluto.portalImpl.aggregation.Fragment getLinkedFragment()
82     {
83         return linkedFragment;
84     }
85
86     public void setLinkedFragment(org.apache.pluto.portalImpl.aggregation.Fragment linkedFragment)
87     {
88         this.linkedFragment = linkedFragment;
89     }
90
91     public String JavaDoc toString()
92     {
93         return toString(0);
94     }
95
96     public String JavaDoc toString(int indent)
97     {
98         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(200);
99         StringUtils.newLine(buffer,indent);
100         buffer.append(getClass().toString()); buffer.append(":");
101         StringUtils.newLine(buffer,indent);
102         buffer.append("{");
103         if (navigation != null)
104         {
105             buffer.append(((org.apache.pluto.portalImpl.om.page.impl.NavigationImpl)navigation).toString(indent));
106         }
107         Iterator JavaDoc iterator = children.iterator();
108         if (iterator.hasNext())
109         {
110             StringUtils.newLine(buffer,indent);
111             buffer.append("Children:");
112         }
113         while (iterator.hasNext())
114         {
115             buffer.append(((Navigation)iterator.next()).toString(indent+2));
116         }
117         StringUtils.newLine(buffer,indent);
118         buffer.append("}");
119         return buffer.toString();
120     }
121
122 }
123
Popular Tags