]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/java/JavaByte.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / accessor / java / JavaByte.java
index 6e63f201db13f55f96133bad6d94378dd9fcac23..9ffca42bb47ee614ae330d655d9dc3a697daba4c 100644 (file)
@@ -1,35 +1,35 @@
-/*******************************************************************************\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
+/*******************************************************************************
+ *  Copyright (c) 2010 Association for Decentralized Information Management in
+ *  Industry THTH ry.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ *
+ *  Contributors:
+ *      VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
 package org.simantics.databoard.accessor.java;
 
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.accessor.Accessor;\r
-import org.simantics.databoard.accessor.ByteAccessor;\r
-import org.simantics.databoard.accessor.error.AccessorConstructionException;\r
-import org.simantics.databoard.accessor.error.AccessorException;\r
-import org.simantics.databoard.accessor.error.ReferenceException;\r
-import org.simantics.databoard.accessor.event.Event;\r
-import org.simantics.databoard.accessor.event.ValueAssigned;\r
-import org.simantics.databoard.accessor.impl.AccessorParams;\r
-import org.simantics.databoard.accessor.impl.ListenerEntry;\r
-import org.simantics.databoard.accessor.interestset.ByteInterestSet;\r
-import org.simantics.databoard.accessor.reference.ChildReference;\r
-import org.simantics.databoard.binding.ArrayBinding;\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.binding.ByteBinding;\r
-import org.simantics.databoard.binding.RecordBinding;\r
-import org.simantics.databoard.binding.VariantBinding;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.type.ByteType;\r
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.accessor.Accessor;
+import org.simantics.databoard.accessor.ByteAccessor;
+import org.simantics.databoard.accessor.error.AccessorConstructionException;
+import org.simantics.databoard.accessor.error.AccessorException;
+import org.simantics.databoard.accessor.error.ReferenceException;
+import org.simantics.databoard.accessor.event.Event;
+import org.simantics.databoard.accessor.event.ValueAssigned;
+import org.simantics.databoard.accessor.impl.AccessorParams;
+import org.simantics.databoard.accessor.impl.ListenerEntry;
+import org.simantics.databoard.accessor.interestset.ByteInterestSet;
+import org.simantics.databoard.accessor.reference.ChildReference;
+import org.simantics.databoard.binding.ArrayBinding;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.ByteBinding;
+import org.simantics.databoard.binding.RecordBinding;
+import org.simantics.databoard.binding.VariantBinding;
+import org.simantics.databoard.binding.error.BindingException;
+import org.simantics.databoard.type.ByteType;
 
 /**
  * Accessor to a Java Object that contains a Byte Type. 
@@ -52,45 +52,45 @@ public class JavaByte extends JavaObject implements ByteAccessor {
        }
 
        @Override
-       public byte getValue() throws AccessorException {\r
+       public byte getValue() throws AccessorException {
                readLock();
                try {
                        return getBinding().getValue_(object);
                } catch (BindingException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       readUnlock();\r
+               } finally {
+                       readUnlock();
                }
-       }\r
+       }
        
        @Override
        public void setValue(byte newValue) throws AccessorException {
-               if (newValue == getValue()) return;\r
-               writeLock();\r
+               if (newValue == getValue()) return;
+               writeLock();
                try {
-                       if (binding.isImmutable() && parent!=null && parent instanceof JavaArray) {\r
-                               JavaObject jo = (JavaObject) parent;\r
-                               ArrayBinding ab = (ArrayBinding) jo.binding;\r
-                               Object nv = getBinding().create(newValue);\r
-                               ab.set(jo.object, (Integer)keyInParent, nv);\r
-                               this.object = nv;\r
-                       } else if (binding.isImmutable() && parent!=null && parent instanceof JavaRecord) {\r
-                               JavaObject jo = (JavaObject) parent;\r
-                               RecordBinding rb = (RecordBinding) jo.binding;\r
-                               Object nv = getBinding().create(newValue);\r
-                               rb.setComponent(jo.object, (Integer)keyInParent, nv);\r
-                               this.object = nv;\r
-                       } else if (binding.isImmutable() && parent!=null && parent instanceof JavaVariant) {\r
-                               JavaObject jo = (JavaObject) parent;\r
-                               VariantBinding vb = (VariantBinding) jo.binding;\r
-                               Object nv = getBinding().create(newValue);\r
-                               vb.setContent(jo.object, getBinding(), nv);\r
-                               this.object = nv;\r
-                       } else {                        \r
-                               // Set value\r
-                               getBinding().setValue(object, newValue);\r
-                       }\r
-\r
+                       if (binding.isImmutable() && parent!=null && parent instanceof JavaArray) {
+                               JavaObject jo = (JavaObject) parent;
+                               ArrayBinding ab = (ArrayBinding) jo.binding;
+                               Object nv = getBinding().create(newValue);
+                               ab.set(jo.object, (Integer)keyInParent, nv);
+                               this.object = nv;
+                       } else if (binding.isImmutable() && parent!=null && parent instanceof JavaRecord) {
+                               JavaObject jo = (JavaObject) parent;
+                               RecordBinding rb = (RecordBinding) jo.binding;
+                               Object nv = getBinding().create(newValue);
+                               rb.setComponent(jo.object, (Integer)keyInParent, nv);
+                               this.object = nv;
+                       } else if (binding.isImmutable() && parent!=null && parent instanceof JavaVariant) {
+                               JavaObject jo = (JavaObject) parent;
+                               VariantBinding vb = (VariantBinding) jo.binding;
+                               Object nv = getBinding().create(newValue);
+                               vb.setContent(jo.object, getBinding(), nv);
+                               this.object = nv;
+                       } else {                        
+                               // Set value
+                               getBinding().setValue(object, newValue);
+                       }
+
                        
                        // Notify
                        ListenerEntry le = listeners;
@@ -105,13 +105,13 @@ public class JavaByte extends JavaObject implements ByteAccessor {
                        
                } catch (BindingException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
        }
 
        @Override
-       public void setValue(Binding binding, Object newValue) throws AccessorException {\r
+       public void setValue(Binding binding, Object newValue) throws AccessorException {
                try {
                        byte nv = ((ByteBinding)binding).getValue_(newValue);
                        setValue(nv);
@@ -130,15 +130,15 @@ public class JavaByte extends JavaObject implements ByteAccessor {
        }
 
        @Override
-       Event applyLocal(Event e, boolean makeRollback) throws AccessorException {\r
-               Event rollback = makeRollback ? new ValueAssigned( Bindings.BYTE, getValue() ) : null;          \r
-               if (e instanceof ValueAssigned) {\r
-                       ValueAssigned va = (ValueAssigned) e;\r
-                       if (va.newValue == null) throw new AccessorException("Byte value expected, got null");                  \r
-                       setValue(va.newValue.getBinding(), va.newValue.getValue());\r
-                       return rollback;\r
-               } else {\r
-                       throw new AccessorException("Cannot apply "+e.getClass().getName()+" to Byte");\r
+       Event applyLocal(Event e, boolean makeRollback) throws AccessorException {
+               Event rollback = makeRollback ? new ValueAssigned( Bindings.BYTE, getValue() ) : null;          
+               if (e instanceof ValueAssigned) {
+                       ValueAssigned va = (ValueAssigned) e;
+                       if (va.newValue == null) throw new AccessorException("Byte value expected, got null");                  
+                       setValue(va.newValue.getBinding(), va.newValue.getValue());
+                       return rollback;
+               } else {
+                       throw new AccessorException("Cannot apply "+e.getClass().getName()+" to Byte");
                }
        }