Class ModelFactory


  • public class ModelFactory
    extends Object
    The factory for model instances for cases when they are somewhat difficult or ambiguously to obtain.
    • Constructor Detail

      • ModelFactory

        public ModelFactory()
    • Method Detail

      • createCategoryText

        public static Category createCategoryText​(String categoryName,
                                                  Map<String,​Column> textColumns)
        Create a Category from text data. Tries to find a strict (i.e. concrete implementation by reflection using the internal) instance of the requested Category.
        Parameters:
        categoryName - the category name
        textColumns - the text data to provide within this category
        Returns:
        the created instance
      • createCategoryTextGeneric

        public static Category createCategoryTextGeneric​(String categoryName,
                                                         Map<String,​Column> textColumns)
        Create a Category from text data. Make no effort to determine the type and roll with BaseCategory.
        Parameters:
        categoryName - the category name
        textColumns - the text data to provide within this category
        Returns:
        the created instance
      • createCategoryBinary

        public static Category createCategoryBinary​(String categoryName,
                                                    int rowCount,
                                                    Object[] encodedColumns)
        Create a Category from binary data. Tries to find a strict (i.e. concrete implementation by reflection using the internal) instance of the requested Category.
        Parameters:
        categoryName - the category name
        rowCount - the row count
        encodedColumns - the data, still encoded, to be decoded once requested
        Returns:
        the created instance
      • createCategoryBinaryGeneric

        public static Category createCategoryBinaryGeneric​(String categoryName,
                                                           int rowCount,
                                                           Object[] encodedColumns)
        Create a Category from binary data. No efforts to find a concrete implementation of the requested Category.
        Parameters:
        categoryName - the category name
        rowCount - the row count
        encodedColumns - the data, still encoded, to be decoded once requested
        Returns:
        the created instance
      • createEmptyCategory

        public static Category createEmptyCategory​(String name)
        Create an empty Category, void of data. Used, so that the data model does not throw a NullPointerException ungracefully. Rather the consumer should enquire whether the Category present (see Category.isDefined(). Has row count 0 and can report its name.
        Parameters:
        name - the name this category should report
        Returns:
        an empty category which will report being undefined
      • createColumnText

        public static Column createColumnText​(String categoryName,
                                              String columnName,
                                              String data,
                                              int[] startToken,
                                              int[] endToken)
        The creation method for a Column based on text data which is not yet parsed.
        Parameters:
        categoryName - the category to retrieve this class from
        columnName - the column name to create
        data - the raw string data to parse
        startToken - the collection of start indices which will be used to extract data
        endToken - the collection of end indices which will be used to extract data
        Returns:
        the text column, ready to parse particular rows
      • createColumnText

        public static Column createColumnText​(String categoryName,
                                              String columnName,
                                              String data,
                                              int[] startToken,
                                              int[] endToken,
                                              Class<? extends Column> columnType)
        The creation method for a Column based on text data which is not yet parsed.
        Parameters:
        categoryName - the category to retrieve this class from
        columnName - the column name to create
        data - the raw string data to parse
        startToken - the collection of start indices which will be used to extract data
        endToken - the collection of end indices which will be used to extract data
        columnType - the column type to enforce when not in dictionary
        Returns:
        the text column, ready to parse particular rows
      • createColumnTextGeneric

        public static Column createColumnTextGeneric​(String columnName,
                                                     String data,
                                                     int[] startToken,
                                                     int[] endToken)
        The creation method for a Column based on text data which is not yet parsed. Don't make any attempt at determining the type. It's a String!
        Parameters:
        columnName - the column name to create
        data - the raw string data to parse
        startToken - the collection of start indices which will be used to extract data
        endToken - the collection of end indices which will be used to extract data
        Returns:
        the StrColumn, ready to parse particular rows
      • createColumnBinary

        public static Column createColumnBinary​(String categoryName,
                                                String columnName,
                                                Map<String,​Object> encodedColumn)
        The creation method for a Column based on binary (still encoded) data.
        Parameters:
        categoryName - the category name to create
        columnName - the column name to create
        encodedColumn - a map encompassing all information needed to create this column
        Returns:
        the decoded column
      • createEmptyColumn

        public static Column createEmptyColumn​(String categoryName,
                                               String columnName)
        The creation method for a Column which is absent.
        Parameters:
        categoryName - the category to retrieve this class from
        columnName - the column name to create
        Returns:
        an empty instance of this column