Fix more project names in headers.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / page / PageToadletFactory.java
1 /*
2  * Sone - PageToadletFactory.java - Copyright © 2010 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.sone.web.page;
19
20 import freenet.client.HighLevelSimpleClient;
21
22 /**
23  * Factory that creates {@link PageToadlet}s using a given
24  * {@link HighLevelSimpleClient}.
25  * 
26  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
27  */
28 public class PageToadletFactory {
29
30         /** The client to use when creating the toadlets. */
31         private final HighLevelSimpleClient highLevelSimpleClient;
32
33         /** The prefix for all pages’ paths. */
34         private final String pathPrefix;
35
36         /**
37          * Creates a new {@link PageToadlet} factory.
38          * 
39          * @param highLevelSimpleClient
40          *            The client to use when creating the toadlets
41          * @param pathPrefix
42          *            The path that is prepended to all pages’ paths
43          */
44         public PageToadletFactory(HighLevelSimpleClient highLevelSimpleClient, String pathPrefix) {
45                 this.highLevelSimpleClient = highLevelSimpleClient;
46                 this.pathPrefix = pathPrefix;
47         }
48
49         /**
50          * Creates a {@link PageToadlet} that wraps the given page and does not
51          * appear in the node’s menu.
52          * 
53          * @param page
54          *            The page to wrap
55          * @return The toadlet wrapped around the page
56          */
57         public PageToadlet createPageToadlet(Page page) {
58                 return createPageToadlet(page, null);
59         }
60
61         /**
62          * Creates a {@link PageToadlet} that wraps the given page and appears in
63          * the node’s menu under the given name.
64          * 
65          * @param page
66          *            The page to wrap
67          * @param menuName
68          *            The name of the menu item
69          * @return The toadlet wrapped around the page
70          */
71         public PageToadlet createPageToadlet(Page page, String menuName) {
72                 return new PageToadlet(highLevelSimpleClient, menuName, page, pathPrefix);
73         }
74
75 }