package ra;
import core.ColumnLabels;
import core.Formulas;
import core.Relation;
import operators.Operator;
/**
*
* @author Jacek Sroka
*/
public class Result {
private Formulas formulas;
private Relation dummyRelation;
private Relation resultRelation;
private ColumnLabels labels;
public Result() {
formulas = new Formulas();
labels = new ColumnLabels();
dummyRelation = Utils.getCaf().getEmptyRelation();
resultRelation = Utils.getCaf().getEmptyRelation();
}
public Result(Formulas f, Relation dummyR, Relation resultR, ColumnLabels l) {
this();
extend(f, dummyR, resultR, l);
}
public Result(Operator oper) {
this();
extend(oper);
}
public Result(Result other) {
this();
extend(other);
}
public Formulas getFormulas() {
return formulas;
}
public Relation getDummyRelation() {
return dummyRelation;
}
public Relation getResultRelation() {
return resultRelation;
}
public ColumnLabels getLabels() {
return labels;
}
//extends this and returns it
final public Result extend(Formulas f, Relation dummyR, Relation resultR, ColumnLabels l) {
formulas.putAll(f);
formulas.sortColumns();
dummyRelation = dummyR;
resultRelation = resultR;
labels.putAll(l);
return this;
}
final public Result extend(Operator oper) {
return extend(oper.getFormulas(), oper.getDummyRelation(), oper.getResultRelation(), oper.getLabels());
}
final public Result extend(Result other) {
return extend(other.getFormulas(), other.getDummyRelation(), other.getResultRelation(), other.getLabels());
}
public Result clone() {
return new Result(this);
}
}