/*
* Created on 2005/02/07
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package org.jpn.xucker.commons.ipod;
/**
*
*
*/
public class PrevNextMenu implements MenuMaker{
private String prevText="Prev";
private String nextText="Next";
private String baseName;
/* (non-Javadoc)
* @see org.jpn.xucker.commons.ipod.MenuMaker#getBytes()
*/
public int getBytes(String encode) {
// TODO Auto-generated method stub
return TextUtil.countText(createPrevMenu(1,3)+createNextMenu(1,3),encode);
}
/* (non-Javadoc)
* @see org.jpn.xucker.commons.ipod.MenuMaker#setText(java.lang.String)
*/
public void setText(String text) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.jpn.xucker.commons.ipod.MenuMaker#getMenu(int, int)
*/
public String getMenu(int currentpage, int maxpage) {
String ret=createPrevMenu(currentpage,maxpage);
ret+=createNextMenu(currentpage,maxpage);
return ret;
}
/**
* @param currentpage
* @param maxpage
* @return
*/
private String createNextMenu(int currentpage, int maxpage) {
if(currentpage==maxpage-1){
return "";
}
return "<a href=\""+baseName+(currentpage+2)+".txt"+"\">"+nextText+"</a>";
}
/**
* @param currentpage
* @param maxpage
* @return
*/
private String createPrevMenu(int currentpage, int maxpage) {
if(currentpage==0){
return "";
}
return "<a href=\""+baseName+(currentpage)+".txt"+"\">"+prevText+"</a>";
}
/* (non-Javadoc)
* @see org.jpn.xucker.commons.ipod.MenuMaker#setBaseName(java.lang.String)
*/
public void setBaseName(String name) {
this.baseName=name;
}
}
|