Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package model;import java.util.ArrayList;public class Formatter{private StringBuilder str;private final String _NN_=System.getProperty("line.separator");public String createList(ArrayList<String>list,boolean showNumber){String initList=showNumber?"[LIST]":"[LIST=1]";int size=list.size();str=new StringBuilder();str.append(initList);for(int i=0;i<size;i++){str.append("[*]").append(list.get(i));if(i<size)
- str.append(_NN_);}
- str.append("[/LIST]");return str.toString();}
- public String setImage(String url){str=new StringBuilder();return str.append("[IMG]").append(url).append("[/IMG]").toString();}
- public String setLink(String url,String textToReplace){str=new StringBuilder();return str.append("[URL=\"").append(url).append("\"]").append(textToReplace).append("[/URL]").toString();}
- public String setLinkWithImage(String url,String imageUrl){str=new StringBuilder();return setLink(url,setImage(imageUrl));}
- public String setHorizontalTextPosition(String pos,String text){str=new StringBuilder();pos=pos.toUpperCase();return str.append("[").append(pos).append("]").append(text).append("[/").append(pos).append("]").toString();}
- public String setTextColor(String colorHex,String text){str=new StringBuilder();return str.append("[COLOR=\"").append(colorHex).append("\"]").append(text).append("[/COLOR]").toString();}
- public String setTextFont(String font,String text){str=new StringBuilder();return str.append("[FONT=").append(font).append("]").append(text).append("[/FONT]").toString();}
- public String setTextSize(int size,String text){str=new StringBuilder();return str.append("[SIZE=").append(size).append("]").append(text).append("[/SIZE]").toString();}
- public String setFontStyle(String style,String text){str=new StringBuilder();switch(style.toLowerCase()){case"italic":str.append("[I]").append(text).append("[/I]");break;case"bold":str.append("[B]").append(text).append("[/B]");break;case"underline":str.append("[U]").append(text).append("[/U]");break;}
- return str.toString();}
- public String nextLine(int line){str=new StringBuilder(_NN_);if(line>1){for(int i=1;i<=line;i++)
- str.append(_NN_);return str.toString();}
- return str.toString();}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement