/** Add capability to the CapabilityMap */ public void addCapability(Capability capability) { if (capability != null) // avoid null due to duplicates in database this.capabilityMap.put(capability.getName(), capability); }
public void addCapability(Capability capability) { if (capabilities == null) capabilities = new ArrayList(); if (!capabilities.contains(capability.getName())) { capabilities.add(capability); } }
/** * Implements the equals operation so that 2 elements are equal if all their member values are equal. * * @param object to compare this one with * @return true if both objects represent the same (logical) content */ public boolean equals(Object object) { if (!(object instanceof Capability)) { return false; } if (this == object) { return true; } // Don't check the ID - id is only set through OJB so this would not recognize equality correctly /* if (this.capabilityId != ((Capability)object).getCapabilityId()) return false; */ String oName = ((Capability) object).getName(); if (oName != null && name != null) { return oName.equals(name); } else if (oName == null && name == null) { return true; } else { return false; } } }
/** * Checks to see if the current agent has the specified capability */ public boolean hasCapability(String capability) { Iterator capabilities = capabilityMap.values().iterator(); while (capabilities.hasNext()) { if (((Capability) capabilities.next()).getName().equals(capability)) { return true; } } return false; }
/** * extract the capabilities and save in snapshot file * * @throws SerializerException */ private void exportCapabilites(Refs refs, JSSnapshot snapshot, Map<String,Object> settings, Logger log) throws SerializerException { Iterator list = caps.getCapabilities(); while (list.hasNext()) { try { Capability _cp = (Capability) list.next(); JSCapability _jsC = new JSCapability(); _jsC.setName(_cp.getName()); refs.capabilityMap.put(_jsC.getName(), _jsC); refs.capabilityMapInt.put(new Integer(_cp.getCapabilityId()), _jsC); snapshot.getCapabilities().add(_jsC); } catch (Exception e) { throw new SerializerException( SerializerException.CREATE_SERIALIZED_OBJECT_FAILED .create(new String[] { "C", e.getMessage()})); } } return; }
.getName()); if (jsCapability != null) jsMediaType.getCapabilities().add(jsCapability);
.getName()); if (_ct != null) jsC.getCapabilities().add(_ct);