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.pluto.om.common;
018:
019: import java.util.HashSet;
020: import java.util.Iterator;
021:
022: import org.apache.pluto.om.common.DescriptionSet;
023: import org.apache.pluto.om.common.SecurityRoleRef;
024: import org.apache.pluto.om.common.SecurityRoleRefSet;
025: import org.apache.pluto.om.common.SecurityRoleRefSetCtrl;
026:
027: /**
028: *
029: *
030: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
031: *
032: * @version CVS $Id: SecurityRoleRefSetImpl.java 433543 2006-08-22 06:22:54Z crossley $
033: */
034: public class SecurityRoleRefSetImpl extends HashSet implements
035: SecurityRoleRefSet, SecurityRoleRefSetCtrl,
036: java.io.Serializable {
037:
038: public SecurityRoleRefSetImpl() {
039: // nothing to do
040: }
041:
042: // SecurityRoleRefSet implementation.
043:
044: public SecurityRoleRef get(String roleName) {
045: Iterator iterator = this .iterator();
046: while (iterator.hasNext()) {
047: SecurityRoleRef securityRoleRef = (SecurityRoleRef) iterator
048: .next();
049: if (securityRoleRef.getRoleName().equals(roleName)) {
050: return securityRoleRef;
051: }
052: }
053: return null;
054: }
055:
056: // SecurityRoleRefSetCtrl implementation.
057:
058: public SecurityRoleRef add(SecurityRoleRef securityRoleRef) {
059: SecurityRoleRefImpl newSecurityRoleRef = new SecurityRoleRefImpl();
060: newSecurityRoleRef.setRoleName(securityRoleRef.getRoleName());
061: newSecurityRoleRef.setRoleLink(securityRoleRef.getRoleLink());
062: newSecurityRoleRef
063: .setDescriptionSet(((SecurityRoleRefImpl) securityRoleRef)
064: .getDescriptionSet());
065:
066: super .add(newSecurityRoleRef);
067:
068: return newSecurityRoleRef;
069: }
070:
071: public SecurityRoleRef remove(String roleName) {
072: Iterator iterator = this .iterator();
073: while (iterator.hasNext()) {
074: SecurityRoleRef securityRoleRef = (SecurityRoleRef) iterator
075: .next();
076: if (securityRoleRef.getRoleName().equals(roleName)) {
077: super .remove(securityRoleRef);
078: return securityRoleRef;
079: }
080: }
081: return null;
082: }
083:
084: public void remove(SecurityRoleRef securityRoleRef) {
085: super .remove(securityRoleRef);
086: }
087:
088: // additional methods.
089:
090: public SecurityRoleRef add(String roleName, String roleLink,
091: DescriptionSet descriptions) {
092: SecurityRoleRefImpl securityRoleRef = new SecurityRoleRefImpl();
093: securityRoleRef.setRoleName(roleName);
094: securityRoleRef.setRoleLink(roleLink);
095: securityRoleRef.setDescriptionSet(descriptions);
096:
097: super .add(securityRoleRef);
098:
099: return securityRoleRef;
100: }
101:
102: // unmodifiable part
103:
104: public static class Unmodifiable extends UnmodifiableSet implements
105: SecurityRoleRefSet {
106:
107: public Unmodifiable(SecurityRoleRefSet c) {
108: super (c);
109: }
110:
111: // additional methods.
112:
113: public SecurityRoleRef get(String roleName) {
114: return ((SecurityRoleRefSet) c).get(roleName);
115: }
116:
117: }
118:
119: }
|