Package org.rcsb.cif.model
Class ModelFactory
- java.lang.Object
-
- org.rcsb.cif.model.ModelFactory
-
public class ModelFactory extends Object
The factory for model instances for cases when they are somewhat difficult or ambiguously to obtain.
-
-
Constructor Summary
Constructors Constructor Description ModelFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CategorycreateCategoryBinary(String categoryName, int rowCount, Object[] encodedColumns)Create aCategoryfrom binary data.static CategorycreateCategoryBinaryGeneric(String categoryName, int rowCount, Object[] encodedColumns)Create aCategoryfrom binary data.static CategorycreateCategoryText(String categoryName, Map<String,Column> textColumns)Create aCategoryfrom text data.static CategorycreateCategoryTextGeneric(String categoryName, Map<String,Column> textColumns)Create aCategoryfrom text data.static ColumncreateColumnBinary(String categoryName, String columnName, Map<String,Object> encodedColumn)The creation method for aColumnbased on binary (still encoded) data.static ColumncreateColumnText(String categoryName, String columnName, String data, int[] startToken, int[] endToken)The creation method for aColumnbased on text data which is not yet parsed.static ColumncreateColumnText(String categoryName, String columnName, String data, int[] startToken, int[] endToken, Class<? extends Column> columnType)The creation method for aColumnbased on text data which is not yet parsed.static ColumncreateColumnTextGeneric(String columnName, String data, int[] startToken, int[] endToken)The creation method for aColumnbased on text data which is not yet parsed.static CategorycreateEmptyCategory(String name)Create an emptyCategory, void of data.static ColumncreateEmptyColumn(String categoryName, String columnName)The creation method for aColumnwhich is absent.
-
-
-
Method Detail
-
createCategoryText
public static Category createCategoryText(String categoryName, Map<String,Column> textColumns)
Create aCategoryfrom text data. Tries to find a strict (i.e. concrete implementation by reflection using the internal) instance of the requestedCategory.- Parameters:
categoryName- the category nametextColumns- the text data to provide within this category- Returns:
- the created instance
-
createCategoryTextGeneric
public static Category createCategoryTextGeneric(String categoryName, Map<String,Column> textColumns)
Create aCategoryfrom text data. Make no effort to determine the type and roll withBaseCategory.- Parameters:
categoryName- the category nametextColumns- the text data to provide within this category- Returns:
- the created instance
-
createCategoryBinary
public static Category createCategoryBinary(String categoryName, int rowCount, Object[] encodedColumns)
Create aCategoryfrom binary data. Tries to find a strict (i.e. concrete implementation by reflection using the internal) instance of the requestedCategory.- Parameters:
categoryName- the category namerowCount- the row countencodedColumns- 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 aCategoryfrom binary data. No efforts to find a concrete implementation of the requestedCategory.- Parameters:
categoryName- the category namerowCount- the row countencodedColumns- the data, still encoded, to be decoded once requested- Returns:
- the created instance
-
createEmptyCategory
public static Category createEmptyCategory(String name)
Create an emptyCategory, void of data. Used, so that the data model does not throw aNullPointerExceptionungracefully. Rather the consumer should enquire whether theCategorypresent (seeCategory.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 aColumnbased on text data which is not yet parsed.- Parameters:
categoryName- the category to retrieve this class fromcolumnName- the column name to createdata- the raw string data to parsestartToken- the collection of start indices which will be used to extract dataendToken- 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 aColumnbased on text data which is not yet parsed.- Parameters:
categoryName- the category to retrieve this class fromcolumnName- the column name to createdata- the raw string data to parsestartToken- the collection of start indices which will be used to extract dataendToken- the collection of end indices which will be used to extract datacolumnType- 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 aColumnbased 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 createdata- the raw string data to parsestartToken- the collection of start indices which will be used to extract dataendToken- 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 aColumnbased on binary (still encoded) data.- Parameters:
categoryName- the category name to createcolumnName- the column name to createencodedColumn- a map encompassing all information needed to create this column- Returns:
- the decoded column
-
-