1.1 --- a/json-tck/src/main/java/net/java/html/json/tests/ConvertTypesTest.java Thu May 16 14:09:18 2013 +0200
1.2 +++ b/json-tck/src/main/java/net/java/html/json/tests/ConvertTypesTest.java Thu May 16 20:40:25 2013 +0200
1.3 @@ -49,7 +49,7 @@
1.4 }
1.5 private static Object createJSON(boolean includeSex)
1.6 throws UnsupportedEncodingException {
1.7 - Map<String,Object> map = new HashMap<>();
1.8 + Map<String,Object> map = new HashMap<String,Object>();
1.9 map.put("firstName", "son");
1.10 map.put("lastName", "dj");
1.11 if (includeSex) {
2.1 --- a/json/pom.xml Thu May 16 14:09:18 2013 +0200
2.2 +++ b/json/pom.xml Thu May 16 20:40:25 2013 +0200
2.3 @@ -8,7 +8,7 @@
2.4 </parent>
2.5 <groupId>org.apidesign.html</groupId>
2.6 <artifactId>net.java.html.json</artifactId>
2.7 - <version>0.3</version>
2.8 + <version>0.3.1</version>
2.9 <name>JSON Model in Java</name>
2.10 <url>http://maven.apache.org</url>
2.11 <properties>
3.1 --- a/json/src/main/java/org/apidesign/html/json/impl/Bindings.java Thu May 16 14:09:18 2013 +0200
3.2 +++ b/json/src/main/java/org/apidesign/html/json/impl/Bindings.java Thu May 16 20:40:25 2013 +0200
3.3 @@ -41,13 +41,13 @@
3.4 }
3.5
3.6 public <M> PropertyBinding registerProperty(String propName, M model, SetAndGet<M> access, boolean readOnly) {
3.7 - PropertyBinding pb = PropertyBindingAccessor.create(new PBData<>(propName, model, access, readOnly));
3.8 + PropertyBinding pb = PropertyBindingAccessor.create(new PBData<M>(propName, model, access, readOnly));
3.9 bp.bind(pb, model, data);
3.10 return pb;
3.11 }
3.12
3.13 public <M> FunctionBinding registerFunction(String name, M model, Callback<M> access) {
3.14 - FunctionBinding fb = PropertyBindingAccessor.createFunction(new FBData<>(name, model, access));
3.15 + FunctionBinding fb = PropertyBindingAccessor.createFunction(new FBData<M>(name, model, access));
3.16 bp.expose(fb, model, data);
3.17 return fb;
3.18 }
3.19 @@ -61,7 +61,7 @@
3.20 Technology<Data> bp, Object model
3.21 ) {
3.22 Data d = bp.wrapModel(model);
3.23 - return new Bindings<>(d, bp);
3.24 + return new Bindings<Data>(d, bp);
3.25 }
3.26
3.27
4.1 --- a/json/src/main/java/org/apidesign/html/json/impl/JSON.java Thu May 16 14:09:18 2013 +0200
4.2 +++ b/json/src/main/java/org/apidesign/html/json/impl/JSON.java Thu May 16 20:40:25 2013 +0200
4.3 @@ -109,7 +109,7 @@
4.4
4.5 private static final Map<Class,FromJSON<?>> froms;
4.6 static {
4.7 - Map<Class,FromJSON<?>> m = new HashMap<>();
4.8 + Map<Class,FromJSON<?>> m = new HashMap<Class,FromJSON<?>>();
4.9 froms = m;
4.10 }
4.11 public static void register(FromJSON<?> from) {
4.12 @@ -160,8 +160,7 @@
4.13 Class.forName(modelClazz.getName(), true, l);
4.14 }
4.15 modelClazz.newInstance();
4.16 - } catch (ClassNotFoundException | InstantiationException |
4.17 - IllegalAccessException | SecurityException ex) {
4.18 + } catch (Exception ex) {
4.19 // ignore and try again
4.20 }
4.21 }
5.1 --- a/json/src/main/java/org/apidesign/html/json/impl/ModelProcessor.java Thu May 16 14:09:18 2013 +0200
5.2 +++ b/json/src/main/java/org/apidesign/html/json/impl/ModelProcessor.java Thu May 16 20:40:25 2013 +0200
5.3 @@ -82,7 +82,7 @@
5.4 * @author Jaroslav Tulach <jtulach@netbeans.org>
5.5 */
5.6 @ServiceProvider(service=Processor.class)
5.7 -@SupportedSourceVersion(SourceVersion.RELEASE_7)
5.8 +@SupportedSourceVersion(SourceVersion.RELEASE_6)
5.9 @SupportedAnnotationTypes({
5.10 "net.java.html.json.Model",
5.11 "net.java.html.json.Function",
5.12 @@ -93,8 +93,8 @@
5.13 })
5.14 public final class ModelProcessor extends AbstractProcessor {
5.15 private static final Logger LOG = Logger.getLogger(ModelProcessor.class.getName());
5.16 - private final Map<Element,String> models = new WeakHashMap<>();
5.17 - private final Map<Element,Prprt[]> verify = new WeakHashMap<>();
5.18 + private final Map<Element,String> models = new WeakHashMap<Element,String>();
5.19 + private final Map<Element,Prprt[]> verify = new WeakHashMap<Element,Prprt[]>();
5.20 @Override
5.21 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
5.22 boolean ok = true;
5.23 @@ -159,10 +159,10 @@
5.24 models.put(e, className);
5.25 try {
5.26 StringWriter body = new StringWriter();
5.27 - List<String> propsGetSet = new ArrayList<>();
5.28 - List<String> functions = new ArrayList<>();
5.29 - Map<String, Collection<String>> propsDeps = new HashMap<>();
5.30 - Map<String, Collection<String>> functionDeps = new HashMap<>();
5.31 + List<String> propsGetSet = new ArrayList<String>();
5.32 + List<String> functions = new ArrayList<String>();
5.33 + Map<String, Collection<String>> propsDeps = new HashMap<String, Collection<String>>();
5.34 + Map<String, Collection<String>> functionDeps = new HashMap<String, Collection<String>>();
5.35 Prprt[] props = createProps(e, m.properties());
5.36
5.37 if (!generateComputedProperties(body, props, e.getEnclosedElements(), propsGetSet, propsDeps)) {
5.38 @@ -217,7 +217,7 @@
5.39 for (int i = 0; i < propsGetSet.size(); i += 5) {
5.40 final String set = propsGetSet.get(i + 2);
5.41 String tn = propsGetSet.get(i + 4);
5.42 - if (processingEnv.getSourceVersion().compareTo(SourceVersion.RELEASE_7) < 0) {
5.43 + if (processingEnv.getSourceVersion().compareTo(SourceVersion.RELEASE_6) <= 0) {
5.44 String btn = findBoxedType(tn);
5.45 if (btn != null) {
5.46 tn = btn;
5.47 @@ -311,8 +311,15 @@
5.48 w.append(type).append(".valueOf((String)ret[" + cnt + "]);\n");
5.49 } else if (isPrimitive(type)) {
5.50 w.append(" this.prop_").append(pn);
5.51 - w.append(" = ret[" + cnt + "] == null ? (").append(type).append(")0 : ");
5.52 - w.append("((Number)").append("ret[" + cnt + "]).");
5.53 + w.append(" = ret[" + cnt + "] == null ? ");
5.54 + if ("char".equals(type)) {
5.55 + w.append("0 : ((Character)");
5.56 + } else if ("boolean".equals(type)) {
5.57 + w.append("false : ((Boolean)");
5.58 + } else {
5.59 + w.append("0 : ((Number)");
5.60 + }
5.61 + w.append("ret[" + cnt + "]).");
5.62 w.append(type).append("Value();\n");
5.63 } else {
5.64 w.append(" this.prop_").append(pn);
5.65 @@ -472,7 +479,7 @@
5.66
5.67 Collection<String> depends = deps.get(dn);
5.68 if (depends == null) {
5.69 - depends = new LinkedHashSet<>();
5.70 + depends = new LinkedHashSet<String>();
5.71 deps.put(dn, depends);
5.72 }
5.73 depends.add(sn);
5.74 @@ -685,14 +692,14 @@
5.75
5.76 Collection<String> change = functionDeps.get(pn);
5.77 if (change == null) {
5.78 - change = new ArrayList<>();
5.79 + change = new ArrayList<String>();
5.80 functionDeps.put(pn, change);
5.81 }
5.82 change.add(call.toString());
5.83 for (String dpn : findDerivedFrom(propDeps, pn)) {
5.84 change = functionDeps.get(dpn);
5.85 if (change == null) {
5.86 - change = new ArrayList<>();
5.87 + change = new ArrayList<String>();
5.88 functionDeps.put(dpn, change);
5.89 }
5.90 change.add(call.toString());
5.91 @@ -741,7 +748,7 @@
5.92 }
5.93 String modelClass = null;
5.94 boolean expectsList = false;
5.95 - List<String> args = new ArrayList<>();
5.96 + List<String> args = new ArrayList<String>();
5.97 {
5.98 for (VariableElement ve : e.getParameters()) {
5.99 TypeMirror modelType = null;
5.100 @@ -1117,7 +1124,7 @@
5.101 private Iterable<String> findParamNames(
5.102 Element e, String url, String jsonParam, StringBuilder... both
5.103 ) {
5.104 - List<String> params = new ArrayList<>();
5.105 + List<String> params = new ArrayList<String>();
5.106 int wasJSON = 0;
5.107
5.108 for (int pos = 0; ;) {
5.109 @@ -1165,11 +1172,13 @@
5.110 "long".equals(type) ||
5.111 "short".equals(type) ||
5.112 "byte".equals(type) ||
5.113 + "char".equals(type) ||
5.114 + "boolean".equals(type) ||
5.115 "float".equals(type);
5.116 }
5.117
5.118 private static Collection<String> findDerivedFrom(Map<String, Collection<String>> propsDeps, String derivedProp) {
5.119 - Set<String> names = new HashSet<>();
5.120 + Set<String> names = new HashSet<String>();
5.121 for (Map.Entry<String, Collection<String>> e : propsDeps.entrySet()) {
5.122 if (e.getValue().contains(derivedProp)) {
5.123 names.add(e.getKey());
5.124 @@ -1269,17 +1278,21 @@
5.125 }
5.126
5.127 String typeName(ProcessingEnvironment env) {
5.128 + RuntimeException ex;
5.129 try {
5.130 return p.type().getName();
5.131 - } catch (IncompleteAnnotationException | AnnotationTypeMismatchException ex) {
5.132 - for (Object v : getAnnoValues(env, e, tm)) {
5.133 - String s = v.toString().replace(" ", "");
5.134 - if (s.startsWith("type=") && s.endsWith(".class")) {
5.135 - return s.substring(5, s.length() - 6);
5.136 - }
5.137 + } catch (IncompleteAnnotationException e) {
5.138 + ex = e;
5.139 + } catch (AnnotationTypeMismatchException e) {
5.140 + ex = e;
5.141 + }
5.142 + for (Object v : getAnnoValues(env, e, tm)) {
5.143 + String s = v.toString().replace(" ", "");
5.144 + if (s.startsWith("type=") && s.endsWith(".class")) {
5.145 + return s.substring(5, s.length() - 6);
5.146 }
5.147 - throw ex;
5.148 }
5.149 + throw ex;
5.150 }
5.151
5.152
6.1 --- a/json/src/test/java/net/java/html/json/Compile.java Thu May 16 14:09:18 2013 +0200
6.2 +++ b/json/src/test/java/net/java/html/json/Compile.java Thu May 16 20:40:25 2013 +0200
6.3 @@ -51,7 +51,8 @@
6.4 * @author Jaroslav Tulach <jtulach@netbeans.org>
6.5 */
6.6 final class Compile implements DiagnosticListener<JavaFileObject> {
6.7 - private final List<Diagnostic<? extends JavaFileObject>> errors = new ArrayList<>();
6.8 + private final List<Diagnostic<? extends JavaFileObject>> errors =
6.9 + new ArrayList<Diagnostic<? extends JavaFileObject>>();
6.10 private final Map<String, byte[]> classes;
6.11 private final String pkg;
6.12 private final String cls;
6.13 @@ -83,7 +84,8 @@
6.14 /** Obtains errors created during compilation.
6.15 */
6.16 public List<Diagnostic<? extends JavaFileObject>> getErrors() {
6.17 - List<Diagnostic<? extends JavaFileObject>> err = new ArrayList<>();
6.18 + List<Diagnostic<? extends JavaFileObject>> err;
6.19 + err = new ArrayList<Diagnostic<? extends JavaFileObject>>();
6.20 for (Diagnostic<? extends JavaFileObject> diagnostic : errors) {
6.21 if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
6.22 err.add(diagnostic);
6.23 @@ -95,7 +97,8 @@
6.24 private Map<String, byte[]> compile(final String html, final String code) throws IOException {
6.25 StandardJavaFileManager sjfm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(this, null, null);
6.26
6.27 - final Map<String, ByteArrayOutputStream> class2BAOS = new HashMap<>();
6.28 + final Map<String, ByteArrayOutputStream> class2BAOS;
6.29 + class2BAOS = new HashMap<String, ByteArrayOutputStream>();
6.30
6.31 JavaFileObject file = new SimpleJavaFileObject(URI.create("mem://mem"), Kind.SOURCE) {
6.32 @Override
6.33 @@ -201,7 +204,7 @@
6.34
6.35 ToolProvider.getSystemJavaCompiler().getTask(null, jfm, this, /*XXX:*/Arrays.asList("-source", sourceLevel, "-target", "1.7"), null, Arrays.asList(file)).call();
6.36
6.37 - Map<String, byte[]> result = new HashMap<>();
6.38 + Map<String, byte[]> result = new HashMap<String, byte[]>();
6.39
6.40 for (Map.Entry<String, ByteArrayOutputStream> e : class2BAOS.entrySet()) {
6.41 result.put(e.getKey(), e.getValue().toByteArray());
7.1 --- a/json/src/test/java/net/java/html/json/MapModelTest.java Thu May 16 14:09:18 2013 +0200
7.2 +++ b/json/src/test/java/net/java/html/json/MapModelTest.java Thu May 16 20:40:25 2013 +0200
7.3 @@ -143,7 +143,7 @@
7.4
7.5 @Override
7.6 public Map<String, One> wrapModel(Object model) {
7.7 - return new HashMap<>();
7.8 + return new HashMap<String, One>();
7.9 }
7.10
7.11 @Override
8.1 --- a/json/src/test/java/net/java/html/json/ModelTest.java Thu May 16 14:09:18 2013 +0200
8.2 +++ b/json/src/test/java/net/java/html/json/ModelTest.java Thu May 16 20:40:25 2013 +0200
8.3 @@ -240,7 +240,7 @@
8.4 }
8.5
8.6 private static class MockTechnology implements Technology<Object> {
8.7 - private final List<String> mutated = new ArrayList<>();
8.8 + private final List<String> mutated = new ArrayList<String>();
8.9
8.10 @Override
8.11 public Object wrapModel(Object model) {
9.1 --- a/json/src/test/java/org/apidesign/html/json/impl/JSONListTest.java Thu May 16 14:09:18 2013 +0200
9.2 +++ b/json/src/test/java/org/apidesign/html/json/impl/JSONListTest.java Thu May 16 20:40:25 2013 +0200
9.3 @@ -40,7 +40,7 @@
9.4 */
9.5 public class JSONListTest implements Technology<Object> {
9.6 private boolean replaceArray;
9.7 - private final Map<String,PropertyBinding> bindings = new HashMap<>();
9.8 + private final Map<String,PropertyBinding> bindings = new HashMap<String,PropertyBinding>();
9.9
9.10 public JSONListTest() {
9.11 }
10.1 --- a/pom.xml Thu May 16 14:09:18 2013 +0200
10.2 +++ b/pom.xml Thu May 16 20:40:25 2013 +0200
10.3 @@ -122,8 +122,8 @@
10.4 <artifactId>maven-compiler-plugin</artifactId>
10.5 <version>2.3.2</version>
10.6 <configuration>
10.7 - <source>1.7</source>
10.8 - <target>1.7</target>
10.9 + <source>1.6</source>
10.10 + <target>1.6</target>
10.11 </configuration>
10.12 </plugin>
10.13 </plugins>