1.1 --- a/geo/src/main/java/net/java/html/geo/GeoHandle.java Sun Jul 07 06:53:26 2013 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,57 +0,0 @@
1.4 -/**
1.5 - * HTML via Java(tm) Language Bindings
1.6 - * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.7 - *
1.8 - * This program is free software: you can redistribute it and/or modify
1.9 - * it under the terms of the GNU General Public License as published by
1.10 - * the Free Software Foundation, version 2 of the License.
1.11 - *
1.12 - * This program is distributed in the hope that it will be useful,
1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.15 - * GNU General Public License for more details. apidesign.org
1.16 - * designates this particular file as subject to the
1.17 - * "Classpath" exception as provided by apidesign.org
1.18 - * in the License file that accompanied this code.
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License
1.21 - * along with this program. Look for COPYING file in the top folder.
1.22 - * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException
1.23 - */
1.24 -package net.java.html.geo;
1.25 -
1.26 -/**
1.27 - *
1.28 - * @author Jaroslav Tulach <jtulach@netbeans.org>
1.29 - */
1.30 -public abstract class GeoHandle {
1.31 - private final boolean oneTime;
1.32 - private boolean enableHighAccuracy;
1.33 - private long timeout;
1.34 - private long maximumAge;
1.35 -
1.36 - protected GeoHandle(boolean oneTime) {
1.37 - this.oneTime = oneTime;
1.38 - }
1.39 -
1.40 - protected abstract void onLocation(Position p);
1.41 - protected abstract void onError(Throwable t);
1.42 -
1.43 - public void setHighAccuracy(boolean enable) {
1.44 - this.enableHighAccuracy = enable;
1.45 - }
1.46 -
1.47 - public void setTimeout(long timeout) {
1.48 - this.timeout = timeout;
1.49 - }
1.50 -
1.51 - public void setMaximumAge(long age) {
1.52 - this.maximumAge = age;
1.53 - }
1.54 -
1.55 - public void start() {
1.56 - }
1.57 -
1.58 - public void stop() {
1.59 - }
1.60 -}
2.1 --- a/geo/src/main/java/net/java/html/geo/Position.java Sun Jul 07 06:53:26 2013 +0200
2.2 +++ b/geo/src/main/java/net/java/html/geo/Position.java Sun Jul 07 06:56:12 2013 +0200
2.3 @@ -46,4 +46,42 @@
2.4 private Double heading;
2.5 private Double speed;
2.6 }
2.7 +
2.8 + /**
2.9 + *
2.10 + */
2.11 + public static abstract class Handle {
2.12 +
2.13 + private final boolean oneTime;
2.14 + private boolean enableHighAccuracy;
2.15 + private long timeout;
2.16 + private long maximumAge;
2.17 +
2.18 + protected Handle(boolean oneTime) {
2.19 + super();
2.20 + this.oneTime = oneTime;
2.21 + }
2.22 +
2.23 + protected abstract void onLocation(Position p);
2.24 +
2.25 + protected abstract void onError(Throwable t);
2.26 +
2.27 + public void setHighAccuracy(boolean enable) {
2.28 + this.enableHighAccuracy = enable;
2.29 + }
2.30 +
2.31 + public void setTimeout(long timeout) {
2.32 + this.timeout = timeout;
2.33 + }
2.34 +
2.35 + public void setMaximumAge(long age) {
2.36 + this.maximumAge = age;
2.37 + }
2.38 +
2.39 + public void start() {
2.40 + }
2.41 +
2.42 + public void stop() {
2.43 + }
2.44 + }
2.45 }
3.1 --- a/geo/src/main/java/org/apidesign/html/geo/impl/GeoProcessor.java Sun Jul 07 06:53:26 2013 +0200
3.2 +++ b/geo/src/main/java/org/apidesign/html/geo/impl/GeoProcessor.java Sun Jul 07 06:56:12 2013 +0200
3.3 @@ -97,7 +97,7 @@
3.4 JavaFileObject fo = processingEnv.getFiler().createSourceFile(fqn, e);
3.5 Writer w = fo.openWriter();
3.6 w.append("package ").append(pkg).append(";\n");
3.7 - w.append("class ").append(className).append(" extends net.java.html.geo.GeoHandle {\n");
3.8 + w.append("class ").append(className).append(" extends net.java.html.geo.Position.Handle {\n");
3.9 w.append(" private ").append(te.getSimpleName()).append(" i;\n");
3.10 w.append(" private ").append(className).append("(boolean oneTime");
3.11 w.append(", ").append(te.getSimpleName()).append(" i");
3.12 @@ -106,7 +106,7 @@
3.13 w.append(" this.i = i;\n");
3.14 }
3.15 w.append("}\n");
3.16 - w.append(" static net.java.html.geo.GeoHandle createQuery(");
3.17 + w.append(" static net.java.html.geo.Position.Handle createQuery(");
3.18 String inst;
3.19 if (!isStatic) {
3.20 w.append(te.getSimpleName()).append(" instance");
3.21 @@ -115,7 +115,7 @@
3.22 inst = "null";
3.23 }
3.24 w.append(") { return new ").append(className).append("(true, ").append(inst).append("); }\n");
3.25 - w.append(" static net.java.html.geo.GeoHandle createWatch(");
3.26 + w.append(" static net.java.html.geo.Position.Handle createWatch(");
3.27 if (!isStatic) {
3.28 w.append(te.getSimpleName()).append(" instance");
3.29 }
4.1 --- a/geo/src/test/java/net/java/html/geo/OnLocationTest.java Sun Jul 07 06:53:26 2013 +0200
4.2 +++ b/geo/src/test/java/net/java/html/geo/OnLocationTest.java Sun Jul 07 06:56:12 2013 +0200
4.3 @@ -33,7 +33,7 @@
4.4 }
4.5
4.6 @Test public void createOneTimeQueryStatic() {
4.7 - GeoHandle h = OnLocationHandle.createQuery();
4.8 + net.java.html.geo.Position.Handle h = OnLocationHandle.createQuery();
4.9 h.setHighAccuracy(false);
4.10 h.setTimeout(1000L);
4.11 h.setMaximumAge(1000L);
4.12 @@ -42,14 +42,14 @@
4.13 }
4.14
4.15 @Test public void onLocationHandleCallback() {
4.16 - GeoHandle h = OnLocationHandle.createQuery();
4.17 + net.java.html.geo.Position.Handle h = OnLocationHandle.createQuery();
4.18 cnt = 0;
4.19 h.onLocation(new Position());
4.20 assertEquals(cnt, 1, "The callback has been made");
4.21 }
4.22
4.23 @Test public void createRepeatableWatchStatic() {
4.24 - GeoHandle h = OnLocationHandle.createQuery();
4.25 + net.java.html.geo.Position.Handle h = OnLocationHandle.createQuery();
4.26 h.setHighAccuracy(false);
4.27 h.setTimeout(1000L);
4.28 h.setMaximumAge(1000L);
4.29 @@ -71,7 +71,7 @@
4.30 @Test public void createOneTimeQueryInstance() {
4.31 OnLocationTest t = new OnLocationTest();
4.32
4.33 - GeoHandle h = InstanceHandle.createQuery(t);
4.34 + net.java.html.geo.Position.Handle h = InstanceHandle.createQuery(t);
4.35 h.setHighAccuracy(false);
4.36 h.setTimeout(1000L);
4.37 h.setMaximumAge(1000L);
4.38 @@ -81,13 +81,13 @@
4.39
4.40 @Test public void onInstanceCallback() {
4.41 OnLocationTest t = new OnLocationTest();
4.42 - GeoHandle h = InstanceHandle.createWatch(t);
4.43 + net.java.html.geo.Position.Handle h = InstanceHandle.createWatch(t);
4.44 h.onLocation(new Position());
4.45 assertEquals(t.instCnt, 1, "One callback made");
4.46 }
4.47
4.48 @Test public void onInstanceError() {
4.49 - GeoHandle h = InstanceHandle.createWatch(this);
4.50 + net.java.html.geo.Position.Handle h = InstanceHandle.createWatch(this);
4.51 InterruptedException e = new InterruptedException();
4.52 h.onError(e);
4.53 assertEquals(instCnt, 1, "One callback made");
4.54 @@ -97,7 +97,7 @@
4.55 @Test public void createRepeatableWatch() {
4.56 OnLocationTest t = new OnLocationTest();
4.57
4.58 - GeoHandle h = InstanceHandle.createWatch(t);
4.59 + net.java.html.geo.Position.Handle h = InstanceHandle.createWatch(t);
4.60 h.setHighAccuracy(false);
4.61 h.setTimeout(1000L);
4.62 h.setMaximumAge(1000L);