Class CapabilitiesHelper


  • public class CapabilitiesHelper
    extends Object
    Helper class for capabilities.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • CapabilitiesHelper

        public CapabilitiesHelper()
    • Method Detail

      • contentTypeToCapability

        public static Capability contentTypeToCapability​(Cell.ContentType type,
                                                         boolean isClass)
        Turns the content type of a cell into the corresponding capability.
        Parameters:
        type - the type of the cell
        isClass - whether the column represents a class column
        Returns:
        the capability
      • forDataset

        public static Capabilities forDataset​(Dataset data,
                                              int col)
        Returns capabilities that are required for the specified dataset column. Uses Capability.UNKNOWN_ATTRIBUTE and Capability.UNKNOWN_CLASS for mixed columns.
        Parameters:
        data - the dataset to get the capabilities for
        col - the column to generate the capabilities for
        Returns:
        the capabilities
      • forDataset

        public static Capabilities forDataset​(Dataset data)
        Returns capabilities that are required for the specified dataset.
        Parameters:
        data - the dataset to get the capabilities for
        Returns:
        the capabilities
      • handles

        public static String handles​(CapabilitiesHandler handler,
                                     Dataset data)
        Returns whether the capabilities handler handles the dataset.
        Parameters:
        handler - the handler to check
        data - the dataset to check against
        Returns:
        null if OK, otherwise error message
      • handles

        public static String handles​(Capabilities caps,
                                     Dataset data)
        Returns whether the capabilities can handle the dataset.
        Parameters:
        caps - the capabilities to use as basis
        data - the dataset to check against
        Returns:
        null if OK, otherwise error message
      • handles

        public static String handles​(Capabilities caps,
                                     Dataset data,
                                     int col)
        Returns whether the capabilities can handle the dataset column.
        Parameters:
        caps - the capabilities to use as basis
        data - the dataset to check against
        col - the column to check
        Returns:
        null if OK, otherwise error message
      • adjust

        public static Dataset adjust​(Dataset data,
                                     CapabilitiesHandler handler)
                              throws Exception
        Tries to adjust the dataset to the capabilities of the handler. Cannot adjust capabilities related to class columns
        Parameters:
        handler - the handler to adjust the dataset for
        data - the dataset to adjust
        Returns:
        the adjusted dataset
        Throws:
        Exception - if failed to adjust
      • adjust

        public static Dataset adjust​(Dataset data,
                                     Capabilities caps)
                              throws Exception
        Tries to adjust the dataset to the capabilities. Cannot adjust capabilities related to class columns
        Parameters:
        caps - the capabilities to adjust the dataset for
        data - the dataset to adjust
        Returns:
        the adjusted dataset
        Throws:
        Exception - if failed to adjust