/** * Checks to see if the current agent has the specified capability */ public boolean hasCapability(int capability) { Iterator capabilities = capabilityMap.values().iterator(); while (capabilities.hasNext()) { if (((Capability) capabilities.next()).getCapabilityId() == capability) { return true; } } return false; }
/** 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); }
/** * 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; }
public Capability createCapability(String capabilityName) throws ClassNotFoundException { Capability capability = null; if (capabilityName != null) { //try to find it in space capability = this.getCapability(capabilityName); if (capability != null) return capability; } try { capability = (Capability) beanFactory.getBean( this.capabilityBeanName, Capability.class); capability.setName(capabilityName); return capability; } catch (Exception e) { log.error("Failed to create capability instance for " + this.capabilityBeanName + " error : " + e.getLocalizedMessage()); throw new ClassNotFoundException("Spring failed to create the " + " capability bean.", e); } }
public void addCapability(Capability capability) { if (capabilities == null) capabilities = new ArrayList(); if (!capabilities.contains(capability.getName())) { capabilities.add(capability); } }
|| (capability.getCapabilityId() == 0))
/** * 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; }
.getName()); if (jsCapability != null) jsMediaType.getCapabilities().add(jsCapability);
.getName()); if (_ct != null) jsC.getCapabilities().add(_ct);