Package reportgen.math.condition.unaryexist

Source Code of reportgen.math.condition.unaryexist.MathExpressionConditionUnaryExist

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

package reportgen.math.condition.unaryexist;

import java.util.ArrayList;
import java.util.List;
import reportgen.math.reference.operator.MathExpressionOperatorRef;
import reportgen.math.reference.operator.variants.MOperator;
import org.jdom.Element;
import reportgen.math.MathExpressionOperand;
import reportgen.prototype.context.Context;
import reportgen.prototype.context.ContextGeneric;
import reportgen.prototype.context.ContextMode;
import reportgen.math.reference.operator.variants.unary.MathOperatorUnary;
import reportgen.utils.ReportException;
import reportgen.prototype.context.group.ContextGroup;
import reportgen.math.condition.MathExpressionConditionUnary;
import reportgen.math.reference.inline.MathExpressionInlineRef;

/**
* @author axe
*/

public class MathExpressionConditionUnaryExist extends MathExpressionConditionUnary {

    public static final ContextGroup GROUP = new UnaryExistCondContextGroup();
    public static final String TAG = "unaryexist";

    public MathExpressionConditionUnaryExist(Context context) {
        super(context);
        MathExpressionOperatorRef operator = new MathExpressionOperatorRef(
                MathOperatorUnary.EXISTS,
                getChildContext(MathExpressionOperatorRef.GROUP)
        );
        setOperator(operator);
    }

    MathExpressionConditionUnaryExist(Context context, MathExpressionOperand operand,
            MathExpressionOperatorRef operator) {
        super(context, operand, operator);
    }

    public MathExpressionConditionUnaryExist(Element element, Context context) throws ReportException {
        super(element, context);
    }

    @Override
    public MathExpressionConditionUnaryExist makeClone() throws ReportException {
        return new MathExpressionConditionUnaryExist(toXML(), getParentContext());
    }

    @Override
    public Context getChildContext(ContextGroup group) {
        if(group.isTheSameType(MathExpressionOperatorRef.GROUP)) {
            return new ContextGeneric(getParentContext()) {
                @Override
                public ContextMode getContextMode() {
                    return getParentContext().getContextMode();
                }

                @Override
                public List<ContextGroup> getAvailiableGroups() {
                    List<ContextGroup> res = new ArrayList<ContextGroup>();
                    res.add(MathExpressionOperatorRef.GROUP);
                    return res;
                }

                @Override
                public List<MOperator> getOperators() {
                    List<MOperator> model = new ArrayList<MOperator>();
                    model.add(MathOperatorUnary.EXISTS);
                    model.add(MathOperatorUnary.NOTEXISTS);
                    return model;
                }
            };
        }
        return getParentContext();
    }
   
    @Override
    public Context getLocalContext() {
        return new ContextGeneric(getParentContext()) {

            @Override
            public ContextMode getContextMode() {
                return getParentContext().getContextMode();
            }
           
            @Override
            public List<ContextGroup> getAvailiableGroups() {
                List<ContextGroup> res = new ArrayList<ContextGroup>();
                res.add(MathExpressionOperatorRef.GROUP);
                res.add(MathExpressionInlineRef.GROUP);
                return res;
            }
        };
    }


    @Override
    public ContextGroup getContextGroup() {
        return GROUP;
    }

    @Override
    protected String getRootTag() {
        return TAG;
    }

    @Override
    public MathExpressionInlineRef getOperand() {
        return (MathExpressionInlineRef) super.getOperand();
    }



}
TOP

Related Classes of reportgen.math.condition.unaryexist.MathExpressionConditionUnaryExist

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.