1 25 26 package net.killingar.forum.wiki; 27 28 import net.killingar.forum.internal.Quote; 29 import net.killingar.forum.internal.managers.ForumManager; 30 import net.killingar.forum.internal.managers.QuoteManager; 31 import net.killingar.wiki.impl.SimpleNode; 32 33 public class QuoteNode extends SimpleNode 34 { 35 String align; 36 37 public QuoteNode( 38 String text, 39 String align, 40 int lineCount, 41 int startIndex, 42 int endIndex) 43 { 44 super(text, lineCount, startIndex, endIndex); 45 46 this.align = align; 47 } 48 49 public String createHTML(Quote q) throws java.sql.SQLException 50 { 51 return "<div align=\""+align+"\">"+q.getBody()+"\n - "+q.getOrigin()+"</div>"; 52 } 53 54 public String toString() 55 { 56 try 57 { 58 javax.servlet.http.HttpServletRequest req = webwork.action.ServletActionContext.getRequest(); 60 ForumManager manager = (ForumManager)req.getSession().getAttribute("manager"); 61 62 QuoteManager qmgr = (QuoteManager)manager.getManager(QuoteManager.class.getName()); 63 64 if (getText().equalsIgnoreCase("random")) 65 { 66 return createHTML(qmgr.getRandomQuote()); 67 } 68 else 69 { 70 try 71 { 72 long l = Long.parseLong(getText()); 73 return createHTML(qmgr.getQuote(l)); 74 } 75 catch (NumberFormatException e) 76 { 77 return e.toString(); 78 } 79 } 80 } 81 catch (Exception e) 82 { 83 return e.toString(); 84 } 85 } 86 } 87 | Popular Tags |