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

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Feb 26 17:37:40 GMT 2014


Author: watt
Date: Wed Feb 26 17:37:40 2014
New Revision: 1752

Log:
Write optional comment after systematic errors in input formatter

Modified:
   trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java

Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java
==============================================================================
--- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java	Tue Feb 25 14:43:57 2014	(r1751)
+++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java	Wed Feb 26 17:37:40 2014	(r1752)
@@ -17,8 +17,8 @@
 
     public static String format(Paper p) {
         if(p == null) return null;
-	    StringBuffer s = new StringBuffer();
-	    s.append("*author: " + p.getAuthors().first() + "\n");
+	StringBuffer s = new StringBuffer();
+	s.append("*author: " + p.getAuthors().first() + "\n");
 
         for (Reference ref : p.getReferences()){
             s.append("*reference: "+ref.getDescription()+" : "+ref.getDate()+"\n");
@@ -42,7 +42,7 @@
         if(p.getRedId()!=null) s.append("*durhamId: " + p.getRedId() + "\n");
 
         if(p.getTitle()!=null) {
-           s.append("*title: "+p.getTitle()+"\n");
+	    s.append("*title: "+p.getTitle()+"\n");
         }
         for (String comment : p.getComments()){
             s.append("*comment: "+comment+"\n");
@@ -90,7 +90,7 @@
             int nyax = ds.getYAxes().size();
             int nxax = ds.getXAxes().size();
             
-         //   s.append("\nThis dataset has "+nxax+" x axes and "+nyax+" y axes with "+numpoints+" points\n");
+	    //   s.append("\nThis dataset has "+nxax+" x axes and "+nyax+" y axes with "+numpoints+" points\n");
             if(nyax > 0 && nxax > 0) {
                 int nycomm = ds.getYAxis(1).getComments().size();
                 int nyprop = ds.getYAxis(1).getProperties().size();;
@@ -125,16 +125,16 @@
                         nyhead=1;
                     }
                 
-                   for (String comm : yax.getComments()){
-                       if(comm.contains(":")){
-                     	StringBuffer tempbuff = new StringBuffer();
-                        String left = comm.split("\\s*:\\s*")[0];
-                        String right = comm.split("\\s*:\\s*")[1];
-                        tempbuff.append("*qual: " + left + " : " + right);
-                        storelist.add(tempbuff.toString());
-                       } else{
-                           nycomm =- 1;
-                       }
+		    for (String comm : yax.getComments()){
+			if(comm.contains(":")){
+			    StringBuffer tempbuff = new StringBuffer();
+			    String left = comm.split("\\s*:\\s*")[0];
+			    String right = comm.split("\\s*:\\s*")[1];
+			    tempbuff.append("*qual: " + left + " : " + right);
+			    storelist.add(tempbuff.toString());
+			} else{
+			    nycomm =- 1;
+			}
                     }
                     for (Property prop : yax.getProperties()){
                         if(!prop.getName().startsWith("sqrts")){
@@ -154,12 +154,12 @@
                         store[n][i]=storelist.get(i);
                     }
                 }
-//                 // now check each property etc. for repetition across yaxes (very simple case first)
+		//                 // now check each property etc. for repetition across yaxes (very simple case first)
                 for (int i=0; i<nyprop+nycomm+nyhead; i++){
                     Boolean same = true;
                     if(nyax > 1){
                         for (int ny=0; ny<nyax-1; ny++){
-                           if(!store[ny][i].equals(store[ny+1][i])) { same = false; }
+			    if(!store[ny][i].equals(store[ny+1][i])) { same = false; }
                         }
                     }
                     if(same) { 
@@ -168,8 +168,8 @@
                     else{
                         s.append(store[0][i]);
                         for(int ny=1; ny<nyax; ny++){
-                           String right = store[ny][i].split("\\s*\\:\\s")[1];
-                           if(!store[0][i].startsWith("*yheader")) {right = store[ny][i].split("\\s*\\:\\s")[2];}
+			    String right = store[ny][i].split("\\s*\\:\\s")[1];
+			    if(!store[0][i].startsWith("*yheader")) {right = store[ny][i].split("\\s*\\:\\s")[2];}
                             s.append(" : "+right);
                         }
                         s.append("\n");
@@ -184,36 +184,36 @@
                 s.append("\n");
                 s.append("*data");
                 for(XAxis xax : ds.getXAxes()){
-                s.append(": x ");
+		    s.append(": x ");
                 }
                 for(YAxis yx : ds.getYAxes()){
-                     s.append(": y ");
+		    s.append(": y ");
                 }     
                 s.append("\n");
                 
                 for (int i=0; i<numpoints; i++){
-///////////////////////// x axes/////////////////////////////////
+		    ///////////////////////// x axes/////////////////////////////////
                     for( int nx=0;  nx<ds.getXAxes().size(); nx++){
                         try{
                             if(ds.getXAxis(nx+1).getBin(i+1).getRelation() != Relation.EQUALS){ 
                                 s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getRelation().toString()); 
                             }
                             if(ds.getXAxis(nx+1).getBin(i+1).getFocus() != null){
-                               SignificantFigures focusx = new SignificantFigures(ds.getXAxis(nx+1).getBin(i+1).getFocus());
-                               int lsd = focusx.getLSD();
-                               int msd = focusx.getMSD();
-                               if(msd == 0) msd = 1;                                    
-                               if(ds.getXAxis(nx+1).getBin(i+1).getFocusLength() != null){
-                                        lsd = -ds.getXAxis(nx+1).getBin(i+1).getFocusLength();
-                               }  
-                               String foc = Formats.forms(ds.getXAxis(nx+1).getBin(i+1).getFocus(),msd,-lsd);
-                               s.append(" " + foc);
-                              // s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getFocus());
-                               if(ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null 
+				SignificantFigures focusx = new SignificantFigures(ds.getXAxis(nx+1).getBin(i+1).getFocus());
+				int lsd = focusx.getLSD();
+				int msd = focusx.getMSD();
+				if(msd == 0) msd = 1;                                    
+				if(ds.getXAxis(nx+1).getBin(i+1).getFocusLength() != null){
+				    lsd = -ds.getXAxis(nx+1).getBin(i+1).getFocusLength();
+				}  
+				String foc = Formats.forms(ds.getXAxis(nx+1).getBin(i+1).getFocus(),msd,-lsd);
+				s.append(" " + foc);
+				// s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getFocus());
+				if(ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null 
                                    && ds.getXAxis(nx+1).getBin(i+1).getHighValue() != null 
                                    && !ds.getXAxis(nx+1).getBin(i+1).getLowValue().equals(ds.getXAxis(nx+1).getBin(i+1).getHighValue())){
-                                       s.append(" (BIN=" + ds.getXAxis(nx+1).getBin(i+1).getLowValue() + " TO " + ds.getXAxis(nx+1).getBin(i+1).getHighValue() + ")");                   
-                               }
+				    s.append(" (BIN=" + ds.getXAxis(nx+1).getBin(i+1).getLowValue() + " TO " + ds.getXAxis(nx+1).getBin(i+1).getHighValue() + ")");                   
+				}
                             } else {
                                 if(ds.getXAxis(nx+1).getBin(i+1).getLowValue() != null && ds.getXAxis(nx+1).getBin(i+1).getHighValue()==null){
                                     s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getLowValue());                   
@@ -224,13 +224,13 @@
                                 else{
                                     s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getDescription());
                                 }
-                           }
+			    }
                         } catch(Exception e){
-                           s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getDescription());
+			    s.append(" " + ds.getXAxis(nx+1).getBin(i+1).getDescription());
                         }
                         s.append(";");                   
                     }
-////////////////////////////y-axes///////////////////////////////////////////
+		    ////////////////////////////y-axes///////////////////////////////////////////
                     for (int n=0; n<nyax; n++){
                         YAxis yax = ds.getYAxis(n+1);
                         try{
@@ -271,38 +271,41 @@
                                     int lsd = Integer.parseInt(f_plus.substring(f_plus.indexOf("E")+2));
                                     int ldiff = f_plus.length() + lsd;
                                     f_plus = Formats.forms(err.getPlus(),1,ldiff-5);
-                                 }
+				}
                                 String f_minus = err.getMinus().toString();
                                 if(f_minus.contains("E-")){
                                     int lsd = Integer.parseInt(f_minus.substring(f_minus.indexOf("E")+2));
                                     int ldiff = f_minus.length() + lsd;
                                     f_minus = Formats.forms(err.getMinus(),1,ldiff-5);
-                                 }
+				}
                                 
                                 if(nerr == 1) {
                                     if(err.isSymmetric()){ 
-//                                        s.append(" +- " + err.getPlus() + norm); 
+					//                                        s.append(" +- " + err.getPlus() + norm); 
                                         s.append(" +- " + f_plus + norm); 
                                     }
                                     else{
-//                                        s.append(" +" + err.getPlus() + norm + ",-" + err.getMinus() + norm);
+					//                                        s.append(" +" + err.getPlus() + norm + ",-" + err.getMinus() + norm);
                                         s.append(" +" + f_plus + norm + ",-" + f_minus + norm);
                                     }
                                 }
                                 else if(nerr == 2) { 
                                     s.append(" (DSYS=");
-//                                    if(err.isSymmetric()) {s.append(err.getPlus() + norm);}
-//                                    else{s.append("+" + err.getPlus() + norm + ",-" + err.getMinus() + norm);}
+				    //                                    if(err.isSymmetric()) {s.append(err.getPlus() + norm);}
+				    //                                    else{s.append("+" + err.getPlus() + norm + ",-" + err.getMinus() + norm);}
                                     if(err.isSymmetric()) {s.append(f_plus + norm);}
                                     else{s.append("+" + f_plus + norm + ",-" + f_minus + norm);}
                                 } 
                                 else { 
                                     s.append(",DSYS=");
-//                                    if(err.isSymmetric()) {s.append(err.getPlus() + norm);}
-//                                    else{s.append("+" + err.getPlus() + norm + ",-" + err.getMinus() + norm);}
+				    //                                    if(err.isSymmetric()) {s.append(err.getPlus() + norm);}
+				    //                                    else{s.append("+" + err.getPlus() + norm + ",-" + err.getMinus() + norm);}
                                     if(err.isSymmetric()) {s.append(f_plus + norm);}
                                     else{s.append("+" + f_plus + norm + ",-" + f_minus + norm);}
-                                } 
+                                }
+                                if(err.getComment() != null && !err.getComment().equals("")) {
+                                    s.append(":" + err.getComment());
+                                }
                             }
                             if(nerr > 1) { s.append(")");}
                         }


More information about the HepData-svn mailing list