|
[HepData-svn] r1453 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/formatsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu May 5 16:32:24 BST 2011
Author: whalley Date: Thu May 5 16:32:24 2011 New Revision: 1453 Log: try to improve plain formatting - needs a lot more work Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java Mon Apr 11 10:11:46 2011 (r1452) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java Thu May 5 16:32:24 2011 (r1453) @@ -6,6 +6,7 @@ import cedar.hepdata.db.*; import java.util.*; +import java.util.regex.*; import org.antlr.stringtemplate.*; @@ -154,8 +155,34 @@ s.append("\t+" + ae.getMinus()); } else { - s.append("\t+" + ae.getPlus()); - s.append("\t-" + ae.getMinus()); + Pattern patt9 = Pattern.compile("\\A" + "(^[\\d]+\\.[\\d]*[012345678])[9]+[012345678]*$" + "\\Z",Pattern.CASE_INSENSITIVE); + Pattern patt0 = Pattern.compile("\\A" + "(^[\\d]+\\.[\\d]*[123456789])[0]+[123456789]*$" + "\\Z",Pattern.CASE_INSENSITIVE); + String tt = ae.getPlus().toString(); + + Matcher m9 = patt9.matcher(tt); + Matcher m0 = patt0.matcher(tt); + + if(m9.matches()){ + s.append("\t+" + m9.group(1)); + } else if(m0.matches()){ + s.append("\t+" + m0.group(1)); + } else { + s.append("\t+" + tt); + } + + tt = ae.getMinus().toString(); + m9 = patt9.matcher(tt); + m0 = patt0.matcher(tt); + + if(m9.matches()){ + s.append("\t-" + m9.group(1)); + } else if(m0.matches()){ + s.append("\t-" + m0.group(1)); + } else { + s.append("\t-" + tt); + } +// s.append("\t+" + ae.getPlus()); +// s.append("\t-" + ae.getMinus()); } } catch (HDException hde) { s.append("\t+?\t?");
More information about the HepData-svn mailing list |