KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > staticexport > CmsLinkTable


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/staticexport/CmsLinkTable.java,v $
3  * Date : $Date: 2005/06/27 23:22:25 $
4  * Version: $Revision: 1.12 $
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.staticexport;
33
34 import java.util.HashMap JavaDoc;
35 import java.util.Iterator JavaDoc;
36
37 /**
38  * Maintains a table of links for an element of a CmsXmlPage.<p>
39  *
40  * @author Carsten Weinholz
41  *
42  * @version $Revision: 1.12 $
43  *
44  * @since 6.0.0
45  */

46 public class CmsLinkTable {
47
48     /** Prefix to identify a link in the content. */
49     private static final String JavaDoc LINK_PREFIX = "link";
50
51     /** The map to store the link table in. */
52     private HashMap JavaDoc m_linkTable;
53
54     /**
55      * Creates a new CmsLinkTable.<p>
56      */

57     public CmsLinkTable() {
58
59         m_linkTable = new HashMap JavaDoc();
60     }
61
62     /**
63      * Adds a new link with a given internal name and internal flag to the link table.<p>
64      *
65      * @param link the <code>CmsLink</code> to add
66      * @return the new link entry
67      */

68     public CmsLink addLink(CmsLink link) {
69
70         m_linkTable.put(link.getName(), link);
71         return link;
72     }
73
74     /**
75      * Adds a new link to the link table.<p>
76      *
77      * @param type type of the link
78      * @param targetUri link destination
79      * @param internal flag to indicate if the link is a local link
80      * @return the new link entry
81      */

82     public CmsLink addLink(String JavaDoc type, String JavaDoc targetUri, boolean internal) {
83
84         CmsLink link = new CmsLink(LINK_PREFIX + m_linkTable.size(), type, targetUri, internal);
85         m_linkTable.put(link.getName(), link);
86         return link;
87     }
88
89     /**
90      * Returns the CmsLink Entry for a given name.<p>
91      *
92      * @param name the internal name of the link
93      * @return the CmsLink entry
94      */

95     public CmsLink getLink(String JavaDoc name) {
96
97         return (CmsLink)m_linkTable.get(name);
98     }
99
100     /**
101      * Returns if the link table is empty.<p>
102      *
103      * @return true if the link table is empty, false otherwise
104      */

105     public boolean isEmpty() {
106
107         return m_linkTable.isEmpty();
108     }
109
110     /**
111      * Returns an iterator over the links in the table.<p>
112      *
113      * The objects iterated are of type <code>{@link CmsLink}</code>.
114      *
115      * @return a string iterator for internal link names
116      */

117     public Iterator JavaDoc iterator() {
118
119         return m_linkTable.values().iterator();
120     }
121
122     /**
123      * Returns the size of this link table.<p>
124      *
125      * @return the size of this link table
126      */

127     public int size() {
128
129         return m_linkTable.size();
130     }
131 }
132
Popular Tags