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.IntegerBinding;
15 import org.simantics.databoard.binding.error.BindingException;
16 import org.simantics.databoard.primitives.MutableInteger;
17 import org.simantics.databoard.type.IntegerType;
19 public class MutableIntegerBinding extends IntegerBinding {
21 public MutableIntegerBinding(IntegerType type) {
26 public Object create(int value) {
27 MutableInteger result = new MutableInteger();
33 public Object create(Integer value) {
34 MutableInteger result = new MutableInteger();
40 public Object create(Number value) {
41 MutableInteger result = new MutableInteger();
42 result.value = value.intValue();
47 public Object create(String value) throws BindingException {
49 MutableInteger result = new MutableInteger();
50 result.value = Integer.valueOf(value);
52 } catch (java.lang.NumberFormatException e) {
53 throw new BindingException( e );
58 public int getValue_(Object obj) throws BindingException {
59 MutableInteger result = (MutableInteger) obj;
64 public Integer getValue(Object obj) throws BindingException {
65 MutableInteger result = (MutableInteger) obj;
70 public boolean isInstance(Object obj) {
71 return obj instanceof MutableInteger;
75 public void setValue(Object obj, int value) throws BindingException {
76 MutableInteger result = (MutableInteger) obj;
81 public void setValue(Object obj, Number value) throws BindingException {
82 MutableInteger result = (MutableInteger) obj;
83 result.value = value.intValue();