]> gcc.gnu.org Git - gcc.git/commitdiff
Properties.java (store): Move the code formerly in list(), into this method.
authorRanjit Mathew <rmathew@hotmail.com>
Mon, 17 Feb 2003 19:05:56 +0000 (19:05 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Mon, 17 Feb 2003 19:05:56 +0000 (19:05 +0000)
2003-02-17  Ranjit Mathew  <rmathew@hotmail.com>

* java/util/Properties.java (store): Move the code formerly in
list(), into this method.
(list (PrintStream)): Just call list (PrintWriter) with a
PrintWriter object constructed from the given PrintStream object.
(list (PrintWriter)): Emulate the output of Properties.list()
as found in JDK 1.3/1.4.

From-SVN: r63006

libjava/ChangeLog
libjava/java/util/Properties.java

index 18ae76856635ece6b3af42c6c48ab22bdb8af5e4..e417849ee5a23e36487f9de0132bd6dc53f95c1d 100644 (file)
@@ -1,3 +1,12 @@
+2003-02-17  Ranjit Mathew  <rmathew@hotmail.com>
+
+       * java/util/Properties.java (store): Move the code formerly in
+       list(), into this method.
+       (list (PrintStream)): Just call list (PrintWriter) with a 
+       PrintWriter object constructed from the given PrintStream object.
+       (list (PrintWriter)): Emulate the output of Properties.list()
+       as found in JDK 1.3/1.4.
+
 2003-02-17  Michael Koch  <konqueror@gmx.de>
 
        * java/net/DatagramSocket.java
index 907ec2c4d7a6a134015ec3b4cd72d749c1acde17..279cf1e7b82ac5b0b756b8cdad4141cc96c509ac 100644 (file)
@@ -377,9 +377,21 @@ label   = Name:\\u0020</pre>
       = new PrintWriter(new OutputStreamWriter(out, "ISO-8859-1"));
     if (header != null)
       writer.println("#" + header);
-    writer.println("#" + new Date());
-    list(writer);
-    writer.flush();
+    writer.println ("#" + Calendar.getInstance ().getTime ());
+    
+    Iterator iter = entrySet ().iterator ();
+    int i = size ();
+    StringBuffer s = new StringBuffer (); // Reuse the same buffer.
+    while (--i >= 0)
+      {
+        Map.Entry entry = (Map.Entry) iter.next ();
+        formatForOutput ((String) entry.getKey (), s, true);
+        s.append ('=');
+        formatForOutput ((String) entry.getValue (), s, false);
+        writer.println (s);
+      }
+
+    writer.flush ();
   }
 
   /**
@@ -453,54 +465,50 @@ label   = Name:\\u0020</pre>
   }
 
   /**
-   * Writes the key/value pairs to the given print stream.  They are
-   * written in the way described in the method store. This does not visit
-   * the keys in the default properties.
+   * Prints the key/value pairs to the given print stream.  This is 
+   * mainly useful for debugging purposes.
    *
-   * @param out the stream, where the key/value pairs are written to
-   * @throws ClassCastException if this property contains any key or
+   * @param out the print stream, where the key/value pairs are written to
+   * @throws ClassCastException if this property contains a key or a
    *         value that isn't a string
-   * @see #store(OutputStream, String)
+   * @see #list(PrintWriter)
    */
   public void list(PrintStream out)
   {
-    Iterator iter = entrySet().iterator();
-    int i = size();
-    StringBuffer s = new StringBuffer(); // Reuse the same buffer.
-    while (--i >= 0)
-      {
-        Map.Entry entry = (Map.Entry) iter.next();
-        formatForOutput((String) entry.getKey(), s, true);
-        s.append('=');
-        formatForOutput((String) entry.getValue(), s, false);
-        out.println(s);
-      }
+    PrintWriter writer = new PrintWriter (out);
+    list (writer);
   }
 
   /**
-   * Writes the key/value pairs to the given print writer.  They are
-   * written in the way, described in the method store.
+   * Prints the key/value pairs to the given print writer.  This is
+   * mainly useful for debugging purposes.
    *
-   * @param out the writer, where the key/value pairs are written to
-   * @throws ClassCastException if this property contains any key or
+   * @param out the print writer where the key/value pairs are written to
+   * @throws ClassCastException if this property contains a key or a
    *         value that isn't a string
-   * @see #store(OutputStream, String)
    * @see #list(PrintStream)
    * @since 1.1
    */
   public void list(PrintWriter out)
   {
-    Iterator iter = entrySet().iterator();
-    int i = size();
-    StringBuffer s = new StringBuffer(); // Reuse the same buffer.
+    out.println ("-- listing properties --");
+
+    Iterator iter = entrySet ().iterator ();
+    int i = size ();
     while (--i >= 0)
       {
-        Map.Entry entry = (Map.Entry) iter.next();
-        formatForOutput((String) entry.getKey(), s, true);
-        s.append('=');
-        formatForOutput((String) entry.getValue(), s, false);
-        out.println(s);
+        Map.Entry entry = (Map.Entry) iter.next ();
+        out.print ((String) entry.getKey () + "=");
+
+        // JDK 1.3/1.4 restrict the printed value, but not the key,
+        // to 40 characters, including the truncating ellipsis.
+        String s = (String ) entry.getValue ();
+        if (s != null && s.length () > 40)
+          out.println (s.substring (0, 37) + "...");
+        else
+          out.println (s);
       }
+    out.flush ();
   }
 
   /**
This page took 0.069259 seconds and 5 git commands to generate.