KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nemesis > forum > proxy > TreeWalkerProxy


1 /*
2  * NEMESIS-FORUM.
3  * Copyright (C) 2002 David Laurent(lithium2@free.fr). All rights reserved.
4  *
5  * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
6  *
7  * Copyright (C) 2001 Yasna.com. All rights reserved.
8  *
9  * Copyright (C) 2000 CoolServlets.com. All rights reserved.
10  *
11  * NEMESIS-FORUM. is free software; you can redistribute it and/or
12  * modify it under the terms of the Apache Software License, Version 1.1,
13  * or (at your option) any later version.
14  *
15  * NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
16  * application are parts of NEMESIS-FORUM and are distributed under
17  * same terms of licence.
18  *
19  *
20  * NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
21  * and software developed by CoolServlets.com (http://www.coolservlets.com).
22  * and software developed by Yasna.com (http://www.yasna.com).
23  *
24  */

25 package org.nemesis.forum.proxy;
26
27 import org.nemesis.forum.Authorization;
28 import org.nemesis.forum.ForumPermissions;
29 import org.nemesis.forum.Message;
30 import org.nemesis.forum.TreeWalker;
31
32 /**
33  * Protection proxy for TreeWalker ojbects
34  */

35 public class TreeWalkerProxy implements TreeWalker {
36
37     private TreeWalker treeWalker;
38     private Authorization authorization;
39     private ForumPermissions permissions;
40
41     public TreeWalkerProxy(TreeWalker treeWalker, Authorization authorization, ForumPermissions permissions) {
42         this.treeWalker = treeWalker;
43         this.authorization = authorization;
44         this.permissions = permissions;
45     }
46
47     public Message getRoot() {
48         Message message = treeWalker.getRoot();
49         return new MessageProxy(message, authorization, permissions);
50     }
51
52     public Message getChild(Message parent, int index) {
53         Message message = treeWalker.getChild(parent, index);
54         return new MessageProxy(message, authorization, permissions);
55     }
56
57     public int getChildCount(Message parent) {
58         return treeWalker.getChildCount(parent);
59     }
60
61     public int getRecursiveChildCount(Message parent) {
62         return treeWalker.getRecursiveChildCount(parent);
63     }
64
65     public int getIndexOfChild(Message parent, Message child) {
66         return treeWalker.getIndexOfChild(parent, child);
67     }
68
69     public boolean isLeaf(Message node) {
70         return treeWalker.isLeaf(node);
71     }
72
73 }
74
Popular Tags