]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/StringBindingDefault.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / impl / StringBindingDefault.java
1 /*******************************************************************************\r
2  *  Copyright (c) 2010 Association for Decentralized Information Management in\r
3  *  Industry THTH ry.\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
8  *\r
9  *  Contributors:\r
10  *      VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.databoard.binding.impl;
13
14 import org.simantics.databoard.binding.StringBinding;\r
15 import org.simantics.databoard.binding.error.BindingException;\r
16 import org.simantics.databoard.binding.error.UnsupportedOperationException;\r
17 import org.simantics.databoard.type.StringType;\r
18 \r
19 /**\r
20  * StringBindingDefault is a binding to java.lang.String class.\r
21  *\r
22  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>\r
23  */
24 public class StringBindingDefault extends StringBinding {
25
26         public StringBindingDefault(StringType type) {
27                 super(type);
28         }
29         
30         public Object create(String value) 
31         {
32                 return value;
33         }
34         
35         public String getValue(Object o) 
36         throws BindingException 
37         {
38                 return (String)o;
39         }
40         
41         public void setValue(Object o, String newValue) 
42         throws BindingException 
43         {
44                 throw new UnsupportedOperationException("Cannot change the value of immutable java.lang.String");
45         }
46
47         @Override
48         public boolean isInstance(Object obj) {
49                 return obj instanceof String;
50         }               
51         
52         @Override
53         public boolean isImmutable() {
54                 return true;
55         }
56         
57         
58 }
59