sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1454424 - in /sis/ip-review: StringConverter.Boolean.xhtml rev/23637/ rev/23637/HEADER.html rev/23637/StringConverter.Boolean.xhtml
Date Fri, 08 Mar 2013 15:26:56 GMT
Author: desruisseaux
Date: Fri Mar  8 15:26:56 2013
New Revision: 1454424

URL: http://svn.apache.org/r1454424
Log:
IP review for StringConverter.Boolean.

Added:
    sis/ip-review/StringConverter.Boolean.xhtml   (with props)
    sis/ip-review/rev/23637/
    sis/ip-review/rev/23637/HEADER.html   (with props)
    sis/ip-review/rev/23637/StringConverter.Boolean.xhtml   (with props)

Added: sis/ip-review/StringConverter.Boolean.xhtml
URL: http://svn.apache.org/viewvc/sis/ip-review/StringConverter.Boolean.xhtml?rev=1454424&view=auto
==============================================================================
--- sis/ip-review/StringConverter.Boolean.xhtml (added)
+++ sis/ip-review/StringConverter.Boolean.xhtml Fri Mar  8 15:26:56 2013
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta charset="UTF-8"/>
+    <title>StringConverter.Boolean history</title>
+    <style type="text/css" media="all">
+      @import url("./reports.css");
+    </style>
+  </head>
+  <body>
+    <div>
+      <h1>StringConverter.Boolean history</h1>
+  <p>Click on the commit message for inspecting the <code>diff</code> and
how the code has been rewritten.</p>
+<p><b>Command line:</b></p>
+<blockquote><code>svn log -r31996:23637 http://svn.osgeo.org/geotools/trunk/modules/library/main/src/main/java/org/geotools/util/BooleanConverterFactory.java</code></blockquote>
+<table>
+  <tr>
+    <th>Rev.</th>
+    <th>Date</th>
+    <th>Author</th>
+    <th class="last">Message</th>
+  </tr>
+<tr><td class="rev">30648</td><td>2008-06-12</td><td>acuster</td><td>Copyright
headers: lib/main, this time with feeling (and the el in Toolkit)</td></tr>
+<tr><td class="rev">30558</td><td>2008-06-06</td><td>acuster</td><td>Copyright
review: update headers on library/main</td></tr>
+<tr><td class="rev">30258</td><td>2008-05-08</td><td>acuster</td><td>Reshuffle
the top level repo: drop uDig, move up trunk, tags, and branches.</td></tr>
+<tr><td class="rev">30257</td><td>2008-05-08</td><td>acuster</td><td>Move
trunk/gt/ directory contents up to trunk/ and drop gt</td></tr>
+<tr><td class="rev">28922</td><td>2008-01-24</td><td>acuster</td><td>Bump
the (at)since version to 2.5 since WKTParser was cut from 2.4</td></tr>
+<tr><td class="rev">28540</td><td>2007-12-29</td><td>acuster</td><td>Hide
buttons which are not yet used</td></tr>
+<tr><td class="rev">25075</td><td>2007-04-09</td><td>desruisseaux</td><td>Fixed
SVN properties.</td></tr>
+<tr><td class="rev">23637</td><td>2007-01-01</td><td class="unav">jdeolive</td><td><a
href="rev/23637/StringConverter.Boolean.xhtml">javadocs</a></td></tr>
+<tr><td class="rev">23505</td><td>2006-12-18</td><td class="unav">jdeolive</td><td><a
href="rev/23637/StringConverter.Boolean.xhtml">added converter factory for handling boolean
conversions</a></td></tr>
+</table>
+    </div>
+  </body>
+</html>

Propchange: sis/ip-review/StringConverter.Boolean.xhtml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/ip-review/StringConverter.Boolean.xhtml
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: sis/ip-review/rev/23637/HEADER.html
URL: http://svn.apache.org/viewvc/sis/ip-review/rev/23637/HEADER.html?rev=1454424&view=auto
==============================================================================
--- sis/ip-review/rev/23637/HEADER.html (added)
+++ sis/ip-review/rev/23637/HEADER.html Fri Mar  8 15:26:56 2013
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta charset="UTF-8"/>
+    <title>Revision 23637</title>
+  </head>
+  <body>
+    <div>
+      <h1>Revision 23637</h1>
+<table>
+  <tr><td><b>Author:</b></td><td>jdeolive</td></tr>
+  <tr><td><b>Date:</b></td><td>2007-01-01</td></tr>
+  <tr><td><b>Message:</b></td><td>javadocs</td></tr>
+</table>
+    </div>
+  </body>
+</html>

Propchange: sis/ip-review/rev/23637/HEADER.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/ip-review/rev/23637/HEADER.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: sis/ip-review/rev/23637/StringConverter.Boolean.xhtml
URL: http://svn.apache.org/viewvc/sis/ip-review/rev/23637/StringConverter.Boolean.xhtml?rev=1454424&view=auto
==============================================================================
--- sis/ip-review/rev/23637/StringConverter.Boolean.xhtml (added)
+++ sis/ip-review/rev/23637/StringConverter.Boolean.xhtml Fri Mar  8 15:26:56 2013
@@ -0,0 +1,176 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta charset="UTF-8"/>
+    <title>StringConverter.Boolean at revision 23637</title>
+    <style type="text/css" media="all">
+      @import url("../../reports.css");
+    </style>
+  </head>
+  <body>
+    <div>
+      <h1>StringConverter.Boolean at revision 23637</h1>
+
+<p>While the idea to provide a converter from <code>String</code> to <code>Boolean</code>
was found in GeoTools
+(as well as many other libraries), the code has been totally rewritten. It still shares in
common with the original
+code a sequence of <code>if (source.equals("foo"))</code> statements, but this
very simple logic can hardly be
+written in an other way.</p>
+
+<p>The table below compares the GeoTools code with the Geotoolkit.org one.</p>
+
+<p><b>Command line:</b></p>
+<blockquote><code>svn cat -r23637 http://svn.osgeo.org/geotools/trunk/modules/library/main/src/main/java/org/geotools/util/BooleanConverterFactory.java</code></blockquote>
+<table class="changes">
+<tr><th>Revision 23637</th><th>Geotoolkit.org</th></tr>
+<tr><td><pre><span class="add">/*
+ *    GeoTools - OpenSource mapping toolkit
+ *    http://geotools.org
+ *    (C) 2002-2006, GeoTools Project Managment Committee (PMC)
+ *
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Lesser General Public
+ *    License as published by the Free Software Foundation;
+ *    version 2.1 of the License.
+ *
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *    Lesser General Public License for more details.
+ */
+package org.geotools.util;
+
+import org.geotools.factory.Hints;
+
+/**
+ * ConverterFactory for handling boolean conversions.
+ * &lt;p&gt;
+ * Supported conversions:
+ * &lt;ul&gt;
+ *  &lt;li&gt;"true" -&gt; Boolean.TRUE
+ *  &lt;li&gt;"false" -&gt; Boolean.FALSE
+ *  &lt;li&gt;"1" -&gt; Boolean.TRUE
+ *  &lt;li&gt;"0" -&gt; Boolean.FALSE
+ *  &lt;li&gt;1 -&gt; Boolean.TRUE
+ *  &lt;li&gt;0 -&gt; Boolean.FALSE
+ * &lt;/ul&gt;
+ * &lt;/p&gt;
+ * @author Justin Deoliveira, The Open Planning Project
+ * @since 2.4
+ */
+public class BooleanConverterFactory implements ConverterFactory {
+
+    public Converter createConverter(Class source, Class target, Hints hints) {
+        if ( target.equals( Boolean.class ) ) {
+
+            //string to boolean
+            if ( source.equals( String.class ) ) {
+                return new Converter() {
+
+                    public Object convert(Object source, Class target) throws Exception {
+                        if ( "true".equals( source ) || "1".equals( source ) ) {
+                                return Boolean.TRUE;
+                        }
+                        if ( "false".equals( source ) || "0".equals( source ) ) {
+                                return Boolean.FALSE;
+                        }
+
+                        return null;
+                    }
+
+                };
+            }
+
+            //integer to boolean
+            if ( source.equals( Integer.class ) ) {
+                return new Converter() {
+
+                    public Object convert(Object source, Class target) throws Exception {
+                        if ( new Integer( 1 ).equals( source ) ) {
+                                return Boolean.TRUE;
+                        }
+                        if ( new Integer( 0 ).equals( source ) ) {
+                                return Boolean.FALSE;
+                        }
+
+                        return null;
+                    }
+
+                };
+            }
+
+        }
+
+        return null;
+    }
+
+}</span></pre></td>
+<td><pre>/**
+ * Converter from {@link java.lang.String} to {@link java.lang.Boolean}.
+ * Conversion table:
+ *
+ * &lt;table&gt;
+ *    &lt;tr&gt;&lt;th&gt;source&lt;/th&gt;          &lt;th&gt;target&lt;/th&gt;&lt;/tr&gt;
+ *    &lt;tr&gt;&lt;td&gt;{@code "true"}  &lt;/td&gt;&lt;td&gt;{@link
java.lang.Boolean#TRUE}  &lt;/td&gt;&lt;/tr&gt;
+ *    &lt;tr&gt;&lt;td&gt;{@code "false"} &lt;/td&gt;&lt;td&gt;{@link
java.lang.Boolean#FALSE} &lt;/td&gt;&lt;/tr&gt;
+ *    &lt;tr&gt;&lt;td&gt;{@code "yes"}   &lt;/td&gt;&lt;td&gt;{@link
java.lang.Boolean#TRUE}  &lt;/td&gt;&lt;/tr&gt;
+ *    &lt;tr&gt;&lt;td&gt;{@code "no"}    &lt;/td&gt;&lt;td&gt;{@link
java.lang.Boolean#FALSE} &lt;/td&gt;&lt;/tr&gt;
+ *    &lt;tr&gt;&lt;td&gt;{@code "on"}    &lt;/td&gt;&lt;td&gt;{@link
java.lang.Boolean#TRUE}  &lt;/td&gt;&lt;/tr&gt;
+ *    &lt;tr&gt;&lt;td&gt;{@code "off"}   &lt;/td&gt;&lt;td&gt;{@link
java.lang.Boolean#FALSE} &lt;/td&gt;&lt;/tr&gt;
+ *    &lt;tr&gt;&lt;td&gt;{@code "1"}     &lt;/td&gt;&lt;td&gt;{@link
java.lang.Boolean#TRUE}  &lt;/td&gt;&lt;/tr&gt;
+ *    &lt;tr&gt;&lt;td&gt;{@code "0"}     &lt;/td&gt;&lt;td&gt;{@link
java.lang.Boolean#FALSE} &lt;/td&gt;&lt;/tr&gt;
+ * &lt;/table&gt;
+ *
+ * @author Justin Deoliveira (TOPP)
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 3.00
+ *
+ * @since 2.4
+ */
+@Immutable
+static final class Boolean extends StringConverter&lt;java.lang.Boolean&gt; {
+    private static final long serialVersionUID = -27525398425996373L;
+    public static final Boolean INSTANCE = new Boolean();
+    private Boolean() {
+    }
+
+    @Override
+    public Class&lt;java.lang.Boolean&gt; getTargetClass() {
+        return java.lang.Boolean.class;
+    }
+
+    @Override
+    public java.lang.Boolean convert(String source) throws NonconvertibleObjectException
{
+        if (source == null) {
+            return null;
+        }
+        source = source.trim();
+        if (source.equalsIgnoreCase("true") ||
+            source.equalsIgnoreCase("yes")  ||
+            source.equalsIgnoreCase("on"))
+        {
+            return java.lang.Boolean.TRUE;
+        }
+        if (source.equalsIgnoreCase("false") ||
+            source.equalsIgnoreCase("no")    ||
+            source.equalsIgnoreCase("off"))
+        {
+            return java.lang.Boolean.FALSE;
+        }
+        final int n;
+        try {
+            n = java.lang.Integer.parseInt(source);
+        } catch (NumberFormatException e) {
+            throw new NonconvertibleObjectException(e);
+        }
+        return java.lang.Boolean.valueOf(n != 0);
+    }
+
+    /** Returns the singleton instance on deserialization. */
+    protected Object readResolve() throws ObjectStreamException {
+        return INSTANCE;
+    }
+}</pre></td></tr>
+</table>
+    </div>
+  </body>
+</html>

Propchange: sis/ip-review/rev/23637/StringConverter.Boolean.xhtml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/ip-review/rev/23637/StringConverter.Boolean.xhtml
------------------------------------------------------------------------------
    svn:mime-type = text/html



Mime
View raw message