Can execute 'dual' tests: bck2brwsr can use regular launcher, javaquery.api can use FX Web View one
2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see http://opensource.org/licenses/GPL-2.0.
19 package org.apidesign.bck2brwsr.htmlpage;
21 import java.lang.reflect.Method;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
27 * @author Jaroslav Tulach <jtulach@netbeans.org>
29 public final class KOProperty {
30 private static final Logger LOG = Logger.getLogger(KOProperty.class.getName());
31 private final Object obj;
32 private final Method getter;
33 private final Method setter;
35 KOProperty(Object obj, String getter, String setter) throws NoSuchMethodException {
37 this.getter = obj.getClass().getDeclaredMethod(getter);
38 this.getter.setAccessible(true);
40 this.setter = obj.getClass().getDeclaredMethod(setter, this.getter.getReturnType());
41 this.setter.setAccessible(true);
47 public Object get() throws Exception {
48 Object v = getter.invoke(obj);
49 LOG.log(Level.FINE, "{0} returns {1}", new Object[] { getter, v });
53 public void set(Object value) throws Exception {
54 LOG.log(Level.FINE, "{0} set to {1}", new Object[] { setter, value });
55 final Class<?> rt = getter.getReturnType();
58 if (rt == String.class) {
59 setter.invoke(obj, value.toString());
62 if (rt == Integer.class || rt == int.class) {
63 setter.invoke(obj, Integer.parseInt(value.toString()));
66 if (rt == Double.class || rt == double.class) {
67 setter.invoke(obj, Double.parseDouble(value.toString()));
70 setter.invoke(obj, value);
71 } catch (Throwable ex) {
72 LOG.log(Level.SEVERE, "Can''t set " + setter, ex);