]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/mutable/MutableStringBinding.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / mutable / MutableStringBinding.java
1 /*******************************************************************************
2  *  Copyright (c) 2010 Association for Decentralized Information Management in
3  *  Industry THTH ry.
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
8  *
9  *  Contributors:
10  *      VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.binding.mutable;
13
14 import org.simantics.databoard.binding.StringBinding;
15 import org.simantics.databoard.binding.error.BindingException;
16 import org.simantics.databoard.primitives.MutableString;
17 import org.simantics.databoard.type.StringType;
18
19 /**
20  * Binds StringType to {@link MutableString}
21  *
22  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
23  */
24 public class MutableStringBinding extends StringBinding {
25
26         public MutableStringBinding(StringType type) {
27                 super(type);
28         }
29
30         @Override
31         public Object create(String value) {
32                 MutableString result = new MutableString();
33                 result.value = value;
34                 return result;
35         }
36
37         @Override
38         public String getValue(Object o) throws BindingException {
39                 MutableString result = (MutableString)o;
40                 return (String) result.value;           
41         }
42
43         @Override
44         public boolean isInstance(Object obj) {
45                 return (obj instanceof MutableString) && ( ((MutableString)obj).value instanceof String );
46         }
47
48         @Override
49         public void setValue(Object o, String newValue) throws BindingException {
50                 MutableString result = (MutableString)o;
51                 result.value = newValue;
52         }       
53         
54 }
55
56