/*
* Created on 2004/11/13
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package org.jpn.xucker.subtitle.sub;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;
/**
*
*
*/
public class SUBObject implements Comparable{
private int startFrame;
private int endFrame;
private String text;
public String getPrintString(){
String line="";
if(text!=null){
line=StringUtils.replace(text,"|",SystemUtils.LINE_SEPARATOR);
}
return line;
}
public int getEndFrame() {
return endFrame;
}
public void setEndFrame(int endFrame) {
this.endFrame = endFrame;
}
public String getText() {
return text;
}
public void setText(String fileName) {
this.text = fileName;
}
public int getStartFrame() {
return startFrame;
}
public void setStartFrame(int startFrame) {
this.startFrame = startFrame;
}
public String toString(){
return ""+startFrame+","+endFrame+","+text;
}
public int getBetweenFrame(){
return endFrame-startFrame;
}
public boolean contain(SUBObject data){
/* return (data.getStartFrame()>=this.getStartFrame() && data.getStartFrame()<=this.getEndFrame())
||
(data.getEndFrame()>=this.getStartFrame() && data.getEndFrame()<=this.getEndFrame())
;*/
return countContainFrame(data)>0;
}
public int countContainFrame(SUBObject data){
int result=0;
for(int i=data.getStartFrame();i<=data.getEndFrame();i++){
if(i>=this.getStartFrame() && i<=this.getEndFrame()){
result++;
}
}
return result;
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(Object o) {
if(o instanceof SUBObject){
return this.getStartFrame()-((SUBObject)o).getStartFrame();
}
// TODO Auto-generated method stub
return 0;
}
}
|