📄 measuredimension.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.Metadata;
import java.util.Vector;
import javax.olap.OLAPException;
import com.prudsys.pdm.Core.MiningException;
import com.prudsys.pdm.Input.MiningInputStream;
import com.prudsys.pdm.Models.Statistics.SimpleStats;
/**
* Xelopes OLAOP dimension that contains measure.
*/
public class MeasureDimension extends com.prudsys.pdm.Olap.Metadata.Dimension {
// -----------------------------------------------------------------------
// Variables declarations
// -----------------------------------------------------------------------
/** Contains all measure attributes. */
protected Vector measureAttributes = new Vector();
/** Mining input stream to be used for measure calculation. */
protected MiningInputStream inputStream = null;
/** Object for statistics calculation. */
protected SimpleStats stats = new SimpleStats();
// -----------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------
/**
* Empty constructor.
*/
public MeasureDimension() {
}
// -----------------------------------------------------------------------
// Getter and setter methods
// -----------------------------------------------------------------------
/**
* Add measure attribute.
*
* @param attribute new measure attribute
* @throws OLAPException attribute no instance of Measure
*/
public void addInputAttribute(org.omg.cwm.objectmodel.core.Attribute
attribute) throws OLAPException {
if (! (attribute instanceof Measure)) {
throw new OLAPException("attribute no instance of Measure class");
}
Measure measure = (Measure) attribute;
measure.setMeasureDimension(this);
// Add attribute to dimension:
addFeature(measure);
// Add to measure attribute:
measureAttributes.addElement(measure);
}
/**
* Returns the number of dimension measures.
*
* @return number of dimension measures
*/
public int getNumberOfDimensionAttributes() {
return measureAttributes.size();
}
/**
* Returns all measures of this dimension.
*
* @return vector of measures of this dimension
*/
public Vector getDimensionAttributes() {
return measureAttributes;
}
/**
* Returns measure attribute that corresponds to specified number.
*
* @param index specified attribute index
* @return attribute of this index, null if not found
*/
public Measure getMeasureAttribute(int index) {
if (index < 0 || index >= measureAttributes.size())
return null;
return (Measure) measureAttributes.elementAt(index);
}
/**
* Returns input stream for measure calculation.
*
* @return input stream for measure calculation
*/
public MiningInputStream getInputStream() {
return inputStream;
}
/**
* Sets input stream for measure calculation.
*
* @param inputStream new input stream for measure calculation
*/
public void setInputStream(MiningInputStream inputStream) {
this.inputStream = inputStream;
this.stats.setInputStream(inputStream);
}
/**
* Returns statistics object.
*
* @return statistics object
*/
public SimpleStats getStats() {
return stats;
}
/**
* Sets new statistics object.
*
* @param stats new statistics object
*/
public void setStats(SimpleStats stats) {
this.stats = stats;
}
// -----------------------------------------------------------------------
// Run statistics calculations
// -----------------------------------------------------------------------
/**
* Calculate basic statisticsl characteristics that can be used
* for calculating the measure.
*
* @throws OLAPException cannot calculate statistical characteristics
*/
public void calcStatistics() throws OLAPException {
try {
stats.runCalculation(true);
}
catch (MiningException ex) {
throw new OLAPException( ex.toString() );
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -