001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.portal.tools;
018:
019: import java.util.ArrayList;
020: import java.util.Collection;
021: import java.util.HashMap;
022: import java.util.Iterator;
023: import java.util.List;
024:
025: /**
026: * Represents a PortalTool
027: *
028: * @version CVS $Id: PortalTool.java 433543 2006-08-22 06:22:54Z crossley $
029: */
030: public class PortalTool {
031:
032: protected final HashMap functions;
033:
034: protected final String toolName;
035: protected final String toolId;
036: protected final ArrayList i18n;
037:
038: /**
039: * Creates a new Portal Tool
040: * @param toolName
041: * @param toolId
042: * @param functions
043: * @param i18n
044: */
045: public PortalTool(String toolName, String toolId,
046: HashMap functions, ArrayList i18n) {
047: this .toolName = toolName;
048: this .toolId = toolId;
049: this .functions = functions;
050: this .i18n = i18n;
051: }
052:
053: /**
054: * returns a collection of available function
055: */
056: public Collection getFunctions() {
057: return functions.values();
058: }
059:
060: /**
061: * returns the function with the id id
062: * @param id
063: */
064: public PortalToolFunction getFunction(String id) {
065: return (PortalToolFunction) functions.get(id);
066: }
067:
068: /**
069: * not in use!
070: */
071: public Collection getInternalFunctions() {
072: ArrayList internal = new ArrayList();
073: Collection funs = functions.values();
074: for (Iterator it = funs.iterator(); it.hasNext();) {
075: PortalToolFunction ptf = (PortalToolFunction) it.next();
076: if (ptf.isInternal()) {
077: internal.add(ptf);
078: }
079: }
080: return internal;
081: }
082:
083: /**
084: * return all public functions
085: */
086: public Collection getPublicFunctions() {
087: ArrayList publik = new ArrayList();
088: Collection funs = functions.values();
089: for (Iterator it = funs.iterator(); it.hasNext();) {
090: PortalToolFunction ptf = (PortalToolFunction) it.next();
091: if (!ptf.isInternal()) {
092: publik.add(ptf);
093: }
094: }
095: return publik;
096: }
097:
098: /**
099: * returns the id of the tools
100: */
101: public String getId() {
102: return toolId;
103: }
104:
105: /**
106: * returns the name of the tool
107: */
108: public String getName() {
109: return toolName;
110: }
111:
112: /**
113: */
114: public List getI18n() {
115: return i18n;
116: }
117: }
|