📄 multipredicateconvert.java
字号:
/**
* 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.Input.Multidimensional;
import com.prudsys.pdm.Core.MiningException;
import com.prudsys.pdm.Input.Predicates.CompoundPredicate;
import com.prudsys.pdm.Input.Predicates.ConstantPredicate;
import com.prudsys.pdm.Input.Predicates.Predicate;
import com.prudsys.pdm.Input.Predicates.SimplePredicate;
import com.prudsys.pdm.Input.Predicates.SimpleSetPredicate;
/**
* Class for conversions to multi predicates.
*/
public class MultiPredicateConvert
{
/**
* Converts a 'usual' predicate into a MultiPredicate.
*
* @param predicate predicate to convert
* @return corresponding multi predicate
* @exception MiningException can't convert predicate
*/
public static MultiPredicate convertToMultiPredicate(Predicate predicate)
throws MiningException {
if (predicate == null)
return null;
if (predicate instanceof MultiPredicate)
return (MultiPredicate) predicate;
if (predicate instanceof ConstantPredicate) {
ConstantPredicate cp = (ConstantPredicate) predicate;
MultiConstantPredicate mcp = new MultiConstantPredicate( cp.getConstant() );
return mcp;
}
else if (predicate instanceof SimplePredicate) {
SimplePredicate sp = (SimplePredicate) predicate;
MultiSimplePredicate msp = new MultiSimplePredicate( sp.getAttribute(),
sp.getValue(), sp.getOperator() );
return msp;
}
else if (predicate instanceof SimpleSetPredicate) {
SimpleSetPredicate ssp = (SimpleSetPredicate) predicate;
int nval = ssp.getValuesNumber();
MultiSimpleSetPredicate mssp = new MultiSimpleSetPredicate( ssp.getAttribute(),
ssp.getOperator(), nval);
for (int i = 0; i < nval; i++)
mssp.setValue( ssp.getStringValue(i), i );
return mssp;
}
else if (predicate instanceof CompoundPredicate) {
CompoundPredicate cp = (CompoundPredicate) predicate;
int npred = cp.getPredicatesNumber();
MultiCompoundPredicate mcp = new MultiCompoundPredicate( cp.getOperator(),
npred);
for (int i = 0; i < npred; i++)
mcp.setPredicate( cp.getPredicate(i), i );
return mcp;
}
else
throw new MiningException("unknown predicate type");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -