|
[HepData-svn] r1468 - trunk/hepdata-model/src/main/java/cedar/hepdata/modelblackhole at projects.hepforge.org blackhole at projects.hepforge.orgTue Aug 9 11:39:17 BST 2011
Author: whalley Date: Tue Aug 9 11:39:17 2011 New Revision: 1468 Log: CR and CT outputs end on word boundaries Modified: trunk/hepdata-model/src/main/java/cedar/hepdata/model/Dataset.java trunk/hepdata-model/src/main/java/cedar/hepdata/model/Paper.java Modified: trunk/hepdata-model/src/main/java/cedar/hepdata/model/Dataset.java ============================================================================== --- trunk/hepdata-model/src/main/java/cedar/hepdata/model/Dataset.java Wed Aug 3 11:56:08 2011 (r1467) +++ trunk/hepdata-model/src/main/java/cedar/hepdata/model/Dataset.java Tue Aug 9 11:39:17 2011 (r1468) @@ -117,12 +117,29 @@ nc += 1; if(nc == n){ if( cr!=null){ - if(n==1) { s.append("CT = " + cr + ";"); } - else { s.append("CT.= " + cr + ";"); } - int num = s.length()/80; - for (int i=0; i<num; i++){s.insert(80*(i+1)+i,'\n');} + + String crnew = ""; + int len = cr.length(); + int ip = 0; + int ipos = 0; + int ntemp=0; + while (ip < len){ + int max = 79; + if(len-ip < 79) { + crnew = crnew + cr.substring(ip); + ip=len; + } else { + ipos = max; + if(cr.substring(ip,ip+max).contains(" ")) { + ipos = cr.substring(ip,ip+max).lastIndexOf(" "); + } + crnew = crnew + cr.substring(ip,ip+ipos) + "\n"; + ip = ip+ipos; + } + } + if(n==1) { s.append("CT = " + crnew + ";"); } + else { s.append("CT.= " + crnew + ";"); } crstring = s.toString(); - break; } } } Modified: trunk/hepdata-model/src/main/java/cedar/hepdata/model/Paper.java ============================================================================== --- trunk/hepdata-model/src/main/java/cedar/hepdata/model/Paper.java Wed Aug 3 11:56:08 2011 (r1467) +++ trunk/hepdata-model/src/main/java/cedar/hepdata/model/Paper.java Tue Aug 9 11:39:17 2011 (r1468) @@ -290,12 +290,28 @@ nc += 1; if(nc == n){ if( cr!=null){ - if(n==1) { s.append("CR = " + cr + ";"); } - else { s.append("CR.= " + cr + ";"); } - int num = s.length()/80; - for (int i=0; i<num; i++){s.insert(80*(i+1)+i,'\n');} + String crnew = ""; + int len = cr.length(); + int ip = 0; + int ipos = 0; + int ntemp=0; + while (ip < len){ + int max = 79; + if(len-ip < 79) { + crnew = crnew + cr.substring(ip); + ip=len; + } else { + ipos = max; + if(cr.substring(ip,ip+max).contains(" ")) { + ipos = cr.substring(ip,ip+max).lastIndexOf(" "); + } + crnew = crnew + cr.substring(ip,ip+ipos) + "\n"; + ip = ip+ipos; + } + } + if(n==1) { s.append("CR = " + crnew + ";"); } + else { s.append("CR.= " + crnew + ";"); } crstring = s.toString(); - break; } } }
More information about the HepData-svn mailing list |