sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1507389 - in /sis/branches/JDK7/core: sis-metadata/src/test/java/org/apache/sis/xml/ sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ sis-utility/src/main/java/org/apache/sis/xml/
Date Fri, 26 Jul 2013 18:35:51 GMT
Author: desruisseaux
Date: Fri Jul 26 18:35:50 2013
New Revision: 1507389

URL: http://svn.apache.org/r1507389
Log:
Renamed 'NilReason.getNilReason' as 'NilReason.forObject'.

Modified:
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java?rev=1507389&r1=1507388&r2=1507389&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/xml/NilReasonMarshallingTest.java
[UTF-8] Fri Jul 26 18:35:50 2013
@@ -46,8 +46,8 @@ public final strictfp class NilReasonMar
     @Test
     public void testMissing() throws JAXBException {
         final String expected =
-                "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
-                                " xmlns:gco=\"" + Namespaces.GCO + '"' +
+                "<gmd:CI_Citation xmlns:gmd=\""   + Namespaces.GMD + '"' +
+                                " xmlns:gco=\""   + Namespaces.GCO + '"' +
                                 " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
                 "  <gmd:title>\n" +
                 "    <gco:CharacterString>A title</gco:CharacterString>\n" +
@@ -85,8 +85,8 @@ public final strictfp class NilReasonMar
     @DependsOnMethod("testMissing")
     public void testMissingBoolean() throws JAXBException {
         final String expected =
-                "<gmd:DQ_ConformanceResult xmlns:gmd=\"" + Namespaces.GMD + '"' +
-                                         " xmlns:gco=\"" + Namespaces.GCO + '"' +
+                "<gmd:DQ_ConformanceResult xmlns:gmd=\""   + Namespaces.GMD + '"' +
+                                         " xmlns:gco=\""   + Namespaces.GCO + '"' +
                                          " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n"
+
                 "  <gmd:explanation>\n" +
                 "    <gco:CharacterString>An explanation</gco:CharacterString>\n"
+
@@ -102,7 +102,7 @@ public final strictfp class NilReasonMar
         assertEquals ("Nil value shall be false.",  Boolean.FALSE, pass);
         assertNotSame("Expected a sentinal value.", Boolean.FALSE, pass);
 
-        final NilReason reason = NilReason.getNilReason(pass);
+        final NilReason reason = NilReason.forObject(pass);
         assertSame("nilReason", NilReason.MISSING, reason);
 
         final String actual = XML.marshal(result);
@@ -119,8 +119,8 @@ public final strictfp class NilReasonMar
     @DependsOnMethod("testMissing")
     public void testOther() throws JAXBException {
         final String expected =
-                "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
-                                " xmlns:gco=\"" + Namespaces.GCO + '"' +
+                "<gmd:CI_Citation xmlns:gmd=\""   + Namespaces.GMD + '"' +
+                                " xmlns:gco=\""   + Namespaces.GCO + '"' +
                                 " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
                 "  <gmd:title>\n" +
                 "    <gco:CharacterString>A title</gco:CharacterString>\n" +
@@ -155,8 +155,8 @@ public final strictfp class NilReasonMar
     @DependsOnMethod("testMissing")
     public void testURI() throws JAXBException {
         final String expected =
-                "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + '"' +
-                                " xmlns:gco=\"" + Namespaces.GCO + '"' +
+                "<gmd:CI_Citation xmlns:gmd=\""   + Namespaces.GMD + '"' +
+                                " xmlns:gco=\""   + Namespaces.GCO + '"' +
                                 " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" +
                 "  <gmd:title>\n" +
                 "    <gco:CharacterString>A title</gco:CharacterString>\n" +

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java?rev=1507389&r1=1507388&r2=1507389&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/PropertyType.java
[UTF-8] Fri Jul 26 18:35:50 2013
@@ -166,8 +166,9 @@ public abstract class PropertyType<Value
     protected PropertyType(final BoundType metadata) {
         this.metadata = metadata;
         /*
-         * Do not invoke NilReason.getNilReason(metadata) in order to avoid unnecessary synchronization.
-         * Subclasses will use PropertyType(BoundType, boolean) when a check for primitive
type is required.
+         * Do not invoke NilReason.forObject(metadata) in order to avoid unnecessary synchronization.
+         * Subclasses will use the PropertyType(BoundType, boolean) constructor instead when
a check
+         * for primitive type is required.
          */
         if (metadata instanceof NilObject) {
             final NilReason reason = ((NilObject) metadata).getNilReason();

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java?rev=1507389&r1=1507388&r2=1507389&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java [UTF-8]
(original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilObject.java [UTF-8]
Fri Jul 26 18:35:50 2013
@@ -82,7 +82,7 @@ public interface NilObject {
      *
      * @return The reason why this object contains no information.
      *
-     * @see NilReason#getNilReason(Object)
+     * @see NilReason#forObject(Object)
      */
     NilReason getNilReason();
 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java?rev=1507389&r1=1507388&r2=1507389&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java [UTF-8]
(original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java [UTF-8]
Fri Jul 26 18:35:50 2013
@@ -469,7 +469,7 @@ public final class NilReason implements 
      *
      * @since 0.4
      */
-    public static NilReason getNilReason(final Object object) {
+    public static NilReason forObject(final Object object) {
         if (object != null) {
             if (object instanceof NilObject) {
                 return ((NilObject) object).getNilReason();
@@ -477,10 +477,14 @@ public final class NilReason implements 
             /*
              * Invoke 'PrimitiveTypeProperties' method only if the given type is one of the
hard-coded
              * types from the above 'createNilPrimitive(Object)' method, in order to avoid
unnecessary
-             * synchronization (implicitly done by PrimitiveTypeProperties).
+             * synchronization (implicitly done by PrimitiveTypeProperties). Note that 'instanceof'
+             * checks on instances of final classes are expected to be very fast.
              */
-            final Class<?> type = object.getClass();
-            if (type == Boolean.class || type == Integer.class || type == Double.class ||
type == String.class) {
+            if ((object instanceof Boolean && ((Boolean) object).booleanValue() ==
false) ||
+                (object instanceof Integer && ((Integer) object).intValue() == 0)
||
+                (object instanceof Double  && Double.isNaN(((Double) object).doubleValue()))
||
+                (object instanceof String  && ((String) object).isEmpty()))
+            {
                 return (NilReason) PrimitiveTypeProperties.property(object);
             }
         }



Mime
View raw message