Manually merging current head with Jirka's conversions and switch to 0.7-SNAPSHOT
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 10 Oct 2013 14:03:53 +0200
changeset 310e05f134eb667
parent 309 7025177bd67e
parent 307 02e82ca3b05a
child 311 67d9ce7a2778
Manually merging current head with Jirka's conversions and switch to 0.7-SNAPSHOT
     1.1 --- a/.hgtags	Thu Oct 10 14:02:18 2013 +0200
     1.2 +++ b/.hgtags	Thu Oct 10 14:03:53 2013 +0200
     1.3 @@ -5,3 +5,4 @@
     1.4  5c5fc5ee2d6396f792114bd8567e17e1e6c4d360 fxlauncher
     1.5  24612fed24b589c313c416a4e86df9cc4a2ecde5 release-0.4
     1.6  6656cca0a73a0f0c3d0a349f471a6c5bab6035a9 release-0.5
     1.7 +3e5e3c96f9f13bc1487c46e050a6d545c427d945 release-0.6
     2.1 --- a/boot-fx/pom.xml	Thu Oct 10 14:02:18 2013 +0200
     2.2 +++ b/boot-fx/pom.xml	Thu Oct 10 14:03:53 2013 +0200
     2.3 @@ -4,11 +4,11 @@
     2.4    <parent>
     2.5      <groupId>org.apidesign</groupId>
     2.6      <artifactId>html</artifactId>
     2.7 -    <version>0.6</version>
     2.8 +    <version>0.7-SNAPSHOT</version>
     2.9    </parent>
    2.10    <groupId>org.apidesign.html</groupId>
    2.11    <artifactId>boot-fx</artifactId>
    2.12 -  <version>0.6</version>
    2.13 +  <version>0.7-SNAPSHOT</version>
    2.14    <name>FX WebView Bootstrap</name>
    2.15    <url>http://maven.apache.org</url>
    2.16    <properties>
     3.1 --- a/boot/pom.xml	Thu Oct 10 14:02:18 2013 +0200
     3.2 +++ b/boot/pom.xml	Thu Oct 10 14:03:53 2013 +0200
     3.3 @@ -4,11 +4,11 @@
     3.4    <parent>
     3.5      <groupId>org.apidesign</groupId>
     3.6      <artifactId>html</artifactId>
     3.7 -    <version>0.6</version>
     3.8 +    <version>0.7-SNAPSHOT</version>
     3.9    </parent>
    3.10    <groupId>org.apidesign.html</groupId>
    3.11    <artifactId>net.java.html.boot</artifactId>
    3.12 -  <version>0.6</version>
    3.13 +  <version>0.7-SNAPSHOT</version>
    3.14    <name>Browser Bootstrap</name>
    3.15    <url>http://maven.apache.org</url>
    3.16    <properties>
     4.1 --- a/context/pom.xml	Thu Oct 10 14:02:18 2013 +0200
     4.2 +++ b/context/pom.xml	Thu Oct 10 14:03:53 2013 +0200
     4.3 @@ -4,11 +4,11 @@
     4.4    <parent>
     4.5      <groupId>org.apidesign</groupId>
     4.6      <artifactId>html</artifactId>
     4.7 -    <version>0.6</version>
     4.8 +    <version>0.7-SNAPSHOT</version>
     4.9    </parent>
    4.10    <groupId>org.apidesign.html</groupId>
    4.11    <artifactId>net.java.html</artifactId>
    4.12 -  <version>0.6</version>
    4.13 +  <version>0.7-SNAPSHOT</version>
    4.14    <name>HTML Context</name>
    4.15    <url>http://maven.apache.org</url>
    4.16    <properties>
     5.1 --- a/geo/pom.xml	Thu Oct 10 14:02:18 2013 +0200
     5.2 +++ b/geo/pom.xml	Thu Oct 10 14:03:53 2013 +0200
     5.3 @@ -4,11 +4,11 @@
     5.4    <parent>
     5.5      <groupId>org.apidesign</groupId>
     5.6      <artifactId>html</artifactId>
     5.7 -    <version>0.6</version>
     5.8 +    <version>0.7-SNAPSHOT</version>
     5.9    </parent>
    5.10    <groupId>org.apidesign.html</groupId>
    5.11    <artifactId>net.java.html.geo</artifactId>
    5.12 -  <version>0.6</version>
    5.13 +  <version>0.7-SNAPSHOT</version>
    5.14    <name>Geolocation API</name>
    5.15    <url>http://maven.apache.org</url>
    5.16    <properties>
    5.17 @@ -39,7 +39,7 @@
    5.18      <dependency>
    5.19        <groupId>org.apidesign.html</groupId>
    5.20        <artifactId>net.java.html.boot</artifactId>
    5.21 -      <version>0.6</version>
    5.22 +      <version>0.7-SNAPSHOT</version>
    5.23        <type>jar</type>
    5.24      </dependency>
    5.25    </dependencies>
     6.1 --- a/json-tck/pom.xml	Thu Oct 10 14:02:18 2013 +0200
     6.2 +++ b/json-tck/pom.xml	Thu Oct 10 14:03:53 2013 +0200
     6.3 @@ -4,11 +4,11 @@
     6.4    <parent>
     6.5      <groupId>org.apidesign</groupId>
     6.6      <artifactId>html</artifactId>
     6.7 -    <version>0.6</version>
     6.8 +    <version>0.7-SNAPSHOT</version>
     6.9    </parent>
    6.10    <groupId>org.apidesign.html</groupId>
    6.11    <artifactId>net.java.html.json.tck</artifactId>
    6.12 -  <version>0.6</version>
    6.13 +  <version>0.7-SNAPSHOT</version>
    6.14    <name>TCK for JSON Model</name>
    6.15    <url>http://maven.apache.org</url>
    6.16    <properties>
    6.17 @@ -31,7 +31,7 @@
    6.18      <dependency>
    6.19        <groupId>org.apidesign.html</groupId>
    6.20        <artifactId>net.java.html.json</artifactId>
    6.21 -      <version>0.6</version>
    6.22 +      <version>0.7-SNAPSHOT</version>
    6.23        <type>jar</type>
    6.24      </dependency>
    6.25      <dependency>
     7.1 --- a/json/pom.xml	Thu Oct 10 14:02:18 2013 +0200
     7.2 +++ b/json/pom.xml	Thu Oct 10 14:03:53 2013 +0200
     7.3 @@ -4,11 +4,11 @@
     7.4    <parent>
     7.5      <groupId>org.apidesign</groupId>
     7.6      <artifactId>html</artifactId>
     7.7 -    <version>0.6</version>
     7.8 +    <version>0.7-SNAPSHOT</version>
     7.9    </parent>
    7.10    <groupId>org.apidesign.html</groupId>
    7.11    <artifactId>net.java.html.json</artifactId>
    7.12 -  <version>0.6</version>
    7.13 +  <version>0.7-SNAPSHOT</version>
    7.14    <name>JSON Model in Java</name>
    7.15    <url>http://maven.apache.org</url>
    7.16    <properties>
     8.1 --- a/json/src/main/java/org/apidesign/html/json/impl/JSON.java	Thu Oct 10 14:02:18 2013 +0200
     8.2 +++ b/json/src/main/java/org/apidesign/html/json/impl/JSON.java	Thu Oct 10 14:03:53 2013 +0200
     8.3 @@ -139,10 +139,50 @@
     8.4          if (Boolean.class == type) {
     8.5              val = boolValue(val);
     8.6          }
     8.7 +        if (String.class == type) {
     8.8 +            val = stringValue(val);
     8.9 +        }
    8.10 +        if (Character.class == type) {
    8.11 +            val = charValue(val);
    8.12 +        }
    8.13 +        if (Integer.class == type) {
    8.14 +            val = val instanceof Number ? ((Number)val).intValue() : 0;
    8.15 +        }
    8.16 +        if (Long.class == type) {
    8.17 +            val = val instanceof Number  ? ((Number)val).longValue() : 0;
    8.18 +        }
    8.19 +        if (Short.class == type) {
    8.20 +            val = val instanceof Number ? ((Number)val).shortValue() : 0;
    8.21 +        }
    8.22 +        if (Byte.class == type) {
    8.23 +            val = val instanceof Number ? ((Number)val).byteValue() : 0;
    8.24 +        }        
    8.25 +        if (Double.class == type) {
    8.26 +            val = val instanceof Number ? ((Number)val).doubleValue() : Double.NaN;
    8.27 +        }
    8.28 +        if (Float.class == type) {
    8.29 +            val = val instanceof Number ? ((Number)val).floatValue() : Float.NaN;
    8.30 +        }
    8.31          return type.cast(val);
    8.32      }
    8.33      
    8.34 +    protected static boolean isNumeric(Object val) {
    8.35 +        return ((val instanceof Integer) || (val instanceof Long) || (val instanceof Short) || (val instanceof Byte));
    8.36 +    }
    8.37 +    
    8.38      public static String stringValue(Object val) {
    8.39 +        if (val instanceof Boolean) {
    8.40 +            return ((Boolean)val ? "true" : "false");
    8.41 +        }
    8.42 +        if (isNumeric(val)) {
    8.43 +            return Long.toString(((Number)val).longValue());
    8.44 +        }
    8.45 +        if (val instanceof Float) {
    8.46 +            return Float.toString((Float)val);
    8.47 +        }
    8.48 +        if (val instanceof Double) {
    8.49 +            return Double.toString((Double)val);
    8.50 +        }
    8.51          return (String)val;
    8.52      }
    8.53  
    8.54 @@ -154,10 +194,23 @@
    8.55                  return Double.NaN;
    8.56              }
    8.57          }
    8.58 +        if (val instanceof Boolean) {
    8.59 +            return (Boolean)val ? 1 : 0;
    8.60 +        }
    8.61          return (Number)val;
    8.62      }
    8.63  
    8.64      public static Character charValue(Object val) {
    8.65 +        if (val instanceof Number) {
    8.66 +            return Character.toChars(numberValue(val).intValue())[0];
    8.67 +        }
    8.68 +        if (val instanceof Boolean) {
    8.69 +            return (Boolean)val ? (char)1 : (char)0;
    8.70 +        }
    8.71 +        if (val instanceof String) {
    8.72 +            String s = (String)val;
    8.73 +            return s.isEmpty() ? (char)0 : s.charAt(0);
    8.74 +        }
    8.75          return (Character)val;
    8.76      }
    8.77      
    8.78 @@ -165,6 +218,10 @@
    8.79          if (val instanceof String) {
    8.80              return Boolean.parseBoolean((String)val);
    8.81          }
    8.82 +        if (val instanceof Number) {
    8.83 +            return numberValue(val).doubleValue() != 0.0;
    8.84 +        }
    8.85 +    
    8.86          return Boolean.TRUE.equals(val);
    8.87      }
    8.88      
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/json/src/test/java/org/apidesign/html/json/impl/JSONTest.java	Thu Oct 10 14:03:53 2013 +0200
     9.3 @@ -0,0 +1,62 @@
     9.4 +/**
     9.5 + * HTML via Java(tm) Language Bindings
     9.6 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     9.7 + *
     9.8 + * This program is free software: you can redistribute it and/or modify
     9.9 + * it under the terms of the GNU General Public License as published by
    9.10 + * the Free Software Foundation, version 2 of the License.
    9.11 + *
    9.12 + * This program is distributed in the hope that it will be useful,
    9.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.15 + * GNU General Public License for more details. apidesign.org
    9.16 + * designates this particular file as subject to the
    9.17 + * "Classpath" exception as provided by apidesign.org
    9.18 + * in the License file that accompanied this code.
    9.19 + *
    9.20 + * You should have received a copy of the GNU General Public License
    9.21 + * along with this program. Look for COPYING file in the top folder.
    9.22 + * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException
    9.23 + */
    9.24 +package org.apidesign.html.json.impl;
    9.25 +
    9.26 +import static org.testng.Assert.*;
    9.27 +import org.testng.annotations.Test;
    9.28 +
    9.29 +/**
    9.30 + *
    9.31 + * @author Jaroslav Tulach <jtulach@netbeans.org>
    9.32 + */
    9.33 +public class JSONTest {
    9.34 +    
    9.35 +    public JSONTest() {
    9.36 +    }
    9.37 +
    9.38 +    @Test public void longToStringValue() {
    9.39 +        assertEquals(JSON.stringValue(Long.valueOf(1)), "1");
    9.40 +    }
    9.41 +    
    9.42 +    @Test public void booleanIsSortOfNumber() {
    9.43 +        assertEquals(JSON.numberValue(Boolean.TRUE), Integer.valueOf(1));
    9.44 +        assertEquals(JSON.numberValue(Boolean.FALSE), Integer.valueOf(0));
    9.45 +    }
    9.46 +    
    9.47 +    @Test public void numberToChar() {
    9.48 +        assertEquals(JSON.charValue(65), Character.valueOf('A'));
    9.49 +    }
    9.50 +    @Test public void booleanToChar() {
    9.51 +        assertEquals(JSON.charValue(false), Character.valueOf((char)0));
    9.52 +        assertEquals(JSON.charValue(true), Character.valueOf((char)1));
    9.53 +    }
    9.54 +    @Test public void stringToChar() {
    9.55 +        assertEquals(JSON.charValue("Ahoj"), Character.valueOf('A'));
    9.56 +    }
    9.57 +    @Test public void stringToBoolean() {
    9.58 +        assertEquals(JSON.boolValue("false"), Boolean.FALSE);
    9.59 +        assertEquals(JSON.boolValue("True"), Boolean.TRUE);
    9.60 +    }
    9.61 +    @Test public void numberToBoolean() {
    9.62 +        assertEquals(JSON.boolValue(0), Boolean.FALSE);
    9.63 +        assertEquals(JSON.boolValue(1), Boolean.TRUE);
    9.64 +    }
    9.65 +}
    10.1 --- a/ko-archetype-test/pom.xml	Thu Oct 10 14:02:18 2013 +0200
    10.2 +++ b/ko-archetype-test/pom.xml	Thu Oct 10 14:03:53 2013 +0200
    10.3 @@ -4,11 +4,11 @@
    10.4      <parent>
    10.5          <groupId>org.apidesign</groupId>
    10.6          <artifactId>html</artifactId>
    10.7 -        <version>0.6</version>
    10.8 +        <version>0.7-SNAPSHOT</version>
    10.9      </parent>
   10.10      <groupId>org.apidesign.html</groupId>
   10.11      <artifactId>ko-archetype-test</artifactId>
   10.12 -    <version>0.6</version>
   10.13 +    <version>0.7-SNAPSHOT</version>
   10.14      <name>Knockout 4 Java Archetype Test</name>
   10.15      <url>http://maven.apache.org</url>
   10.16      <description>Verifies the Knockout &amp; net.java.html.json archetype behaves properly.</description>
   10.17 @@ -19,7 +19,7 @@
   10.18          <dependency>
   10.19              <groupId>${project.groupId}</groupId>
   10.20              <artifactId>knockout4j-archetype</artifactId>
   10.21 -            <version>0.6</version>
   10.22 +            <version>0.7-SNAPSHOT</version>
   10.23          </dependency>
   10.24          <dependency>
   10.25              <groupId>org.testng</groupId>
    11.1 --- a/ko-archetype/pom.xml	Thu Oct 10 14:02:18 2013 +0200
    11.2 +++ b/ko-archetype/pom.xml	Thu Oct 10 14:03:53 2013 +0200
    11.3 @@ -4,11 +4,11 @@
    11.4    <parent>
    11.5      <artifactId>html</artifactId>
    11.6      <groupId>org.apidesign</groupId>
    11.7 -    <version>0.6</version>
    11.8 +    <version>0.7-SNAPSHOT</version>
    11.9    </parent>
   11.10    <groupId>org.apidesign.html</groupId>
   11.11    <artifactId>knockout4j-archetype</artifactId>
   11.12 -  <version>0.6</version>
   11.13 +  <version>0.7-SNAPSHOT</version>
   11.14    <packaging>jar</packaging>
   11.15    <name>Knockout 4 Java Maven Archetype</name>
   11.16    <description>
    12.1 --- a/ko-fx/pom.xml	Thu Oct 10 14:02:18 2013 +0200
    12.2 +++ b/ko-fx/pom.xml	Thu Oct 10 14:03:53 2013 +0200
    12.3 @@ -4,11 +4,11 @@
    12.4    <parent>
    12.5      <groupId>org.apidesign</groupId>
    12.6      <artifactId>html</artifactId>
    12.7 -    <version>0.6</version>
    12.8 +    <version>0.7-SNAPSHOT</version>
    12.9    </parent>
   12.10    <groupId>org.apidesign.html</groupId>
   12.11    <artifactId>ko-fx</artifactId>
   12.12 -  <version>0.6</version>
   12.13 +  <version>0.7-SNAPSHOT</version>
   12.14    <name>Knockout.fx</name>
   12.15    <url>http://maven.apache.org</url>
   12.16    <properties>
    13.1 --- a/ko-ws-tyrus/pom.xml	Thu Oct 10 14:02:18 2013 +0200
    13.2 +++ b/ko-ws-tyrus/pom.xml	Thu Oct 10 14:03:53 2013 +0200
    13.3 @@ -4,11 +4,11 @@
    13.4    <parent>
    13.5      <groupId>org.apidesign</groupId>
    13.6      <artifactId>html</artifactId>
    13.7 -    <version>0.6</version>
    13.8 +    <version>0.7-SNAPSHOT</version>
    13.9    </parent>
   13.10    <groupId>org.apidesign.html</groupId>
   13.11    <artifactId>ko-ws-tyrus</artifactId>
   13.12 -  <version>0.6</version>
   13.13 +  <version>0.7-SNAPSHOT</version>
   13.14    <name>Tyrus Based WebSockets</name>
   13.15    <url>http://maven.apache.org</url>
   13.16      <build>
    14.1 --- a/pom.xml	Thu Oct 10 14:02:18 2013 +0200
    14.2 +++ b/pom.xml	Thu Oct 10 14:03:53 2013 +0200
    14.3 @@ -3,7 +3,7 @@
    14.4    <modelVersion>4.0.0</modelVersion>
    14.5    <groupId>org.apidesign</groupId>
    14.6    <artifactId>html</artifactId>
    14.7 -  <version>0.6</version>
    14.8 +  <version>0.7-SNAPSHOT</version>
    14.9    <packaging>pom</packaging>
   14.10    <name>HTML APIs via Java</name>
   14.11    <parent> 
   14.12 @@ -44,7 +44,7 @@
   14.13        <connection>scm:hg:https://hg.apidesign.org/hg/html~html4j</connection>
   14.14        <developerConnection>scm:hg:https://hg.apidesign.org/hg/html~html4j</developerConnection>
   14.15        <url>https://hg.apidesign.org/hg/html~html4j</url>
   14.16 -      <tag>release-0.6</tag>
   14.17 +      <tag>default</tag>
   14.18    </scm>
   14.19    <repositories>
   14.20        <repository>
    15.1 --- a/sound/pom.xml	Thu Oct 10 14:02:18 2013 +0200
    15.2 +++ b/sound/pom.xml	Thu Oct 10 14:03:53 2013 +0200
    15.3 @@ -4,11 +4,11 @@
    15.4      <parent>
    15.5          <groupId>org.apidesign</groupId>
    15.6          <artifactId>html</artifactId>
    15.7 -        <version>0.6</version>
    15.8 +        <version>0.7-SNAPSHOT</version>
    15.9      </parent>
   15.10      <groupId>org.apidesign.html</groupId>
   15.11      <artifactId>net.java.html.sound</artifactId>
   15.12 -    <version>0.6</version>
   15.13 +    <version>0.7-SNAPSHOT</version>
   15.14      <name>Sound API via HTML</name>
   15.15      <url>http://maven.apache.org</url>
   15.16      <properties>
   15.17 @@ -35,7 +35,7 @@
   15.18          <dependency>
   15.19              <groupId>org.apidesign.html</groupId>
   15.20              <artifactId>net.java.html.boot</artifactId>
   15.21 -            <version>0.6</version>
   15.22 +            <version>0.7-SNAPSHOT</version>
   15.23              <type>jar</type>
   15.24          </dependency>
   15.25          <dependency>