Package reportgen.ren.report.extendedformat

Source Code of reportgen.ren.report.extendedformat.DataRange

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package reportgen.ren.report.extendedformat;

import org.jdom.Element;
import reportgen.prototype.context.Context;
import reportgen.utils.ReportException;
import reportgen.math.complex.conditions.MathExpressionConditions;
import reportgen.utils.SupportXMLRootImpl;
import reportgen.utils.Atom;
import simplesheet.style.Style;
import simplesheet.model.cell.StyleDefault;

/**
*
* @author axe
*/
abstract public class DataRange extends SupportXMLRootImpl {

    private static final String ATTR_TITLE = "title";

    private final Atom atom;
    private final Context context;
    private final Style style;
    private MathExpressionConditions criteria;
    private String title;

    public DataRange(String title, Context context) {
        this.title = title;
        this.context = context;
        this.criteria = new MathExpressionConditions(context);
        atom = new Atom();
        style = new StyleDefault();
    }

    protected DataRange(Element element, Context context) throws ReportException {
        this.context = context;
        atom = new Atom(element, context);
        title = getStringAttribute(element, ATTR_TITLE);
        style = new StyleAdaptor(element).getStyle();
       
        Element criteriaEl = element.getChild(MathExpressionConditions.TAG);
        if(criteriaEl != null) {
            criteria = new MathExpressionConditions(criteriaEl, context);
        } else {
            criteria = new MathExpressionConditions(context);
        }
    }

    @Override
    protected void toXML(Element root) {
        atom.toXML(root);
        root.setAttribute(ATTR_TITLE, title);
        Element StyleElement = new StyleAdaptor(style).toXML();
        if(StyleElement != null) {
            root.addContent(StyleElement);
        }
        if(!criteria.isEmpty()) {
            root.addContent(criteria.toXML());
        }
    }

    public Style getStyle() {
        return style;
    }

    public final Context getParentContext() {
        return context;
    }

    public Context getLocalContext() {
        return context;
    }

    public Atom getAtom() {
        return atom;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public MathExpressionConditions getCriteria() {
        return criteria;
    }

    public void setCriteria(MathExpressionConditions criteria) {
        this.criteria = criteria;
    }

    /**
     *
     * @param entity
     * @return
     */
    public boolean isContain(Object object) {
        if(this == object || criteria.isContain(object)) {
            return true;
        }
        return false;
    }

    public void validate() throws ReportException {
        criteria.validate();
    }
}
TOP

Related Classes of reportgen.ren.report.extendedformat.DataRange

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.