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.LongBinding;
\r
15 import org.simantics.databoard.binding.error.BindingException;
\r
16 import org.simantics.databoard.primitives.MutableLong;
\r
17 import org.simantics.databoard.type.LongType;
\r
20 * Binds LongType to {@link MutableLong}
22 * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
24 public class MutableLongBinding extends LongBinding {
26 public MutableLongBinding(LongType type) {
31 public Object create(long value) {
32 MutableLong result = new MutableLong();
38 public Object create(Long value) {
39 MutableLong result = new MutableLong();
45 public Object create(Number value) {
46 MutableLong result = new MutableLong();
47 result.value = value.longValue();
52 public Object create(String value) throws BindingException {
\r
54 MutableLong result = new MutableLong();
55 result.value = Long.valueOf(value);
57 } catch (java.lang.NumberFormatException e) {
\r
58 throw new BindingException( e );
\r
63 public long getValue_(Object o) throws BindingException {
64 MutableLong result = (MutableLong) o;
69 public Long getValue(Object o) throws BindingException {
70 MutableLong result = (MutableLong) o;
75 public boolean isInstance(Object obj) {
76 return obj instanceof MutableLong;
80 public void setValue(Object obj, long value) throws BindingException {
81 MutableLong result = (MutableLong) obj;
86 public void setValue(Object obj, Number value) throws BindingException {
87 MutableLong result = (MutableLong) obj;
88 result.value = value.longValue();