2 * shortener - PageToadletFactory.java - Copyright © 2010 David Roden
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.
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.
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/>.
18 package net.pterodactylus.sone.web.page;
20 import freenet.client.HighLevelSimpleClient;
23 * Factory that creates {@link PageToadlet}s using a given
24 * {@link HighLevelSimpleClient}.
26 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
28 public class PageToadletFactory {
30 /** The client to use when creating the toadlets. */
31 private final HighLevelSimpleClient highLevelSimpleClient;
33 /** The prefix for all pages’ paths. */
34 private final String pathPrefix;
37 * Creates a new {@link PageToadlet} factory.
39 * @param highLevelSimpleClient
40 * The client to use when creating the toadlets
42 * The path that is prepended to all pages’ paths
44 public PageToadletFactory(HighLevelSimpleClient highLevelSimpleClient, String pathPrefix) {
45 this.highLevelSimpleClient = highLevelSimpleClient;
46 this.pathPrefix = pathPrefix;
50 * Creates a {@link PageToadlet} that wraps the given page and does not
51 * appear in the node’s menu.
55 * @return The toadlet wrapped around the page
57 public PageToadlet createPageToadlet(Page page) {
58 return createPageToadlet(page, null);
62 * Creates a {@link PageToadlet} that wraps the given page and appears in
63 * the node’s menu under the given name.
68 * The name of the menu item
69 * @return The toadlet wrapped around the page
71 public PageToadlet createPageToadlet(Page page, String menuName) {
72 return new PageToadlet(highLevelSimpleClient, menuName, page, pathPrefix);