/*
	File : Item.java
	게시판의 게시물 하나에 대한 정보를 가지는 클래스
 */

package com.etri.groupware.bbs;

import java.util.StringTokenizer;


public class Item
{
	private String TeamID;					//부서 이름 
	
	private String BBSBoardName;		//게시판의 종류
	private int number;						//식별자
	private String author;					//작성자
	private String email;					//게시자 메일주소
	private String title;						//제목
	private String itemType;				//게시물의 종류 : 긴급, 일반, 답변
	private String content;					//내용
	private String attachedFile;			//첨부파일
	private String date;						//게시일
	private int viewCount;					//조회수
	private int reference;					//게시물이 답변일경우, 답변이 되는 게시물의 번호
	private int step;							//답변되는 게시물을 기준으로한 순서
	private int lev;								//몇번째 단계의 답변인가를 표시		
	

	public Item()
	{
	}
	
	// WriterServlet 에서 item 초기화할때 사용함.
	public Item(String TeamID, String BBSBoardName, String author, String email, String title,
		String itemType, String content, String attachedFile, String date, int viewCount, int reference, int step, int lev)
	{
		this.TeamID = TeamID;
		this.BBSBoardName = BBSBoardName;
		this.number = number;
		this.author = author;
		this.email = email;
		this.title = title;
		this.itemType = itemType;
		this.content = content;
		this.attachedFile = attachedFile;
		this.date = date;
		this.viewCount = viewCount;
		this.reference = reference;
		this.step = step;
		this.lev = lev;
	}
			
		
	// D/B list를 초기화할때 사용함.
	public Item(String TeamID, String BBSBoardName,int number, String author, String email, String title,
		String itemType, String content, String attachedFile, String date, int viewCount, int reference, int step, int lev)
	{
		this.TeamID = TeamID;
		this.BBSBoardName = BBSBoardName;
		this.number = number;
		this.author = author;
		this.email = email;
		this.title = title;
		this.itemType = itemType;
		this.content = content;
		this.attachedFile = attachedFile;
		this.date = date;
		this.viewCount = viewCount;
		this.reference = reference;
		this.step = step;
		this.lev = lev;
	}

	// set
	public void setTeamID(String _TeamID)
	{
		TeamID = _TeamID;
	}

	public void setBBSBoardName(String _BBSBoardName)
	{
		BBSBoardName = _BBSBoardName;
	}
		 
	public void setNumber(int _number) 
	{
		number = _number;
	}

	public void setAuthor(String _author) 
	{
		author = _author;
	}
	
	public void setEmail(String _email) 
	{
		email = _email;
	}
	
	public void setTitle(String _title) 
	{
		title = _title;
	}
	
	public void setItemType(String _itemType)
	{
		itemType = _itemType;
	}
	
	public void setContent(String _content) 
	{
		content = _content;
	}
	
	public void setAttachedFile(String _attachedFile)
	{
		attachedFile = _attachedFile;
	}

	public void setDate(String _date) 
	{
		date = _date;
	}
	
	public void setViewCount(int _viewCount) 
	{
		viewCount = _viewCount;
	}
		
	public void setReference(int _reference)
	{
		reference = _reference;
	}
	
	public void setStep(int _step)
	{
		step = _step;
	}
	
	public void setLev(int _lev)
	{
		lev = _lev;
	}
		

	// get	
	public String getTeamID()
	{
		return TeamID;
	}
	
	public String getBBSBoardName()
	{
		return BBSBoardName;
	}
	
	public int getNumber()
	{
		return number;
	}
	
	public String getAuthor() 
	{
		return author;
	}
	
	public String getEmail() 
	{
		return email;
	}
	
	public String getTitle() 
	{
		return title;
	}
	
	public String getItemType()
	{
		return itemType;
	}

	public String getContent() 
	{
		return content;
	}
	
	public String getAttachedFile()
	{
		return attachedFile;
	}

	public String getDate () 
	{
		return date;
	}

	public int getViewCount() 
	{
		return viewCount;
	}
	
	public int getReference()
	{
		return reference;
	}
	
	public int getStep()
	{
		return step;
	}
	
	public int getLev()
	{
		return lev;
	}
	

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: getReply<br>
	 [기능]: 어떤 글에 대한 대답을 할때에 그 내용을 참조할때 사용하는 메쏘드<br>
	 [파라미터]: 없음<br>
	 [호출자] : this<br>
	 */
	/*--------------------------------------------------------------- */	
	public String getReply()
	{
		StringBuffer buffer = new StringBuffer();
		try
		{
			StringTokenizer token = new StringTokenizer(content, ";");
			while(token.hasMoreTokens())
			{
				buffer.append("> " + token.nextToken() + "\n");
			}
		}
		catch (NullPointerException e)
		{
			e.printStackTrace();
		}
		return buffer.toString();
	}

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: getModify<br>
	 [기능]: 어떤 글에 대한 수정을 할때에 그 내용을 참조할때 사용하는 메쏘드<br>
	 [파라미터]: 없음<br>
	 [호출자] : this<br>
	 */
	/*--------------------------------------------------------------- */	
	public String getModify()
	{
		StringBuffer buffer = new StringBuffer();
		try
		{
			StringTokenizer token = new StringTokenizer(content, ";");
			while(token.hasMoreTokens())
			{
				buffer.append(token.nextToken() + "\n");
			}
		}
		catch (NullPointerException e)
		{
			e.printStackTrace();
		}
		return buffer.toString();
	}

	/*----------------------------------------------------------------- */
	/**
	 [메소드이름]: writeContent<br>
	 [기능]: 어떤 글에 대한 내용을 html로 보여줄때,  enter를 <br>로 변환하는 기능<br>
	 [파라미터]: 없음<br>
	 [호출자] : this<br>
	 */
	/*--------------------------------------------------------------- */	
	public String writeContent()
	{
		StringBuffer buffer = new StringBuffer();
		try
		{
			StringTokenizer token = new StringTokenizer(content, ";");
			while(token.hasMoreTokens())
			{
				buffer.append(token.nextToken() + "<br>");
			}
		}
		catch (NullPointerException e)
		{
			e.printStackTrace();
		}
		return buffer.toString();
	}


}