📄 attributefilter.java
字号:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* Title: XELOPES Data Mining Library
* Description: The XELOPES library is an open platform-independent and data-source-independent library for Embedded Data Mining.
* Copyright: Copyright (c) 2002 Prudential Systems Software GmbH
* Company: ZSoft (www.zsoft.ru), Prudsys (www.prudsys.com)
* @author Michael Thess
* @version 1.2
*/
package com.prudsys.pdm.Olap.Query.DimensionFilters;
import javax.olap.OLAPException;
import javax.olap.query.enumerations.OperatorType;
import javax.olap.query.enumerations.OperatorTypeEnum;
import com.prudsys.pdm.Core.MiningAttribute;
import com.prudsys.pdm.Input.Predicates.Predicate;
import com.prudsys.pdm.Input.Predicates.SimplePredicate;
import com.prudsys.pdm.Olap.Query.Core.DimensionFilter;
import com.prudsys.pdm.Olap.Query.Core.DimensionStepManager;
/**
* Attribute filter class.
*/
public class AttributeFilter extends DimensionFilter implements javax.olap.query.dimensionfilters.AttributeFilter{
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/** Operator. */
protected OperatorType op;
/** Right hand side. */
protected Object rhs;
/** Attribute. */
protected org.omg.cwm.objectmodel.core.Attribute attribute;
/** Predicate for evaluations. */
protected SimplePredicate simplePredicate;
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
/**
* Attribute filter with dimension step manager.
*
* @param dimensionStepManager dimension step manager
*/
public AttributeFilter(DimensionStepManager dimensionStepManager) {
super(dimensionStepManager);
}
// -----------------------------------------------------------------------
// Getter and setter methods
// -----------------------------------------------------------------------
public OperatorType getOp() throws OLAPException {
return op;
}
public void setOp(OperatorType input) throws OLAPException {
this.op = input;
}
public Object getRhs() throws OLAPException {
return rhs;
}
public void setRhs(Object input) throws OLAPException {
this.rhs = input;
}
public void setAttribute(org.omg.cwm.objectmodel.core.Attribute input) throws OLAPException {
this.attribute = input;
}
public org.omg.cwm.objectmodel.core.Attribute getAttribute() throws OLAPException {
return attribute;
}
// -----------------------------------------------------------------------
// Construct selection predicate
// -----------------------------------------------------------------------
public Predicate getPredicate() throws OLAPException {
if ( !(attribute instanceof MiningAttribute) )
throw new OLAPException("AttributeFilter: Attribute no MiningAttribute");
MiningAttribute ma = (MiningAttribute) attribute;
if ( !(rhs instanceof String) )
throw new OLAPException("AttributeFilter: rhs not of String type");
String value = (String) rhs;
int oper = -1;
if (op == OperatorTypeEnum.EQ) {
oper = SimplePredicate.EQUAL;
}
else if (op == OperatorTypeEnum.GE) {
oper = SimplePredicate.GREATER_OR_EQUAL;
}
else if (op == OperatorTypeEnum.GT) {
oper = SimplePredicate.GREATER;
}
else if (op == OperatorTypeEnum.LE) {
oper = SimplePredicate.LESS_OR_EQUAL;
}
else if (op == OperatorTypeEnum.LT) {
oper = SimplePredicate.LESS;
}
else if (op == OperatorTypeEnum.NE) {
oper = SimplePredicate.NOT_EQUAL;
}
else {
throw new OLAPException("AttributeFilter: unknown operator type");
}
simplePredicate = new SimplePredicate(ma, value, oper);
return simplePredicate;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -