Advertisement
xlrnxnlx

Formatter - min

Jul 4th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.11 KB | None | 0 0
  1. 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)
  2. str.append(_NN_);}
  3. str.append("[/LIST]");return str.toString();}
  4. public String setImage(String url){str=new StringBuilder();return str.append("[IMG]").append(url).append("[/IMG]").toString();}
  5. public String setLink(String url,String textToReplace){str=new StringBuilder();return str.append("[URL=\"").append(url).append("\"]").append(textToReplace).append("[/URL]").toString();}
  6. public String setLinkWithImage(String url,String imageUrl){str=new StringBuilder();return setLink(url,setImage(imageUrl));}
  7. 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();}
  8. public String setTextColor(String colorHex,String text){str=new StringBuilder();return str.append("[COLOR=\"").append(colorHex).append("\"]").append(text).append("[/COLOR]").toString();}
  9. public String setTextFont(String font,String text){str=new StringBuilder();return str.append("[FONT=").append(font).append("]").append(text).append("[/FONT]").toString();}
  10. public String setTextSize(int size,String text){str=new StringBuilder();return str.append("[SIZE=").append(size).append("]").append(text).append("[/SIZE]").toString();}
  11. 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;}
  12. return str.toString();}
  13. public String nextLine(int line){str=new StringBuilder(_NN_);if(line>1){for(int i=1;i<=line;i++)
  14. str.append(_NN_);return str.toString();}
  15. return str.toString();}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement