1 11 package org.jboss.portlet.forums.helper; 12 13 14 18 public class Goto 19 extends Range 20 { 21 private int postSize; 22 private int postsPerPage; 23 private int topicId; 24 private String imgUrl; 25 private String gotoText; 26 27 33 public Goto(int postsPerPage, 34 String gotoText) 35 { 36 super(3, 0, 3); 37 this.postsPerPage = postsPerPage; 38 this.gotoText = gotoText; 39 } 40 41 46 public int getPostSize() 47 { 48 return postSize; 49 } 50 51 56 public void setPostSize(int postSize) 57 { 58 this.postSize = postSize; 59 } 60 61 66 public int getTopicId() 67 { 68 return topicId; 69 } 70 71 76 public void setTopicId(int topicId) 77 { 78 this.topicId = topicId; 79 } 80 81 86 public String getImgUrl() 87 { 88 return imgUrl; 89 } 90 91 96 public void setImgUrl(String imgUrl) 97 { 98 this.imgUrl = imgUrl; 99 } 100 101 106 public String generate() 107 { 108 if (postSize >= postsPerPage) 109 { 110 return build((int) Math.ceil((double) (postSize + 1) / (double) postsPerPage), -1); 111 } 112 else 113 { 114 return ""; 115 } 116 } 117 118 123 protected void start(StringBuffer buffer) 124 { 125 buffer.append("[ <img SRC=\"").append(imgUrl).append("\" alt=\"" + gotoText + "\" title=\"" + gotoText 126 + "\"/>" + gotoText + ": "); 127 } 128 129 134 protected final void end(StringBuffer buffer) 135 { 136 buffer.append(" ] "); 137 } 138 139 145 protected final void normal(StringBuffer buffer, 146 int index) 147 { 148 lastNormal(buffer, index); 149 buffer.append(", "); 150 } 151 152 158 protected final void enhanced(StringBuffer buffer, 159 int index) 160 { 161 lastNormal(buffer, index); 162 buffer.append(", "); 163 } 164 165 171 protected final void lastNormal(StringBuffer buffer, 172 int index) 173 { 174 buffer.append("<a HREF=\"index.html?module=bb&op=viewtopic&t=").append(topicId).append("&start=") 175 .append(index * postsPerPage).append("\">").append(index + 1).append("</a>"); 176 } 177 178 184 protected final void lastEnhanced(StringBuffer buffer, 185 int index) 186 { 187 lastNormal(buffer, index); 188 } 189 } | Popular Tags |