|
[HepData-svn] r1523 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/componentsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Mar 15 16:21:38 GMT 2012
Author: whalley Date: Thu Mar 15 16:21:38 2012 New Revision: 1523 Log: missing routine Added: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplayDatasetComments.java Added: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplayDatasetComments.java ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/components/DisplayDatasetComments.java Thu Mar 15 16:21:38 2012 (r1523) @@ -0,0 +1,65 @@ +package cedar.hepdata.webapp.components; + +import org.apache.tapestry5.MarkupWriter; +import org.apache.tapestry5.annotations.*; +import org.apache.tapestry5.ioc.annotations.*; +import cedar.hepdata.model.*; +import java.util.*; + +public class DisplayDatasetComments { + + @BeginRender + void renderMessage(MarkupWriter writer) { + + if (_dataset != null) { + List <String> comarray = new ArrayList(); + StringBuffer b = new StringBuffer(); +// writer.element("p class='datasetcomment'"); + for (String comment : _dataset.getComments()){ + if(!comment.startsWith("Location")){ + comment = comment.replace(">", ">"); + comment = comment.replace("<", "<"); + comment = comment.replace("& gt;", ">"); + comment = comment.replace("& lt;", "<"); + while (comment.length() > 1){ + int ip = comment.indexOf(". "); + if(ip < 0) {ip = comment.length();} + int printcom=1; + for (int ii=0; ii<comarray.size(); ii++){ + if(comment.substring(0,ip).equals(comarray.get(ii))){ printcom=0; } + } + if(printcom == 1){ b.append(comment.substring(0,ip) + ". ");} + comarray.add(comment.substring(0,ip)); + if(comment.length() != ip) {comment = comment.substring(ip+2);} + else {comment = "";} + } + } + } + String bs = b.toString(); + int ls=bs.length(); + System.out.println(bs + " " + ls); + while (ls>0){ + int iend = ls; + int ihash = bs.indexOf("#"); + System.out.println("ihash "+ihash+" iend " + ls); + + if(ihash>=0) { iend = ihash; } + writer.element("br"); writer.end(); + writer.write(bs.substring(0,iend)); + if(iend<ls){ + bs=bs.substring(ihash+1); + ls=bs.length(); + } else { + ls=0; + } + } + +// writer.end(); + + + + } + } + @Parameter(name="ds") + private Dataset _dataset; +}
More information about the HepData-svn mailing list |