KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > frontend > templateone > CmsTemplateLink


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/frontend/templateone/CmsTemplateLink.java,v $
3  * Date : $Date: 2005/06/23 11:11:43 $
4  * Version: $Revision: 1.7 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.frontend.templateone;
33
34 /**
35  * Represents a single link to be used to display on the page.<p>
36  *
37  * These objects are used for the head link row creation of template one.<p>
38  *
39  * @author Andreas Zahner
40  *
41  * @version $Revision: 1.7 $
42  *
43  * @since 6.0.0
44  */

45 public class CmsTemplateLink implements Comparable JavaDoc {
46
47     /** The anchor of the link.<p> */
48     private String JavaDoc m_anchor;
49
50     /** The order of the link, can be used to sort link lists.<p> */
51     private int m_order;
52
53     /** The target of the link.<p> */
54     private String JavaDoc m_target;
55
56     /** The text of the link.<p> */
57     private String JavaDoc m_text;
58
59     /**
60      * Creates a new CmsTemplateLink.<p>
61      */

62     public CmsTemplateLink() {
63
64         m_target = "";
65         m_order = 0;
66     }
67
68     /**
69      *
70      * Creates a new CmsTemplateLink with initialized parameters.<p>
71      *
72      * @param anchor the link anchor
73      * @param text the text to display for the link
74      * @param target the linkt target, can be left empty
75      * @param order the order number for sorting link lists
76      */

77     public CmsTemplateLink(String JavaDoc anchor, String JavaDoc text, String JavaDoc target, int order) {
78
79         m_anchor = anchor;
80         if (target != null) {
81             m_target = target;
82         } else {
83             m_target = "";
84         }
85         m_text = text;
86         m_order = order;
87     }
88
89     /**
90      * Compares this instance to another given object instance of this class to sort a list of links.<p>
91      *
92      * Use java.util.Collections.sort(List) to sort a list of link objects by their order number ascending.<p>
93      *
94      * @param theObject the other given object instance to compare with
95      * @return the comparison result for the objects
96      */

97     public int compareTo(Object JavaDoc theObject) {
98
99         // sort links by their order number in ascending order
100
return new Integer JavaDoc(getOrder()).compareTo(new Integer JavaDoc(((CmsTemplateLink)theObject).getOrder()));
101     }
102
103     /**
104      * Returns the link anchor.<p>
105      *
106      * @return the link anchor
107      */

108     public String JavaDoc getAnchor() {
109
110         return m_anchor;
111     }
112
113     /**
114      * Returns the order number of the link.<p>
115      *
116      * @return the order number of the link
117      */

118     public int getOrder() {
119
120         return m_order;
121     }
122
123     /**
124      * Returns the target of the link.<p>
125      *
126      * @return the target of the link
127      */

128     public String JavaDoc getTarget() {
129
130         return m_target;
131     }
132
133     /**
134      * Returns the displayed link text.<p>
135      *
136      * @return the displayed link text
137      */

138     public String JavaDoc getText() {
139
140         return m_text;
141     }
142
143     /**
144      * Sets the link anchor.<p>
145      *
146      * @param anchor the link anchor
147      */

148     public void setAnchor(String JavaDoc anchor) {
149
150         m_anchor = anchor;
151     }
152
153     /**
154      * Sets the order number of the link.<p>
155      *
156      * @param order the order number of the link
157      */

158     public void setOrder(int order) {
159
160         m_order = order;
161     }
162
163     /**
164      * Sets the target of the link.<p>
165      *
166      * @param target the target of the link
167      */

168     public void setTarget(String JavaDoc target) {
169
170         if (target != null) {
171             m_target = target;
172         } else {
173             m_target = "";
174         }
175     }
176
177     /**
178      * Sets the displayed link text.<p>
179      *
180      * @param text the displayed link text
181      */

182     public void setText(String JavaDoc text) {
183
184         m_text = text;
185     }
186
187 }
188
Popular Tags