Class RecordMetaDataImpl<C extends Context>

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) <T> java.lang.annotation.Annotation buildAnnotation​(java.lang.Class<T> type, java.lang.String args1, java.lang.String... args2)  
      (package private) static java.lang.annotation.Annotation buildBooleanStringAnnotation​(java.lang.String[] trueStrings, java.lang.String[] falseStrings)  
      boolean containsColumn​(java.lang.String headerName)
      Queries whether a given header name exists in the Records parsed from the input
      private static java.lang.Object convert​(MetaData md, java.lang.String[] data, Conversion[] conversions)  
      private <T> T convert​(MetaData md, java.lang.String[] data, java.lang.Class<T> expectedType, Conversion[] conversions)  
      private <T> T convert​(MetaData md, java.lang.String[] data, java.lang.Class<T> type, T defaultValue, java.lang.annotation.Annotation annotation)  
      private java.lang.Object convert​(MetaData md, java.lang.String[] data, java.lang.Object defaultValue, Conversion[] conversions)  
      FieldSet<java.lang.String> convertFields​(Conversion... conversions)
      Associates a sequence of Conversions to fields of a given set of field names
      <T extends java.lang.Enum<T>>
      FieldSet<T>
      convertFields​(java.lang.Class<T> enumType, Conversion... conversions)
      Associates a sequence of Conversions to fields of a given set of fields
      FieldSet<java.lang.Integer> convertIndexes​(Conversion... conversions)
      Associates a sequence of Conversions to fields of a given set of column indexes
      java.lang.Object defaultValueOf​(int columnIndex)
      Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))
      java.lang.Object defaultValueOf​(java.lang.Enum<?> column)
      Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))
      java.lang.Object defaultValueOf​(java.lang.String headerName)
      Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))
      private FieldConversionMapping getConversions()  
      MetaData getMetaData​(int index)  
      private MetaData getMetaData​(java.lang.Enum<?> column)  
      private MetaData getMetaData​(java.lang.String name)  
      (package private) <T> T getObjectValue​(java.lang.String[] data, int columnIndex, java.lang.Class<T> type, T defaultValue)  
      (package private) <T> T getObjectValue​(java.lang.String[] data, int columnIndex, java.lang.Class<T> type, T defaultValue, java.lang.String format, java.lang.String... formatOptions)  
      (package private) <T> T getObjectValue​(java.lang.String[] data, java.lang.Enum<?> column, java.lang.Class<T> type, T defaultValue)  
      (package private) <T> T getObjectValue​(java.lang.String[] data, java.lang.Enum<?> column, java.lang.Class<T> type, T defaultValue, java.lang.String format, java.lang.String... formatOptions)  
      (package private) <T> T getObjectValue​(java.lang.String[] data, java.lang.String headerName, java.lang.Class<T> type, T defaultValue)  
      (package private) <T> T getObjectValue​(java.lang.String[] data, java.lang.String headerName, java.lang.Class<T> type, T defaultValue, java.lang.String format, java.lang.String... formatOptions)  
      private NormalizedString[] getValidatedHeaders()  
      (package private) java.lang.String getValue​(java.lang.String[] data, int columnIndex)  
      (package private) <T> T getValue​(java.lang.String[] data, int columnIndex, java.lang.Class<T> expectedType, Conversion[] conversions)  
      (package private) <T> T getValue​(java.lang.String[] data, int columnIndex, T defaultValue, Conversion[] conversions)  
      (package private) java.lang.String getValue​(java.lang.String[] data, java.lang.Enum<?> column)  
      (package private) <T> T getValue​(java.lang.String[] data, java.lang.Enum<?> column, java.lang.Class<T> expectedType, Conversion[] conversions)  
      (package private) <T> T getValue​(java.lang.String[] data, java.lang.Enum<?> column, T defaultValue, Conversion[] conversions)  
      (package private) java.lang.String getValue​(java.lang.String[] data, java.lang.String headerName)  
      (package private) <T> T getValue​(java.lang.String[] data, java.lang.String headerName, java.lang.Class<T> expectedType, Conversion[] conversions)  
      (package private) <T> T getValue​(java.lang.String[] data, java.lang.String headerName, T defaultValue, Conversion[] conversions)  
      java.lang.String[] headers()
      Returns the column names of the Records parsed from the input.
      int indexOf​(java.lang.Enum<?> column)
      Returns the index of a given column
      int indexOf​(java.lang.String headerName)
      Returns the index of a given column
      private void initializeMetadataConversions​(java.lang.String[] data, MetaData md)  
      (package private) MetaData metadataOf​(int columnIndex)  
      (package private) MetaData metadataOf​(java.lang.Enum<?> column)  
      (package private) MetaData metadataOf​(java.lang.String headerName)  
      private static java.lang.annotation.Annotation newFormatAnnotation​(java.lang.String format, java.lang.String... formatOptions)  
      java.lang.String[] selectedHeaders()
      Returns the sequence of headers that have been selected.
      <T> void setDefaultValueOfColumns​(T defaultValue, int... columnIndexes)
      Associates a default value with one or more columns, in case the values contained are null
      <T> void setDefaultValueOfColumns​(T defaultValue, java.lang.Enum<?>... columns)
      Associates a default value with one or more columns, in case the values contained are null
      <T> void setDefaultValueOfColumns​(T defaultValue, java.lang.String... headerNames)
      Associates a default value with one or more columns, in case the values contained are null
      void setTypeOfColumns​(java.lang.Class<?> type, int... columnIndexes)
      Associates a type with one or more column.
      void setTypeOfColumns​(java.lang.Class<?> type, java.lang.Enum... columns)
      Associates a type with one or more column.
      void setTypeOfColumns​(java.lang.Class<?> type, java.lang.String... headerNames)
      Associates a type with one or more column.
      java.lang.Class<?> typeOf​(int columnIndex)
      Returns the type associated with a given column, defined with the method setTypeOfColumns(type, columns)
      java.lang.Class<?> typeOf​(java.lang.Enum<?> column)
      Returns the type associated with a given column, defined with the method setTypeOfColumns(type, columns)
      java.lang.Class<?> typeOf​(java.lang.String headerName)
      Returns the type associated with a given column name, defined with the method setTypeOfColumns(type, columns)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • context

        final C extends Context context
      • conversionByType

        private java.util.Map<java.lang.Class,​Conversion> conversionByType
      • conversionsByAnnotation

        private java.util.Map<java.lang.Class,​java.util.Map<java.lang.annotation.Annotation,​Conversion>> conversionsByAnnotation
      • annotationHashes

        private java.util.Map<java.lang.Integer,​java.lang.annotation.Annotation> annotationHashes
    • Constructor Detail

      • RecordMetaDataImpl

        RecordMetaDataImpl​(C context)
    • Method Detail

      • getMetaData

        private MetaData getMetaData​(java.lang.String name)
      • getMetaData

        private MetaData getMetaData​(java.lang.Enum<?> column)
      • getMetaData

        public MetaData getMetaData​(int index)
      • indexOf

        public int indexOf​(java.lang.Enum<?> column)
        Description copied from interface: RecordMetaData
        Returns the index of a given column
        Specified by:
        indexOf in interface RecordMetaData
        Parameters:
        column - the column whose index will be returned
        Returns:
        index of the given column
      • metadataOf

        MetaData metadataOf​(java.lang.String headerName)
      • metadataOf

        MetaData metadataOf​(java.lang.Enum<?> column)
      • metadataOf

        MetaData metadataOf​(int columnIndex)
      • indexOf

        public int indexOf​(java.lang.String headerName)
        Description copied from interface: RecordMetaData
        Returns the index of a given column
        Specified by:
        indexOf in interface RecordMetaData
        Parameters:
        headerName - name of the column whose index will be returned
        Returns:
        index of the given column
      • typeOf

        public java.lang.Class<?> typeOf​(java.lang.Enum<?> column)
        Description copied from interface: RecordMetaData
        Returns the type associated with a given column, defined with the method setTypeOfColumns(type, columns)
        Specified by:
        typeOf in interface RecordMetaData
        Parameters:
        column - the column whose type will be returned
        Returns:
        the type of the given column
      • typeOf

        public java.lang.Class<?> typeOf​(java.lang.String headerName)
        Description copied from interface: RecordMetaData
        Returns the type associated with a given column name, defined with the method setTypeOfColumns(type, columns)
        Specified by:
        typeOf in interface RecordMetaData
        Parameters:
        headerName - name of the column whose type will be returned
        Returns:
        the type of the given column
      • typeOf

        public java.lang.Class<?> typeOf​(int columnIndex)
        Description copied from interface: RecordMetaData
        Returns the type associated with a given column, defined with the method setTypeOfColumns(type, columns)
        Specified by:
        typeOf in interface RecordMetaData
        Parameters:
        columnIndex - the position of the column whose type will be returned
        Returns:
        the type of the given column
      • setDefaultValueOfColumns

        public <T> void setDefaultValueOfColumns​(T defaultValue,
                                                 java.lang.Enum<?>... columns)
        Description copied from interface: RecordMetaData
        Associates a default value with one or more columns, in case the values contained are null
        Specified by:
        setDefaultValueOfColumns in interface RecordMetaData
        Type Parameters:
        T - type of the default value.
        Parameters:
        defaultValue - the value to be used for the given column when the parsed result is null
        columns - the columns to be associated with a default value.
      • setDefaultValueOfColumns

        public <T> void setDefaultValueOfColumns​(T defaultValue,
                                                 java.lang.String... headerNames)
        Description copied from interface: RecordMetaData
        Associates a default value with one or more columns, in case the values contained are null
        Specified by:
        setDefaultValueOfColumns in interface RecordMetaData
        Type Parameters:
        T - type of the default value.
        Parameters:
        defaultValue - the value to be used for the given column when the parsed result is null
        headerNames - the column names to be associated with a default value.
      • setDefaultValueOfColumns

        public <T> void setDefaultValueOfColumns​(T defaultValue,
                                                 int... columnIndexes)
        Description copied from interface: RecordMetaData
        Associates a default value with one or more columns, in case the values contained are null
        Specified by:
        setDefaultValueOfColumns in interface RecordMetaData
        Type Parameters:
        T - type of the default value.
        Parameters:
        defaultValue - the value to be used for the given column when the parsed result is null
        columnIndexes - the column indexes to be associated with a default value.
      • defaultValueOf

        public java.lang.Object defaultValueOf​(java.lang.Enum<?> column)
        Description copied from interface: RecordMetaData
        Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))
        Specified by:
        defaultValueOf in interface RecordMetaData
        Parameters:
        column - the column whose default value will be returned
        Returns:
        the default value associated with the given column or null.
      • defaultValueOf

        public java.lang.Object defaultValueOf​(java.lang.String headerName)
        Description copied from interface: RecordMetaData
        Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))
        Specified by:
        defaultValueOf in interface RecordMetaData
        Parameters:
        headerName - the column name whose default value will be returned
        Returns:
        the default value associated with the given column or null.
      • defaultValueOf

        public java.lang.Object defaultValueOf​(int columnIndex)
        Description copied from interface: RecordMetaData
        Returns the default value associated with a column (defined using setDefaultValueOf(Column, Object))
        Specified by:
        defaultValueOf in interface RecordMetaData
        Parameters:
        columnIndex - the column index whose default value will be returned
        Returns:
        the default value associated with the given column or null.
      • convertFields

        public <T extends java.lang.Enum<T>> FieldSet<T> convertFields​(java.lang.Class<T> enumType,
                                                                       Conversion... conversions)
        Description copied from interface: RecordMetaData
        Associates a sequence of Conversions to fields of a given set of fields
        Specified by:
        convertFields in interface RecordMetaData
        Type Parameters:
        T - the enumeration type
        Parameters:
        enumType - the type of the enumeration whose values represent headers in the input Records
        conversions - the sequence of conversions to apply
        Returns:
        (modifiable) set of fields to be selected and against which the given conversion sequence will be applied.
      • convertFields

        public FieldSet<java.lang.String> convertFields​(Conversion... conversions)
        Description copied from interface: RecordMetaData
        Associates a sequence of Conversions to fields of a given set of field names
        Specified by:
        convertFields in interface RecordMetaData
        Parameters:
        conversions - the sequence of conversions to apply
        Returns:
        (modifiable) set of fields names to be selected and against which the given conversion sequence will be applied.
      • convertIndexes

        public FieldSet<java.lang.Integer> convertIndexes​(Conversion... conversions)
        Description copied from interface: RecordMetaData
        Associates a sequence of Conversions to fields of a given set of column indexes
        Specified by:
        convertIndexes in interface RecordMetaData
        Parameters:
        conversions - the sequence of conversions to apply
        Returns:
        (modifiable) set of column indexes to be selected and against which the given conversion sequence will be applied.
      • selectedHeaders

        public java.lang.String[] selectedHeaders()
        Description copied from interface: RecordMetaData
        Returns the sequence of headers that have been selected. If no selection has been made, all available headers will be returned, producing the same output as a call to method RecordMetaData.headers().
        Specified by:
        selectedHeaders in interface RecordMetaData
        Returns:
        the sequence of selected headers, or all headers if no selection has been made.
      • getValue

        java.lang.String getValue​(java.lang.String[] data,
                                  java.lang.String headerName)
      • getValue

        java.lang.String getValue​(java.lang.String[] data,
                                  int columnIndex)
      • getValue

        java.lang.String getValue​(java.lang.String[] data,
                                  java.lang.Enum<?> column)
      • convert

        private <T> T convert​(MetaData md,
                              java.lang.String[] data,
                              java.lang.Class<T> expectedType,
                              Conversion[] conversions)
      • convert

        private java.lang.Object convert​(MetaData md,
                                         java.lang.String[] data,
                                         java.lang.Object defaultValue,
                                         Conversion[] conversions)
      • convert

        private static java.lang.Object convert​(MetaData md,
                                                java.lang.String[] data,
                                                Conversion[] conversions)
      • getValue

        <T> T getValue​(java.lang.String[] data,
                       java.lang.String headerName,
                       T defaultValue,
                       Conversion[] conversions)
      • getValue

        <T> T getValue​(java.lang.String[] data,
                       int columnIndex,
                       T defaultValue,
                       Conversion[] conversions)
      • getValue

        <T> T getValue​(java.lang.String[] data,
                       java.lang.Enum<?> column,
                       T defaultValue,
                       Conversion[] conversions)
      • getValue

        <T> T getValue​(java.lang.String[] data,
                       java.lang.String headerName,
                       java.lang.Class<T> expectedType,
                       Conversion[] conversions)
      • getValue

        <T> T getValue​(java.lang.String[] data,
                       int columnIndex,
                       java.lang.Class<T> expectedType,
                       Conversion[] conversions)
      • getValue

        <T> T getValue​(java.lang.String[] data,
                       java.lang.Enum<?> column,
                       java.lang.Class<T> expectedType,
                       Conversion[] conversions)
      • convert

        private <T> T convert​(MetaData md,
                              java.lang.String[] data,
                              java.lang.Class<T> type,
                              T defaultValue,
                              java.lang.annotation.Annotation annotation)
      • initializeMetadataConversions

        private void initializeMetadataConversions​(java.lang.String[] data,
                                                   MetaData md)
      • getObjectValue

        <T> T getObjectValue​(java.lang.String[] data,
                             java.lang.String headerName,
                             java.lang.Class<T> type,
                             T defaultValue)
      • getObjectValue

        <T> T getObjectValue​(java.lang.String[] data,
                             int columnIndex,
                             java.lang.Class<T> type,
                             T defaultValue)
      • getObjectValue

        <T> T getObjectValue​(java.lang.String[] data,
                             java.lang.Enum<?> column,
                             java.lang.Class<T> type,
                             T defaultValue)
      • getObjectValue

        <T> T getObjectValue​(java.lang.String[] data,
                             java.lang.String headerName,
                             java.lang.Class<T> type,
                             T defaultValue,
                             java.lang.String format,
                             java.lang.String... formatOptions)
      • getObjectValue

        <T> T getObjectValue​(java.lang.String[] data,
                             int columnIndex,
                             java.lang.Class<T> type,
                             T defaultValue,
                             java.lang.String format,
                             java.lang.String... formatOptions)
      • getObjectValue

        <T> T getObjectValue​(java.lang.String[] data,
                             java.lang.Enum<?> column,
                             java.lang.Class<T> type,
                             T defaultValue,
                             java.lang.String format,
                             java.lang.String... formatOptions)
      • buildBooleanStringAnnotation

        static java.lang.annotation.Annotation buildBooleanStringAnnotation​(java.lang.String[] trueStrings,
                                                                            java.lang.String[] falseStrings)
      • newFormatAnnotation

        private static java.lang.annotation.Annotation newFormatAnnotation​(java.lang.String format,
                                                                           java.lang.String... formatOptions)
      • buildAnnotation

        <T> java.lang.annotation.Annotation buildAnnotation​(java.lang.Class<T> type,
                                                            java.lang.String args1,
                                                            java.lang.String... args2)
      • setTypeOfColumns

        public void setTypeOfColumns​(java.lang.Class<?> type,
                                     java.lang.Enum... columns)
        Description copied from interface: RecordMetaData
        Associates a type with one or more column. This allows the parsed data to be converted automatically to the given type when reading data from a Record, e.g. Record.toFieldObjectMap(String...) will convert the selected field values to their respective types, and then set the result as the values in the map.
        Specified by:
        setTypeOfColumns in interface RecordMetaData
        Parameters:
        type - the type to associate with a list of column
        columns - the columns that will be associated with the given type.
      • setTypeOfColumns

        public void setTypeOfColumns​(java.lang.Class<?> type,
                                     java.lang.String... headerNames)
        Description copied from interface: RecordMetaData
        Associates a type with one or more column. This allows the parsed data to be converted automatically to the given type when reading data from a Record, e.g. Record.toFieldObjectMap(String...) will convert the selected field values to their respective types, and then set the result as the values in the map.
        Specified by:
        setTypeOfColumns in interface RecordMetaData
        Parameters:
        type - the type to associate with a list of column
        headerNames - the columns that will be associated with the given type.
      • setTypeOfColumns

        public void setTypeOfColumns​(java.lang.Class<?> type,
                                     int... columnIndexes)
        Description copied from interface: RecordMetaData
        Associates a type with one or more column. This allows the parsed data to be converted automatically to the given type when reading data from a Record, e.g. Record.toFieldObjectMap(String...) will convert the selected field values to their respective types, and then set the result as the values in the map.
        Specified by:
        setTypeOfColumns in interface RecordMetaData
        Parameters:
        type - the type to associate with a list of column
        columnIndexes - the columns that will be associated with the given type.
      • containsColumn

        public boolean containsColumn​(java.lang.String headerName)
        Description copied from interface: RecordMetaData
        Queries whether a given header name exists in the Records parsed from the input
        Specified by:
        containsColumn in interface RecordMetaData
        Parameters:
        headerName - name of the header
        Returns:
        true if the given header name exists in the input records, otherwise false