📄 algorithmstatusmessage.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-2004 prudsys AG
* Company: ZSoft (www.zsoft.ru), Prudsys (www.prudsys.com)
* @author Toni Volkmer
* @version 1.0
*/
package com.prudsys.pdm.Core.Event;
import java.lang.String;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;
import com.prudsys.pdm.Core.MiningEventMessage;
/**
* Object used as description in MiningEvent.
* This message object is created by the algorithms to give status reports.
*
* @author Toni Volkmer
*/
public class AlgorithmStatusMessage extends MiningEventMessage {
/**
* Constant for any message which signals that a model creation has started.
*/
public static final int MESSAGE_CREATION_MODEL_BEGIN = 3;
/**
* Constant for any message which signals that a model creation has finished.
*/
public static final int MESSAGE_CREATION_MODEL_END = 4;
/**
* Constant for all messages that do not belong to any of the other groups.
*/
public static final int MESSAGE_OTHER = 0;
/**
* Constant for any message which signals that reading of data has started.
*/
public static final int MESSAGE_READING_BEGIN = 1;
/**
* Constant for any message which signals that reading of data has finished.
*/
public static final int MESSAGE_READING_END = 2;
/* public static final int TYPE_GLOBAL = 0;
public static final int TYPE_LOCAL = 1; */
/**
* Contains locale name used for creating language-dependent messages.
*/
private static String localeName = "";
/**
* Contains language-specific messages.
*/
private static ResourceBundle resources = null;
/**
* Contains the value of one of the constants.
*/
public int messageGroup;
// public int messageType;
/**
* Contains the number of parent algorithms, the algorithm which created this message, has.
* Default value is 0.
*/
int level = 0;
/**
* Constructor setting level to 0 and empty message.
* @param group type of message.
*/
public AlgorithmStatusMessage(int group) {
this(group, 0, null);
}
/**
* Constructor.
* @param group type of message
* @param level number of parent algorithms
* @param msg message description
*/
public AlgorithmStatusMessage(int group, int level, String msg) {
if(msg==null)
msg = "";
this.messageGroup = group;
// this.messageType = type;
this.level = level;
this.description = msg;
}
/**
* Constructor for message type MESSAGE_OTHER.
* @param level number of parent algorithms
* @param key key value in resources
* @param params parameter for resources, may be null
*/
public AlgorithmStatusMessage(int level, String key, Object[] params) {
this(MESSAGE_OTHER, level, getDescription(key, params));
}
/**
* Constructor.
* @param group type of message
* @param level number of parent algorithms
* @param key key value in resources
* @param params parameter for resources, may be null
*/
public AlgorithmStatusMessage(int group, int level, String key, Object[] params) {
this(group, level, getDescription(key, params));
}
/**
* Constructor for message type MESSAGE_OTHER, level 0 and no parameter.
* @param key key value in resources
*/
public AlgorithmStatusMessage(String key) {
this(key, null);
}
/**
* Constructor for message type MESSAGE_OTHER and level 0.
* @param key key value in resources
* @param params parameter for resources, may be null
*/
public AlgorithmStatusMessage(String key, Object[] params) {
this(MESSAGE_OTHER, 0, key, params);
}
/**
* Returns type of message.
* @return constant for message type.
*/
public int getMessageGroup() {
return messageGroup;
}
/* public int getMessageType() {
return messageType;
}*/
/**
* Returns language-specific String for resources key and parameters.
* @param key key value in resources
* @param params parameter for resources, may be null
* @return language-specific message as String representation
*/
public static String getDescription(String key, Object[] params) {
String descr = null;
try {
if(resources==null)
resources = ResourceBundle.getBundle("com.prudsys.pdm.Core.Event.EventMessages");
descr = resources.getString(key);
descr = MessageFormat.format(descr, params);
}
catch (Exception ex) {
// ex.printStackTrace();
}
if(descr==null)
descr = "";
return descr;
}
/**
* Returns locale name used for creating language-dependent messages.
* @return locale name as String representation
*/
public static String getLocaleName() {
return localeName;
}
/**
* Returns resources for language-specific messages
* @return resources
*/
public static ResourceBundle getResources() {
return resources;
}
/**
* Sets locale name and updates created new ResourceBundle.
* @param s locale name
*/
public static void setLocaleName(String s) {
if(s==null || s.equals("")) {
localeName = "";
setResources( EventResourceBundle.getBundle(
"com.prudsys.pdm.Core.Event.EventMessages", null, AlgorithmStatusMessage.class.getClassLoader()) );
}
else {
localeName = s;
Locale l = new Locale(localeName);
setResources( EventResourceBundle.getBundle(
"com.prudsys.pdm.Core.Event.EventMessages", l, AlgorithmStatusMessage.class.getClassLoader()) );
}
}
/**
* Sets new ResourceBundle.
* @param bundle resources
*/
public static void setResources(ResourceBundle bundle) {
resources = bundle;
}
/**
* Returns the number of parent algorithms, the algorithm which created this message, has.
* @return number of parent algorithms
*/
public int getLevel() {
return level;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -