KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > tools > PortalTool


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.portal.tools;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.Collection JavaDoc;
20 import java.util.HashMap JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.List JavaDoc;
23
24 /**
25  * Represents a PortalTool
26  *
27  * @version CVS $Id: PortalTool.java 149055 2005-01-29 18:21:34Z cziegeler $
28  */

29 public class PortalTool {
30     
31     protected final HashMap JavaDoc functions;
32     
33     protected final String JavaDoc toolName;
34     protected final String JavaDoc toolId;
35     protected final ArrayList JavaDoc i18n;
36     
37     /**
38      * Creates a new Portal Tool
39      * @param toolName
40      * @param toolId
41      * @param functions
42      * @param i18n
43      */

44     public PortalTool(String JavaDoc toolName, String JavaDoc toolId, HashMap JavaDoc functions, ArrayList JavaDoc i18n) {
45         this.toolName = toolName;
46         this.toolId = toolId;
47         this.functions = functions;
48         this.i18n = i18n;
49     }
50     
51     /**
52      * returns a collection of available function
53      * @return
54      */

55     public Collection JavaDoc getFunctions() {
56         return functions.values();
57     }
58     
59     /**
60      * returns the function with the id id
61      * @param id
62      * @return
63      */

64     public PortalToolFunction getFunction(String JavaDoc id) {
65         return (PortalToolFunction) functions.get(id);
66     }
67     
68     /**
69      * not in use!
70      * @return
71      */

72     public Collection JavaDoc getInternalFunctions() {
73         ArrayList JavaDoc internal = new ArrayList JavaDoc();
74         Collection JavaDoc funs = functions.values();
75         for(Iterator JavaDoc it = funs.iterator(); it.hasNext(); ) {
76             PortalToolFunction ptf = (PortalToolFunction) it.next();
77             if (ptf.isInternal()) {
78                 internal.add(ptf);
79             }
80         }
81         return internal;
82     }
83     
84     /**
85      * return all public functions
86      */

87     public Collection JavaDoc getPublicFunctions() {
88         ArrayList JavaDoc publik = new ArrayList JavaDoc();
89         Collection JavaDoc funs = functions.values();
90         for(Iterator JavaDoc it = funs.iterator(); it.hasNext(); ) {
91             PortalToolFunction ptf = (PortalToolFunction) it.next();
92             if (!ptf.isInternal()) {
93                 publik.add(ptf);
94             }
95         }
96         return publik;
97     }
98
99     /**
100      * returns the id of the tools
101      * @return
102      */

103     public String JavaDoc getId() {
104         return toolId;
105     }
106     
107     /**
108      * returns the name of the tool
109      * @return
110      */

111     public String JavaDoc getName() {
112         return toolName;
113     }
114     
115     /**
116      * @return
117      */

118     public List JavaDoc getI18n() {
119         return i18n;
120     }
121     
122 }
123
Popular Tags