com.alipay.rdf.file.model.FileSlice Maven / Gradle / Ivy
package com.alipay.rdf.file.model;
import java.io.File;
/**
* Copyright (C) 2013-2018 Ant Financial Services Group
*
* 文件分片的信息
*
* @author hongwei.quhw
* @version $Id: FileSlice.java, v 0.1 2016-12-20 下午4:39:11 hongwei.quhw Exp $
*/
public class FileSlice {
private final FileDataTypeEnum fileDataType;
private final String filePath;
private final long start;
private final long end;
private final String key;
/**
* 初始化一个文件分片的信息, 表示了从start ~ end之间的范围, 其中包括start, 不包括end
* @param start 起始位置
* @param end 终止位置
*/
public FileSlice(String filePath, FileDataTypeEnum fileDataType, long start, long end) {
this.filePath = filePath;
this.fileDataType = fileDataType;
this.start = start;
this.end = end;
this.key = new File(filePath).getName() + "-" + start + "-" + end;
}
public FileDataTypeEnum getFileDataType() {
return fileDataType;
}
/**
* Getter method for property start.
*
* @return property value of start
*/
public long getStart() {
return start;
}
/**
* Getter method for property end.
*
* @return property value of end
*/
public long getEnd() {
return end;
}
/**
* Getter method for property filePath.
*
* @return property value of filePath
*/
public String getFilePath() {
return filePath;
}
/**
* 返回长度, end - start
*/
public long getLength() {
return getEnd() - getStart();
}
/**
* Getter method for property key.
*
* @return property value of key
*/
public String getKey() {
return key;
}
@Override
public String toString() {
return getKey();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy