/**
 * Copyright 2017 - 2018  The Hyve B.V.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */ import { TableDimension } from './table-dimension' ; import { Row } from './row' ; import { Col } from './col' ; import { Constraint } from '../constraint-models/constraint' ; import { TrueConstraint } from '../constraint-models/true-constraint' ; export class DataTable { private _constraint : Constraint ; private _rowDimensions : Array < TableDimension > ; private _columnDimensions : Array < TableDimension > ; private _rows : Array < Row > ; private _cols : Array < Col > ; private _isLastPage : boolean ; private _offset : number ; private _limit : number ; private _currentPage : number ; constructor ( ) { this . constraint = new TrueConstraint ( ) ; this . isLastPage = false ; this . currentPage = 1 ; this . offset = 0 ; this . limit = 10 ; this . clear ( ) ; } clear ( ) { this . clearDimensions ( ) ; this . clearCells ( ) ; } clearDimensions ( ) { this . rowDimensions = [ ] ; this . columnDimensions = [ ] ; } clearCells ( ) { this . rows = [ ] ; this . cols = [ ] ; } get rowDimensions ( ) : Array < TableDimension > { return this . _rowDimensions ; } set rowDimensions ( value ) { this . _rowDimensions = value ; } get columnDimensions ( ) : Array < TableDimension > { return this . _columnDimensions ; } set columnDimensions ( value ) { this . _columnDimensions = value ; } get rows ( ) : Array < Row > { return this . _rows ; } set rows ( value ) { this . _rows = value ; } get cols ( ) : Array < Col > { return this . _cols ; } set cols ( value ) { this . _cols = value ; } get constraint ( ) : Constraint { return this . _constraint ; } set constraint ( value ) { this . _constraint = value ; } get offset ( ) : number { return this . _offset ; } set offset ( value ) { this . _offset = value ; } get limit ( ) : number { return this . _limit ; } set limit ( value ) { this . _limit = value ; } get isLastPage ( ) : boolean { return this . _isLastPage ; } set isLastPage ( value ) { this . _isLastPage = value ; } get currentPage ( ) : number { return this . _currentPage ; } set currentPage ( value ) { this . _currentPage = value ; this . offset = this . limit * ( value - 1 ) ; } }