📄 filesystemsource.java
字号:
/* created at 2005-12-19 */
package com.clustering.data;
import java.io.BufferedReader;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* 数据源来自于文件系统,当前情况.
* <p>
* 该类严重依赖于文件的存储格式,文件的存储格式有Formatter保存,所以该类严重依赖于Formatter
* <p>
* 这里使用三元组存储记录的一个项.所谓的项就是记录的一个字段值
*
* @author Avon
* @version 0.9
* @since 0.9
*/
public abstract class FileSystemSource implements SimpleSource {
protected Formatter formatter;
protected SourceInfo sourceInfo;
protected String location;
protected Log log = LogFactory.getLog(this.getClass());
protected boolean transposable;
public FileSystemSource(String location, Formatter formatter, SourceInfo sourceInfo, boolean transposable) {
this.location = location;
this.formatter = formatter;
this.sourceInfo = sourceInfo;
this.transposable = transposable;
}
/*
* 文件系统的数据源创建就是严格按照这三个属性创建的,因此这三个属性不应该在基于文件系统的数据源创建后被更改
*/
public SourceInfo getSourceInfo() {
return sourceInfo;
}
public Formatter getFormatter() {
return formatter;
}
public String getLocation() {
return location;
}
/**
* 是否转置
* @return 是否转置
*/
public boolean isTransposable() {
return transposable;
}
/*
* 最后还是使用了readLine,这里保留了这个方法,如果以后 数据源的格式变了,可以修改这个方法的逻辑通过
* Formatter.getRecordSeperator以读取记录,应该使用 InputStream来读取数据源文件,这里为了简单使用Reader
* 来读取文件
*/
protected String readLine(BufferedReader reader) {
try {
return reader.readLine();
} catch (IOException exob) {
log.error("File source read error at FileSystemSource.java, line:"
+ new Exception().getStackTrace()[0].getLineNumber());
}
return null;
}
public void destroy() {
// do noting
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -