]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/java/JavaOptional.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / accessor / java / JavaOptional.java
index 8ec107c6f7df166c82b289d59212dd4250dd0d38..f6f3df943bb8a8c16bc963ce41e1545ebb7d1fbc 100644 (file)
@@ -1,42 +1,42 @@
-/*******************************************************************************\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 java.lang.ref.SoftReference;\r
-import java.util.concurrent.Executor;\r
-\r
-import org.simantics.databoard.accessor.Accessor;\r
-import org.simantics.databoard.accessor.OptionalAccessor;\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.OptionalValueAssigned;\r
-import org.simantics.databoard.accessor.event.OptionalValueRemoved;\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.InterestSet;\r
-import org.simantics.databoard.accessor.interestset.OptionalInterestSet;\r
-import org.simantics.databoard.accessor.reference.ChildReference;\r
-import org.simantics.databoard.accessor.reference.ComponentReference;\r
-import org.simantics.databoard.accessor.reference.LabelReference;\r
-import org.simantics.databoard.adapter.AdaptException;\r
-import org.simantics.databoard.adapter.AdapterConstructionException;\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.binding.OptionalBinding;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.binding.mutable.MutableVariant;\r
-import org.simantics.databoard.type.OptionalType;\r
+import java.lang.ref.SoftReference;
+import java.util.concurrent.Executor;
+
+import org.simantics.databoard.accessor.Accessor;
+import org.simantics.databoard.accessor.OptionalAccessor;
+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.OptionalValueAssigned;
+import org.simantics.databoard.accessor.event.OptionalValueRemoved;
+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.InterestSet;
+import org.simantics.databoard.accessor.interestset.OptionalInterestSet;
+import org.simantics.databoard.accessor.reference.ChildReference;
+import org.simantics.databoard.accessor.reference.ComponentReference;
+import org.simantics.databoard.accessor.reference.LabelReference;
+import org.simantics.databoard.adapter.AdaptException;
+import org.simantics.databoard.adapter.AdapterConstructionException;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.OptionalBinding;
+import org.simantics.databoard.binding.error.BindingException;
+import org.simantics.databoard.binding.mutable.MutableVariant;
+import org.simantics.databoard.type.OptionalType;
 
 public class JavaOptional extends JavaObject implements OptionalAccessor {
 
@@ -114,7 +114,7 @@ public class JavaOptional extends JavaObject implements OptionalAccessor {
        
        @Override
        public Object getComponentValue(Binding componentBinding)
-                       throws AccessorException {      \r
+                       throws AccessorException {      
                readLock();
                try {
                        if (!getBinding().hasValue(object))
@@ -127,10 +127,10 @@ public class JavaOptional extends JavaObject implements OptionalAccessor {
                        throw new AccessorException(e);
                } catch (AdaptException e) {
                        throw new AccessorException(e);
-               } catch (AdapterConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } finally {\r
-                       readUnlock();\r
+               } catch (AdapterConstructionException e) {
+                       throw new AccessorException(e);
+               } finally {
+                       readUnlock();
                }
        }
        
@@ -163,30 +163,30 @@ public class JavaOptional extends JavaObject implements OptionalAccessor {
        @SuppressWarnings("unchecked")
        @Override
        public <T extends Accessor> T getComponent(ChildReference reference) throws AccessorConstructionException {
-               if (reference==null) return (T) this;\r
-\r
-               if (reference instanceof LabelReference) {\r
-                       LabelReference lr = (LabelReference) reference;\r
-                       if (lr.label.equals("o")) {\r
-                               Accessor result = getComponentAccessor();\r
-                               if (reference.getChildReference() != null)\r
-                                       result = result.getComponent(reference.getChildReference());\r
-                               return (T) result;                      \r
-                       }                       \r
-               }\r
+               if (reference==null) return (T) this;
+
+               if (reference instanceof LabelReference) {
+                       LabelReference lr = (LabelReference) reference;
+                       if (lr.label.equals("o")) {
+                               Accessor result = getComponentAccessor();
+                               if (reference.getChildReference() != null)
+                                       result = result.getComponent(reference.getChildReference());
+                               return (T) result;                      
+                       }                       
+               }
                
                if (reference instanceof ComponentReference) {
                        Accessor result = getComponentAccessor();
                        if (reference.getChildReference() != null)
                                result = result.getComponent(reference.getChildReference());
                        return (T) result;                      
-               } \r
+               } 
                
                throw new ReferenceException(reference.getClass()+" is not a reference of OptionalType");               
        }
 
        @Override
-       public void setValue(Binding binding, Object newValue) throws AccessorException {\r
+       public void setValue(Binding binding, Object newValue) throws AccessorException {
                writeLock();
                try {
                        OptionalBinding rb = (OptionalBinding) binding;
@@ -203,26 +203,26 @@ public class JavaOptional extends JavaObject implements OptionalAccessor {
                        
                } catch (BindingException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
        }
 
        @Override
-       public boolean hasValue() throws AccessorException {\r
+       public boolean hasValue() throws AccessorException {
                readLock();
                try {
                        return getBinding().hasValue(object);
                } catch (BindingException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       readUnlock();\r
+               } finally {
+                       readUnlock();
                }
        }
 
 
        @Override
-       public void setNoValue() throws AccessorException {\r
+       public void setNoValue() throws AccessorException {
                writeLock();
                try {
                        boolean hadValue = getBinding().hasValue(object);
@@ -250,14 +250,14 @@ public class JavaOptional extends JavaObject implements OptionalAccessor {
                        
                } catch (BindingException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
        }
 
        @Override
        public void setComponentValue(Binding binding, Object value)
-                       throws AccessorException {\r
+                       throws AccessorException {
                writeLock();
                try {
                        Binding rcb = binding;
@@ -301,10 +301,10 @@ public class JavaOptional extends JavaObject implements OptionalAccessor {
                        throw new AccessorException(e);
                } catch (AdaptException e) {
                        throw new AccessorException(e);
-               } catch (AdapterConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } finally {\r
-                       writeUnlock();\r
+               } catch (AdapterConstructionException e) {
+                       throw new AccessorException(e);
+               } finally {
+                       writeUnlock();
                }
                
        }
@@ -318,11 +318,11 @@ public class JavaOptional extends JavaObject implements OptionalAccessor {
                                Binding cb = getBinding().getComponentBinding();                        
                                rollback = hasValue() ? new OptionalValueAssigned(cb, b.getValue(object)) : new OptionalValueRemoved(); 
                        }                       
-                       if (e instanceof ValueAssigned) {\r
-                               ValueAssigned va = (ValueAssigned) e;\r
-                               setValue(va.newValue.getBinding(), va.newValue.getValue());\r
-                               return rollback;\r
-                       } else          \r
+                       if (e instanceof ValueAssigned) {
+                               ValueAssigned va = (ValueAssigned) e;
+                               setValue(va.newValue.getBinding(), va.newValue.getValue());
+                               return rollback;
+                       } else          
                        if (e instanceof OptionalValueAssigned) {
                                OptionalValueAssigned oa = (OptionalValueAssigned) e;
                                if (oa.newValue==null) throw new AccessorException("Cannot apply field assignment event, the value is missing");