1 /*******************************************************************************
\r
2 * Copyright (c) 2010 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.databoard.binding.mutable;
14 import org.simantics.databoard.binding.IntegerBinding;
\r
15 import org.simantics.databoard.binding.error.BindingException;
\r
16 import org.simantics.databoard.primitives.MutableInteger;
\r
17 import org.simantics.databoard.type.IntegerType;
\r
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 {
\r
49 MutableInteger result = new MutableInteger();
50 result.value = Integer.valueOf(value);
52 } catch (java.lang.NumberFormatException e) {
\r
53 throw new BindingException( e );
\r
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();