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

📄 threadtag.java

📁 这是学习Java必须读懂两套源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  public final String getName()
  {
    return ct.getName();
  }

  /**
   * Forum Name property which can be obtained by the JSP page
   * using &lt;jsp:getProperty name=<i>"id"</i> property="forumName"/&gt;
   *
   * @return String - name of the forum this thread is in
   */
  public final String getForumName()
  {
    return ct.getForum().getName();
  }

  /**
   * Forum ID property which can be obtained by the JSP page
   * using &lt;jsp:getProperty name=<i>"id"</i> property="forumid"/&gt;
   *
   * @return String - id of the forum this thread is in
   */
  public final String getForumid()
  {
    return "" + ct.getForum().getID();
  }

  /**
   * Date and time of Thread CreationDate (integer) property which can be
   * obtained by the JSP page using
   * &lt;jsp:getProperty name=<i>"id"</i> property="creationDate"/&gt;
   *
   * @return date and time of Thread CreationDate as an integer
   */
  public final String getCreationDate()
  {
    return "" + ct.getCreationDate().getTime();
  }

  /**
   * Date and time of Thread ModifiedDate (integer) property which can be
   * obtained by the JSP page using
   * &lt;jsp:getProperty name=<i>"id"</i> property="modifiedDate"/&gt;
   *
   * @return date and time of Thread ModifiedDate as an integer
   */
  public final String getModifiedDate()
  {
    return "" + ct.getModifiedDate().getTime();
  }

  /**
   * Next Thread ID property which can be obtained by the JSP page
   * using &lt;jsp:getProperty name=<i>"id"</i> property="nextThreadid"/&gt;
   *
   * @return String - next thread ID
   */
  public final String getNextThreadid()
  {
    return "" + nextThreadID;
  }

  /**
   * Previous Thread ID property which can be obtained by the JSP page
   * using &lt;jsp:getProperty name=<i>"id"</i> property="prevThreadid"/&gt;
   *
   * @return String - previous thread ID
   */
  public final String getPrevThreadid()
  {
    return "" + prevThreadID;
  }

  /**
   * Get the root message for this thread
   *
   * @return ForumMessage
   */
  public final ForumMessage getMessage() {
    return ct.getRootMessage();
  }

  /**
   * Move the thread to a different forum, used by move_thread tag.
   *
   * @return true if thread moved, false if thread move failed
   */
  public final boolean moveThread() throws JspException
  {
    Forum cf = ct.getForum();
    int threadid = ct.getID();
    if( mf == null )
      throw new JspException(
	"Yazd thread tag, you must set a forum using change_forum tag before using move_thread tag");
    try {
      cf.moveThread(ct,mf);
      return true;

      /* This should no longer be needed, it should be
         encapsulated in moveThread now
      try {
        ForumThread nt = mf.getThread(threadid);
	ct = nt;
	SearchIndexer si = jr.getForumFactory().getSearchIndexer();
        si.updateThreadForum(ct);
	return true;
      } catch(ForumThreadNotFoundException e) {}
      */

    } catch(UnauthorizedException ue) {
      jr.addError(TagPropertyManager.getTagProperty("yazd.tag.post.authorize.failed"));
    }
    return false;
  }

  /**
   * Remove the thread and post its message as a reply to a parent message
   * for a different forum thread, used by move_message tag.
   *
   * @return true if message moved, false if message move failed
   */
  public final boolean moveMessage() throws JspException
  {
    Forum cf = ct.getForum();
    int threadid = ct.getID();
    ForumMessage cm = null;
    ForumThread mt = null;

    cm = ct.getRootMessage();
    if( cm == null )
      throw new JspException(
        "Yazd thread tag, could not find message to move using move_message tag");

    if( ct.getMessageCount() != 1 )
      throw new JspException(
        "Yazd thread tag, you can not move a message thread that has replies using move_message tag");

    if( mf == null )
      throw new JspException(
        "Yazd thread tag, you must set a forum using change_forum tag before using move_message tag");

    if( mtid == 0 )
      throw new JspException(
        "Yazd thread tag, you must set a thread using set_thread tag before using move_message tag");

    if( mmid == 0 )
      throw new JspException(
        "Yazd thread tag, you must set a parent message using set_parent_message tag before using move_message tag");

    cm = ct.getRootMessage();
    if( cm == null ) {
      throw new JspException(
        "Yazd thread tag, could not find thread root message for move_message tag");
    }

    try {
      mt = mf.getThread(mtid);
    } catch(ForumThreadNotFoundException e) {
      throw new JspException(
        "Yazd thread tag, could not find thread to move message to");
    }
    try {
      ForumMessage parentMessage = mt.getMessage( mmid );
      ct.moveMessage(cm,mt,parentMessage);
      ct = mt;
      return true;

      /* old move message code
      cf.removeThread(ct);
      try {
	ForumMessage parentMessage = mt.getMessage( mmid );
	mt.addMessage( parentMessage, cm );
        ct = mt;
        SearchIndexer si = jr.getForumFactory().getSearchIndexer();
        si.updateMessageForum(ct.getMessage(cm.getID()));
        return true;
      } catch(ForumMessageNotFoundException e) {
        throw new JspException(
          "Yazd thread tag, could not find parent message for move_message tag");
      }
      */

    } catch(UnauthorizedException ue) {
      jr.addError(TagPropertyManager.getTagProperty("yazd.tag.post.authorize.failed"));
    } catch(ForumMessageNotFoundException e) {
      throw new JspException(
        "Yazd thread tag, could not find parent message for move_message tag");
    }
    return false;
  }

  /**
   *  Set an alternate forum where message is to be moved
   */
  public final void changeForum(Forum apf)
  {
    mf = apf;
  }

  /**
   * Determine if thread has new messages since users last visit.
   *
   * @return boolean - true or false
   */
  public final boolean newMessages()
  {
    if( js.getLastForumVisitDate(ct.getForum(),jr).getTime() <
        ct.getModifiedDate().getTime() )
                return true;
    return false;
  }

  /**
   * Determine if there is a thread preceding this one
   *
   * @return boolean - true or false
   */
  public final boolean prevThread()
  {
    if( prevThreadID > 0 )
      return true;
    return false;
  }

  /**
   * Determine if there is a thread following this one
   *
   * @return boolean - true or false
   */
  public final boolean nextThread()
  {
    if( nextThreadID > 0 )
      return true;
    return false;
  }

  /**
   *  Set the threadId for thread message is being moved to
   */
  public final void setThread(int tid)
  {
    mtid = tid;
  }

  /**
   *  Change to a different thread
   */
  public final void changeThread(int at) throws JspException
  {
    // See if we are nested inside a forum tag
    ForumTag ft = null;
    try {
      ft = (ForumTag)this.findAncestorWithClass(this,
        Class.forName("com.Yasna.forum.tags.ForumTag"));
    } catch(Exception e) {
    }
    if( ft == null ) {
      throw new JspException("Yazd thread tag must be nested inside a forum tag");
    }

    try {
      ForumThread nt = ft.getForum().getThread(at);
      ct = nt;
    } catch(ForumThreadNotFoundException e) {
      throw new JspException(
        "Yazd thread tag, could not find thread to change_thread to");
    }
  }

  /**
   *  Set the parent message id for message being moved
   */
  public final void setParentMessage(int mid)
  {
    mmid = mid;
  }


  /**
   * Remove the script variable after forum tag closed out
   */
  public final void release()
  {
    if( id != null && id.length() > 0 )
      pageContext.removeAttribute(id,PageContext.PAGE_SCOPE);
  }

}

⌨️ 快捷键说明

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