LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-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

HPS-SVN Home

HPS-SVN Home

HPS-SVN  March 2016

HPS-SVN March 2016

Subject:

r4274 - /java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java

From:

[log in to unmask]

Reply-To:

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

Date:

Tue, 1 Mar 2016 23:48:57 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (81 lines)

Author: [log in to unmask]
Date: Tue Mar  1 15:48:54 2016
New Revision: 4274

Log:
Use CSV output in print instead of space or tab delimited (compatible with load command now).

Modified:
    java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java

Modified: java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java
 =============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java	(original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/cli/PrintCommand.java	Tue Mar  1 15:48:54 2016
@@ -40,16 +40,15 @@
     static {
         options.addOption(new Option("h", "help", false, "print help for print command"));
         options.addOption(new Option("t", "table", true, "table name"));
-        options.addOption(new Option("i", "print-id", false, "print the ID for the records (off by default)"));
-        options.addOption(new Option("f", "file", true, "write print output to a file (must be used with -t option)"));
+        options.addOption(new Option("i", "print-id", false, "include the row IDs in printouts"));
+        options.addOption(new Option("f", "file", true, "write output to a file (requires -t option)"));
         options.addOption(new Option("H", "no-header", false, "suppress printing of conditions record and table info"));
-        options.addOption(new Option("d", "tabs", false, "use tabs for field delimiter instead of spaces"));
     }
 
     /**
      * The field delimiter for print output.
      */
-    private char fieldDelimiter = ' ';
+    private static final char DELIMITER = ',';    
 
     /**
      * Output file if printing to a file.
@@ -125,11 +124,6 @@
         // Print header info. Option turns this off.
         if (commandLine.hasOption("h")) {
             this.printHeaders = false;
-        }
-
-        // Use tabs instead of spaces for field delimiter.
-        if (commandLine.hasOption("d")) {
-            this.fieldDelimiter = '\t';
         }
 
         // List of conditions records to print.
@@ -173,7 +167,7 @@
             for (final String columnName : collection.getTableMetaData().getFieldNames()) {
                 if (!"collection_id".equals(columnName)) {
                     buffer.append(((ConditionsObject) object).getFieldValue(columnName));
-                    buffer.append(this.fieldDelimiter);
+                    buffer.append(DELIMITER);
                 }
             }
             buffer.setLength(buffer.length() - 1);
@@ -221,15 +215,17 @@
     private void printColumnNames(final TableMetaData tableMetaData) {
         if (this.printIDs) {
             this.ps.print("id");
-            this.ps.print(this.fieldDelimiter);
-        }
+            this.ps.print(DELIMITER);
+        }
+        StringBuffer sb = new StringBuffer();
         for (final String columnName : tableMetaData.getFieldNames()) {
             if (!"collection_id".equals(columnName)) {
-                this.ps.print(columnName);
-                this.ps.print(this.fieldDelimiter);
-            }
-        }
-        this.ps.println();
+                sb.append(columnName);
+                sb.append(DELIMITER);
+            }
+        }
+        sb.setLength(sb.length() - 1);
+        this.ps.println(sb.toString());
     }
 
     /**

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

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
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