You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2013/04/17 15:04:45 UTC

svn commit: r1468887 - in /felix/trunk/inventory/src: main/java/org/apache/felix/inventory/ main/java/org/apache/felix/inventory/impl/ main/java/org/apache/felix/inventory/impl/webconsole/ test/java/org/apache/felix/inventory/

Author: fmeschbe
Date: Wed Apr 17 13:04:44 2013
New Revision: 1468887

URL: http://svn.apache.org/r1468887
Log:
FELIX-4025 Cleanup InventoryPrinter API

- Rename PrinterMode to Format
- Reorder InventoryPrinter.print arguments
- Rename InventoryPrinter constants
- Relax InventoryPrinter service property requirements

Added:
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/Format.java
      - copied, changed from r1461812, felix/trunk/inventory/src/main/java/org/apache/felix/inventory/PrinterMode.java
    felix/trunk/inventory/src/test/java/org/apache/felix/inventory/FormatTest.java
      - copied, changed from r1468326, felix/trunk/inventory/src/test/java/org/apache/felix/inventory/PrinterModeTest.java
Removed:
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/PrinterMode.java
    felix/trunk/inventory/src/test/java/org/apache/felix/inventory/PrinterModeTest.java
Modified:
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinter.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/AbstractWebConsolePlugin.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConfigurationPrinterAdapter.java
    felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java

Copied: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/Format.java (from r1461812, felix/trunk/inventory/src/main/java/org/apache/felix/inventory/PrinterMode.java)
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/Format.java?p2=felix/trunk/inventory/src/main/java/org/apache/felix/inventory/Format.java&p1=felix/trunk/inventory/src/main/java/org/apache/felix/inventory/PrinterMode.java&r1=1461812&r2=1468887&rev=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/PrinterMode.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/Format.java Wed Apr 17 13:04:44 2013
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,51 +19,81 @@
 package org.apache.felix.inventory;
 
 /**
- * Enumeration for the different printer modes.
+ * Java 1.4 compatible enumeration of formats used for inventory printing.
+ * <p>
+ * {@link InventoryPrinter} services indicate supported formats listing any of
+ * these values in their {@link InventoryPrinter#FORMAT} service
+ * properties.
+ * <p>
+ * Requestors of inventory printing indicate the desired output format by
+ * specifying the respective constant when calling the
+ * {@link InventoryPrinter#print(java.io.PrintWriter, Format, boolean)} method.
+ * <p>
+ * Round-tripping is guaranteed between the {@link #toString()} and
+ * {@link #valueOf(String)} methods.
  */
-public final class PrinterMode
+public final class Format
 {
 
-    // plain text
-    public static PrinterMode TEXT = new PrinterMode("TEXT");
+    /**
+     * Inventory is printed in plain text format.
+     */
+    public static Format TEXT = new Format("TEXT");
+
+    /**
+     * Inventory is printed in HTML format.
+     * <p>
+     * Technically the output is expected to be an HTML fragment which is
+     * intended to be inserted into any block element, such as {@code <div>},
+     * within a HTML {@code <body>}.
+     */
+    public static Format HTML = new Format("HTML");
+
+    /**
+     * Inventory is printed in JSON format.
+     * <p>
+     * The output is expected to be a valid JSON object. That is, the output
+     * must start with an opening curly brace (<code>{</code>) and end with a
+     * closing curly brace (<code>}</code>).
+     */
+    public static Format JSON = new Format("JSON");
 
-    // valid HTML fragment (no external references)
-    public static PrinterMode HTML_FRAGMENT = new PrinterMode("HTML_FRAGMENT");
+    private final String format;
 
-    // JSON output
-    public static PrinterMode JSON = new PrinterMode("JSON");
-
-    private final String mode;
-
-    private PrinterMode(final String mode)
+    private Format(final String format)
     {
-        this.mode = mode;
+        this.format = format;
     }
 
-    public static PrinterMode valueOf(final String m)
+    /**
+     * Converts the given {@code format} string into an instance of
+     * this class.
+     *
+     * @param format The string value to be converted into a {@code Format}.
+     * @return One of the defined {@code Format} constants or {@code null}.
+     */
+    public static Format valueOf(final String format)
     {
-        if (TEXT.name().equalsIgnoreCase(m))
+        if (TEXT.format.equalsIgnoreCase(format))
         {
             return TEXT;
         }
-        else if (HTML_FRAGMENT.name().equalsIgnoreCase(m))
+        else if (HTML.format.equalsIgnoreCase(format))
         {
-            return HTML_FRAGMENT;
+            return HTML;
         }
-        else if (JSON.name().equalsIgnoreCase(m))
+        else if (JSON.format.equalsIgnoreCase(format))
         {
             return JSON;
         }
         return null;
     }
 
-    public String name()
-    {
-        return this.mode;
-    }
-
+    /**
+     * Returns the string value of this format.
+     */
     public String toString()
     {
-        return name();
+        return format;
     }
 }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinter.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinter.java?rev=1468887&r1=1468886&r2=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinter.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/InventoryPrinter.java Wed Apr 17 13:04:44 2013
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -24,15 +24,15 @@ import java.io.PrintWriter;
  * The <code>InventoryPrinter</code> is a service interface to be
  * implemented by providers which want to hook into the display of the
  * current configuration and state of the OSGi framework and application.
- * 
- * A inventory printer must configure at least these three configuration
- * properties
+ * <p>
+ * The following service registration properties further declare the
+ * {@code InventoryPrinter} service:
  * <ul>
- * <li>{@link #CONFIG_PRINTER_MODES} - the supported modes</li>
- * <li>{@link #CONFIG_TITLE} - the printer title</li>
- * <li>{@link #CONFIG_NAME} - the printer name</li>
+ * <li>{@link #FORMAT} - the supported formats</li>
+ * <li>{@link #TITLE} - the printer title</li>
+ * <li>{@link #NAME} - the printer name</li>
+ * <li>{@link #WEBCONSOLE} - whether to confine the printer to the Web Console</li>
  * </ul>
- * 
  */
 public interface InventoryPrinter
 {
@@ -41,60 +41,67 @@ public interface InventoryPrinter
      * The service name under which services of this class must be registered
      * to be picked for inclusion in the configuration report.
      */
-    String SERVICE = InventoryPrinter.class.getName(); //$NON-NLS-1$
+    String SERVICE = "org.apache.felix.inventory.InventoryPrinter"; //$NON-NLS-1$
 
     /**
-     * The property defining the supported rendering modes.
-     * The value of this property is either a string or a string array
-     * containing
-     * valid names of {@link PrinterMode}.
-     * 
-     * If this property is missing or contains invalid values,
-     * the printer is ignored.
+     * The property defining one or more supported formats. The value of this
+     * property is either a string, a string array or a Collection<String>
+     * containing valid names of the constants defined in the {@link Format}
+     * class.
+     * <p>
+     * Any unknown formats are ignored. If this property is not declared or does
+     * not declare any known formats, the {@link Format#TEXT} format is assumed
+     * as the printer's supported format.
      */
-    String CONFIG_PRINTER_MODES = "felix.inventory.printer.modes"; //$NON-NLS-1$
+    String FORMAT = "felix.inventory.printer.format"; //$NON-NLS-1$
 
     /**
-     * The unique name of the printer.
-     * If this property is missing the printer is ignored.
-     * If there are two or more services with the same name, the
-     * service with the highest ranking is used.
+     * The unique name (or label) of the printer.
+     * <p>
+     * If this property is missing or an empty string, the name is constructed
+     * from the string {@code InventoryPrinter} and the service's
+     * {@code service.id} property.
      */
-    String CONFIG_NAME = "felix.inventory.printer.name"; //$NON-NLS-1$
+    String NAME = "felix.inventory.printer.name"; //$NON-NLS-1$
 
     /**
      * The title displayed by tools when this printer is used. It should be
      * descriptive but short.
-     * If this property is missing the printer is ignored.
+     * <p>
+     * If this property is missing or an empty string, the {@link #NAME} value
+     * is used as the title.
+     */
+    String TITLE = "felix.inventory.printer.title"; //$NON-NLS-1$
+
+    /**
+     * The inventory printer feature has first class integration with the
+     * Apache Felix Web Console. This service registration property can be used
+     * to hide an inventory printer service from the Web Console. The service
+     * will still be called to generate the single file or ZIP file output of
+     * inventory printers.
+     * <p>
+     * By default, a printer is displayed in the web console, unless this
+     * property is set to {@code false}. The property value can either be a
+     * boolean or a string.
      */
-    String CONFIG_TITLE = "felix.inventory.printer.title"; //$NON-NLS-1$
-
-    /**
-     * Optional property controlling whether the printer will be displayed
-     * in the web console. By default, a printer is displayed in the
-     * web console, unless this property is added with the value 'false'.
-     * The property value can either be a boolean or a string.
-     */
-    String CONFIG_WEBCONSOLE = "felix.inventory.printer.webconsole"; //$NON-NLS-1$
+    String WEBCONSOLE = "felix.inventory.printer.webconsole"; //$NON-NLS-1$
 
     /**
      * Prints the configuration report to the given <code>printWriter</code>.
      * Implementations are free to print whatever information they deem useful.
-     * 
-     * If a printer is invoked with a mode it doesn't support (
-     * {@link #CONFIG_PRINTER_MODES})
+     * <p>
+     * If a printer is invoked with a format it doesn't support ( {@link #FORMAT})
      * the printer should just do/print nothing and directly return.
-     * 
+     * <p>
      * A printer might be used in one of two different situations: either for
      * directly displaying the information to a user (like in the web console)
      * or the output is included in a ZIP. The printer might want to return
      * different output depending on the usage situation.
-     * 
-     * @param mode The render mode.
-     * @param printWriter where to write the configuration data. It might be
-     *            flushed,
-     *            but must not be closed.
+     *
+     * @param printWriter where to write the data. Implementations may flush the
+     *            writer but must not close it.
+     * @param format The render format.
      * @param isZip whether this is included in a ZIP file or used directly
      */
-    void print(PrinterMode mode, PrintWriter printWriter, boolean isZip);
+    void print(PrintWriter printWriter, Format format, boolean isZip);
 }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/AbstractWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/AbstractWebConsolePlugin.java?rev=1468887&r1=1468886&r2=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/AbstractWebConsolePlugin.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/AbstractWebConsolePlugin.java Wed Apr 17 13:04:44 2013
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,7 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.felix.inventory.PrinterMode;
+import org.apache.felix.inventory.Format;
 
 /**
  * The web console plugin for a inventory printer.
@@ -46,7 +46,7 @@ public abstract class AbstractWebConsole
 
     /**
      * Constructor
-     * 
+     *
      * @param inventoryPrinterManager The manager
      */
     AbstractWebConsolePlugin(final InventoryPrinterManagerImpl inventoryPrinterManager)
@@ -56,22 +56,22 @@ public abstract class AbstractWebConsole
 
     protected abstract InventoryPrinterHandler getInventoryPrinterHandler();
 
-    private void printConfigurationInventory(final ConfigurationWriter pw, final PrinterMode mode,
+    private void printConfigurationInventory(final ConfigurationWriter pw, final Format format,
         final InventoryPrinterHandler handler) throws IOException
     {
         if (handler == null)
         {
-            final InventoryPrinterHandler[] adapters = this.inventoryPrinterManager.getHandlers(mode);
+            final InventoryPrinterHandler[] adapters = this.inventoryPrinterManager.getHandlers(format);
             for (int i = 0; i < adapters.length; i++)
             {
-                pw.printInventory(mode, adapters[i]);
+                pw.printInventory(format, adapters[i]);
             }
         }
         else
         {
-            if (handler.supports(mode))
+            if (handler.supports(format))
             {
-                pw.printInventory(mode, handler);
+                pw.printInventory(format, handler);
             }
         }
     }
@@ -83,7 +83,7 @@ public abstract class AbstractWebConsole
      * <p>
      * This method sets the <code>Cache-Control</code>, <code>Expires</code>,
      * and <code>Pragma</code> headers.
-     * 
+     *
      * @param response The response for which to set the cache prevention
      */
     private final void setNoCache(final HttpServletResponse response)
@@ -120,7 +120,7 @@ public abstract class AbstractWebConsole
         if (request.getPathInfo().endsWith(".txt")) { //$NON-NLS-2$
             response.setContentType("text/plain; charset=utf-8"); //$NON-NLS-2$
             final ConfigurationWriter pw = new PlainTextConfigurationWriter(response.getWriter());
-            printConfigurationInventory(pw, PrinterMode.TEXT, handler);
+            printConfigurationInventory(pw, Format.TEXT, handler);
             pw.flush();
         }
         else if (request.getPathInfo().endsWith(".zip")) { //$NON-NLS-2$
@@ -140,7 +140,7 @@ public abstract class AbstractWebConsole
             final ZipEntry entry = new ZipEntry("timestamp.txt"); //$NON-NLS-2$
             entry.setTime(now.getTime());
             zip.putNextEntry(entry);
-            final StringBuilder sb = new StringBuilder();
+            final StringBuffer sb = new StringBuffer();
             sb.append("Date: ");
             synchronized (InventoryPrinterAdapter.DISPLAY_DATE_FORMAT)
             {
@@ -154,8 +154,8 @@ public abstract class AbstractWebConsole
             zip.closeEntry();
 
             final ZipConfigurationWriter pw = new ZipConfigurationWriter(zip);
-            printConfigurationInventory(pw, PrinterMode.TEXT, handler);
-            printConfigurationInventory(pw, PrinterMode.JSON, handler);
+            printConfigurationInventory(pw, Format.TEXT, handler);
+            printConfigurationInventory(pw, Format.JSON, handler);
 
             zip.finish();
         }
@@ -174,20 +174,20 @@ public abstract class AbstractWebConsole
             pw.println("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
             pw.println("<head><title>dummy</title></head><body><div>");
 
-            if (handler.supports(PrinterMode.HTML_FRAGMENT))
+            if (handler.supports(Format.HTML))
             {
-                handler.print(PrinterMode.HTML_FRAGMENT, pw, false);
+                handler.print(pw, Format.HTML, false);
             }
-            else if (handler.supports(PrinterMode.TEXT))
+            else if (handler.supports(Format.TEXT))
             {
                 pw.enableFilter(true);
-                handler.print(PrinterMode.TEXT, pw, false);
+                handler.print(pw, Format.TEXT, false);
                 pw.enableFilter(false);
             }
             else
             {
                 pw.enableFilter(true);
-                handler.print(PrinterMode.JSON, pw, false);
+                handler.print(pw, Format.JSON, false);
                 pw.enableFilter(false);
             }
             pw.println("</div></body></html>");
@@ -204,17 +204,17 @@ public abstract class AbstractWebConsole
             response.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
 
             final JSONConfigurationWriter jcw = new JSONConfigurationWriter(response.getWriter());
-            final PrinterMode mode;
-            if (handler.supports(PrinterMode.JSON))
+            final Format format;
+            if (handler.supports(Format.JSON))
             {
-                mode = PrinterMode.JSON;
+                format = Format.JSON;
             }
             else
             {
-                mode = PrinterMode.TEXT;
+                format = Format.TEXT;
                 jcw.startJSONWrapper();
             }
-            printConfigurationInventory(jcw, mode, handler);
+            printConfigurationInventory(jcw, format, handler);
             jcw.endJSONWrapper();
             jcw.flush();
         }
@@ -260,26 +260,26 @@ public abstract class AbstractWebConsole
             pw.print("<button type=\"button\" class=\"downloadFullZip\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download Full Zip</button>");
             pw.print("<button type=\"button\" class=\"downloadFullTxt\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download Full Text</button>");
 
-            if (handler.supports(PrinterMode.JSON))
+            if (handler.supports(Format.JSON))
             {
                 pw.print("<button type=\"button\" class=\"downloadJson\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download As JSON</button>");
             }
             pw.print("<button type=\"button\" class=\"downloadZip\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download As Zip</button>");
-            if (handler.supports(PrinterMode.TEXT))
+            if (handler.supports(Format.TEXT))
             {
                 pw.print("<button type=\"button\" class=\"downloadTxt\" style=\"float: right; margin-right: 30px; margin-top: 5px;\">Download As Text</button>");
             }
 
             pw.println("<br/>&nbsp;</p>"); // status line
             pw.print("<div>");
-            if (handler.supports(PrinterMode.HTML_FRAGMENT))
+            if (handler.supports(Format.HTML))
             {
-                handler.print(PrinterMode.HTML_FRAGMENT, pw, false);
+                handler.print(pw, Format.HTML, false);
             }
             else
             {
                 pw.enableFilter(true);
-                handler.print(PrinterMode.TEXT, pw, false);
+                handler.print(pw, Format.TEXT, false);
                 pw.enableFilter(false);
             }
             pw.print("</div>");
@@ -307,10 +307,10 @@ public abstract class AbstractWebConsole
             // dummy implementation
         }
 
-        public void printInventory(final PrinterMode mode, final InventoryPrinterHandler handler) throws IOException
+        public void printInventory(final Format format, final InventoryPrinterHandler handler) throws IOException
         {
             this.title(handler.getTitle());
-            handler.print(mode, this, false);
+            handler.print(this, format, false);
             this.end();
         }
     }
@@ -555,14 +555,14 @@ public abstract class AbstractWebConsole
 
         /**
          * Escapes HTML special chars like: <>&\r\n and space
-         * 
-         * 
+         *
+         *
          * @param text the text to escape
          * @return the escaped text
          */
         private String escapeHtml(final String text)
         {
-            final StringBuilder sb = new StringBuilder(text.length() * 4 / 3);
+            final StringBuffer sb = new StringBuffer(text.length() * 4 / 3);
             char ch, oldch = '_';
             for (int i = 0; i < text.length(); i++)
             {
@@ -637,29 +637,29 @@ public abstract class AbstractWebConsole
             this.zip = zip;
         }
 
-        public void printInventory(final PrinterMode mode, final InventoryPrinterHandler handler) throws IOException
+        public void printInventory(final Format format, final InventoryPrinterHandler handler) throws IOException
         {
-            if (mode == PrinterMode.TEXT)
+            if (format == Format.TEXT)
             {
                 final ZipEntry entry = new ZipEntry(handler.getName().concat(".txt"));
                 zip.putNextEntry(entry);
-                handler.print(mode, this, false);
+                handler.print(this, format, false);
                 flush();
                 zip.closeEntry();
 
                 handler.addAttachments(handler.getName().concat("/"), this.zip);
             }
-            else if (mode == PrinterMode.JSON)
+            else if (format == Format.JSON)
             {
                 final String name = "json/".concat(handler.getName()).concat(".json");
 
                 final ZipEntry entry = new ZipEntry(name);
                 zip.putNextEntry(entry);
-                handler.print(PrinterMode.JSON, this, true);
+                handler.print(this, Format.JSON, true);
                 flush();
 
                 zip.closeEntry();
-                if (!handler.supports(PrinterMode.TEXT))
+                if (!handler.supports(Format.TEXT))
                 {
                     handler.addAttachments(handler.getName().concat("/"), this.zip);
                 }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java?rev=1468887&r1=1468886&r2=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/DefaultWebConsolePlugin.java Wed Apr 17 13:04:44 2013
@@ -20,7 +20,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.zip.ZipOutputStream;
 
-import org.apache.felix.inventory.PrinterMode;
+import org.apache.felix.inventory.Format;
 import org.apache.felix.inventory.impl.webconsole.ConsoleConstants;
 
 /**
@@ -63,27 +63,27 @@ public class DefaultWebConsolePlugin ext
     }
 
     /**
-     * @see org.apache.felix.inventory..implInventoryPrinterHandler#getModes()
+     * @see org.apache.felix.inventory..implInventoryPrinterHandler#getformats()
      */
-    public PrinterMode[] getModes()
+    public Format[] getFormats()
     {
-        return new PrinterMode[]
-            { PrinterMode.TEXT };
+        return new Format[]
+            { Format.TEXT };
     }
 
     /**
-     * @see org.apache.felix.inventory.impl.InventoryPrinterHandler#supports(org.apache.felix.inventory.PrinterMode)
+     * @see org.apache.felix.inventory.impl.InventoryPrinterHandler#supports(org.apache.felix.inventory.Format)
      */
-    public boolean supports(final PrinterMode mode)
+    public boolean supports(final Format format)
     {
-        return mode == PrinterMode.TEXT;
+        return format == Format.TEXT;
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinter#print(org.apache.felix.inventory.PrinterMode,
-     *      java.io.PrintWriter, boolean)
+     * @see org.apache.felix.inventory.InventoryPrinter#print(java.io.PrintWriter,
+     *      org.apache.felix.inventory.Format, boolean)
      */
-    public void print(final PrinterMode mode, final PrintWriter printWriter, final boolean isZip)
+    public void print(final PrintWriter printWriter, final Format format, final boolean isZip)
     {
         final InventoryPrinterHandler[] handlers = this.inventoryPrinterManager.getAllHandlers();
         printWriter.print("Currently registered ");

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java?rev=1468887&r1=1468886&r2=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterAdapter.java Wed Apr 17 13:04:44 2013
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,14 +24,14 @@ import java.util.Locale;
 import java.util.zip.ZipOutputStream;
 
 import org.apache.felix.inventory.InventoryPrinter;
-import org.apache.felix.inventory.PrinterMode;
+import org.apache.felix.inventory.Format;
 import org.apache.felix.inventory.ZipAttachmentProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
 /**
  * Helper class for a inventory printer.
- * 
+ *
  * The adapter simplifies accessing and working with the inventory printer.
  */
 public class InventoryPrinterAdapter implements InventoryPrinterHandler, Comparable
@@ -77,7 +77,7 @@ public class InventoryPrinterAdapter imp
     {
         if (this.registration == null)
         {
-            final Object value = this.description.getServiceReference().getProperty(InventoryPrinter.CONFIG_WEBCONSOLE);
+            final Object value = this.description.getServiceReference().getProperty(InventoryPrinter.WEBCONSOLE);
             if (value == null || !"false".equalsIgnoreCase(value.toString()))
             {
                 this.registration = WebConsolePlugin.register(context, manager, this.description);
@@ -111,11 +111,11 @@ public class InventoryPrinterAdapter imp
     }
 
     /**
-     * All supported modes.
+     * All supported formats.
      */
-    public PrinterMode[] getModes()
+    public Format[] getFormats()
     {
-        return this.description.getModes();
+        return this.description.getFormats();
     }
 
     /**
@@ -131,13 +131,13 @@ public class InventoryPrinterAdapter imp
     }
 
     /**
-     * Whether the printer supports this mode.
+     * Whether the printer supports this format.
      */
-    public boolean supports(final PrinterMode mode)
+    public boolean supports(final Format format)
     {
-        for (int i = 0; i < this.description.getModes().length; i++)
+        for (int i = 0; i < this.description.getFormats().length; i++)
         {
-            if (this.description.getModes()[i] == mode)
+            if (this.description.getFormats()[i] == format)
             {
                 return true;
             }
@@ -146,14 +146,14 @@ public class InventoryPrinterAdapter imp
     }
 
     /**
-     * @see org.apache.felix.inventory.InventoryPrinter#print(org.apache.felix.inventory.PrinterMode,
+     * @see org.apache.felix.inventory.InventoryPrinter#print(org.apache.felix.inventory.Format,
      *      java.io.PrintWriter)
      */
-    public void print(final PrinterMode mode, final PrintWriter printWriter, final boolean isZip)
+    public void print(final PrintWriter printWriter, final Format format, final boolean isZip)
     {
-        if (this.supports(mode))
+        if (this.supports(format))
         {
-            this.printer.print(mode, printWriter, isZip);
+            this.printer.print(printWriter, format, isZip);
         }
     }
 

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java?rev=1468887&r1=1468886&r2=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterDescription.java Wed Apr 17 13:04:44 2013
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,10 +16,11 @@
  */
 package org.apache.felix.inventory.impl;
 
+import java.util.ArrayList;
 import java.util.Arrays;
-
 import org.apache.felix.inventory.InventoryPrinter;
-import org.apache.felix.inventory.PrinterMode;
+import org.apache.felix.inventory.Format;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 
 /**
@@ -30,7 +31,7 @@ public class InventoryPrinterDescription
 
     private final ServiceReference reference;
 
-    private final PrinterMode[] modes;
+    private final Format[] formats;
 
     private final String name;
 
@@ -42,76 +43,79 @@ public class InventoryPrinterDescription
     {
         this.reference = ref;
 
-        // check modes
-        final Object modesCfg = ref.getProperty(InventoryPrinter.CONFIG_PRINTER_MODES);
-        if (modesCfg instanceof String)
+        // check formats
+        Format[] formats = null;
+        final Object formatsCfg = ref.getProperty(InventoryPrinter.FORMAT);
+        if (formatsCfg instanceof String)
         {
-            final PrinterMode mode = PrinterMode.valueOf((String) modesCfg);
-            if (mode != null)
-            {
-                this.modes = new PrinterMode[]
-                    { mode };
-            }
-            else
+            final Format format = Format.valueOf((String) formatsCfg);
+            if (format != null)
             {
-                this.modes = null;
+                formats = new Format[]
+                    { format };
             }
         }
-        else if (modesCfg instanceof String[])
+        else if (formatsCfg instanceof String[])
         {
-            final String[] modesCfgArray = (String[]) modesCfg;
-            final PrinterMode[] pModes = new PrinterMode[modesCfgArray.length];
-            boolean invalid = false;
-            for (int i = 0; i < modesCfgArray.length; i++)
+            final String[] formatsCfgArray = (String[]) formatsCfg;
+            final ArrayList formatList = new ArrayList();
+            for (int i = 0; i < formatsCfgArray.length; i++)
             {
-                pModes[i] = PrinterMode.valueOf(modesCfgArray[i]);
-                if (pModes[i] == null)
+                final Format format = Format.valueOf(formatsCfgArray[i]);
+                if (format != null)
                 {
-                    invalid = true;
+                    formatList.add(format);
                 }
             }
-            if (invalid)
-            {
-                this.modes = null;
-            }
-            else
+            if (!formatList.isEmpty())
             {
-                this.modes = pModes;
+                formats = (Format[]) formatList.toArray(new Format[formatList.size()]);
             }
         }
-        else
-        {
-            this.modes = null;
-        }
 
         // check name
-        if (ref.getProperty(InventoryPrinter.CONFIG_NAME) != null)
+        final String name;
+        if (ref.getProperty(InventoryPrinter.NAME) != null)
         {
-            this.name = ref.getProperty(InventoryPrinter.CONFIG_NAME).toString();
+            name = ref.getProperty(InventoryPrinter.NAME).toString();
         }
         else
         {
-            this.name = null;
+            name = "InventoryPrinter." + ref.getProperty(Constants.SERVICE_ID);
         }
 
         // check title
-        if (ref.getProperty(InventoryPrinter.CONFIG_TITLE) != null)
+        final String title;
+        String sortKey = null;
+        if (ref.getProperty(InventoryPrinter.TITLE) != null)
         {
-            this.title = ref.getProperty(InventoryPrinter.CONFIG_TITLE).toString();
-            if (this.title.startsWith("%"))
+            title = ref.getProperty(InventoryPrinter.TITLE).toString();
+            if (title.startsWith("%"))
             {
-                this.sortKey = this.title.substring(1);
-            }
-            else
-            {
-                this.sortKey = this.title;
+                sortKey = title.substring(1);
             }
         }
         else
         {
-            this.title = null;
-            this.sortKey = null;
+            title = name;
+        }
+
+        // cleanup
+        if (formats == null)
+        {
+            formats = new Format[]
+                { Format.TEXT };
+        }
+        if (sortKey == null)
+        {
+            sortKey = title;
         }
+
+        // set fields
+        this.formats = formats;
+        this.name = name;
+        this.title = title;
+        this.sortKey = sortKey;
     }
 
     public String getTitle()
@@ -129,9 +133,9 @@ public class InventoryPrinterDescription
         return this.name;
     }
 
-    public PrinterMode[] getModes()
+    public Format[] getFormats()
     {
-        return this.modes;
+        return this.formats;
     }
 
     public ServiceReference getServiceReference()
@@ -159,7 +163,7 @@ public class InventoryPrinterDescription
 
     public String toString()
     {
-        return "InventoryPrinterDescription [title=" + title + ", name=" + name + ", modes=" + Arrays.toString(modes)
+        return "InventoryPrinterDescription [title=" + title + ", name=" + name + ", formats=" + Arrays.toString(formats)
             + ", sortKey=" + sortKey + "]";
     }
 }

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java?rev=1468887&r1=1468886&r2=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterHandler.java Wed Apr 17 13:04:44 2013
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,13 +19,13 @@
 package org.apache.felix.inventory.impl;
 
 import org.apache.felix.inventory.InventoryPrinter;
-import org.apache.felix.inventory.PrinterMode;
+import org.apache.felix.inventory.Format;
 import org.apache.felix.inventory.ZipAttachmentProvider;
 
 /**
  * The inventory printer handler can be used by clients to access
  * a inventory printer.
- * 
+ *
  * For clients using inventory printers, a handler simplifies accessing and
  * working with the inventory printer.
  */
@@ -38,9 +38,9 @@ public interface InventoryPrinterHandler
     /** The human readable title for the inventory printer. */
     String getTitle();
 
-    /** All supported modes. */
-    PrinterMode[] getModes();
+    /** All supported formats. */
+    Format[] getFormats();
 
-    /** Whether the printer supports this mode. */
-    boolean supports(final PrinterMode mode);
+    /** Whether the printer supports this format. */
+    boolean supports(final Format format);
 }
\ No newline at end of file

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java?rev=1468887&r1=1468886&r2=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/InventoryPrinterManagerImpl.java Wed Apr 17 13:04:44 2013
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,7 +30,7 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentSkipListSet;
 
 import org.apache.felix.inventory.InventoryPrinter;
-import org.apache.felix.inventory.PrinterMode;
+import org.apache.felix.inventory.Format;
 import org.apache.felix.inventory.impl.webconsole.ConsoleConstants;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -38,7 +38,6 @@ import org.osgi.framework.InvalidSyntaxE
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.log.LogService;
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
@@ -70,7 +69,7 @@ public class InventoryPrinterManagerImpl
 
     /**
      * Create the inventory printer manager
-     * 
+     *
      * @param btx Bundle Context
      * @throws InvalidSyntaxException Should only happen if we have an error in
      *             the code
@@ -153,34 +152,8 @@ public class InventoryPrinterManagerImpl
     private void addService(final ServiceReference reference, final InventoryPrinter obj)
     {
         final InventoryPrinterDescription desc = new InventoryPrinterDescription(reference);
+        final InventoryPrinterAdapter adapter = new InventoryPrinterAdapter(desc, obj);
 
-        boolean valid = true;
-        if (desc.getModes() == null)
-        {
-            Activator.log(null, LogService.LOG_INFO,
-                "Ignoring inventory printer - printer modes configuration is missing: " + reference, null);
-            valid = false;
-        }
-        if (desc.getName() == null)
-        {
-            Activator.log(null, LogService.LOG_INFO, "Ignoring inventory printer - name configuration is missing: "
-                + reference, null);
-            valid = false;
-        }
-        if (desc.getTitle() == null)
-        {
-            Activator.log(null, LogService.LOG_INFO, "Ignoring inventory printer - title configuration is missing: "
-                + reference, null);
-            valid = false;
-        }
-        if (valid)
-        {
-            this.addAdapter(new InventoryPrinterAdapter(desc, obj));
-        }
-    }
-
-    private void addAdapter(final InventoryPrinterAdapter adapter)
-    {
         InventoryPrinterAdapter removeAdapter = null;
         InventoryPrinterAdapter addAdapter = null;
 
@@ -281,7 +254,7 @@ public class InventoryPrinterManagerImpl
 
     /**
      * Get all inventory printer handlers.
-     * 
+     *
      * @return A list of handlers - might be empty.
      */
     public InventoryPrinterHandler[] getAllHandlers()
@@ -291,18 +264,18 @@ public class InventoryPrinterManagerImpl
     }
 
     /**
-     * Get all handlers supporting the mode.
-     * 
+     * Get all handlers supporting the format.
+     *
      * @return A list of handlers - might be empty.
      */
-    public InventoryPrinterHandler[] getHandlers(final PrinterMode mode)
+    public InventoryPrinterHandler[] getHandlers(final Format format)
     {
         final List result = new ArrayList();
         final Iterator i = this.usedAdapters.iterator();
         while (i.hasNext())
         {
             final InventoryPrinterAdapter printer = (InventoryPrinterAdapter) i.next();
-            if (printer.supports(mode))
+            if (printer.supports(format))
             {
                 result.add(printer);
             }
@@ -312,7 +285,7 @@ public class InventoryPrinterManagerImpl
 
     /**
      * Return a handler for the unique name.
-     * 
+     *
      * @return The corresponding handler or <code>null</code>.
      */
     public InventoryPrinterHandler getHandler(final String name)

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConfigurationPrinterAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConfigurationPrinterAdapter.java?rev=1468887&r1=1468886&r2=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConfigurationPrinterAdapter.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/ConfigurationPrinterAdapter.java Wed Apr 17 13:04:44 2013
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.felix.inventory.PrinterMode;
+import org.apache.felix.inventory.Format;
 import org.osgi.framework.ServiceReference;
 
 /**
@@ -213,17 +213,17 @@ public class ConfigurationPrinterAdapter
         final Set list = new HashSet();
         if (this.match(ConsoleConstants.MODE_TXT) || this.match(ConsoleConstants.MODE_ZIP))
         {
-            list.add(PrinterMode.TEXT.name());
+            list.add(Format.TEXT.toString());
         }
         if (this.match(ConsoleConstants.MODE_WEB))
         {
             if (!escapeHtml)
             {
-                list.add(PrinterMode.HTML_FRAGMENT.name());
+                list.add(Format.HTML.toString());
             }
             else
             {
-                list.add(PrinterMode.TEXT.name());
+                list.add(Format.TEXT.toString());
             }
         }
         return (String[]) list.toArray(new String[list.size()]);

Modified: felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java?rev=1468887&r1=1468886&r2=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java (original)
+++ felix/trunk/inventory/src/main/java/org/apache/felix/inventory/impl/webconsole/WebConsoleAdapter.java Wed Apr 17 13:04:44 2013
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,7 @@ import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
 import org.apache.felix.inventory.InventoryPrinter;
-import org.apache.felix.inventory.PrinterMode;
+import org.apache.felix.inventory.Format;
 import org.apache.felix.inventory.ZipAttachmentProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -112,9 +112,9 @@ public class WebConsoleAdapter implement
                 cpa.label = cpa.title;
             }
             final Dictionary props = new Hashtable();
-            props.put(InventoryPrinter.CONFIG_NAME, cpa.label);
-            props.put(InventoryPrinter.CONFIG_TITLE, cpa.title);
-            props.put(InventoryPrinter.CONFIG_PRINTER_MODES, cpa.getPrinterModes());
+            props.put(InventoryPrinter.NAME, cpa.label);
+            props.put(InventoryPrinter.TITLE, cpa.title);
+            props.put(InventoryPrinter.FORMAT, cpa.getPrinterModes());
 
             final ServiceRegistration reg = this.bundleContext.registerService(InventoryPrinter.class.getName(),
                 new WebConsolePrinter(cpa), props);
@@ -182,21 +182,21 @@ public class WebConsoleAdapter implement
         }
 
         /**
-         * @see org.apache.felix.inventory.InventoryPrinter#print(org.apache.felix.inventory.PrinterMode,
+         * @see org.apache.felix.inventory.InventoryPrinter#print(org.apache.felix.inventory.Format,
          *      java.io.PrintWriter)
          */
-        public void print(final PrinterMode mode, final PrintWriter printWriter, final boolean isZip)
+        public void print(final PrintWriter printWriter, final Format format, final boolean isZip)
         {
             final String m;
-            if (!isZip && mode == PrinterMode.HTML_FRAGMENT)
+            if (!isZip && format == Format.HTML)
             {
                 m = ConsoleConstants.MODE_WEB;
             }
-            else if (!isZip && mode == PrinterMode.TEXT)
+            else if (!isZip && format == Format.TEXT)
             {
                 m = ConsoleConstants.MODE_TXT;
             }
-            else if (isZip && (mode == PrinterMode.TEXT || mode == PrinterMode.HTML_FRAGMENT))
+            else if (isZip && (format == Format.TEXT || format == Format.HTML))
             {
                 m = ConsoleConstants.MODE_ZIP;
             }

Copied: felix/trunk/inventory/src/test/java/org/apache/felix/inventory/FormatTest.java (from r1468326, felix/trunk/inventory/src/test/java/org/apache/felix/inventory/PrinterModeTest.java)
URL: http://svn.apache.org/viewvc/felix/trunk/inventory/src/test/java/org/apache/felix/inventory/FormatTest.java?p2=felix/trunk/inventory/src/test/java/org/apache/felix/inventory/FormatTest.java&p1=felix/trunk/inventory/src/test/java/org/apache/felix/inventory/PrinterModeTest.java&r1=1468326&r2=1468887&rev=1468887&view=diff
==============================================================================
--- felix/trunk/inventory/src/test/java/org/apache/felix/inventory/PrinterModeTest.java (original)
+++ felix/trunk/inventory/src/test/java/org/apache/felix/inventory/FormatTest.java Wed Apr 17 13:04:44 2013
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License. You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -20,46 +20,46 @@ package org.apache.felix.inventory;
 
 import junit.framework.TestCase;
 
-public class PrinterModeTest extends TestCase
+public class FormatTest extends TestCase
 {
 
     public void test_valueOf()
     {
-        TestCase.assertSame(PrinterMode.TEXT, PrinterMode.valueOf("TEXT"));
-        TestCase.assertSame(PrinterMode.JSON, PrinterMode.valueOf("JSON"));
-        TestCase.assertSame(PrinterMode.HTML_FRAGMENT, PrinterMode.valueOf("HTML_FRAGMENT"));
-
-        TestCase.assertSame(PrinterMode.TEXT, PrinterMode.valueOf("text"));
-        TestCase.assertSame(PrinterMode.JSON, PrinterMode.valueOf("json"));
-        TestCase.assertSame(PrinterMode.HTML_FRAGMENT, PrinterMode.valueOf("html_fragment"));
-
-        TestCase.assertSame(PrinterMode.TEXT, PrinterMode.valueOf("Text"));
-        TestCase.assertSame(PrinterMode.JSON, PrinterMode.valueOf("Json"));
-        TestCase.assertSame(PrinterMode.HTML_FRAGMENT, PrinterMode.valueOf("HTML_Fragment"));
+        TestCase.assertSame(Format.TEXT, Format.valueOf("TEXT"));
+        TestCase.assertSame(Format.JSON, Format.valueOf("JSON"));
+        TestCase.assertSame(Format.HTML, Format.valueOf("HTML"));
+
+        TestCase.assertSame(Format.TEXT, Format.valueOf("text"));
+        TestCase.assertSame(Format.JSON, Format.valueOf("json"));
+        TestCase.assertSame(Format.HTML, Format.valueOf("html"));
+
+        TestCase.assertSame(Format.TEXT, Format.valueOf("Text"));
+        TestCase.assertSame(Format.JSON, Format.valueOf("Json"));
+        TestCase.assertSame(Format.HTML, Format.valueOf("HtMl"));
 
-        TestCase.assertNull(PrinterMode.valueOf("unsupported_name"));
+        TestCase.assertNull(Format.valueOf("unsupported_name"));
     }
 
-    public void test_name()
+    public void test_toString()
     {
-        TestCase.assertEquals("TEXT", PrinterMode.TEXT.name());
-        TestCase.assertEquals("JSON", PrinterMode.JSON.name());
-        TestCase.assertEquals("HTML_FRAGMENT", PrinterMode.HTML_FRAGMENT.name());
+        TestCase.assertEquals("TEXT", Format.TEXT.toString());
+        TestCase.assertEquals("JSON", Format.JSON.toString());
+        TestCase.assertEquals("HTML", Format.HTML.toString());
     }
 
     public void test_equals()
     {
-        TestCase.assertTrue(PrinterMode.TEXT.equals(PrinterMode.TEXT));
-        TestCase.assertFalse(PrinterMode.TEXT.equals(PrinterMode.JSON));
-        TestCase.assertFalse(PrinterMode.TEXT.equals(PrinterMode.HTML_FRAGMENT));
-
-        TestCase.assertFalse(PrinterMode.JSON.equals(PrinterMode.TEXT));
-        TestCase.assertTrue(PrinterMode.JSON.equals(PrinterMode.JSON));
-        TestCase.assertFalse(PrinterMode.JSON.equals(PrinterMode.HTML_FRAGMENT));
-
-        TestCase.assertFalse(PrinterMode.HTML_FRAGMENT.equals(PrinterMode.TEXT));
-        TestCase.assertFalse(PrinterMode.HTML_FRAGMENT.equals(PrinterMode.JSON));
-        TestCase.assertTrue(PrinterMode.HTML_FRAGMENT.equals(PrinterMode.HTML_FRAGMENT));
+        TestCase.assertTrue(Format.TEXT.equals(Format.TEXT));
+        TestCase.assertFalse(Format.TEXT.equals(Format.JSON));
+        TestCase.assertFalse(Format.TEXT.equals(Format.HTML));
+
+        TestCase.assertFalse(Format.JSON.equals(Format.TEXT));
+        TestCase.assertTrue(Format.JSON.equals(Format.JSON));
+        TestCase.assertFalse(Format.JSON.equals(Format.HTML));
+
+        TestCase.assertFalse(Format.HTML.equals(Format.TEXT));
+        TestCase.assertFalse(Format.HTML.equals(Format.JSON));
+        TestCase.assertTrue(Format.HTML.equals(Format.HTML));
     }
 
 }