📄 pmmlexporter.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.
*/
/*
* Created on 2005/1/13
*
* $Author$
* $Date$
* $Revision$
*
*/
package eti.bi.alphaminer.operation.result.export;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import com.prudsys.pdm.Transform.Filter.MiningFileFilter;
import eti.bi.exception.AppException;
import eti.bi.exception.SysException;
/**
* @author kelvinj
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class PmmlExporter extends FileExporter{
public final static MiningFileFilter FILTER;
public final static String EXTENSION = "xml";
public final static String DESCRIPTION = "PMML Files";
public static File DEFAULT_FILE = new File("pmml1.xml");
private String m_PmmlString = new String();
static
{
FILTER = new MiningFileFilter();
FILTER.addExtension(EXTENSION);
FILTER.setDescription(DESCRIPTION);
}
public PmmlExporter(String a_PmmlString, File a_File, boolean a_EnforceFileName)
{
m_PmmlString = a_PmmlString;
if (a_EnforceFileName && !FILTER.accept(a_File))
{
String oldPath = a_File.getAbsolutePath();
String newPath = oldPath.concat(".");
newPath = newPath.concat(EXTENSION);
File newFile = new File(newPath);
m_ExportFile = newFile;
}else
{
m_ExportFile = a_File;
}
}
/* (non-Javadoc)
* @see eti.bi.alphaminer.common.util.FileExporter#export()
*/
public void export() throws SysException, AppException {
if (m_ExportFile != null && m_ExportFile.exists())
{
if (!m_ExportFile.delete())
{
throw new AppException("File '"+m_ExportFile.getAbsolutePath()+"' is already open.");
}
}
try {
FileWriter fileWriter = new FileWriter(m_ExportFile);
fileWriter.write(m_PmmlString);
fileWriter.close();
} catch (FileNotFoundException e) {
// e.printStackTrace();
new AppException("Could not find file " + m_ExportFile.getAbsolutePath());
} catch (IOException e1) {
// e1.printStackTrace();
new AppException("Unable to access file " + m_ExportFile.getAbsolutePath());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -