com.spss.psapi.data

Interface DataModel



  • public interface DataModel
    This defines the properties of a set of columns. Applications that wish to construct data model instances must do so using the DataModelFactory rather than implementing the interface directly.
    Since:
    PSAPI 1.0
    Version:
    1.1
    Author:
    Julian Clinton, Rob Duncan
    See Also:
    Column, DataModelFactory
    Specification Status:
    Under Development
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface and Description
      static interface  DataModel.ColumnFilter
      A column filter can be used to extract a subset of a data model, returning a new data model.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      java.util.Iterator columnGroupIterator()
      Returns an iterator that returns each column group in turn.
      java.util.Iterator columnIterator()
      Returns an iterator that returns each column in the "natural" insert order.
      boolean contains(java.lang.String name)
      Returns true if a column with the supplied name exists in this DataModel, false otherwise.
      DataModel filterDataModel(DataModel.ColumnFilter columnFilter)
      Returns a new data model with the supplied filter applied to all columns in the data model.
      Column getColumn(java.lang.String name)
      Returns the column with the specified name.
      int getColumnCount()
      Returns the number of columns in this set.
      ColumnGroup getColumnGroup(java.lang.String name)
      Returns the named column group or null if no such column group exists.
      int getColumnGroupCount()
      Returns the number of column groups in this data model.
      java.lang.String getColumnLabel(java.lang.String name)
      Returns the label of the named column or an empty string if there is no label associated with the column.
      ExtendedMeasure getExtendedMeasure(java.lang.String name)
      Returns additional metadata that is specific for this field.
      ExtendedStorage getExtendedStorage(java.lang.String name)
      Returns additional metadata for this field's storage or null if no additional storage metadata is defined.
      java.lang.Object getFalseFlag(java.lang.String name)
      Returns the "false" indicator value for the column, or null if either the value is not known or the column is not a flag.
      java.lang.Object getLowerBound(java.lang.String name)
      Returns the lower bound value for the values in the named column, or null if either the value is not known or the column is not continuous.
      MeasureType getMeasureType(java.lang.String name)
      Returns the measure type for values in the named column.
      MissingValueDefinition getMissingValueDefinition(java.lang.String name)
      Returns the missing value definition for the column or null.
      ModelingRole getModelingRole(java.lang.String name)
      Returns the modeling role for the named column.
      DataModel getPredictedColumns()
      Returns the set of columns which are being predicted by columns in this data model.
      java.lang.Object[] getSetValues(java.lang.String name)
      Returns an array of valid values for the column, or null if either the values are not known or the column is not a set.
      StorageType getStorageType(java.lang.String name)
      Returns the storage type for values in the named column.
      java.lang.Object getTrueFlag(java.lang.String name)
      Returns the "true" indicator value for the column, or null if either the value is not known or the column is not a flag.
      java.lang.Object getUpperBound(java.lang.String name)
      Returns the upper bound value for the values in the named column, or null if either the value is not known or the column is not continuous.
      java.lang.String getValueLabel(java.lang.String name, java.lang.Object value)
      Returns the label for the value in the named column or an empty string if there is no label associated with the value.
      boolean hasMissingValueDefinition(java.lang.String name)
      Returns true if the column has a missing value definition.
      boolean isList(java.lang.String name)
      Returns true if this field is a list field.
      boolean isMeasureDiscrete(java.lang.String name)
      Returns true if the column is discrete.
      boolean isModelOutputColumn(java.lang.String name)
      Returns true if this is a model output column.
      boolean isStorageDatetime(java.lang.String name)
      Returns true if the column's storage is a time, date or timestamp value.
      boolean isStorageNumeric(java.lang.String name)
      Returns true if the column's storage is an integer or a real number.
      boolean isValidValue(java.lang.String name, java.lang.Object value)
      Returns true if the specified value is valid for this storage and valid when the valid column values are known.
      DataModel modifyColumns(java.util.Collection<Column> modifiedColumns)
      Creates and returns a new data model based on this data model with the specified columns modified.
      java.util.Iterator nameIterator()
      Returns an iterator that returns the name of each column in the "natural" insert order.
      DataModel removeColumns(java.util.Collection<java.lang.String> columnNames)
      Creates and returns a new data model based on this data model with the specified columns modified.
      DataModel renameColumns(java.util.Map<java.lang.String,java.lang.String> modifiedNames)
      Creates and returns a new data model based on this data model with the specified columns renamed.
      Column[] toArray()
      Returns the data model as an array of columns.
    • Method Detail

      • getColumnCount

        int getColumnCount()
        Returns the number of columns in this set.
        Returns:
        the number of columns in this set
      • nameIterator

        java.util.Iterator nameIterator()
        Returns an iterator that returns the name of each column in the "natural" insert order.
        Returns:
        an iterator that returns the name of each column in the "natural" insert order
      • columnIterator

        java.util.Iterator columnIterator()
        Returns an iterator that returns each column in the "natural" insert order. The iterator returns instances of Column.
        Returns:
        an iterator that returns each column in the "natural" insert order
        Since:
        PSAPI 2.0
        See Also:
        Column
      • contains

        boolean contains(java.lang.String name)
        Returns true if a column with the supplied name exists in this DataModel, false otherwise.
        Parameters:
        name - the column name
        Returns:
        true if the column with the supplied name exists in this DataModel, false otherwise
      • toArray

        Column[] toArray()
        Returns the data model as an array of columns. The columns are ordered in their natural/insert order.
        Returns:
        an array of the columns in the data model
        Since:
        PSAPI 2.0
      • getStorageType

        StorageType getStorageType(java.lang.String name)
                                   throws DataModelException
        Returns the storage type for values in the named column.
        Parameters:
        name - the column name
        Returns:
        the storage type
        Throws:
        DataModelException - if the named column does not exist
      • getMeasureType

        MeasureType getMeasureType(java.lang.String name)
                                   throws DataModelException
        Returns the measure type for values in the named column.
        Parameters:
        name - the column name
        Returns:
        the measure type
        Throws:
        DataModelException - if the named column does not exist
      • getModelingRole

        ModelingRole getModelingRole(java.lang.String name)
                                     throws DataModelException
        Returns the modeling role for the named column.
        Parameters:
        name - the column name
        Returns:
        the modeling role
        Throws:
        DataModelException - if the named column does not exist
      • isMeasureDiscrete

        boolean isMeasureDiscrete(java.lang.String name)
                                  throws DataModelException
        Returns true if the column is discrete. Columns that are either a set or a flag are considered discrete.
        Parameters:
        name - the column name
        Returns:
        true if the column is either a set or a flag type, false otherwise.
        Throws:
        DataModelException - if the named column does not exist
      • isStorageNumeric

        boolean isStorageNumeric(java.lang.String name)
                                 throws DataModelException
        Returns true if the column's storage is an integer or a real number.
        Parameters:
        name - the column name
        Returns:
        true if the column's storage is an integer or a real number, false otherwise.
        Throws:
        DataModelException - if the named column does not exist
      • isStorageDatetime

        boolean isStorageDatetime(java.lang.String name)
                                  throws DataModelException
        Returns true if the column's storage is a time, date or timestamp value.
        Parameters:
        name - the column name
        Returns:
        true if the column's storage is a time, date or timestamp value, false otherwise.
        Throws:
        DataModelException - if the named column does not exist
      • getLowerBound

        java.lang.Object getLowerBound(java.lang.String name)
                                       throws DataModelException
        Returns the lower bound value for the values in the named column, or null if either the value is not known or the column is not continuous.
        Parameters:
        name - the column name
        Returns:
        the lower bound value for the column or null
        Throws:
        DataModelException - if the named column does not exist
      • getUpperBound

        java.lang.Object getUpperBound(java.lang.String name)
                                       throws DataModelException
        Returns the upper bound value for the values in the named column, or null if either the value is not known or the column is not continuous.
        Parameters:
        name - the column name
        Returns:
        the upper bound value for the column or null
        Throws:
        DataModelException - if the named column does not exist
      • getSetValues

        java.lang.Object[] getSetValues(java.lang.String name)
                                        throws DataModelException
        Returns an array of valid values for the column, or null if either the values are not known or the column is not a set.
        Parameters:
        name - the column name
        Returns:
        an array of valid values for named column or null
        Throws:
        DataModelException - if the named column does not exist
      • getTrueFlag

        java.lang.Object getTrueFlag(java.lang.String name)
                                     throws DataModelException
        Returns the "true" indicator value for the column, or null if either the value is not known or the column is not a flag.
        Parameters:
        name - the column name
        Returns:
        the true value for named column or null
        Throws:
        DataModelException - if the named column does not exist
      • getFalseFlag

        java.lang.Object getFalseFlag(java.lang.String name)
                                      throws DataModelException
        Returns the "false" indicator value for the column, or null if either the value is not known or the column is not a flag.
        Parameters:
        name - the column name
        Returns:
        the true value for named column or null
        Throws:
        DataModelException - if the named column does not exist
      • isValidValue

        boolean isValidValue(java.lang.String name,
                           java.lang.Object value)
                             throws DataModelException
        Returns true if the specified value is valid for this storage and valid when the valid column values are known.
        Parameters:
        name - the column name
        value - the value
        Returns:
        true if the specified value is valid for this storage and valid when the valid column values are known
        Throws:
        DataModelException - if the named column does not exist
      • hasMissingValueDefinition

        boolean hasMissingValueDefinition(java.lang.String name)
                                          throws DataModelException
        Returns true if the column has a missing value definition.
        Parameters:
        name - the column name
        Returns:
        true if the column has missing value definition
        Throws:
        DataModelException - if the named column does not exist
      • getMissingValueDefinition

        MissingValueDefinition getMissingValueDefinition(java.lang.String name)
                                                         throws DataModelException
        Returns the missing value definition for the column or null.
        Parameters:
        name - the column name
        Returns:
        the missing value definition for the column or null
        Throws:
        DataModelException - if the named column does not exist
      • getColumnLabel

        java.lang.String getColumnLabel(java.lang.String name)
                                        throws DataModelException
        Returns the label of the named column or an empty string if there is no label associated with the column.
        Parameters:
        name - the column name
        Returns:
        the label for the value in the named column or an empty string
        Throws:
        DataModelException - if the named column does not exist
        Since:
        PSAPI 1.1
      • getValueLabel

        java.lang.String getValueLabel(java.lang.String name,
                                     java.lang.Object value)
                                       throws DataModelException
        Returns the label for the value in the named column or an empty string if there is no label associated with the value.
        Parameters:
        name - the column name
        value - the value
        Returns:
        the label for the value in the named column or an empty string
        Throws:
        DataModelException - if the named column does not exist
        Since:
        PSAPI 1.1
      • isModelOutputColumn

        boolean isModelOutputColumn(java.lang.String name)
                                    throws DataModelException
        Returns true if this is a model output column.
        Parameters:
        name - the column name
        Returns:
        true if this is a model output column
        Throws:
        DataModelException - if the named column does not exist
        Since:
        PSAPI 2.0
      • getColumnGroupCount

        int getColumnGroupCount()
        Returns the number of column groups in this data model.
        Returns:
        the number of column groups in this data model
        Since:
        PSAPI 12.0
      • columnGroupIterator

        java.util.Iterator columnGroupIterator()
        Returns an iterator that returns each column group in turn.
        Returns:
        an iterator that returns each column group in turn
        Since:
        PSAPI 12.0
      • getColumnGroup

        ColumnGroup getColumnGroup(java.lang.String name)
        Returns the named column group or null if no such column group exists.
        Parameters:
        name -
        Returns:
        the named column group or null
        Since:
        PSAPI 12.0
      • getExtendedMeasure

        ExtendedMeasure getExtendedMeasure(java.lang.String name)
                                           throws DataModelException
        Returns additional metadata that is specific for this field. For example, geospatial fields may return a geospatial-specific descriptor that defines the metadata necessary for the correct interpretation of the values.
        Parameters:
        name - the column name
        Returns:
        the extended metadata for named column or null
        Throws:
        DataModelException - if the named column does not exist
        Since:
        PSAPI 17.0
        See Also:
        isList(String)
      • modifyColumns

        DataModel modifyColumns(java.util.Collection<Column> modifiedColumns)
                                throws DataModelException
        Creates and returns a new data model based on this data model with the specified columns modified. The supplied columns will be used to replace any existing column with the same name meaning that this method cannot be used to change the name of columns in the data model. If a supplied column name does not match an existing column, it will be ignored.
        Parameters:
        modifiedColumns - the columns to be modified
        Returns:
        the updated data model
        Throws:
        DataModelException - if the modified columns are invalid
        Since:
        PSAPI 17.0
        See Also:
        renameColumns(Map), removeColumns(Collection)
      • renameColumns

        DataModel renameColumns(java.util.Map<java.lang.String,java.lang.String> modifiedNames)
                                throws DataModelException
        Creates and returns a new data model based on this data model with the specified columns renamed. If the map contains keys that do not correspond to colunms in the data model, the key will be ignored.
        Parameters:
        modifiedNames - a map containing the original column names as the key and the new name as the associated value
        Returns:
        an updated data model
        Throws:
        DataModelException - if the new column names are invalid, for example cause the data model to have duplicate names.
        Since:
        PSAPI 17.0
        See Also:
        modifyColumns(Collection), removeColumns(Collection)
      • removeColumns

        DataModel removeColumns(java.util.Collection<java.lang.String> columnNames)
                                throws DataModelException
        Creates and returns a new data model based on this data model with the specified columns modified. The supplied columns will be used to replace any existing column with the same name meaning that this method cannot be used to change the name of columns in the data model. If a supplied column does not match an existing column, it will be added to the end of the data model.
        Parameters:
        modifiedColumns - the columns to be modified
        Returns:
        the updated data model
        Throws:
        DataModelException - if the modified columns are invalid
        Since:
        PSAPI 17.0
        See Also:
        renameColumns(Map), modifyColumns(Collection)
      • getPredictedColumns

        DataModel getPredictedColumns()
        Returns the set of columns which are being predicted by columns in this data model. For example, if this data model includes predictor columns such as predictedDrug and predictedIncome then the resulting data model will contain metadata about the original columns being predicted, even if this data model does not include the original columns (as would be the case for deployment). The resulting data model may not include all the original metadata about each predicted column, and may be empty.
        Returns:
        a data model containing matadata about columns whose values are being predicted by columns in this data model
        Since:
        PSAPI 18.1
      • filterDataModel

        DataModel filterDataModel(DataModel.ColumnFilter columnFilter)
        Returns a new data model with the supplied filter applied to all columns in the data model. The natural insert order of the returned data model is consistent with the insert order in this data model.
        Parameters:
        columnFilter - the column filter
        Returns:
        a new data model

(C) Copyright IBM Corp. 1994, 2015. All Rights Reserved.