Print

Print


Commit in java/sandbox/data-cat/src/main/java/org/srs/datacat/server on MAIN
LcioContentChecker.java+12-8473 -> 474
alpha sort the collections returned by checker

java/sandbox/data-cat/src/main/java/org/srs/datacat/server
LcioContentChecker.java 473 -> 474
--- java/sandbox/data-cat/src/main/java/org/srs/datacat/server/LcioContentChecker.java	2014-04-10 22:13:00 UTC (rev 473)
+++ java/sandbox/data-cat/src/main/java/org/srs/datacat/server/LcioContentChecker.java	2014-04-10 22:13:26 UTC (rev 474)
@@ -2,15 +2,16 @@
 
 import hep.lcio.event.LCEvent;
 import hep.lcio.implementation.io.LCFactory;
-import hep.lcio.io.ILCFactory;
 import hep.lcio.io.LCReader;
 
 import java.io.IOException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.Map;
 
 public class LcioContentChecker implements ContentChecker {
@@ -19,13 +20,13 @@
     private long maxRunNumber = Integer.MIN_VALUE;
     private long nevents = 0;
     private String status;
-    private LinkedHashSet<String> collections;
+    private HashSet<String> uniqueCollections;
     Map<String, Object> metaData;
         
     @Override   
     public void setLocation(long datasetVersion, URL url) throws IOException {
         status = "OK";
-        collections = new LinkedHashSet<String>();
+        uniqueCollections = new HashSet<String>();
         metaData = new HashMap<String, Object>();
         if (!url.getProtocol().equals("file")) {
             throw new IOException("Only file protocol is supported.");
@@ -34,7 +35,7 @@
         reader.open(url.getPath());
         LCEvent event = reader.readNextEvent();
         minRunNumber = Integer.MAX_VALUE;
-        maxRunNumber = Integer.MIN_VALUE;        
+        maxRunNumber = Integer.MIN_VALUE;
         while (event != null) {
         
             int thisRunNumber = event.getRunNumber();
@@ -44,15 +45,18 @@
             if (thisRunNumber > maxRunNumber)
                 maxRunNumber = thisRunNumber;
             
-            collections.addAll(Arrays.asList(event.getCollectionNames()));
+            uniqueCollections.addAll(Arrays.asList(event.getCollectionNames()));
             
             nevents++;
             
             event = reader.readNextEvent();
         }
         
+        List<String> sortedCollections = new ArrayList<String>(uniqueCollections);
+        Collections.sort(sortedCollections);
+        
         StringBuffer buff = new StringBuffer();
-        for (String collectionName : collections) {
+        for (String collectionName : sortedCollections) {
             buff.append(collectionName);
             buff.append(',');
         }
@@ -89,6 +93,6 @@
     }
     
     @Override
-    public void close()  throws IOException {        
+    public void close() throws IOException {
     }           
 }
\ No newline at end of file
SVNspam 0.1