[HepData-svn] r1496 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Dec 9 13:55:40 GMT 2011


Author: whalley
Date: Fri Dec  9 13:55:40 2011
New Revision: 1496

Log:
more tweaks to Plain formatting

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	Fri Dec  9 12:58:40 2011	(r1495)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/PlainFormatter.java	Fri Dec  9 13:55:40 2011	(r1496)
@@ -91,6 +91,7 @@
             String[][] store = new String[d.getYAxes().size()][nstore];
 
             boolean hassqrt = false;
+            String sqrts = "";
             for (int ny=1; ny<=d.getYAxes().size(); ny++ ) {
                 List <String> storelist = new ArrayList();
                 for (String c : d.getYAxis(ny).getComments()) {
@@ -100,30 +101,35 @@
                 for(int i=0; i<storelist.size(); i++){
                     store[ny-1][i]=storelist.get(i);
                 }
-//                storelist.clear();
-//            }
-//
-//
-//            for (int ny=1; ny<=d.getYAxes().size(); ny++ ) {
-//                List <String> storelist = new ArrayList();
                 for (Property p : d.getYAxis(ny).getProperties()) {
                     /// @todo Do better matching on "SQRT(S)" etc.
-                    String str = "";
+                    StringBuffer sb = new StringBuffer();
                     if (! p.getName().toLowerCase().equals("sqrts")) {
-                        str.concat(p.getName() + " : ");
+                        sb.append(p.getName() + " : ");
                         if (p.getLowValue() != null && p.getHighValue() != null &&
                             p.getLowValue().equals(p.getHighValue())) {
-                            str.concat(p.getLowValue().toString());
+                            sb.append(p.getLowValue().toString());
                         } else {
-                            str.concat(p.getLowValue().toString() + " - " + p.getHighValue().toString());
+                            sb.append(p.getLowValue().toString() + " - " + p.getHighValue().toString());
                         }
                         if (!p.getUnit().isDimensionless()) {
-                            str.concat(" " + p.getUnit().toString());
+                            sb.append(" " + p.getUnit().toString());
                         }
-                        storelist.add(str);
+                        storelist.add(sb.toString());
                     }
                     else {
-                        hassqrt = true;    
+                        hassqrt = true;  
+                        sb.append(p.getName() + " : ");
+                        if (p.getLowValue() != null && p.getHighValue() != null &&
+                            p.getLowValue().equals(p.getHighValue())) {
+                            sb.append(p.getLowValue().toString());
+                        } else {
+                            sb.append(p.getLowValue().toString() + " - " + p.getHighValue().toString());
+                        }
+                        if (!p.getUnit().isDimensionless()) {
+                            sb.append(" " + p.getUnit().toString());
+                        }
+                        sqrts = sb.toString();
                     }       
              
                 }
@@ -134,7 +140,10 @@
                 storelist.clear();
             }
 
-            if(hassqrt) { nstore -= 1; }
+            if(hassqrt) { 
+                nstore -= 1;
+                s.append(sqrts + "\n"); 
+            }
             for(int i=0; i<nstore; i++){
                 s.append(store[0][i]);
                 for (int ny=2; ny<=d.getYAxes().size(); ny++ ) {


More information about the HepData-svn mailing list