%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.Document" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.Page" %>
<%@ page import="javax.validation.constraints.NotNull" %>
<%@ page import="org.crosswire.xml.XMLBlock" %>
<%@ page import="org.crosswire.webtools.annotation.*" %>
<%@ page import="org.crosswire.sword.keys.VerseKey" %>
<%@ page import="org.crosswire.sword.keys.ListKey" %>
<%@ page import="org.crosswire.webtools.*" %>
<%!
@Description(value = "Retrieve index information about the content of manuscript page.", name = "biblicalcontent/get")
public static class MyParameters extends Parameters {
@NotNull
@Description(value = "manuscript id to query", example = "10046")
public Integer docID = null;
@Description(value = "page id to query", example = "10")
public Integer pageID = null;
@Description(value = "whether to use a (short) range format for verses or break them up into individual entries (long)", defaultValue = "short", example = "long")
public String detail = "short";
}
%>
<%
MyParameters params = new MyParameters().loadFromRequest(request, response, false);
if (params.getErrors().size() == 0) {
Document doc = Document.getDocument(params.docID);
String v11n = doc.getV11n();
VerseKey vk = new VerseKey();
vk.setIntros(true);
if (v11n != null) vk.setVersificationSystem(v11n);
Page pages[] = (params.pageID != null) ? new Page[] {Page.getPage(params.docID, params.pageID)} : Page.getPagesBCOnly(params.docID);
StringBuffer accumulatedVerses = new StringBuffer();
StringBuffer pagesResult = new StringBuffer();
for (Page p : pages) {
if (p == null) continue;
if (accumulatedVerses.length() > 0) accumulatedVerses.append(",");
String bc = p.getBiblicalContent();
if (bc != null) accumulatedVerses.append(bc);
if (!"long".equals(params.detail)) {
pagesResult.append("");
}
else {
for (int i : p.getVerses()) {
vk.setHashNumber(i);
pagesResult.append("");
}
}
}
ListKey verses = vk.ParseVerseList(accumulatedVerses.toString(), "Mat.1.1", true);
verses.mergeContiguousElements();
StringBuffer retVal = new StringBuffer();
retVal.append("");
retVal.append(pagesResult.toString());
retVal.append("");
Serializer.output(response, out, params, XMLBlock.createXMLBlock(retVal.toString()));
return;
}
else params.format = "html";
Serializer.reportErrors(request, response, out, params, true);
%>