1 /*******************************************************************************
2 * Copyright (c) 2010 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.databoard.binding.mutable;
14 import org.simantics.databoard.binding.DoubleBinding;
15 import org.simantics.databoard.binding.error.BindingException;
16 import org.simantics.databoard.primitives.MutableDouble;
17 import org.simantics.databoard.type.DoubleType;
20 * Binds DoubleType to {@link MutableDouble}
22 * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
24 public class MutableDoubleBinding extends DoubleBinding {
26 public MutableDoubleBinding(DoubleType type) {
31 public Object create(double value) {
32 MutableDouble result = new MutableDouble();
38 public Object create(Double value) {
39 MutableDouble result = new MutableDouble();
45 public Object create(Number value) {
46 MutableDouble result = new MutableDouble();
47 result.value = value.doubleValue();
52 public Object create(String value) throws BindingException {
54 MutableDouble result = new MutableDouble();
55 result.value = Double.valueOf(value);
57 } catch (java.lang.NumberFormatException e) {
58 throw new BindingException( e );
63 public double getValue_(Object o) throws BindingException {
64 MutableDouble result = (MutableDouble) o;
69 public Double getValue(Object o) throws BindingException {
70 MutableDouble result = (MutableDouble) o;
75 public boolean isInstance(Object obj) {
76 return obj instanceof MutableDouble;
80 public void setValue(Object obj, double value) throws BindingException {
81 MutableDouble result = (MutableDouble) obj;
86 public void setValue(Object obj, Number value) throws BindingException {
87 MutableDouble result = (MutableDouble) obj;
88 result.value = value.doubleValue();