1 16 17 package org.apache.jetspeed.om.registry.base; 18 19 import org.apache.jetspeed.om.registry.CapabilityMap; 20 import java.util.Vector ; 21 import java.util.Iterator ; 22 23 30 public class BaseCapabilityMap implements CapabilityMap, java.io.Serializable 31 { 32 private Vector caps = new Vector (); 33 34 public BaseCapabilityMap() 35 { 36 } 37 38 42 public boolean equals(Object object) 43 { 44 if (object==null) 45 { 46 return false; 47 } 48 49 BaseCapabilityMap obj = (BaseCapabilityMap)object; 50 51 Iterator i = caps.iterator(); 52 Iterator i2 = obj.caps.iterator(); 53 while(i.hasNext()) 54 { 55 String c1 = (String )i.next(); 56 String c2 = null; 57 58 if (i2.hasNext()) 59 { 60 c2 = (String )i2.next(); 61 } 62 else 63 { 64 return false; 65 } 66 67 if (!c1.equals(c2)) 68 { 69 return false; 70 } 71 } 72 73 if (i2.hasNext()) 74 { 75 return false; 76 } 77 78 return true; 79 } 80 81 public Iterator getCapabilities() 82 { 83 return caps.iterator(); 84 } 85 86 public void addCapability(String name) 87 { 88 if (!caps.contains(name)) 89 { 90 caps.add(name); 91 } 92 } 93 94 public void removeCapability(String name) 95 { 96 caps.remove(name); 97 } 98 99 105 public boolean contains(String capability) 106 { 107 return caps.contains(capability); 108 } 109 110 118 public boolean containsAll(CapabilityMap map) 119 { 120 Iterator i = map.getCapabilities(); 121 122 while(i.hasNext()) 123 { 124 String capability = (String )i.next(); 125 if (!contains(capability)) 126 { 127 return false; 128 } 129 } 130 131 return true; 132 } 133 134 136 public Vector getCaps() 137 { 138 return caps; 139 } 140 141 } 142 | Popular Tags |