LISTSERV mailing list manager LISTSERV 16.5

Help for LCDET-SVN Archives


LCDET-SVN Archives

LCDET-SVN Archives


LCDET-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

LCDET-SVN Home

LCDET-SVN Home

LCDET-SVN  January 2015

LCDET-SVN January 2015

Subject:

r3483 - /projects/lcsim/trunk/event-processing/src/main/java/org/lcsim/util/loop/LCIODriver.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the lcdet svn repository <[log in to unmask]>

Date:

Thu, 8 Jan 2015 01:06:39 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (273 lines)

Author: [log in to unmask]
Date: Wed Jan  7 17:06:35 2015
New Revision: 3483

Log:
Have Driver add slcio file extension if necessary.

Modified:
    projects/lcsim/trunk/event-processing/src/main/java/org/lcsim/util/loop/LCIODriver.java

Modified: projects/lcsim/trunk/event-processing/src/main/java/org/lcsim/util/loop/LCIODriver.java
 =============================================================================
--- projects/lcsim/trunk/event-processing/src/main/java/org/lcsim/util/loop/LCIODriver.java	(original)
+++ projects/lcsim/trunk/event-processing/src/main/java/org/lcsim/util/loop/LCIODriver.java	Wed Jan  7 17:06:35 2015
@@ -12,154 +12,123 @@
 import org.lcsim.lcio.LCIOWriter;
 
 /**
- * A driver for writing out LCIO events. 
+ * A driver for writing out LCIO events.
  * 
- * By default this will write out the entire event, but you can control
- * what collections are written out by using {@link #setIgnoreCollection(String)},
- * {@link #setIgnoreCollections(String[])}, {@link #setWriteOnlyCollection(String)},
- * and {@link #setWriteOnlyCollections(String[])}.  
+ * By default this will write out the entire event, but you can control what collections are written 
+ * out by using {@link #setIgnoreCollection(String)}, {@link #setIgnoreCollections(String[])},
+ * {@link #setWriteOnlyCollection(String)}, and {@link #setWriteOnlyCollections(String[])}.
  * 
  * @author tonyj
  * @see org.lcsim.util.lcio.LCIOWriter
  */
-public class LCIODriver extends Driver
-{
-	private LCIOWriter writer;
-	private Set<String> listIgnore = new HashSet<String>();
-	private Set<String> listKeep = new HashSet<String>();
-	private File outputFile;
-	
-	public LCIODriver(String file)
-	{
-		this(file, null);
-	}
-	
-	public LCIODriver(File file)
-	{
-		this(file, null);
-	}
-	
-	public LCIODriver(String file, Collection<String> listIgnore)
-	{
-		this(new File(file),listIgnore);
-	}
-	
-	public LCIODriver(File file, Collection<String> listIgnore)
-	{
+public class LCIODriver extends Driver {
+    private LCIOWriter writer;
+    private Set<String> listIgnore = new HashSet<String>();
+    private Set<String> listKeep = new HashSet<String>();
+    private File outputFile;
+
+    public LCIODriver(String file) {
+        this(addFileExtension(file), null);
+    }
+
+    public LCIODriver(File file) {
+        this(file, null);
+    }
+
+    public LCIODriver(String file, Collection<String> listIgnore) {
+        this(new File(addFileExtension(file)), listIgnore);
+    }
+
+    public LCIODriver(File file, Collection<String> listIgnore) {
         this.outputFile = file;
-        if (listIgnore != null)
-        {
+        if (listIgnore != null) {
             this.listIgnore.addAll(listIgnore);
         }
-	}
-		
-	public LCIODriver()
-	{}
-		
-	public void setOutputFilePath(String filePath)
-	{	
-		if (!filePath.endsWith(".slcio"))
-			filePath += ".slcio";
-        outputFile = new File(filePath);
-	}
-	
-	public void setIgnoreCollections(String[] ignoreCollections)
-	{
-		listIgnore.addAll(Arrays.asList(ignoreCollections));
-	}
-	
-	public void setWriteOnlyCollections(String [] keepCollections)
-	{
-		listKeep.addAll(Arrays.asList(keepCollections));
-	}
+    }
 
-    public void setIgnoreCollection(String ignoreCollection)
-    {
+    public LCIODriver() {
+    }
+
+    public void setOutputFilePath(String filePath) {
+        outputFile = new File(addFileExtension(filePath));
+    }
+
+    public void setIgnoreCollections(String[] ignoreCollections) {
+        listIgnore.addAll(Arrays.asList(ignoreCollections));
+    }
+
+    public void setWriteOnlyCollections(String[] keepCollections) {
+        listKeep.addAll(Arrays.asList(keepCollections));
+    }
+
+    public void setIgnoreCollection(String ignoreCollection) {
         listIgnore.add(ignoreCollection);
     }
 
-    public void setWriteOnlyCollection(String writeOnlyCollection)
-    {
+    public void setWriteOnlyCollection(String writeOnlyCollection) {
         listKeep.add(writeOnlyCollection);
     }
-	
-    private void setupWriter()
-    {
-    	// Cleanup existing writer.
-    	if (writer != null)
-    	{
-    		try 
-    		{
-    			writer.flush();
-    			writer.close();
-    			writer = null;
-    		}
-    		catch (IOException x)
-    		{
-    			System.err.println(x.getMessage());
-    		}    		
-    	}
-    	
-    	// Setup new writer.
-        try 
-        {
-            writer = new LCIOWriter(outputFile); 
+
+    private void setupWriter() {
+        // Cleanup existing writer.
+        if (writer != null) {
+            try {
+                writer.flush();
+                writer.close();
+                writer = null;
+            } catch (IOException x) {
+                System.err.println(x.getMessage());
+            }
         }
-        catch (IOException x)
-        {
-            throw new RuntimeException("Error creating writer",x);
+
+        // Setup new writer.
+        try {
+            writer = new LCIOWriter(outputFile);
+        } catch (IOException x) {
+            throw new RuntimeException("Error creating writer", x);
         }
         writer.addAllIgnore(listIgnore);
         writer.addAllWriteOnly(listKeep);
-        
-        try 
-        {
+
+        try {
             writer.reOpen();
-		}
-		catch (IOException x)
-		{
-			throw new RuntimeException("Error rewinding LCIO file",x);
-		}
+        } catch (IOException x) {
+            throw new RuntimeException("Error rewinding LCIO file", x);
+        }
     }
-	
-	protected void startOfData()
-	{
+
+    protected void startOfData() {
         setupWriter();
-	}
-	
-	protected void endOfData()
-	{
-		try
-		{
-			writer.close();
-		}
-		catch (IOException x)
-		{
-			throw new RuntimeException("Error rewinding LCIO file",x);
-		}
-	}
-	
-	protected void process(EventHeader event)
-	{
-		try
-		{
-			writer.write(event);
-		}
-		catch (IOException x)
-		{
-			throw new RuntimeException("Error writing LCIO file",x);
-		}
-	}
+    }
 
-	protected void suspend()
-	{
-		try
-		{
-			writer.flush();
-		}
-		catch (IOException x)
-		{
-			throw new RuntimeException("Error flushing LCIO file",x);
-		}
-	}
+    protected void endOfData() {
+        try {
+            writer.close();
+        } catch (IOException x) {
+            throw new RuntimeException("Error rewinding LCIO file", x);
+        }
+    }
+
+    protected void process(EventHeader event) {
+        try {
+            writer.write(event);
+        } catch (IOException x) {
+            throw new RuntimeException("Error writing LCIO file", x);
+        }
+    }
+
+    protected void suspend() {
+        try {
+            writer.flush();
+        } catch (IOException x) {
+            throw new RuntimeException("Error flushing LCIO file", x);
+        }
+    }
+
+    private static String addFileExtension(String filePath) {
+        if (!filePath.endsWith(".slcio")) {
+            return filePath + ".slcio";
+        } else
+            return filePath;
+    }
 }

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use