]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/StringBindingDefault.java b/bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/StringBindingDefault.java
new file mode 100644 (file)
index 0000000..b3254df
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************\r
+ *  Copyright (c) 2010 Association for Decentralized Information Management in\r
+ *  Industry THTH ry.\r
+ *  All rights reserved. This program and the accompanying materials\r
+ *  are made available under the terms of the Eclipse Public License v1.0\r
+ *  which accompanies this distribution, and is available at\r
+ *  http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ *  Contributors:\r
+ *      VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.databoard.binding.impl;
+
+import org.simantics.databoard.binding.StringBinding;\r
+import org.simantics.databoard.binding.error.BindingException;\r
+import org.simantics.databoard.binding.error.UnsupportedOperationException;\r
+import org.simantics.databoard.type.StringType;\r
+\r
+/**\r
+ * StringBindingDefault is a binding to java.lang.String class.\r
+ *\r
+ * @author Toni Kalajainen <toni.kalajainen@vtt.fi>\r
+ */
+public class StringBindingDefault extends StringBinding {
+
+       public StringBindingDefault(StringType type) {
+               super(type);
+       }
+       
+       public Object create(String value) 
+       {
+               return value;
+       }
+       
+       public String getValue(Object o) 
+       throws BindingException 
+       {
+               return (String)o;
+       }
+       
+       public void setValue(Object o, String newValue) 
+       throws BindingException 
+       {
+               throw new UnsupportedOperationException("Cannot change the value of immutable java.lang.String");
+       }
+
+       @Override
+       public boolean isInstance(Object obj) {
+               return obj instanceof String;
+       }               
+       
+       @Override
+       public boolean isImmutable() {
+               return true;
+       }
+       
+       
+}
+