Constructor
new HTMLTableWrapperUtils()
Not actually a constructor as there are no instance methods; underlying definition is an empty object. Documented as a class for the purposes of this documentation generator only.
- Source:
Members
(static, constant) COLUMN_TYPE_INFER :number
Indicates the values of cells within a column should be inferred, and converted to an appropriate underlying type prior to processing.
Type:
- number
- Source:
(static, constant) COLUMN_TYPE_TEXT :number
Indicates the values of cells within a column should be considered to be text only, and can be directly processed.
Type:
- number
- Source:
(static, constant) FILTER_FLAG_IGNORE_CASE :number
Bit flag indicating string-type comparisons during a filtering operation should ignore case.
Type:
- number
- Source:
(static, constant) FILTER_FLAG_NOT :number
Bit flag indicating the requested filtering operation should be logically negated.
Type:
- number
- Source:
(static, constant) FILTER_OP_CONTAINS :number
Bit flag indicating only cells containing a specified value should remain after a filtering operation.
Type:
- number
- Source:
(static, constant) FILTER_OP_EQUALS :number
Bit flag indicating only cells with a value equal to a specified value should remain after a filtering operation.
Type:
- number
- Source:
(static, constant) FILTER_OP_GREATER_THAN :number
Bit flag indicating only cells with a value greater than a specified value should remain after a filtering operation.
Type:
- number
- Source:
(static, constant) FILTER_OP_LESS_THAN :number
Bit flag indicating only cells with a value less than a specified value should remain after a filtering operation.
Type:
- number
- Source:
Methods
(private, static) getNumber(val, strictopt)
Utility function for obtaining a number from the given val
. If the given val
is, itself, a number, it
is simply returned. If not, it is treated as a string, and parsed as an integer if it contains only digits,
or as a float if it contains a decimal point and/or a scientific E-notation exponents. If val
is not numeric
and not parsable as a number, it is returned as-is if strict is false
, or NaN
is returned if strict is true
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
val |
string | number | Value to be converted to a number. |
||
strict |
boolean |
<optional> |
false | Whether to return |
- Source:
(static) shouldInclude(cellValue, operation, compareValue, columnType) → {boolean}
Utility function to aid in the implementation of FilterDescriptor#include. Compares the given cellValue
to the given compareValue
using
the given operator
and columnType
.
The operator
is a combination of the operator and flag bitfield constants defined on this class. Namely, it is a combination of one or more of the
following operators:
- HTMLTableWrapperUtils.FILTER_OP_EQUALS
- HTMLTableWrapperUtils.FILTER_OP_GREATER_THAN
- HTMLTableWrapperUtils.FILTER_OP_LESS_THAN
- HTMLTableWrapperUtils.FILTER_OP_CONTAINS
And optionally has zero or more of the following flags set:
Comparisons are performed in two distinct steps. The first are the 'simple' comparisons, which correspond to the combination of the relational operator
bitfields: HTMLTableWrapperUtils.FILTER_OP_EQUALS, HTMLTableWrapperUtils.FILTER_OP_LESS_THAN, and HTMLTableWrapperUtils.FILTER_OP_GREATER_THAN.
The next is the 'contains' comparison (corresponding to the HTMLTableWrapperUtils.FILTER_OP_CONTAINS bitfield). The 'contains' comparison is only performed
if its corresponding flag is set, and the 'simple' (relational) comparisons fail, and/or none of their flags are set. I.e. this function will
return true
on the first (requested) comparison that succeeds, otherwise false
.
For the 'simple' relational comparisons (outlined above), if columnType
is HTMLTableWrapperUtils.COLUMN_TYPE_INFER, the given values will be treated as
numbers if they are so convertible, otherwise they will be compared as given; if HTMLTableWrapperUtils.COLUMN_TYPE_TEXT, they will be converted
to strings prior to comparison. For the 'contains' comparison, the values are always converted to strings; columnType
has no effect on the 'contains' comparison.
If the HTMLTableWrapperUtils.FILTER_FLAG_IGNORE_CASE flag is set, it only affects the result of the 'simple' relational comparisons if the given columnType
is HTMLTableWrapperUtils.COLUMN_TYPE_TEXT, or the inferred value of a column is a string. The flag will always, however, affect the 'contains' comparison.
In either case, though, the applicable values are converted to a consistent case prior to comparison.
If the HTMLTableWrapperUtils.FILTER_FLAG_NOT flag is set, it forms the logical negation of the 'simple' relational comparisons. E.g. (in logical terms) 'equals' becomes 'not equal to', 'less than' becomes 'greater than or equal to', etc. For the 'contains' comparison, it simply causes the logical inverse of the result to be returned. Of note, the HTMLTableWrapperUtils.FILTER_FLAG_NOT flag only affects the operators, and has no effect on the HTMLTableWrapperUtils.FILTER_FLAG_IGNORE_CASE flag; if HTMLTableWrapperUtils.FILTER_FLAG_IGNORE_CASE is set, case will always be ignored for string-type comparisons, regardless of whether HTMLTableWrapperUtils.FILTER_FLAG_NOT is set.
Parameters:
Name | Type | Description |
---|---|---|
cellValue |
string | number | Value of the current cell being tested. |
operation |
number | Bitfield representing the combination of one or more |
compareValue |
string | number | Value against which to test the given |
columnType |
number | One of the |
- Source:
Returns:
true
if any of the requested comparisons succeed, otherwise false
.
- Type
- boolean