Class AbstractColumn<T>

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.mixin.KeyAccessor

        org.refcodes.mixin.KeyAccessor.KeyBuilder<K extends Object,​B extends org.refcodes.mixin.KeyAccessor.KeyBuilder<K,​B>>, org.refcodes.mixin.KeyAccessor.KeyMutator<K extends Object>, org.refcodes.mixin.KeyAccessor.KeyProperty<K extends Object>
      • Nested classes/interfaces inherited from interface org.refcodes.mixin.TypeAccessor

        org.refcodes.mixin.TypeAccessor.TypeBuilder<T extends Object,​B extends org.refcodes.mixin.TypeAccessor.TypeBuilder<T,​B>>, org.refcodes.mixin.TypeAccessor.TypeMutator<T extends Object>, org.refcodes.mixin.TypeAccessor.TypeProperty<T extends Object>
    • Constructor Detail

      • AbstractColumn

        public AbstractColumn​(String aKey,
                              Class<T> aType)
        Constructs a column.
        Parameters:
        aKey - The key describing the column.
        aType - The type describing the column.
    • Method Detail

      • toStorageString

        public String toStorageString​(T aValue)
        A Column implementation can provide its own text exchange format for the given objects. This method enables the Column to convert a value of the given type to a String and via Column.fromStorageString(String) back to the value (bijective). This method supports data sinks (such as relational databases) which allow only a single value in a row's entry: In case T is an array type, then the storage String representation of the elements in that array are represented by a single returned String. Question: Why does the detour through the method Column.toStorageString(Object) not function?!? Having this snippet in the code seems to be fine for the compiler ... trying Column.toStorageString_(Object) instead :-( In case a data sink (such as Amazon's SimpleDb) is to be addressed which provides dedicated support for multiple values in one row's entry, then the method Column.toStorageStrings(Object) may be used instead.
        Specified by:
        toStorageString in interface Column<T>
        Parameters:
        aValue - the element to be converted to a String.
        Returns:
        The String representation of the value.
      • fromStorageString

        public T fromStorageString​(String aStringValue)
                            throws ParseException
        A Column implementation can provide its own text exchange format for the given objects. This method enables the Column to convert a String value to a value of the given type and via Column.toStorageString(Object) back to the String (bijective). This method supports data sinks (such as relational databases) which allow only a single value in a row's entry: In case T is an array type, then the storage String representation of the elements in that array are represented by the single passed String. In case a data sink (such as Amazon's SimpleDb) is to be addressed which provides dedicated support for multiple values in one row's entry, then the method Column.fromStorageStrings(String[]) may be used instead.
        Specified by:
        fromStorageString in interface Column<T>
        Parameters:
        aStringValue - The value to be converted to a type instance.
        Returns:
        The type representation of the value.
        Throws:
        ParseException - in case parsing the String was not possible
      • toPrintable

        public String toPrintable​(T aValue)
        A Column implementation can provide its own printable format of the given objects; for example a human readable text representation of the value (or in very specialized cases even enriched with ANSI escape codes). This method enables the Column to convert a value of the given type to a human readable text. The human readable text, in comparison to the method Object.toString() (or Column.toStorageString(Object)) is not intended to be converted back to the actual value (not bijective). This method may be used a Header instance's method HeaderRow.toPrintable(Record).
        Specified by:
        toPrintable in interface Column<T>
        Parameters:
        aValue - the element to be converted to a human readable text.
        Returns:
        The human readable representation of the value.
      • contains

        public boolean contains​(Record<?> aRecord)
        Tests whether the Record contains a value identified by the Column instance's key and where the value's type is assignable to the Column instance's type. Only if them both criteria match, then true is returned. False is returned if there is no such value or the value is not assignable to the Column instance's type.
        Specified by:
        contains in interface Column<T>
        Parameters:
        aRecord - The Record which to test if there is a value associated to the Column instance's key and if it can be casted to the Column instance's type.
        Returns:
        True in case the Record contains a value identified by the Column instance's key and where the value's type is assignable to the Column instance's type.
      • remove

        public T remove​(Record<?> aRecord)
                 throws ColumnMismatchException
        Removes an entry (key and value pair) from the provided Record matching the key and the type of the Column.
        Specified by:
        remove in interface Column<T>
        Parameters:
        aRecord - The Record from which to remove the related entry.
        Returns:
        The value related to the given Column instance's key or null if there was none such value found.
        Throws:
        ColumnMismatchException - in case the value in the Record associated with the Column instance's key does not fit the Column instance's type.
      • getType

        public Class<T> getType()
        Specified by:
        getType in interface org.refcodes.mixin.TypeAccessor<T>
      • getKey

        public String getKey()
        Specified by:
        getKey in interface org.refcodes.mixin.KeyAccessor<T>