Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 26303 invoked from network); 12 May 2010 15:55:07 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 12 May 2010 15:55:07 -0000 Received: (qmail 89513 invoked by uid 500); 12 May 2010 15:55:07 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 89320 invoked by uid 500); 12 May 2010 15:55:07 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 89216 invoked by uid 99); 12 May 2010 15:55:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 May 2010 15:55:07 +0000 X-ASF-Spam-Status: No, hits=-1553.5 required=10.0 tests=ALL_TRUSTED,AWL,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 May 2010 15:55:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C6B64238899C; Wed, 12 May 2010 15:54:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r943559 - /felix/trunk/gogo/felixcommands/src/main/java/org/apache/felix/gogo/felixcommands/Basic.java Date: Wed, 12 May 2010 15:54:45 -0000 To: commits@felix.apache.org From: rickhall@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100512155445.C6B64238899C@eris.apache.org> Author: rickhall Date: Wed May 12 15:54:45 2010 New Revision: 943559 URL: http://svn.apache.org/viewvc?rev=943559&view=rev Log: Make "lb" command output more compact. (FELIX-2042) Modified: felix/trunk/gogo/felixcommands/src/main/java/org/apache/felix/gogo/felixcommands/Basic.java Modified: felix/trunk/gogo/felixcommands/src/main/java/org/apache/felix/gogo/felixcommands/Basic.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/felixcommands/src/main/java/org/apache/felix/gogo/felixcommands/Basic.java?rev=943559&r1=943558&r2=943559&view=diff ============================================================================== --- felix/trunk/gogo/felixcommands/src/main/java/org/apache/felix/gogo/felixcommands/Basic.java (original) +++ felix/trunk/gogo/felixcommands/src/main/java/org/apache/felix/gogo/felixcommands/Basic.java Wed May 12 15:54:45 2010 @@ -20,7 +20,6 @@ package org.apache.felix.gogo.felixcomma import java.io.IOException; import java.io.InputStream; -import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.annotation.Annotation; @@ -30,7 +29,6 @@ import java.net.URL; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; -import java.util.Comparator; import java.util.Date; import java.util.Dictionary; import java.util.Enumeration; @@ -945,77 +943,89 @@ public class Basic System.out.println("START LEVEL " + startLevel.getStartLevel()); } - // Print column headers. - String msg = " Name"; + // Determine last column. + String lastColumn = "Name"; if (showLoc) { - msg = " Location"; + lastColumn = "Location"; } else if (showSymbolic) { - msg = " Symbolic name"; + lastColumn = "Symbolic name"; } else if (showUpdate) { - msg = " Update location"; + lastColumn = "Update location"; + } + + // Print column headers. + if (startLevel != null) + { + System.out.println( + String.format( + "%5s %-11s %5s %s", "ID", "State", "Level", lastColumn)); } - String level = (startLevel == null) ? "" : " Level "; - System.out.println(" ID " + " State " + level + msg); - for (int i = 0; i < bundles.length; i++) + else + { + System.out.println( + String.format( + "%5s %-11s %s", "ID", "State", lastColumn)); + } + for (Bundle bundle : bundles) { // Get the bundle name or location. String name = (String) - bundles[i].getHeaders().get(Constants.BUNDLE_NAME); + bundle.getHeaders().get(Constants.BUNDLE_NAME); // If there is no name, then default to symbolic name. - name = (name == null) ? bundles[i].getSymbolicName() : name; + name = (name == null) ? bundle.getSymbolicName() : name; // If there is no symbolic name, resort to location. - name = (name == null) ? bundles[i].getLocation() : name; + name = (name == null) ? bundle.getLocation() : name; // Overwrite the default value is the user specifically // requested to display one or the other. if (showLoc) { - name = bundles[i].getLocation(); + name = bundle.getLocation(); } else if (showSymbolic) { - name = bundles[i].getSymbolicName(); + name = bundle.getSymbolicName(); name = (name == null) ? "" : name; } else if (showUpdate) { name = (String) - bundles[i].getHeaders().get(Constants.BUNDLE_UPDATELOCATION); + bundle.getHeaders().get(Constants.BUNDLE_UPDATELOCATION); name = (name == null) - ? bundles[i].getLocation() : name; + ? bundle.getLocation() : name; } + // Show bundle version if not showing location. - String version = (String) - bundles[i].getHeaders().get(Constants.BUNDLE_VERSION); - name = (!showLoc && !showUpdate && (version != null)) - ? name + " (" + version + ")" : name; - long l = bundles[i].getBundleId(); - String id = String.valueOf(l); - if (startLevel == null) + name = (!showLoc && !showUpdate) + ? name + " (" + bundle.getVersion() + ")" : name; + + // Get the bundle's start level. + int level = (startLevel == null) + ? -1 + : startLevel.getBundleStartLevel(bundle); + + if (level < 0) { - level = "1"; + System.out.println( + String.format( + "%5d|%-11s|%s", + bundle.getBundleId(), getStateString(bundle), + name, bundle.getVersion())); } else { - level = String.valueOf(startLevel.getBundleStartLevel(bundles[i])); - } - while (level.length() < 5) - { - level = " " + level; - } - while (id.length() < 4) - { - id = " " + id; + System.out.println( + String.format( + "%5d|%-11s|%5d|%s", + bundle.getBundleId(), getStateString(bundle), + level, name, bundle.getVersion())); } - System.out.println("[" + id + "] [" - + getStateString(bundles[i]) - + "] [" + level + "] " + name); } }