ForumTopic.java
上传用户:yuyunping
上传日期:2013-03-21
资源大小:1844k
文件大小:3k
源码类别:

Java书籍

开发平台:

Java

  1. package net.acai.forum;
  2. /**
  3.  * Title:        清清网络
  4.  * Description:
  5.  * Copyright:    Copyright (c) 2002
  6.  * Company:      www.SuperSpace.com
  7.  * @author:       SuperSpace
  8.  * @version 1.0
  9.  */
  10. import net.acai.forum.*;
  11. import net.acai.database.DBConnect;
  12. import java.sql.ResultSet;
  13. import net.acai.util.*;
  14. import net.acai.filter.*;
  15. public class ForumTopic extends ForumMSG{
  16. String followMSG="-----",followUser="-------",followDateAndTime="-------";
  17. public ForumTopic(){
  18. }
  19. public ForumTopic(int forumRootID){
  20. super();
  21. try{
  22. String sql="select  username,dateandtime,topic,body from bbs.bbs1 where rootid=? and announceid!=? order by announceid desc";
  23. DBConnect dbc=new DBConnect(sql);
  24. dbc.setInt(1,forumRootID);
  25. dbc.setInt(2,forumRootID);
  26. ResultSet rs=dbc.executeQuery();
  27. if(rs.next()){
  28. followUser=rs.getString(1);
  29. followDateAndTime=rs.getString(2);
  30. String followTopic=rs.getString(3);
  31. if(followTopic!=null&&!"".equals(followTopic.trim()))
  32. followMSG=StringUtils.escapeHTMLTags(followTopic);
  33. else{
  34. if(rs.getString(4).length()>24)
  35. followMSG=StringUtils.escapeHTMLTags(rs.getString(4).substring(0,24).replaceAll("\r|\n","").replaceAll(" "," "));
  36. else
  37. followMSG=StringUtils.escapeHTMLTags(rs.getString(4).replaceAll("\r|\n","").replaceAll(" "," "));
  38. }
  39. }
  40. dbc.close();
  41. }
  42. catch(Exception e){
  43. e.printStackTrace();
  44. }
  45. }
  46. public String getNoFilterTopic(){
  47. if(topic!=null&&!"".equals(topic.trim()))
  48. return StringUtils.replace(StringUtils.replace(StringUtils.convertNewlines(StringUtils.escapeHTMLTags(topic))," ","&nbsp;"),"<BR>","");
  49. else{
  50. String tempString="";
  51. if(body.length()>24)
  52. tempString=body.substring(0,24);
  53. else
  54. tempString=body;
  55. return StringUtils.replace(StringUtils.replace(StringUtils.escapeHTMLTags(tempString).replaceAll("\r|\n","&nbsp;")," ","&nbsp;"),"<BR>","");
  56. }
  57. }
  58. public String getTopic(){
  59. if(topic!=null&&!("".equals(topic.trim())))
  60. return (new MyFilter(StringUtils.replace(StringUtils.convertNewlines(StringUtils.escapeHTMLTags(topic))," ","&nbsp;"))).getFilterString();
  61. else{
  62. if(body.length()>24)
  63. return (new MyFilter(StringUtils.replace(StringUtils.convertNewlines(StringUtils.escapeHTMLTags(body.substring(0,24)))," ","&nbsp;"))).getFilterString();
  64. else
  65. return (new MyFilter(StringUtils.replace(StringUtils.convertNewlines(StringUtils.escapeHTMLTags(body))," ","&nbsp;"))).getFilterString();
  66. }
  67. }
  68. public String getFollowMSG(){
  69. return followMSG;
  70. }
  71. public String getFollowUser(){
  72. return followUser;
  73. }
  74. public String getFollowDateAndTime(){
  75. return followDateAndTime;
  76. }
  77. }