1 25 26 package com.j2biz.blogunity.util; 27 28 import java.io.File ; 29 import java.io.FileFilter ; 30 import java.text.SimpleDateFormat ; 31 import java.util.Calendar ; 32 import java.util.Date ; 33 import java.util.Iterator ; 34 import java.util.List ; 35 import java.util.Locale ; 36 import java.util.StringTokenizer ; 37 38 import javax.servlet.http.HttpServletRequest ; 39 import javax.servlet.http.HttpServletResponse ; 40 import javax.servlet.http.HttpSession ; 41 42 import org.apache.commons.lang.StringUtils; 43 import org.apache.commons.logging.Log; 44 import org.apache.commons.logging.LogFactory; 45 46 import com.j2biz.blogunity.BlogunityManager; 47 import com.j2biz.blogunity.IConstants; 48 import com.j2biz.blogunity.dao.CalendarEntryDAO; 49 import com.j2biz.blogunity.dao.UserDAO; 50 import com.j2biz.blogunity.exception.BlogunityException; 51 import com.j2biz.blogunity.exception.BlogunityRuntimeException; 52 import com.j2biz.blogunity.i18n.I18N; 53 import com.j2biz.blogunity.i18n.I18NMessageManager; 54 import com.j2biz.blogunity.i18n.I18NStatusFactory; 55 import com.j2biz.blogunity.pojo.Blog; 56 import com.j2biz.blogunity.pojo.CalendarEntry; 57 import com.j2biz.blogunity.pojo.Category; 58 import com.j2biz.blogunity.pojo.Comment; 59 import com.j2biz.blogunity.pojo.Entry; 60 import com.j2biz.blogunity.pojo.User; 61 import com.j2biz.blogunity.web.FormError; 62 import com.j2biz.blogunity.web.FormErrorList; 63 import com.j2biz.blogunity.web.IActionResult; 64 import com.j2biz.blogunity.web.NavigationStack; 65 66 73 public class BlogUtils { 74 77 private static final Log log = LogFactory.getLog(BlogUtils.class); 78 79 private static BlogUtils INSTANCE = null; 80 81 private BlogUtils() { 82 } 83 84 public static final BlogUtils getInstance() { 85 if (INSTANCE == null) { 86 INSTANCE = new BlogUtils(); 87 } 88 return INSTANCE; 89 } 90 91 public static final String getVersion() { 92 return IConstants.VERSION; 93 } 94 95 public static final String getBuild() { 96 return IConstants.BUILD; 97 } 98 99 public static final String getCodename() { 100 return IConstants.CODENAME; 101 } 102 103 public String getSiteTitle() { 104 return BlogunityManager.getSystemConfiguration().getSiteTitle(); 105 } 106 107 public String getSiteKeywords() { 108 109 return BlogunityManager.getSystemConfiguration().getSiteKeywords(); 110 } 111 112 public String getSiteDescription() { 113 114 return BlogunityManager.getSystemConfiguration().getSiteDescription(); 115 } 116 117 public int getNumberOfIndividualBlogsPerUser() { 118 return BlogunityManager.getSystemConfiguration().getIndividualBlogsPerUser(); 119 } 120 121 public int getNumberOfCommunityBlogsPerUser() { 122 return BlogunityManager.getSystemConfiguration().getCommunityBlogsPerUser(); 123 } 124 125 public int getTotalNumberOfBlogsPerUser() { 126 127 int individual = BlogunityManager.getSystemConfiguration().getIndividualBlogsPerUser(); 128 if (individual == -1) return -1; 129 130 int community = BlogunityManager.getSystemConfiguration().getCommunityBlogsPerUser(); 131 if (community == -1) return -1; 132 133 return (community + individual); 134 } 135 136 public String formatDate(Date date) { 137 138 String format = BlogunityManager.getSystemConfiguration().getDateFormat(); 139 140 SimpleDateFormat f = new SimpleDateFormat (format); 141 return f.format(date).toString(); 142 } 143 144 public String formatTime(Date date) { 145 146 String format = BlogunityManager.getSystemConfiguration().getTimeFormat(); 147 148 SimpleDateFormat f = new SimpleDateFormat (format); 149 return f.format(date).toString(); 150 } 151 152 public String formatDateTime(Date date) { 153 154 String format = BlogunityManager.getSystemConfiguration().getDatetimeFormat(); 155 156 SimpleDateFormat f = new SimpleDateFormat (format); 157 return f.format(date).toString(); 158 } 159 160 166 public String formatYear(HttpServletRequest request, Date date) { 167 Locale locale = (Locale ) request.getAttribute(IConstants.Request.LOCALE); 168 SimpleDateFormat f = new SimpleDateFormat ("yyyy", locale); 169 return f.format(date).toString(); 170 } 171 172 178 public String formatMonth(HttpServletRequest request, Date date) { 179 Locale locale = (Locale ) request.getAttribute(IConstants.Request.LOCALE); 180 SimpleDateFormat f = new SimpleDateFormat ("MMMMM yyyy", locale); 181 return f.format(date).toString(); 182 } 183 184 190 public String formatDay(HttpServletRequest request, Date date) { 191 Locale locale = (Locale ) request.getAttribute(IConstants.Request.LOCALE); 192 193 SimpleDateFormat f = new SimpleDateFormat ("EEE, dd MMMMM yyyy", locale); 194 return f.format(date).toString(); 195 } 196 197 203 public String formatDayShort(Date date) { 204 205 SimpleDateFormat f = new SimpleDateFormat ("dd.MM"); 206 return f.format(date).toString(); 207 } 208 209 215 public String formatDayLink(Date date) { 216 217 SimpleDateFormat f = new SimpleDateFormat ("/yyyy/MM/dd"); 218 return f.format(date).toString(); 219 } 220 221 public boolean isValidEmailAddress(String email) { 222 223 String regex = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[_A-Za-z0-9-]+)"; 224 return email.matches(regex); 225 226 } 227 228 public boolean isValidNickname(String nick) { 229 230 String regex = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*"; 231 return nick.matches(regex); 232 } 233 234 241 public boolean isValidBlogname(String name) { 242 String regex = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*"; 243 return name.matches(regex); 244 } 245 246 253 public boolean isValidAliasname(String name) { 254 String regex = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*"; 255 return name.matches(regex); 256 } 257 258 public NavigationStack getNavigationStack(HttpServletRequest request) { 259 HttpSession session = request.getSession(false); 260 if (session == null) return new NavigationStack(); 261 262 NavigationStack stack = (NavigationStack) session 263 .getAttribute(IConstants.Session.NAVIGATION_STACK); 264 if (stack == null) return new NavigationStack(); 265 else 266 return stack; 267 } 268 269 public String peekLastActionFromStack(HttpServletRequest request) { 270 NavigationStack stack = getNavigationStack(request); 271 272 if (stack == null || stack.empty()) return null; 273 IActionResult result = stack.peek(); 274 return request.getContextPath() + result.getPath(); 275 } 276 277 public String peekNextToLastActionFromStack(HttpServletRequest request) { 278 NavigationStack stack = getNavigationStack(request); 279 280 if (stack == null || stack.empty()) return null; 281 IActionResult result = stack.peekNextToLast(); 282 283 if (result == null) return null; 284 285 return request.getContextPath() + result.getPath(); 286 } 287 288 295 public String renderUser(User user, HttpServletRequest request) { 296 StringBuffer out = new StringBuffer (); 297 298 if (user == null) { 299 out.append("anonymous"); 300 return out.toString(); 301 } 302 303 out.append("<nobr>"); 304 out.append("<img SRC=\"" + request.getContextPath() + "/images/" 305 + ((user.getSex() == User.MALE) ? "male.gif" : "female.gif") + "\">"); 306 out.append("<a HREF=\"" + request.getContextPath() + "/users/" + user.getNickname() 307 + "\" title=\"" + user.getFirstname() + " " + user.getLastname() + "\">"); 308 out.append(user.getNickname()); 309 out.append("</a>"); 310 311 if (BlogunityManager.getSystemConfiguration().isRankingOn()) { 313 out.append("<sup>"); 314 out.append("<img SRC=\""); 315 out.append(request.getContextPath() + "/images/ranks/newbie1.gif"); 316 out.append("\" title=\"just a simple user ranking\">"); 317 out.append("</sup>"); 318 } 319 320 User loggedUser = null; 321 HttpSession session = request.getSession(false); 322 if (session != null) loggedUser = (User) session.getAttribute(IConstants.Session.USER); 323 324 if (loggedUser != null && loggedUser.getId().longValue() != user.getId().longValue()) { 325 326 try { 327 UserDAO dao = new UserDAO(); 329 loggedUser = dao.getUserByID(loggedUser.getId()); 330 } catch (BlogunityException e) { 331 return out.toString(); 332 } 333 334 if (loggedUser.containsAsFriend(user)) { 335 out.append("<sup><a HREF=\"" + request.getContextPath() 336 + "/my/deleteFriendConfirm?id=" + user.getId() 337 + "\" title=\"remove from friends\">" + "<img SRC=\"" 338 + request.getContextPath() + "/images/friend_remove.gif\" border=\"0\">" 339 + "</a></sup>"); 340 } else { 341 out.append("<sup><a HREF=\"" + request.getContextPath() + "/my/addFriend?nickname=" 342 + user.getNickname() + "\" title=\"add to friends\">" + "<img SRC=\"" 343 + request.getContextPath() + "/images/friend_add.gif\" border=\"0\">" 344 + "</a></sup>"); 345 } 346 } 347 out.append("</nobr>"); 348 return out.toString(); 349 350 } 351 352 360 public String renderCategory(Blog b, Category category, HttpServletRequest request) { 361 362 StringBuffer out = new StringBuffer (); 363 out.append("<nobr>"); 364 out.append("<a HREF=\"" 365 + BlogunityManager.getBase() 366 + "/blogs/" 367 + b.getUrlName() 368 + "/category/" 369 + category.getId() 370 + "\" title=\"" 371 + (StringUtils.isEmpty(category.getDescription()) ? category.getName() : category 372 .getDescription()) + "\">"); 373 out.append(category.getName()); 374 375 out.append("</a>"); 376 out.append("<sup>"); 377 out.append((category.getType() == Category.GLOBAL) ? "<img SRC=\"" 378 + request.getContextPath() 379 + "/images/category_global.gif\" title=\"global blogunity category\">" 380 : "<img SRC=\"" + request.getContextPath() 381 + "/images/category_local.gif\" title=\"local blog category\">"); 382 out.append("</sup>"); 383 out.append("</nobr>"); 384 return out.toString(); 385 } 386 387 394 public String renderBlog(Blog blog, HttpServletRequest request) { 395 396 String style = "individual_blog"; 397 String title = "individual blog"; 398 if (blog.getType() == Blog.COMMUNITY_BLOG) { 399 if (blog.getCommunityType() == Blog.PUBLIC_COMMUNTIY) { 400 style = "public_community_blog"; 401 title = "public community blog"; 402 } else if (blog.getCommunityType() == Blog.PRIVATE_COMMUNTIY) { 403 style = "private_community_blog"; 404 title = "private community blog"; 405 } 406 } 407 408 String icon = BlogunityManager.getBase() + "/images/" + style + ".gif"; 409 StringBuffer out = new StringBuffer (); 410 out.append("<nobr>"); 411 out.append("<img SRC=\"" + icon + "\"/> "); 412 out.append("<a class=\"" + style + "\" HREF=\"" + BlogunityManager.getBase() + "/blogs/" 413 + blog.getUrlName() + "\" title=\"" + title + "\">"); 414 out.append(blog.getFullName()); 415 out.append("</a>"); 416 out.append("</nobr>"); 417 return out.toString(); 418 419 } 420 421 428 public String renderEntry(Entry entry, HttpServletRequest request) { 429 StringBuffer out = new StringBuffer (); 430 out.append("<nobr>"); 431 String icon = BlogunityManager.getBase() + "/images/entry.gif"; 432 out.append("<img SRC=\"" + icon + "\"/> "); 433 out.append("<a class=\"entry\" HREF=\"" + BlogunityManager.getBase() + "/blogs/" 434 + entry.getBlog().getUrlName() + entry.getPermalink() + "\" title=\"" 435 + entry.getTitle() + "\">"); 436 out.append(StringUtils.abbreviate(entry.getTitle(), 100)); 437 out.append("</a>"); 438 out.append("</nobr>"); 439 return out.toString(); 440 } 441 442 449 public String renderComment(Comment comment, HttpServletRequest request) { 450 StringBuffer out = new StringBuffer (); 451 out.append("<nobr>"); 452 453 String icon = BlogunityManager.getBase() + "/images/comment.gif"; 454 out.append("<img SRC=\"" + icon + "\"/> "); 455 out.append("<a class=\"comment\" HREF=\"" + BlogunityManager.getBase() + "/blogs/" 456 + comment.getCommentedEntry().getBlog().getUrlName() 457 + comment.getCommentedEntry().getPermalink() + "#" + comment.getId() 458 + "\" title=\"" + comment.getTitle() + "\">"); 459 460 out.append(StringUtils.abbreviate(comment.getTitle(), 100)); 461 out.append("</a>"); 462 out.append("</nobr>"); 463 return out.toString(); 464 } 465 466 public String showErrors(FormErrorList errors, String key) { 467 StringBuffer out = new StringBuffer (); 468 if (errors != null && errors.size() > 0) { 469 for (Iterator iter = errors.get(key).iterator(); iter.hasNext();) { 470 FormError err = (FormError) iter.next(); 471 out.append(err.getValue() + "<br/>"); 472 } 473 } 474 return out.toString(); 475 } 476 477 public String showErrorsLayer(FormErrorList errors, String key) { 478 StringBuffer out = new StringBuffer (); 479 if (errors != null && errors.containsErrorsForKey(key)) { 480 out.append("<div id=\""); 481 out.append("errorLayer"); 482 out.append(StringUtils.capitalize(key)); 483 out.append("\""); 484 out 485 .append("style=\"display: none; visibility: hidden; position: relative; padding-bottom: 5px;"); 486 out 487 .append("padding-top: 0px; padding-left: 7px; margin-bottom: 5px; margin-top: 0px; color: #A1231F;\">"); 488 out.append(showErrors(errors, key)); 489 out.append("</div>"); 490 } 491 492 return out.toString(); 493 } 494 495 public String drawCalendar(HttpServletRequest request, HttpServletResponse response) { 496 497 Locale locale = (Locale ) request.getAttribute(IConstants.Request.LOCALE); 498 499 Blog blog = (Blog) request.getAttribute("blog"); 501 if (blog == null) { 502 return I18NMessageManager.getInstance().getError(I18N.ERRORS.DRAWING_CALENDAR_FAILED); 503 } 504 505 Date now = new Date (); 506 Date requestedDate = new Date (); 507 508 510 String baseWithBlogname = BlogunityManager.getBase() + "/blogs/" + blog.getUrlName(); 511 String url = StringUtils.substringAfter(request.getRequestURL().toString(), 512 baseWithBlogname); 513 514 if (url.matches(IConstants.PATTERNS.GLOBAL_CALENDAR_PATTERN)) { 515 516 if (url.startsWith("/")) url = url.substring(1); 517 518 StringTokenizer st = new StringTokenizer (url, "/"); 519 520 int year = 2005; 521 int month = Calendar.JANUARY; 522 int day = 1; 523 524 if (st.hasMoreTokens()) { 526 String yearStr = st.nextToken(); 527 try { 528 year = Integer.parseInt(yearStr); 529 } catch (NumberFormatException e) { 530 year = 2005; 531 } 532 } 533 534 if (st.hasMoreTokens()) { 536 String monthStr = st.nextToken(); 537 try { 538 month = Integer.parseInt(monthStr) - 1; 539 if (month < Calendar.JANUARY || month > Calendar.DECEMBER) 540 month = Calendar.JANUARY; 541 } catch (NumberFormatException e) { 542 month = Calendar.JANUARY; 543 } 544 } 545 546 if (st.hasMoreTokens()) { 548 String dayStr = st.nextToken(); 549 try { 550 day = Integer.parseInt(dayStr); 551 if (day < 1 || day > 31) day = 1; 552 } catch (NumberFormatException e) { 553 day = 1; 554 } 555 } 556 557 Calendar dayObj = Calendar.getInstance(); 558 dayObj.set(year, month, day, 0, 0, 0); 559 requestedDate = dayObj.getTime(); 560 } 561 562 Calendar currentMonth = Calendar.getInstance(); 563 currentMonth.setTime(requestedDate); 564 565 Calendar prevMonth = Calendar.getInstance(); 566 prevMonth.setTime(requestedDate); 567 prevMonth.add(Calendar.MONTH, -1); 568 569 Calendar nextMonth = Calendar.getInstance(); 570 nextMonth.setTime(requestedDate); 571 nextMonth.add(Calendar.MONTH, 1); 572 573 StringBuffer out = new StringBuffer (); 574 575 out.append("<table width=\"100%\" cellpadding=\"1\" cellspacing=\"1\">"); 576 577 out.append("<tr>"); 579 out.append("<td colspan=\"7\" align=\"center\">"); 580 int temp = (prevMonth.get(Calendar.MONTH) + 1); 581 out.append("<a HREF=\"" + baseWithBlogname + "/" + prevMonth.get(Calendar.YEAR) + "/" 582 + ((temp < 10) ? "0" + temp : "" + temp) + "\"><</a> "); 583 584 temp = (currentMonth.get(Calendar.MONTH) + 1); 585 out.append("<a HREF=\"" + baseWithBlogname + "/" + currentMonth.get(Calendar.YEAR) + "/" 586 + ((temp < 10) ? "0" + temp : "" + temp) + "\">" 587 + new SimpleDateFormat ("MMMM", locale).format(currentMonth.getTime()) 588 + "</a> "); 589 590 String monthFormat = new SimpleDateFormat ("yyyy", locale).format(currentMonth.getTime()); 591 out.append("<a HREF=\"" + baseWithBlogname + "/" + currentMonth.get(Calendar.YEAR) + "\">" 592 + monthFormat + "</a> "); 593 594 temp = (nextMonth.get(Calendar.MONTH) + 1); 595 out.append("<a HREF=\"" + baseWithBlogname + "/" + nextMonth.get(Calendar.YEAR) + "/" 596 + ((temp < 10) ? "0" + temp : "" + temp) + "\">></a> "); 597 598 out.append("</td>"); 599 out.append("</tr>"); 600 601 SimpleDateFormat fmt = new SimpleDateFormat ("EE", locale); 603 Calendar daysOfWeek = Calendar.getInstance(); 604 daysOfWeek.setTime(currentMonth.getTime()); 605 606 int FIRST_DAY_OF_WEEK = daysOfWeek.getFirstDayOfWeek(); 607 608 for (int i = 1; i < 20; i++) { 609 daysOfWeek.add(Calendar.DAY_OF_MONTH, 1); 610 if (daysOfWeek.get(Calendar.DAY_OF_WEEK) == FIRST_DAY_OF_WEEK) break; 611 } 612 out.append("<tr>\n"); 613 out.append("<td><b>" + fmt.format(daysOfWeek.getTime()) + "</b></td>\n"); 614 daysOfWeek.add(Calendar.DAY_OF_MONTH, 1); 615 out.append("<td><b>" + fmt.format(daysOfWeek.getTime()) + "</b></td>\n"); 616 daysOfWeek.add(Calendar.DAY_OF_MONTH, 1); 617 out.append("<td><b>" + fmt.format(daysOfWeek.getTime()) + "</b></td>\n"); 618 daysOfWeek.add(Calendar.DAY_OF_MONTH, 1); 619 out.append("<td><b>" + fmt.format(daysOfWeek.getTime()) + "</b></td>\n"); 620 daysOfWeek.add(Calendar.DAY_OF_MONTH, 1); 621 out.append("<td><b>" + fmt.format(daysOfWeek.getTime()) + "</b></td>\n"); 622 daysOfWeek.add(Calendar.DAY_OF_MONTH, 1); 623 out.append("<td><b>" + fmt.format(daysOfWeek.getTime()) + "</b></td>\n"); 624 daysOfWeek.add(Calendar.DAY_OF_MONTH, 1); 625 out.append("<td><b>" + fmt.format(daysOfWeek.getTime()) + "</b></td>\n"); 626 out.append("</tr>\n"); 627 628 Calendar today = Calendar.getInstance(); 630 today.setTime(currentMonth.getTime()); 631 today.set(Calendar.DAY_OF_MONTH, 1); 632 633 int spacer = (today.get(Calendar.DAY_OF_WEEK) - FIRST_DAY_OF_WEEK); 634 635 int month = today.get(Calendar.MONTH); 636 if (spacer < 0) spacer = 7 + spacer; 637 638 out.append("<tr>\n"); 639 640 if (spacer > 0) out.append("<td colspan=\"" + spacer + "\"> </td>\n"); 641 642 List calendarEntries; 643 try { 644 CalendarEntryDAO dao = new CalendarEntryDAO(); 645 calendarEntries = dao.getCalendarEntryForBlogByMonthYear(blog, today 646 .get(Calendar.MONTH) + 1, today.get(Calendar.YEAR)); 647 } catch (BlogunityException e) { 648 throw new BlogunityRuntimeException(I18NStatusFactory.create( 649 I18N.ERRORS.DRAWING_CALENDAR_FAILED, e)); 650 } 651 652 int currentWeek = today.get(Calendar.WEEK_OF_MONTH); 653 while (today.get(Calendar.MONTH) == month) { 654 655 if (currentWeek != today.get(Calendar.WEEK_OF_MONTH)) { 656 out.append("</tr>\n"); 657 out.append("<tr>\n"); 658 currentWeek = today.get(Calendar.WEEK_OF_MONTH); 659 } 660 661 out.append("<td>"); 662 663 String _day = (today.get(Calendar.DAY_OF_MONTH) < 10) ? "0" 664 + today.get(Calendar.DAY_OF_MONTH) : "" + today.get(Calendar.DAY_OF_MONTH); 665 666 CalendarEntry e = findEntryForDay(calendarEntries, today.get(Calendar.DAY_OF_MONTH)); 667 if (e != null) { 668 String _year = String.valueOf(today.get(Calendar.YEAR)); 670 671 int x = today.get(Calendar.MONTH) + 1; 672 String _month = (x < 10) ? "0" + x : "" + x; 673 674 out.append("<a HREF=\"" + baseWithBlogname + "/" + _year + "/" + _month + "/" 675 + _day + "\" title=\"" + e.getNumberOfMessages() + " entries\">"); 676 out.append(_day); 677 out.append("</a>"); 678 } else { 679 out.append(_day); 680 } 681 out.append("</td>\n"); 682 683 today.add(Calendar.DAY_OF_MONTH, 1); 684 } 685 686 spacer = (today.get(Calendar.DAY_OF_WEEK) - today.getFirstDayOfWeek()); 687 if (spacer < 0) spacer = 7 + spacer; 688 if (spacer > 0) out.append("<td colspan=\"" + (7 - spacer) + "\"> </td>\n"); 689 out.append("</tr>\n"); 690 691 693 out.append("<tr>"); 694 out.append("<td colspan=\"7\" align=\"center\">"); 695 out.append("<a HREF=\"" + baseWithBlogname 696 + new SimpleDateFormat ("/yyyy/MM/dd").format(now) + "\">" 697 + I18NMessageManager.getInstance().getMessage("CALENDAR_TODAY", locale) 698 + "</a> "); 699 out.append("| <a HREF=\"" + baseWithBlogname + "\">" 700 + I18NMessageManager.getInstance().getMessage("CALENDAR_FRONTPAGE", locale) 701 + "</a>"); 702 out.append("</td></tr>"); 703 704 out.append("</table>"); 705 706 return out.toString(); 707 708 } 709 710 public File [] getThemeDirectories() throws BlogunityException { 711 File defaultThemesDir = new File (BlogunityManager.getServletContext().getRealPath( 712 IConstants.BLOG_THEMES_DIRECTORY)); 713 714 if (!defaultThemesDir.exists() || !defaultThemesDir.isDirectory() 715 || !defaultThemesDir.canRead()) { throw new BlogunityException(I18NStatusFactory 716 .create(I18N.ERRORS.THEME_READ_ERROR)); } 717 718 File [] themeDirs = defaultThemesDir.listFiles(new FileFilter () { 719 public boolean accept(File f) { 720 if (f.isDirectory() && f.canRead()) { 721 if (f.list().length <= 0) return false; 722 return true; 723 } 724 return false; 725 } 726 }); 727 728 return themeDirs; 729 } 730 731 private CalendarEntry findEntryForDay(List entries, int day) { 732 733 for (Iterator it = entries.iterator(); it.hasNext();) { 734 CalendarEntry e = (CalendarEntry) it.next(); 735 if (e.getDay() == day) return e; 736 } 737 738 return null; 739 } 740 741 } | Popular Tags |