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.jetspeed.om.portlet.impl;
018:
019: import java.io.Serializable;
020: import java.util.ArrayList;
021: import java.util.Collection;
022: import java.util.Iterator;
023:
024: import org.apache.pluto.om.common.ObjectID;
025: import org.apache.pluto.om.portlet.PortletDefinition;
026: import org.apache.pluto.om.portlet.PortletDefinitionList;
027:
028: /**
029: *
030: * PortletDefinitionListImpl
031: *
032: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
033: * @version $Id: PortletDefinitionListImpl.java 516448 2007-03-09 16:25:47Z ate $
034: *
035: */
036: public class PortletDefinitionListImpl implements
037: PortletDefinitionList, Serializable {
038:
039: protected Collection innerCollection;
040:
041: /**
042: *
043: */
044: public PortletDefinitionListImpl() {
045: super ();
046: innerCollection = new ArrayList();
047: }
048:
049: public PortletDefinitionListImpl(Collection collection) {
050: super ();
051: innerCollection = collection;
052: }
053:
054: /**
055: * @see org.apache.pluto.om.portlet.PortletDefinitionList#iterator()
056: */
057: public Iterator iterator() {
058: return innerCollection.iterator();
059: }
060:
061: /**
062: * @see org.apache.pluto.om.portlet.PortletDefinitionList#get(org.apache.pluto.om.common.ObjectID)
063: */
064: public PortletDefinition get(ObjectID id) {
065: Iterator itr = innerCollection.iterator();
066: while (itr.hasNext()) {
067: PortletDefinition pd = (PortletDefinition) itr.next();
068: if (pd.getId().equals(id)) {
069: return pd;
070: }
071: }
072:
073: return null;
074: }
075:
076: /**
077: * Retrieves a <code>PortletDefinition</code> from this
078: * collection by the PortletDefinitions proper name
079: * @param name Proper name of PortletDefinition to locate.
080: * @return PortletDefinition matching <code>name</code> or <code>null</code>
081: * if no PortletDefinition within this PortletApplication has that name.
082: */
083: public PortletDefinition get(String name) {
084: Iterator itr = innerCollection.iterator();
085: while (itr.hasNext()) {
086: PortletDefinition pd = (PortletDefinition) itr.next();
087: if (pd.getName().equals(name)) {
088: return pd;
089: }
090: }
091:
092: return null;
093: }
094:
095: /**
096: * @see java.util.Collection#add(java.lang.Object)
097: */
098: public boolean add(Object o) {
099: PortletDefinition pd = (PortletDefinition) o;
100: return innerCollection.add(pd);
101: }
102:
103: /**
104: * @see java.util.Collection#remove(java.lang.Object)
105: */
106: public boolean remove(Object o) {
107: PortletDefinition pd = (PortletDefinition) o;
108: return innerCollection.remove(pd);
109: }
110:
111: /**
112: * @return
113: */
114: public Collection getInnerCollection() {
115: return innerCollection;
116: }
117:
118: /**
119: * @param collection
120: */
121: public void setInnerCollection(Collection collection) {
122: innerCollection = collection;
123: }
124:
125: }
|