]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/StringBindingDefault.java
Merge "Remove unnecessary getComparableKey from HashMapBinding"
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / impl / StringBindingDefault.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.impl;
13
14 import org.simantics.databoard.binding.StringBinding;
15 import org.simantics.databoard.binding.error.BindingException;
16 import org.simantics.databoard.binding.error.UnsupportedOperationException;
17 import org.simantics.databoard.type.StringType;
18
19 /**
20  * StringBindingDefault is a binding to java.lang.String class.
21  *
22  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
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