Example #1
0
  /**
   * retrieves the data from the given Capabilities object
   *
   * @param c the capabilities object to initialize with
   */
  public void assign(Capabilities c) {
    for (Capability cap : Capability.values()) {
      // capability
      if (c.handles(cap)) enable(cap);
      else disable(cap);
      // dependency
      if (c.hasDependency(cap)) enableDependency(cap);
      else disableDependency(cap);
    }

    setMinimumNumberInstances(c.getMinimumNumberInstances());
  }
Example #2
0
  /**
   * performs an OR conjunction with the capabilities of the given Capabilities object and updates
   * itself
   *
   * @param c the capabilities to OR with
   */
  public void or(Capabilities c) {
    for (Capability cap : Capability.values()) {
      // capability
      if (handles(cap) || c.handles(cap)) m_Capabilities.add(cap);
      else m_Capabilities.remove(cap);
      // dependency
      if (hasDependency(cap) || c.hasDependency(cap)) m_Dependencies.add(cap);
      else m_Dependencies.remove(cap);
    }

    if (c.getMinimumNumberInstances() < getMinimumNumberInstances())
      setMinimumNumberInstances(c.getMinimumNumberInstances());
  }
Example #3
0
  /**
   * Returns true if the currently set capabilities support (or have a dependency) at least all of
   * the capabilities of the given Capabilities object (checks only the enum!)
   *
   * @param c the capabilities (or dependencies) to support at least
   * @return true if all the requested capabilities are supported (or at least have a dependency)
   */
  public boolean supportsMaybe(Capabilities c) {
    boolean result;

    result = true;

    for (Capability cap : Capability.values()) {
      if (c.handles(cap) && !(handles(cap) || hasDependency(cap))) {
        result = false;
        break;
      }
    }

    return result;
  }
Example #4
0
  /**
   * Returns true if the currently set capabilities support at least all of the capabiliites of the
   * given Capabilities object (checks only the enum!)
   *
   * @param c the capabilities to support at least
   * @return true if all the requested capabilities are supported
   */
  public boolean supports(Capabilities c) {
    boolean result;

    result = true;

    for (Capability cap : Capability.values()) {
      if (c.handles(cap) && !handles(cap)) {
        result = false;
        break;
      }
    }

    return result;
  }
Example #5
0
  /**
   * performs an AND conjunction with the capabilities of the given Capabilities object and updates
   * itself
   *
   * @param c the capabilities to AND with
   */
  public void and(Capabilities c) {
    for (Capability cap : Capability.values()) {
      // capability
      if (handles(cap) && c.handles(cap)) m_Capabilities.add(cap);
      else m_Capabilities.remove(cap);
      // dependency
      if (hasDependency(cap) && c.hasDependency(cap)) m_Dependencies.add(cap);
      else m_Dependencies.remove(cap);
    }

    // minimum number of instances that both handlers need at least to work
    if (c.getMinimumNumberInstances() > getMinimumNumberInstances())
      setMinimumNumberInstances(c.getMinimumNumberInstances());
  }
Example #6
0
  /**
   * Returns default capabilities of the classifier.
   *
   * @return the capabilities of this classifier
   */
  public Capabilities getCapabilities() {
    Capabilities result = getKernel().getCapabilities();
    result.setOwner(this);

    // attribute
    result.enableAllAttributeDependencies();
    // with NominalToBinary we can also handle nominal attributes, but only
    // if the kernel can handle numeric attributes
    if (result.handles(Capability.NUMERIC_ATTRIBUTES)) result.enable(Capability.NOMINAL_ATTRIBUTES);
    result.enable(Capability.MISSING_VALUES);

    // class
    result.disableAllClasses();
    result.disableAllClassDependencies();
    result.disable(Capability.NO_CLASS);
    result.enable(Capability.NUMERIC_CLASS);
    result.enable(Capability.DATE_CLASS);
    result.enable(Capability.MISSING_CLASS_VALUES);

    return result;
  }