All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.lightlink.excel.AbstractExcelStreamVisitor Maven / Gradle / Ivy

There is a newer version: 1.2.4
Show newest version
package io.lightlink.excel;

/*
 * #%L
 * LightLink Core
 * %%
 * Copyright (C) 2015 - 2016 Vitaliy Shevchuk
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */


import java.util.List;

public abstract class AbstractExcelStreamVisitor extends ExcelStreamVisitor {

    @Override
    public void visit(RowNode rowNode, RowPrintCallback rowPrintCallback) {


        List cells = rowNode.getCells();
        int size = cells.size();

        int rowRepeat = getRowRepeatCount(rowNode);
        for (int r = 0; r < rowRepeat; r++) {
            nextRow();
            RowNode cloneRowNode = rowNode.clone();
            for (int i = 0; i < size; i++) {
                CellNode cell = cells.get(i);
                handleCell(cloneRowNode, rowPrintCallback, i, cell);
            }
            rowPrintCallback.printRowNode(cloneRowNode);
        }

    }

    protected void nextRow() {
        // do nothing by default
    }

    protected int getRowRepeatCount(RowNode rowNode) {
        return 1;
    }

    protected void handleCell(RowNode rowNode, RowPrintCallback rowPrintCallback, int i, CellNode cell) {
        String s = cell.getDecodedValue();
        if (s != null && s.startsWith(":")) {
            String trimmedValue = s.trim();

            String property = trimmedValue.substring(1); // cut leading :
            handleBinding(property, rowNode, i, rowPrintCallback);

        }
    }

    protected void handleBinding(String property, RowNode rowNode, int i, RowPrintCallback rowPrintCallback) {

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy