⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blog.java

📁 pebble-blog 博客源码博客源码博客源码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
          blogEntries.addAll(service.getBlogEntries(this, y.getYear(), months[month].getMonth()));        } catch (BlogServiceException e) {          log.error(e);        }      }    }    return blogEntries;  }  /**   * Gets all unpublished blog entries for this blog.   *   * @return  a List of BlogEntry objects   */  public List<BlogEntry> getUnpublishedBlogEntries() {    List<BlogEntry> blogEntries = new ArrayList<BlogEntry>();    BlogService service = new BlogService();    List<String> blogEntryIds = blogEntryIndex.getUnpublishedBlogEntries();    for (String blogEntryId : blogEntryIds) {      try {        blogEntries.add(service.getBlogEntry(this, blogEntryId));      } catch (BlogServiceException e) {        log.error(e);      }    }    return blogEntries;  }  /**   * Gets the number of blog entries for this blog.   *   * @return  an int   */  public int getNumberOfBlogEntries() {    return blogEntryIndex.getNumberOfBlogEntries();  }  /**   * Gets the number of published blog entries for this blog.   *   * @return  an int   */  public int getNumberOfPublishedBlogEntries() {    return blogEntryIndex.getNumberOfPublishedBlogEntries();  }  /**   * Gets the number of unpublished blog entries for this blog.   *   * @return  an int   */  public int getNumberOfUnpublishedBlogEntries() {    return blogEntryIndex.getNumberOfUnpublishedBlogEntries();  }  /**   * Gets the number of static pages for this blog.   *   * @return  an int   */  public int getNumberOfStaticPages() {    return staticPageIndex.getNumberOfStaticPages();  }  /**   * Gets the most recent blog entries, the number   * of which is specified.   *   * @param numberOfEntries the number of entries to get   * @return a List containing the most recent blog entries   */  public List getRecentBlogEntries(int numberOfEntries) {    BlogService service = new BlogService();    List<String> blogEntryIds = blogEntryIndex.getBlogEntries();    List blogEntries = new ArrayList();    for (String blogEntryId : blogEntryIds) {      try {        BlogEntry blogEntry = service.getBlogEntry(this, blogEntryId);        blogEntries.add(blogEntry);      } catch (BlogServiceException e) {        log.error(e);      }      if (blogEntries.size() == numberOfEntries) {        break;      }    }    return blogEntries;  }  /**   * Gets the most recent published blog entries, the number of which   * is taken from the recentBlogEntriesOnHomePage property.   *   * @return a List containing the most recent blog entries   */  public List getRecentPublishedBlogEntries() {    return getRecentPublishedBlogEntries(getRecentBlogEntriesOnHomePage());  }  /**   * Gets the most recent published blog entries, the number of which   * is specified   *   * @param number    the number of blog entries to get   * @return a List containing the most recent blog entries   */  public List getRecentPublishedBlogEntries(int number) {    BlogService service = new BlogService();    List<String> blogEntryIds = blogEntryIndex.getPublishedBlogEntries();    List blogEntries = new ArrayList();    for (String blogEntryId : blogEntryIds) {      if (blogEntries.size() == number) {        break;      }      try {        BlogEntry blogEntry = service.getBlogEntry(this, blogEntryId);        if (blogEntry != null) {          blogEntries.add(blogEntry);        }      } catch (BlogServiceException e) {        log.error(e);      }    }    return blogEntries;  }  /**   * Gets blog entries for a given list of IDs.   *   * @param blogEntryIds    the list of blog entry IDs   * @return a List containing the blog entries   */  public List<BlogEntry> getBlogEntries(List<String> blogEntryIds) {    BlogService service = new BlogService();    List<BlogEntry> blogEntries = new LinkedList<BlogEntry>();    for (String blogEntryId : blogEntryIds) {      try {        BlogEntry blogEntry = service.getBlogEntry(this, blogEntryId);        if (blogEntry != null) {          blogEntries.add(blogEntry);        }      } catch (BlogServiceException e) {        log.error(e);      }    }    return blogEntries;  }  /**   * Gets the most recent published blog entries for a given category, the   * number of which is taken from the recentBlogEntriesOnHomePage property.   *   * @param   category          a category   * @return  a List containing the most recent blog entries   */  public List getRecentPublishedBlogEntries(Category category) {    BlogService service = new BlogService();    List<String> blogEntryIds = categoryIndex.getRecentBlogEntries(category);    List blogEntries = new ArrayList();    for (String blogEntryId : blogEntryIds) {      try {        BlogEntry blogEntry = service.getBlogEntry(this, blogEntryId);        if (blogEntry != null && blogEntry.isPublished()) {          blogEntries.add(blogEntry);        }      } catch (BlogServiceException e) {        log.error(e);      }      if (blogEntries.size() == getRecentBlogEntriesOnHomePage()) {        break;      }    }    return blogEntries;  }  /**   * Gets the most recent published blog entries for a given category, the   * number of which is taken from the recentBlogEntriesOnHomePage property.   *   * @param   author    the author's username   * @return  a List containing the most recent blog entries   */  public List getRecentPublishedBlogEntries(String author) {    BlogService service = new BlogService();    List<String> blogEntryIds = authorIndex.getRecentBlogEntries(author);    List blogEntries = new ArrayList();    for (String blogEntryId : blogEntryIds) {      try {        BlogEntry blogEntry = service.getBlogEntry(this, blogEntryId);        if (blogEntry != null && blogEntry.isPublished()) {          blogEntries.add(blogEntry);        }      } catch (BlogServiceException e) {        log.error(e);      }      if (blogEntries.size() == getRecentBlogEntriesOnHomePage()) {        break;      }    }    return blogEntries;  }  /**   * Gets the most recent published blog entries for a given tag, the   * number of which is taken from the recentBlogEntriesOnHomePage property.   *   * @param tag             a tag   * @return a List containing the most recent blog entries   */  public List getRecentPublishedBlogEntries(Tag tag) {    BlogService service = new BlogService();    List<String> blogEntryIds = tagIndex.getRecentBlogEntries(tag);    List blogEntries = new ArrayList();    for (String blogEntryId : blogEntryIds) {      try {        BlogEntry blogEntry = service.getBlogEntry(this, blogEntryId);        if (blogEntry != null && blogEntry.isPublished()) {          blogEntries.add(blogEntry);        }      } catch (BlogServiceException e) {        log.error(e);      }      if (blogEntries.size() == getRecentBlogEntriesOnHomePage()) {        break;      }    }    return blogEntries;  }  /**   * Gets the most recent responses.   *   * @return a List containing the most recent blog entries   */  public List<Response> getRecentApprovedResponses() {    BlogService service = new BlogService();    List<String> responseIds = responseIndex.getApprovedResponses();    List<Response> responses = new ArrayList<Response>();    for (String responseId : responseIds) {      try {        Response response = service.getResponse(this, responseId);        if (response != null && response.getBlogEntry().isPublished()) {          responses.add(response);        }      } catch (BlogServiceException e) {        log.error(e);      }      if (responses.size() == getRecentResponsesOnHomePage()) {        break;      }    }    return responses;  }  /**   * Gets the list of approved responses.   *   * @return  a List of response IDs   */  public List<String> getApprovedResponses() {    return responseIndex.getApprovedResponses();  }  /**   * Gets the list of pending responses.   *   * @return  a List of response IDs   */  public List<String> getPendingResponses() {    return responseIndex.getPendingResponses();  }  /**   * Gets the list of rejected responses.   *   * @return  a List of response IDs   */  public List<String> getRejectedResponses() {    return responseIndex.getRejectedResponses();  }  /**   * Gets the number of responses.   *   * @return the number of responses   */  public int getNumberOfResponses() {    return responseIndex.getNumberOfResponses();  }  /**   * Gets the number of approved responses.   *   * @return the number of approved responses   */  public int getNumberOfApprovedResponses() {    return responseIndex.getNumberOfApprovedResponses();  }  /**   * Gets the number of pending responses.   *   * @return the number of pending responses   */  public int getNumberOfPendingResponses() {    return responseIndex.getNumberOfPendingResponses();  }  /**   * Gets the number of rejected responses.   *   * @return the number of rejected responses   */  public int getNumberOfRejectedResponses() {    return responseIndex.getNumberOfRejectedResponses();  }  /**   * Gets the date that this blog was last updated through the addition   * of a blog entry.   *   * @return  a Date instance representing the time of the most recent entry   */  public Date getLastModified() {    Date date = new Date(0);    List blogEntries = getRecentPublishedBlogEntries(1);    if (blogEntries.size() == 1) {      date = ((BlogEntry)blogEntries.get(0)).getDate();    }    return date;  }  /**   * Gets the date of the most recent response.   *   * @return  a Date instance representing the time of the most recent entry   */  public Date getDateOfLastResponse() {    List<Response> responses = this.getRecentApprovedResponses();    if (responses != null && responses.size() > 0) {      return responses.get(0).getDate();    } else {      return new Date(0);    }  }  public BlogEntry getPreviousBlogEntry(BlogEntry blogEntry) {    Day firstDay = getBlogForFirstMonth().getBlogForFirstDay();    Day day = getBlogForDay(blogEntry.getDate());    String blogEntryId = day.getPreviousBlogEntry(blogEntry.getId());    while (day != firstDay && blogEntryId == null) {      day = day.getPreviousDay();      blogEntryId = day.getLastBlogEntry();    }    if (blogEntryId != null) {      BlogService service = new BlogService();      try {        BlogEntry previousBlogEntry = service.getBlogEntry(this, blogEntryId);        return previousBlogEntry;      } catch (BlogServiceException e) {        // do nothing      }    }    return null;  }  public BlogEntry getNextBlogEntry(BlogEntry blogEntry) {    Day lastDay = getBlogForToday();    Day day = getBlogForDay(blogEntry.getDate());    String blogEntryId = day.getNextBlogEntry(blogEntry.getId());    while (day != lastDay && blogEntryId == null) {      day = day.getNextDay();      blogEntryId = day.getFirstBlogEntry();    }    if (blogEntryId != null) {      BlogService service = new BlogService();      try {        BlogEntry nextBlogEntry = service.getBlogEntry(this, blogEntryId);        return nextBlogEntry;      } catch (BlogServiceException e) {        // do nothing      }    }    return null;  }  /**   * Gets the categories associated with this blog.   *   * @return  a List of Category instances   */  public List<Category> getCategories() {    CategoryBuilder builder = new CategoryBuilder(this, rootCategory);    return builder.getCategories();  }  /**   * Gets a specific category.   *   * @return  a Category instance   */  public Category getCategory(String id) {    CategoryBuilder builder = new CategoryBuilder(this, rootCategory);    return builder.getCategory(id);  }  /**   * Gets the root category for this blog.   *   * @return  a Category instance   */  public Category getRootCategory() {    return this.rootCategory;  }  /**   * Sets the root category for this blog.   *   * @param category    a Category instance   */  public void setRootCategory(Category category) {    this.rootCategory = category;  }  /**   * Adds a category.   *   * @param category    the Category to be added   */  public synchronized void addCategory(Category category) {    if (getCategory(category.getId()) == null) {      CategoryBuilder builder = new CategoryBuilder(this, rootCategory);      builder.addCategory(category);    }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -