/*
* Created on 2005/02/09
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package org.jpn.xucker.commons.ipod;
import org.apache.commons.lang.StringUtils;
/**
*
*
*/
public class DoubleLineTextPopper implements TextPopper{
private String baseText;
/* (non-Javadoc)
* @see org.jpn.xucker.commons.ipod.TextPopper#nextLine()
*/
public String nextLine() {
if(baseText.length()==0){
return null;
}
int index=baseText.indexOf("\n");
if(index==-1){
if(baseText.length()>0){
String tmp= baseText;
baseText="";
return tmp;
}else{
return null;
}
}
int index2=baseText.indexOf("\n",index+1);
if(index==-1){
String tmp= baseText;
baseText="";
return tmp;
}else{
String tmp=baseText.substring(0,index2);
baseText=baseText.substring(index2+1);
return tmp;
}
}
/*
public String nextLine() {
int index=baseText.indexOf("\n");
if(index==-1){
if(baseText.length()>0){
return baseText;
}else{
return null;
}
}
String tmp=baseText.substring(index);
baseText=baseText.substring(index+1);
return tmp;
}
*/
/* (non-Javadoc)
* @see org.jpn.xucker.commons.ipod.TextPopper#setText(java.lang.String)
*/
public void setText(String text) {
baseText=text;
//replaceText;
baseText=StringUtils.replace(baseText,"\r\n","\n");
baseText=StringUtils.replace(baseText,"\r","\n");
}
}
|