KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > web > Crumb


1 /*
2  * Created on May 24, 2004
3  */

4 package com.openedit.web;
5
6 import java.util.ArrayList JavaDoc;
7 import java.util.List JavaDoc;
8
9
10 /**
11  * @author cburkey
12  *
13  */

14 public class Crumb {
15     String JavaDoc fieldText;
16     String JavaDoc fieldPath;
17     Crumb fieldParent;
18     boolean fieldFinal;
19     public Crumb()
20     {
21         
22     }
23     public Crumb getParent() {
24         return fieldParent;
25     }
26     public void setParent(Crumb inParent)
27     {
28         //look for myself in the list. If found then pull off old parent
29
/* Crumb self = inParent;
30         while( self != null && self.getText() != null)
31         {
32             if( !getText().equals(self.getText() ) )
33             {
34                 inParent = self.getParent();
35                 break;
36             }
37             self = self.getParent();
38         }
39     */
fieldParent = inParent;
40     }
41     public String JavaDoc getPath() {
42         return fieldPath;
43     }
44     public void setPath(String JavaDoc inPath) {
45         fieldPath = inPath;
46     }
47     public String JavaDoc getText() {
48         return fieldText;
49     }
50     public void setText(String JavaDoc inText) {
51         fieldText = inText;
52     }
53     String JavaDoc toLink()
54     {
55         if ( getText() == null )
56         {
57             return "";
58         }
59         return "<a HREF='" + getPath()+ "'>" + getText() + "</a>";
60     }
61     public List JavaDoc getCrumbs()
62     {
63         List JavaDoc parents = new ArrayList JavaDoc();
64         Crumb parent = this;
65         while(parent != null )
66         {
67             parents.add(0, parent);
68             parent = parent.getParent();
69         }
70         return parents;
71     }
72     public boolean isFinal() {
73         return fieldFinal;
74     }
75     public void setFinal(boolean inFinal) {
76         fieldFinal = inFinal;
77     }
78     
79     public String JavaDoc toString()
80     {
81         if ( getParent() == null )
82         {
83             return toLink();
84         }
85         else
86         {
87             return getParent().toString() + " : " + toLink();
88         }
89     }
90 }
91
Popular Tags