/*
 * ============================================================================
 * (c) Copyright 2004 Nokia
 * This material, including documentation and any related computer programs,
 * is protected by copyright controlled by Nokia and its licensors. 
 * All rights are reserved.
 * 
 * These materials have been contributed  to the Open Services Gateway 
 * Initiative (OSGi)as "MEMBER LICENSED MATERIALS" as defined in, and subject 
 * to the terms of, the OSGi Member Agreement specifically including, but not 
 * limited to, the license rights and warranty disclaimers as set forth in 
 * Sections 3.2 and 12.1 thereof, and the applicable Statement of Work. 
 * All company, brand and product names contained within this document may be 
 * trademarks that are the sole property of the respective owners.  
 * The above notice must be included on all copies of this document.
 * ============================================================================
 */
package unittests;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
import org.osgi.service.condpermadmin.ConditionInfo;
import org.osgi.service.condpermadmin.ConditionalPermissionAdmin;
import org.osgi.service.condpermadmin.ConditionalPermissionInfo;
import org.osgi.service.permissionadmin.PermissionInfo;

/**
 *
 * TODO Add Javadoc comment for this type.
 * 
 * @version $Revision$
 */
public class DummyConditionalPermissionAdmin implements
		ConditionalPermissionAdmin {

	private Set PIs = new TreeSet();
	
	private class PI implements ConditionalPermissionInfo {
		ConditionInfo[] conditionInfo;
		PermissionInfo[] permissionInfo;

		public PI(ConditionInfo[] conditionInfo,PermissionInfo[] permissionInfo) {
			this.conditionInfo = conditionInfo;
			this.permissionInfo = permissionInfo;
		}
		public void delete() {
			PIs.remove(this);
		}
		public ConditionInfo[] getConditionInfos() {
			return conditionInfo;
		}
		public PermissionInfo[] getPermissionInfos() {
			return permissionInfo;
		}
	}
	
	public ConditionalPermissionInfo addCollection(ConditionInfo[] conds,
			PermissionInfo[] perms) {
		PI pi = new PI(conds,perms);
		PIs.add(pi);
		return pi;
	}

	public Enumeration getCollections() {
		final Iterator iter = PIs.iterator();
		
		return new Enumeration() {
			public boolean hasMoreElements() {
				return iter.hasNext();
			}

			public Object nextElement() {
				return iter.next();
			} };
	}
}

@@ -1043,30 +1043,8 @@
 or;%0A
-import java.util.Set;%0A
 impo
@@ -1065,16 +1065,16 @@
 reeSet;%0A
+
 import o
@@ -1432,16 +1432,32 @@
 onAdmin 
+extends TreeSet 
 implemen
@@ -1491,56 +1491,18 @@
 dmin
- %7B%0A%0A%09private Set PIs = new TreeSet();%0A%09%0A%09private
+%0A%7B%0A%09public
  cla
@@ -1543,16 +1543,28 @@
 sionInfo
+, Comparable
  %7B%0A%09%09Con
@@ -1816,20 +1816,16 @@
 () %7B%0A%09%09%09
-PIs.
 remove(t
@@ -1989,16 +1989,465 @@
 fo;%0A%09%09%7D%0A
+%09%09public int compareTo(Object o) %7B%0A%09%09%09PI other = (PI) o;%0A%09%09%09return toString().compareTo(other.toString());%0A%09%09%7D%0A%09%09%0A%09%09public String toString() %7B%0A%09%09%09StringBuffer sb = new StringBuffer();%0A%09%09%09for(int i=0;i%3CconditionInfo.length;i++) %7B%0A%09%09%09%09sb.append(conditionInfo%5Bi%5D.getEncoded());%0A%09%09%09%09sb.append('%5Cn');%0A%09%09%09%7D%0A%09%09%09for(int i=0;i%3CpermissionInfo.length;i++) %7B%0A%09%09%09%09sb.append(permissionInfo%5Bi%5D.getEncoded());%0A%09%09%09%09sb.append('%5Cn');%0A%09%09%09%7D%0A%09%09%09return sb.toString();%0A%09%09%7D%0A
 %09%7D%0A%09%0A%09pu
@@ -2576,20 +2576,16 @@
 rms);%0A%09%09
-PIs.
 add(pi);
@@ -2669,12 +2669,8 @@
 r = 
-PIs.
 iter
@@ -2845,13 +2845,14 @@
 %09%09%09%7D %7D;%0A
-
 %09%7D%0A
+%0A
 %7D%0A

make it a TreeSet in itself