<%@ page import="org.apache.lucene.document.Document,
                 java.util.Enumeration,
                 org.apache.lucene.document.Field,
                 org.apache.lucene.index.IndexReader,
                 java.io.IOException,
				 java.net.URLEncoder,
                 com.opensymphony.util.TextUtils" %>

<%@ page contentType="text/html; charset=UTF-8" %>                  

<%

	IndexReader reader = null;
    String indexDir = null;

	if (session.getAttribute("lucene.index.dir") != null)
	{
		indexDir = (String)session.getAttribute("lucene.index.dir");

		try
		{
			reader = IndexReader.open(indexDir);
		}
		catch (IOException e)
		{
			out.println("<strong>Error</strong>: Could not open index: " + e);
		}
	}

	int documentNumber = Integer.parseInt(request.getParameter("doc"));
%>

<html>

	<head>

		<title>View Document</title>

	</head>

	<body>



	<% if (reader != null) { %>



	<strong>Index</strong>: <a href="indexbrowser.jsp?index.dir=<%= URLEncoder.encode(indexDir) %>"><%= indexDir %></a><br/>

	<strong>Index Location</strong>: <%= indexDir %><br/>

	<strong>Number of Documents</strong>: <%= reader.numDocs() %><br/>



	<%

		Document doc = reader.document(documentNumber);

	%>

		<%--<strong><a href="<%= request.getContextPath() %>/display/ViewIssue.jspa?id=<%= doc.get(DocumentConstants.ISSUE_ID) %>"><%= doc.get("title") %></a></strong>--%>
		<strong>Page Title:</strong> <%= doc.get("title") %>



        <table cellspacing=0 cellpadding=0 border=0 bgcolor=cccccc><tr><td>
		<table cellpadding=2 cellspacing=1 border=0>
			<tr>

				<td valign=top><strong>Name</strong></td>
                               
				<td valign=top><strong>Indexed</strong></td>
                               
				<td valign=top><strong>Stored</strong></td>
                               
				<td valign=top><strong>Tokenized</strong></td>
                               
				<td valign=top><strong>Content</strong></td>

			</tr>

			<%

				Enumeration fields = doc.fields();



				while (fields.hasMoreElements())

				{

					Field f = (Field) fields.nextElement();

			%>

				<tr bgcolor=ffffff>

				<td valign=top><strong><%= f.name() %></strong></td>
                               
				<td valign=top><strong><%= f.isIndexed() %></strong></td>
                               
				<td valign=top><strong><%= f.isStored() %></strong></td>
                               
				<td valign=top><strong><%= f.isTokenized() %></strong></td>
                               
				<td valign=top>

					<%= TextUtils.htmlEncode(f.stringValue()) %>

				</td>

				</tr>

			<%

				}

			%>

		</table>

        </td></tr></table>

	<% } %>



</body>

</html>