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.
+ * <p>
+ * Supported conversions:
+ * <ul>
+ * <li>"true" -> Boolean.TRUE
+ * <li>"false" -> Boolean.FALSE
+ * <li>"1" -> Boolean.TRUE
+ * <li>"0" -> Boolean.FALSE
+ * <li>1 -> Boolean.TRUE
+ * <li>0 -> Boolean.FALSE
+ * </ul>
+ * </p>
+ * @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:
+ *
+ * <table>
+ * <tr><th>source</th>
<th>target</th></tr>
+ * <tr><td>{@code "true"} </td><td>{@link
java.lang.Boolean#TRUE} </td></tr>
+ * <tr><td>{@code "false"} </td><td>{@link
java.lang.Boolean#FALSE} </td></tr>
+ * <tr><td>{@code "yes"} </td><td>{@link
java.lang.Boolean#TRUE} </td></tr>
+ * <tr><td>{@code "no"} </td><td>{@link
java.lang.Boolean#FALSE} </td></tr>
+ * <tr><td>{@code "on"} </td><td>{@link
java.lang.Boolean#TRUE} </td></tr>
+ * <tr><td>{@code "off"} </td><td>{@link
java.lang.Boolean#FALSE} </td></tr>
+ * <tr><td>{@code "1"} </td><td>{@link
java.lang.Boolean#TRUE} </td></tr>
+ * <tr><td>{@code "0"} </td><td>{@link
java.lang.Boolean#FALSE} </td></tr>
+ * </table>
+ *
+ * @author Justin Deoliveira (TOPP)
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 3.00
+ *
+ * @since 2.4
+ */
+@Immutable
+static final class Boolean extends StringConverter<java.lang.Boolean> {
+ private static final long serialVersionUID = -27525398425996373L;
+ public static final Boolean INSTANCE = new Boolean();
+ private Boolean() {
+ }
+
+ @Override
+ public Class<java.lang.Boolean> 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