]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/binary/BinaryMap.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / accessor / binary / BinaryMap.java
index 0915acfc623824361d7225832bab0f6e9d8129ff..4a90524fb4f198c83d4abb153b70cb708e14f4eb 100644 (file)
@@ -1,58 +1,58 @@
-/*******************************************************************************\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.binary;
 
-import java.io.IOException;\r
-import java.lang.ref.SoftReference;\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-import java.util.concurrent.Executor;\r
-\r
-import org.simantics.databoard.accessor.Accessor;\r
-import org.simantics.databoard.accessor.MapAccessor;\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.MapEntryAdded;\r
-import org.simantics.databoard.accessor.event.MapEntryRemoved;\r
-import org.simantics.databoard.accessor.event.ValueAssigned;\r
-import org.simantics.databoard.accessor.file.FileMapAccessor;\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.MapInterestSet;\r
-import org.simantics.databoard.accessor.reference.ChildReference;\r
-import org.simantics.databoard.accessor.reference.KeyReference;\r
-import org.simantics.databoard.accessor.reference.LabelReference;\r
-import org.simantics.databoard.adapter.AdaptException;\r
-import org.simantics.databoard.adapter.Adapter;\r
-import org.simantics.databoard.adapter.AdapterConstructionException;\r
-import org.simantics.databoard.binding.ArrayBinding;\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.binding.MapBinding;\r
-import org.simantics.databoard.binding.error.BindingConstructionException;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.binding.mutable.MutableVariant;\r
-import org.simantics.databoard.parser.repository.DataTypeSyntaxError;\r
-import org.simantics.databoard.parser.repository.DataValueRepository;\r
-import org.simantics.databoard.serialization.RuntimeSerializerConstructionException;\r
-import org.simantics.databoard.serialization.SerializationException;\r
-import org.simantics.databoard.serialization.Serializer;\r
-import org.simantics.databoard.serialization.SerializerConstructionException;\r
-import org.simantics.databoard.type.Datatype;\r
-import org.simantics.databoard.type.MapType;\r
-import org.simantics.databoard.util.binary.Blob;\r
-import org.simantics.databoard.util.binary.RandomAccessBinary.ByteSide;\r
+import java.io.IOException;
+import java.lang.ref.SoftReference;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.Executor;
+
+import org.simantics.databoard.accessor.Accessor;
+import org.simantics.databoard.accessor.MapAccessor;
+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.MapEntryAdded;
+import org.simantics.databoard.accessor.event.MapEntryRemoved;
+import org.simantics.databoard.accessor.event.ValueAssigned;
+import org.simantics.databoard.accessor.file.FileMapAccessor;
+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.MapInterestSet;
+import org.simantics.databoard.accessor.reference.ChildReference;
+import org.simantics.databoard.accessor.reference.KeyReference;
+import org.simantics.databoard.accessor.reference.LabelReference;
+import org.simantics.databoard.adapter.AdaptException;
+import org.simantics.databoard.adapter.Adapter;
+import org.simantics.databoard.adapter.AdapterConstructionException;
+import org.simantics.databoard.binding.ArrayBinding;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.MapBinding;
+import org.simantics.databoard.binding.error.BindingConstructionException;
+import org.simantics.databoard.binding.error.BindingException;
+import org.simantics.databoard.binding.mutable.MutableVariant;
+import org.simantics.databoard.parser.repository.DataTypeSyntaxError;
+import org.simantics.databoard.parser.repository.DataValueRepository;
+import org.simantics.databoard.serialization.RuntimeSerializerConstructionException;
+import org.simantics.databoard.serialization.SerializationException;
+import org.simantics.databoard.serialization.Serializer;
+import org.simantics.databoard.serialization.SerializerConstructionException;
+import org.simantics.databoard.type.Datatype;
+import org.simantics.databoard.type.MapType;
+import org.simantics.databoard.util.binary.Blob;
+import org.simantics.databoard.util.binary.RandomAccessBinary.ByteSide;
 
 /**
  * BinaryMap is accessor to a map structure in a file or byte memory.
@@ -195,7 +195,7 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                return higherChildEntry(key);
        }
        
-       Entry getEntryAt(long pos) throws SerializationException, IOException, BindingException {\r
+       Entry getEntryAt(long pos) throws SerializationException, IOException, BindingException {
                Object k = getKeyAt(pos);
                if (k==null) return null;
                return new Entry(k, pos, getChild(k));
@@ -215,22 +215,22 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
        }
 
        @Override
-       public void clear() throws AccessorException {\r
-               assert b.isOpen();\r
+       public void clear() throws AccessorException {
+               assert b.isOpen();
                writeLock();
                try {
                        clearNoflush();
                        b.flush();
                } catch (IOException e) {
                        throw new AccessorException( e );
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
        }       
 
        @Override
-       public int size() throws AccessorException {\r
-               assert b.isOpen();\r
+       public int size() throws AccessorException {
+               assert b.isOpen();
                readLock();
                try {
                        if (constantSize != null) return (int) ((b.length()-4) / constantSize);
@@ -238,15 +238,15 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        return b.readInt();
                } catch (IOException e) {
                        throw new AccessorException( e );
-               } finally {\r
-                       readUnlock();\r
+               } finally {
+                       readUnlock();
                }
        }       
 
        @Override
        public boolean containsKey(Binding keyBinding, Object key)
-                       throws AccessorException {\r
-               assert b.isOpen();\r
+                       throws AccessorException {
+               assert b.isOpen();
                readLock();
                try {
                        Object lk = adapt(key, keyBinding, kb);
@@ -254,17 +254,17 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        return e != null;
                } 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();
                }
        }
 
        @Override
        public boolean containsValue(Binding valueBinding, Object value)
-                       throws AccessorException {              \r
-               assert b.isOpen();\r
+                       throws AccessorException {              
+               assert b.isOpen();
                readLock();
                try {
                        Serializer vs = params.serializerScheme.getSerializer( valueBinding );
@@ -277,18 +277,18 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        }
                } catch (IOException e) {
                        throw new AccessorException(e);
-               } catch (SerializerConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } finally {\r
-                       readUnlock();\r
+               } catch (SerializerConstructionException e) {
+                       throw new AccessorException(e);
+               } finally {
+                       readUnlock();
                }
                return false;
        }
 
        @Override
        public Object get(Binding keyBinding, Object key, Binding valueBinding)
-                       throws AccessorException {\r
-               assert b.isOpen();\r
+                       throws AccessorException {
+               assert b.isOpen();
                readLock();
                try {
                        Object lk = adapt(key, keyBinding, kb);
@@ -304,19 +304,19 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        throw new AccessorException(e);
                } catch (RuntimeSerializerConstructionException e) {
                        throw new AccessorException(e);
-               } catch (AdapterConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } catch (SerializerConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } finally {\r
-                       readUnlock();\r
+               } catch (AdapterConstructionException e) {
+                       throw new AccessorException(e);
+               } catch (SerializerConstructionException e) {
+                       throw new AccessorException(e);
+               } finally {
+                       readUnlock();
                }
        }
 
        @Override
        public void getAll(Binding keyBinding, Binding valueBinding,
                        Map<Object, Object> to) throws AccessorException {
-               assert b.isOpen();\r
+               assert b.isOpen();
                readLock();
                try {
                        Adapter ka = params.adapterScheme.getAdapter(kb, keyBinding, true, false);
@@ -337,8 +337,8 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        throw new AccessorException(e);
                } catch (AdaptException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       readUnlock();\r
+               } finally {
+                       readUnlock();
                }
                
        }
@@ -346,7 +346,7 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
        @Override
        public void getAll(Binding keyBinding, Binding valueBinding, Object[] keys,
                        Object[] values) throws AccessorException {
-               assert b.isOpen();\r
+               assert b.isOpen();
                readLock();
                try {
                        Adapter ka = params.adapterScheme.getAdapter(kb, keyBinding, true, false);
@@ -370,154 +370,154 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        throw new AccessorException(e);
                } catch (AdaptException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       readUnlock();\r
+               } finally {
+                       readUnlock();
                }
                
-       }\r
-       \r
-       @Override\r
-       public int count(Binding keyBinding, Object from, boolean fromInclusive,\r
-                       Object end, boolean endInclusive) throws AccessorException {\r
-               assert b.isOpen();\r
-               readLock();\r
-               try {\r
-                       Object lf = params.adapterScheme.adapt(from, keyBinding, kb);\r
-                       Object le = params.adapterScheme.adapt(end, keyBinding, kb);\r
-                       \r
-                       Entry fromEntry = fromInclusive ? index.ceiling(lf) : index.higher(lf);\r
-                       Entry endEntry  = endInclusive  ? index.floor(le)   : index.lower(le);\r
-                       if (endEntry==null || fromEntry == null) return 0;\r
-\r
-                       if (fromEntry.pos>endEntry.pos) return 0;\r
-                       if (fromEntry.pos==endEntry.pos) return 1;\r
-                                               \r
-                       if (constantSize != null) {\r
-                               return (int) ((endEntry.pos-fromEntry.pos)/constantSize)+1;\r
-                       }\r
-                       \r
-                       int result = 1;\r
-                       b.position(fromEntry.pos);\r
-                       while (b.position()<endEntry.pos) {\r
-                               ks.skip(b);\r
-                               vs.skip(b);\r
-                               result++;\r
-                       }\r
-                       return result;                  \r
-               } catch (IOException e) {\r
-                       throw new AccessorException(e);\r
-               } catch (AdaptException e) {\r
-                       throw new AccessorException(e);\r
-               } finally {\r
-                       readUnlock();\r
-               }\r
-       }\r
-       \r
-       @Override\r
-       public int getEntries(Binding keyBinding, Object from,\r
-                       boolean fromInclusive, Object end, boolean endInclusive,\r
-                       ArrayBinding keyArrayBinding, Object keysArray,\r
-                       ArrayBinding valueArrayBinding, Object valueArray, int limit)\r
-                       throws AccessorException {\r
-               assert b.isOpen();\r
-               readLock();\r
-               try {\r
-                       Object lf = params.adapterScheme.adapt(from, keyBinding, kb);\r
-                       Object le = params.adapterScheme.adapt(end, keyBinding, kb);\r
-                       \r
-                       Entry fromEntry = fromInclusive ? index.ceiling(lf) : index.higher(lf);\r
-                       Entry endEntry  = endInclusive  ? index.floor(le)   : index.lower(le);\r
-                       if (endEntry==null || fromEntry == null) return 0;\r
-                       \r
-                       // Requester's Key & Value Binding\r
-                       Binding rkb   = keyArrayBinding.getComponentBinding();\r
-                       Binding rvb   = valueArrayBinding.getComponentBinding();\r
-                       \r
-                       // Local Key & Value type & bindings\r
-                       Datatype lkt  = type().keyType;\r
-                       Datatype lvt  = type().valueType;\r
-                       \r
-                       boolean adaptKey   = !rkb.type().equals(lkt);\r
-                       boolean adaptValue = !rvb.type().equals(lvt);\r
-                       \r
-                       Serializer ks, vs;\r
-                       Adapter ka = null, va = null;\r
-                       \r
-                       if (adaptKey) {\r
-                               Binding lkb   = params.bindingScheme.getBinding( lkt );\r
-                               ka = params.adapterScheme.getAdapter( lkb, rkb, true, false);\r
-                               ks = params.serializerScheme.getSerializer( lkb );\r
-                       } else {\r
-                               ks = params.serializerScheme.getSerializer( rkb );                              \r
-                       }\r
-                       \r
-                       if (adaptValue) {\r
-                               Binding lvb   = params.bindingScheme.getBinding( lvt );\r
-                               va = params.adapterScheme.getAdapter( lvb, rvb, true, false);\r
-                               vs = params.serializerScheme.getSerializer( lvb );\r
-                       } else {\r
-                               vs = params.serializerScheme.getSerializer( rvb );\r
-                       }                       \r
-                       \r
-                       int i = 0;\r
-                       int kac = keyArrayBinding.size( keysArray );\r
-                       int vac = valueArrayBinding.size( valueArray ); \r
-                       b.position(fromEntry.pos);\r
-                       while (b.position()<=endEntry.pos) {\r
-                               if (limit>=0 && i>=limit) break;\r
-                               Object key = ks.deserialize(b);\r
-                               if (adaptKey) key = ka.adapt(key);\r
-                               Object value = vs.deserialize(b);\r
-                               if (adaptValue) value = va.adapt(value);\r
-                               \r
-                               if (i<kac) keyArrayBinding.set(keysArray, i, key); else keyArrayBinding.add(keysArray, i, key);\r
-                               if (i<vac) valueArrayBinding.set(valueArray, i, value); else valueArrayBinding.add(valueArray, i, value);\r
-                               \r
-                               i++;\r
-                       }\r
-                       return i;                       \r
-               } catch (IOException e) {\r
-                       throw new AccessorException(e);\r
-               } catch (AdaptException e) {\r
-                       throw new AccessorException(e);\r
-               } catch (SerializerConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } catch (BindingException e) {\r
-                       throw new AccessorException(e);\r
-               } catch (BindingConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } catch (AdapterConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } finally {\r
-                       readUnlock();\r
-               }\r
+       }
+       
+       @Override
+       public int count(Binding keyBinding, Object from, boolean fromInclusive,
+                       Object end, boolean endInclusive) throws AccessorException {
+               assert b.isOpen();
+               readLock();
+               try {
+                       Object lf = params.adapterScheme.adapt(from, keyBinding, kb);
+                       Object le = params.adapterScheme.adapt(end, keyBinding, kb);
+                       
+                       Entry fromEntry = fromInclusive ? index.ceiling(lf) : index.higher(lf);
+                       Entry endEntry  = endInclusive  ? index.floor(le)   : index.lower(le);
+                       if (endEntry==null || fromEntry == null) return 0;
+
+                       if (fromEntry.pos>endEntry.pos) return 0;
+                       if (fromEntry.pos==endEntry.pos) return 1;
+                                               
+                       if (constantSize != null) {
+                               return (int) ((endEntry.pos-fromEntry.pos)/constantSize)+1;
+                       }
+                       
+                       int result = 1;
+                       b.position(fromEntry.pos);
+                       while (b.position()<endEntry.pos) {
+                               ks.skip(b);
+                               vs.skip(b);
+                               result++;
+                       }
+                       return result;                  
+               } catch (IOException e) {
+                       throw new AccessorException(e);
+               } catch (AdaptException e) {
+                       throw new AccessorException(e);
+               } finally {
+                       readUnlock();
+               }
+       }
+       
+       @Override
+       public int getEntries(Binding keyBinding, Object from,
+                       boolean fromInclusive, Object end, boolean endInclusive,
+                       ArrayBinding keyArrayBinding, Object keysArray,
+                       ArrayBinding valueArrayBinding, Object valueArray, int limit)
+                       throws AccessorException {
+               assert b.isOpen();
+               readLock();
+               try {
+                       Object lf = params.adapterScheme.adapt(from, keyBinding, kb);
+                       Object le = params.adapterScheme.adapt(end, keyBinding, kb);
+                       
+                       Entry fromEntry = fromInclusive ? index.ceiling(lf) : index.higher(lf);
+                       Entry endEntry  = endInclusive  ? index.floor(le)   : index.lower(le);
+                       if (endEntry==null || fromEntry == null) return 0;
+                       
+                       // Requester's Key & Value Binding
+                       Binding rkb   = keyArrayBinding.getComponentBinding();
+                       Binding rvb   = valueArrayBinding.getComponentBinding();
+                       
+                       // Local Key & Value type & bindings
+                       Datatype lkt  = type().keyType;
+                       Datatype lvt  = type().valueType;
+                       
+                       boolean adaptKey   = !rkb.type().equals(lkt);
+                       boolean adaptValue = !rvb.type().equals(lvt);
+                       
+                       Serializer ks, vs;
+                       Adapter ka = null, va = null;
+                       
+                       if (adaptKey) {
+                               Binding lkb   = params.bindingScheme.getBinding( lkt );
+                               ka = params.adapterScheme.getAdapter( lkb, rkb, true, false);
+                               ks = params.serializerScheme.getSerializer( lkb );
+                       } else {
+                               ks = params.serializerScheme.getSerializer( rkb );                              
+                       }
+                       
+                       if (adaptValue) {
+                               Binding lvb   = params.bindingScheme.getBinding( lvt );
+                               va = params.adapterScheme.getAdapter( lvb, rvb, true, false);
+                               vs = params.serializerScheme.getSerializer( lvb );
+                       } else {
+                               vs = params.serializerScheme.getSerializer( rvb );
+                       }                       
+                       
+                       int i = 0;
+                       int kac = keyArrayBinding.size( keysArray );
+                       int vac = valueArrayBinding.size( valueArray ); 
+                       b.position(fromEntry.pos);
+                       while (b.position()<=endEntry.pos) {
+                               if (limit>=0 && i>=limit) break;
+                               Object key = ks.deserialize(b);
+                               if (adaptKey) key = ka.adapt(key);
+                               Object value = vs.deserialize(b);
+                               if (adaptValue) value = va.adapt(value);
+                               
+                               if (i<kac) keyArrayBinding.set(keysArray, i, key); else keyArrayBinding.add(keysArray, i, key);
+                               if (i<vac) valueArrayBinding.set(valueArray, i, value); else valueArrayBinding.add(valueArray, i, value);
+                               
+                               i++;
+                       }
+                       return i;                       
+               } catch (IOException e) {
+                       throw new AccessorException(e);
+               } catch (AdaptException e) {
+                       throw new AccessorException(e);
+               } catch (SerializerConstructionException e) {
+                       throw new AccessorException(e);
+               } catch (BindingException e) {
+                       throw new AccessorException(e);
+               } catch (BindingConstructionException e) {
+                       throw new AccessorException(e);
+               } catch (AdapterConstructionException e) {
+                       throw new AccessorException(e);
+               } finally {
+                       readUnlock();
+               }
        }       
 
        @Override
        public Object getCeilingKey(Binding keyBinding, Object key)
-                       throws AccessorException {\r
-               assert b.isOpen();\r
+                       throws AccessorException {
+               assert b.isOpen();
                readLock();
                try {
                        Object lk = adapt(key, keyBinding, kb);
-                       if (ks.getConstantSize()!=null) {\r
-                               if (getChild(lk)!=null) return key;\r
+                       if (ks.getConstantSize()!=null) {
+                               if (getChild(lk)!=null) return key;
                        }
                        Entry e = index.ceiling(lk);
                        if (e==null) return null;
                        return adapt(e.key, kb, keyBinding);
                } catch (AdaptException e1) {
                        throw new AccessorException( e1 );
-               } catch (AdapterConstructionException e) {\r
-                       throw new AccessorException( e );\r
-               } finally {\r
-                       readUnlock();\r
+               } catch (AdapterConstructionException e) {
+                       throw new AccessorException( e );
+               } finally {
+                       readUnlock();
                }
        }
 
        @Override
-       public Object getFirstKey(Binding keyBinding) throws AccessorException {\r
-               assert b.isOpen();\r
+       public Object getFirstKey(Binding keyBinding) throws AccessorException {
+               assert b.isOpen();
                readLock();
                try {
                        b.position(0L);
@@ -528,21 +528,21 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        throw new AccessorException(e);
                } catch (IOException e) {
                        throw new AccessorException(e);
-               } catch (SerializerConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } finally {\r
-                       readUnlock();\r
+               } catch (SerializerConstructionException e) {
+                       throw new AccessorException(e);
+               } finally {
+                       readUnlock();
                }
        }
 
        @Override
        public Object getFloorKey(Binding keyBinding, Object key)
-                       throws AccessorException {\r
-               assert b.isOpen();\r
+                       throws AccessorException {
+               assert b.isOpen();
                readLock();
                try {
                        Object lk = adapt(key, keyBinding, kb);
-                       if (ks.getConstantSize()!=null) {\r
+                       if (ks.getConstantSize()!=null) {
                                // See if we get exact match
                                if (getChild(lk)!=null) return key;
                        }
@@ -551,17 +551,17 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        return adapt(e.key, kb, keyBinding);
                } catch (AdaptException e1) {
                        throw new AccessorException( e1 );
-               } catch (AdapterConstructionException e) {\r
-                       throw new AccessorException( e );\r
-               } finally {\r
-                       readUnlock();\r
+               } catch (AdapterConstructionException e) {
+                       throw new AccessorException( e );
+               } finally {
+                       readUnlock();
                }
        }
 
        @Override
        public Object getHigherKey(Binding keyBinding, Object key)
-                       throws AccessorException {\r
-               assert b.isOpen();\r
+                       throws AccessorException {
+               assert b.isOpen();
                readLock();
                try {
                        Object lk = adapt(key, keyBinding, kb);
@@ -570,16 +570,16 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        return adapt(e.key, kb, keyBinding);
                } catch (AdaptException e1) {
                        throw new AccessorException( e1 );
-               } catch (AdapterConstructionException e) {\r
-                       throw new AccessorException( e );\r
-               } finally {\r
-                       readUnlock();\r
+               } catch (AdapterConstructionException e) {
+                       throw new AccessorException( e );
+               } finally {
+                       readUnlock();
                }
        }
 
        @Override
-       public Object[] getKeys(Binding keyBinding) throws AccessorException {\r
-               assert b.isOpen();\r
+       public Object[] getKeys(Binding keyBinding) throws AccessorException {
+               assert b.isOpen();
                readLock();
                try {
                        Adapter ka = params.adapterScheme.getAdapter(kb, keyBinding, true, false);
@@ -599,14 +599,14 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        throw new AccessorException(e);
                } catch (AdaptException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       readUnlock();\r
+               } finally {
+                       readUnlock();
                }
        }
 
        @Override
-       public Object getLastKey(Binding keyBinding) throws AccessorException {\r
-               assert b.isOpen();\r
+       public Object getLastKey(Binding keyBinding) throws AccessorException {
+               assert b.isOpen();
                readLock();
                try {
                        Entry e = index.last();
@@ -614,17 +614,17 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        return adapt(e.key, kb, keyBinding);
                } catch (AdaptException e1) {
                        throw new AccessorException( e1 );
-               } catch (AdapterConstructionException e) {\r
-                       throw new AccessorException( e );\r
-               } finally {\r
-                       readUnlock();\r
+               } catch (AdapterConstructionException e) {
+                       throw new AccessorException( e );
+               } finally {
+                       readUnlock();
                }
        }
 
        @Override
        public Object getLowerKey(Binding keyBinding, Object key)
-                       throws AccessorException {\r
-               assert b.isOpen();\r
+                       throws AccessorException {
+               assert b.isOpen();
                readLock();
                try {
                        Object lk = adapt(key, keyBinding, kb);
@@ -633,10 +633,10 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        return adapt(e.key, kb, keyBinding);
                } catch (AdaptException e1) {
                        throw new AccessorException( e1 );
-               } catch (AdapterConstructionException e) {\r
-                       throw new AccessorException( e );\r
-               } finally {\r
-                       readUnlock();\r
+               } catch (AdapterConstructionException e) {
+                       throw new AccessorException( e );
+               } finally {
+                       readUnlock();
                }
        }
 
@@ -645,24 +645,24 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
        @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
-                       try {\r
-                               DataValueRepository rep = new DataValueRepository(); \r
-                               kb.parseValue(lr.label, rep);\r
-                               Object value = rep.get( rep.getValueNames().iterator().next() );\r
-                               \r
-                               Accessor result = (T) getValueAccessor(kb, value);\r
-                               if (reference.getChildReference() != null)\r
-                                       result = result.getComponent(reference.getChildReference());\r
-                               return (T) result;                      \r
-                       } catch ( BindingException e1 ) {\r
-                               throw new ReferenceException(e1);                               \r
-                       } catch ( DataTypeSyntaxError e2 ) {\r
-                               throw new ReferenceException(e2);                               \r
-                       }                       \r
+               if (reference==null) return (T) this;
+               
+               if (reference instanceof LabelReference) {
+                       LabelReference lr = (LabelReference) reference;
+                       try {
+                               DataValueRepository rep = new DataValueRepository(); 
+                               kb.parseValue(lr.label, rep);
+                               Object value = rep.get( rep.getValueNames().iterator().next() );
+                               
+                               Accessor result = (T) getValueAccessor(kb, value);
+                               if (reference.getChildReference() != null)
+                                       result = result.getComponent(reference.getChildReference());
+                               return (T) result;                      
+                       } catch ( BindingException e1 ) {
+                               throw new ReferenceException(e1);                               
+                       } catch ( DataTypeSyntaxError e2 ) {
+                               throw new ReferenceException(e2);                               
+                       }                       
                } else          
                if (reference instanceof KeyReference) {
                        KeyReference ref = (KeyReference) reference;
@@ -677,8 +677,8 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
        @Override
        public <T extends Accessor> T getValueAccessor(Binding keyBinding,
                        Object key) throws AccessorConstructionException {
-               \r
-               assert b.isOpen();\r
+               
+               assert b.isOpen();
                readLock();
                try {                   
                        Object rk = key;
@@ -755,16 +755,16 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        throw new AccessorConstructionException(e);
                } catch (AccessorException e) {
                        throw new AccessorConstructionException(e);
-               } finally {\r
-                       readUnlock();\r
+               } finally {
+                       readUnlock();
                }
        }
        
        @Override
-       public Object[] getValues(Binding valueBinding) throws AccessorException {\r
-               assert b.isOpen();\r
+       public Object[] getValues(Binding valueBinding) throws AccessorException {
+               assert b.isOpen();
                readLock();
-               try {\r
+               try {
                        Serializer rvs = params.serializerScheme.getSerializer(valueBinding);
                        b.position(0L);
                        int count = b.readInt();
@@ -776,19 +776,19 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        return result;
                } catch (IOException e) {
                        throw new AccessorException( e );
-               } catch (SerializerConstructionException e) {\r
-                       throw new AccessorException( e );\r
-               } finally {\r
-                       readUnlock();\r
+               } catch (SerializerConstructionException e) {
+                       throw new AccessorException( e );
+               } finally {
+                       readUnlock();
                }
        }
 
        @Override
        public void setValueNoflush(Binding binding, Object mapValue)
                        throws AccessorException {              
-               assert b.isOpen();\r
+               assert b.isOpen();
                MapBinding mb = (MapBinding) binding;
-               if (children.isEmpty() && listeners==null) {\r
+               if (children.isEmpty() && listeners==null) {
                        writeLock();
                        try {
                                // Write
@@ -800,13 +800,13 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                                s.serialize(b, null, mapValue);                 
                        } catch (IOException e) {
                                throw new AccessorException( e );
-                       } catch (SerializerConstructionException e) {\r
-                               throw new AccessorException( e );\r
-                       } finally {\r
-                               writeUnlock();\r
+                       } catch (SerializerConstructionException e) {
+                               throw new AccessorException( e );
+                       } finally {
+                               writeUnlock();
                        }
                } else {
-\r
+
                        writeLock();
                        try {
                                int nc = mb.size(mapValue);
@@ -816,8 +816,8 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                                setAllNoflush(mb.getKeyBinding(), mb.getValueBinding(), nks, nvs);
                        } catch (BindingException e) {
                                throw new AccessorException(e);
-                       } finally {\r
-                               writeUnlock();\r
+                       } finally {
+                               writeUnlock();
                        }
                        
                }
@@ -826,7 +826,7 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
 
        @Override
        public void clearNoflush() throws AccessorException {
-               assert b.isOpen();\r
+               assert b.isOpen();
                writeLock();
                try {
                        boolean hasListeners = listeners!=null;
@@ -862,8 +862,8 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        
                } catch (IOException e) {
                        throw new AccessorException( e );
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
                
        }
@@ -893,26 +893,26 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        if (!hadPreviousValue) newItemsCount++;
                }
 
-               if (newItemsCount>0) {\r
-                       assert b.isOpen();\r
+               if (newItemsCount>0) {
+                       assert b.isOpen();
                        writeLock();
                        try {
                                b.position(0L);
                                int oldCount = b.readInt();
-                               b.position(0L);\r
+                               b.position(0L);
                                b.writeInt( oldCount + newItemsCount);                  
                        } catch (IOException e) {
                                throw new AccessorException(e);
-                       } finally {\r
-                               writeUnlock();\r
+                       } finally {
+                               writeUnlock();
                        }
                }
        
        }
        
        public void setAllNoflush(Binding kb, Binding vb,
-                       Object[] nks, Object[] nvs) throws AccessorException {\r
-               assert b.isOpen();\r
+                       Object[] nks, Object[] nvs) throws AccessorException {
+               assert b.isOpen();
                writeLock();
                try {
                        Serializer ks = params.serializerScheme.getSerializer( kb );
@@ -1036,7 +1036,7 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                                ks.serialize(b, null, nk);
                                vs.serialize(b, null, nv);
                                long endPos = b.position();
-                               long len = endPos - startPos;\r
+                               long len = endPos - startPos;
                                Object lk = params.adapterScheme.adapt(nk, kb, this.kb);
                                BinaryObject sa = getChild(lk);
                                if (sa!=null) sa.b.setPositionInSource(startPos, len);                                  
@@ -1047,18 +1047,18 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        throw new AccessorException(e);
                } catch (AdaptException e) {
                        throw new AccessorException(e);
-               } catch (SerializerConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } finally {\r
-                       writeUnlock();\r
+               } catch (SerializerConstructionException e) {
+                       throw new AccessorException(e);
+               } finally {
+                       writeUnlock();
                }
        }
 
        
        @Override
        public void putNoflush(Binding kb, Object key,
-                       Binding vb, Object value) throws AccessorException {\r
-               assert b.isOpen();\r
+                       Binding vb, Object value) throws AccessorException {
+               assert b.isOpen();
                writeLock();
                try {
                        boolean hadPreviousEntry = _putNoflush(kb, key, vb, value);
@@ -1073,8 +1073,8 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        throw new AccessorException(e);
                } catch (RuntimeSerializerConstructionException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
        }
        
@@ -1092,7 +1092,7 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        Binding vb, Object value) throws AccessorException {
                writeLock();
                try {
-                       Object lk = adapt(key, kb, this.kb);\r
+                       Object lk = adapt(key, kb, this.kb);
                        long insertPos = index.getInsertPos(lk);
                        Serializer ks = params.serializerScheme.getSerializer( kb );
                        Serializer vs = params.serializerScheme.getSerializer( vb );                    
@@ -1197,20 +1197,20 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        throw new AccessorException(e);
                } catch (RuntimeSerializerConstructionException e) {
                        throw new AccessorException(e);
-               } catch (AdapterConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } catch (SerializerConstructionException e) {\r
-                       throw new AccessorException(e);\r
-               } finally {\r
-                       writeUnlock();\r
+               } catch (AdapterConstructionException e) {
+                       throw new AccessorException(e);
+               } catch (SerializerConstructionException e) {
+                       throw new AccessorException(e);
+               } finally {
+                       writeUnlock();
                }
                
        }
 
        @Override
        public void removeNoflush(Binding keyBinding, Object key)
-                       throws AccessorException {\r
-               assert b.isOpen();\r
+                       throws AccessorException {
+               assert b.isOpen();
                writeLock();
                try {
                        Object lk = params.adapterScheme.getAdapter(keyBinding, kb, true, listeners!=null).adapt(key);
@@ -1253,8 +1253,8 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        throw new AccessorException(e);
                } catch (AdapterConstructionException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
        }
        
@@ -1311,18 +1311,18 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
        Event applyLocal(Event e, boolean makeRollback) throws AccessorException {
                Event rollback = null;
                
-               if (e instanceof ValueAssigned) {\r
-                       try {\r
-                               ValueAssigned va = (ValueAssigned) e;\r
-                               if (makeRollback) {\r
-                                       Binding binding = params.bindingScheme.getBinding(type());\r
-                                       rollback = new ValueAssigned(binding, getValue(binding));                               \r
-                               }\r
-                               setValueNoflush(va.newValue.getBinding(), va.newValue.getValue());\r
-                               return rollback;\r
-                       } catch (BindingConstructionException e1) {\r
-                               throw new AccessorException( e1 );\r
-                       }\r
+               if (e instanceof ValueAssigned) {
+                       try {
+                               ValueAssigned va = (ValueAssigned) e;
+                               if (makeRollback) {
+                                       Binding binding = params.bindingScheme.getBinding(type());
+                                       rollback = new ValueAssigned(binding, getValue(binding));                               
+                               }
+                               setValueNoflush(va.newValue.getBinding(), va.newValue.getValue());
+                               return rollback;
+                       } catch (BindingConstructionException e1) {
+                               throw new AccessorException( e1 );
+                       }
                } else if (e instanceof MapEntryAdded) {
                        MapEntryAdded ea = (MapEntryAdded) e;
                        if (ea.key==null) throw new AccessorException("Cannot apply entry added event because key is missing");
@@ -1335,7 +1335,7 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        }
                        
                        putNoflush(ea.key.getBinding(), ea.key.getValue(), ea.value.getBinding(), ea.value.getValue());
-                       return rollback;\r
+                       return rollback;
                        
                } else if (e instanceof MapEntryRemoved) {
                        MapEntryRemoved er = (MapEntryRemoved) e;
@@ -1354,10 +1354,10 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                        }
                        
                        removeNoflush( er.key.getBinding(), er.key.getValue() );
-                       return rollback;\r
+                       return rollback;
                        
-               } else {\r
-                       throw new AccessorException("Cannot apply "+e.getClass().getName()+" to Map Type");\r
+               } else {
+                       throw new AccessorException("Cannot apply "+e.getClass().getName()+" to Map Type");
                }               
        }
 
@@ -1365,60 +1365,60 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
        
        @Override
        public void put(Binding keyBinding, Object key, Binding valueBinding,
-                       Object value) throws AccessorException {\r
-               assert b.isOpen();\r
+                       Object value) throws AccessorException {
+               assert b.isOpen();
                writeLock();
                try {
                        putNoflush(keyBinding, key, valueBinding, value);
                        b.flush();
                } catch (IOException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
        }
 
        @Override
        public void putAll(Binding keyBinding, Binding valueBinding,
-                       Map<Object, Object> from) throws AccessorException {\r
-               assert b.isOpen();\r
+                       Map<Object, Object> from) throws AccessorException {
+               assert b.isOpen();
                writeLock();
                try {
                        putAllNoflush(keyBinding, valueBinding, from);
                        b.flush();
                } catch (IOException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
        }
 
        @Override
        public void putAll(Binding keyBinding, Binding valueBinding, Object[] keys,
-                       Object[] values) throws AccessorException {\r
-               assert b.isOpen();\r
+                       Object[] values) throws AccessorException {
+               assert b.isOpen();
                writeLock();
                try {
                        putAllNoflush(keyBinding, valueBinding, keys, values);
                        b.flush();
                } catch (IOException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
        }
 
        @Override
-       public void remove(Binding keyBinding, Object key) throws AccessorException {\r
-               assert b.isOpen();\r
+       public void remove(Binding keyBinding, Object key) throws AccessorException {
+               assert b.isOpen();
                writeLock();
                try {
                        removeNoflush(keyBinding, key);         
                        b.flush();
                } catch (IOException e) {
                        throw new AccessorException(e);
-               } finally {\r
-                       writeUnlock();\r
+               } finally {
+                       writeUnlock();
                }
        }
        
@@ -1429,7 +1429,7 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                 * Get insert pos
                 * @param key
                 * @return if >0 position of existing entry of same key, <0 insertion position 
-                * @throws AccessorException \r
+                * @throws AccessorException 
                 */
                abstract long getInsertPos(Object key) throws AccessorException;
 
@@ -1528,15 +1528,15 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                int indexOf(long pos) {
                        return (int) ((pos - 4L) / constantSize);
                }
-               \r
-               \r
-               /**\r
-                * \r
-                * @param fromIndex\r
-                * @param toIndex exclusive\r
-                * @param key\r
-                * @return\r
-                * @throws AccessorException\r
+               
+               
+               /**
+                * 
+                * @param fromIndex
+                * @param toIndex exclusive
+                * @param key
+                * @return
+                * @throws AccessorException
                 */
                int binarySearch(int fromIndex, int toIndex, Object key) throws AccessorException {
                        int low = fromIndex;
@@ -1624,16 +1624,16 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                                long pos = getInsertPos(key);
        
                                if (pos>0) {
-                                       // Exact match\r
+                                       // Exact match
                                        int index = indexOf(pos)+1;
-                                       if (index>=count()) return null;\r
+                                       if (index>=count()) return null;
                                        pos = getPos(index);
                                        key = getKeyAt(pos);
                                        return new Entry(key, pos, null);
-                               } else {\r
+                               } else {
                                        // Insert here match
                                        int index = indexOf(-pos);
-                                       if (index>=count()) return null;\r
+                                       if (index>=count()) return null;
                                        pos = getPos(index);
                                        key = getKeyAt(pos);
                                        return new Entry(key, pos, null);
@@ -1693,13 +1693,13 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
        
        /** Variable size enetry, Sequential search */
        class Sequential extends Index {
-\r
-               /**\r
-                * Get insert pos\r
-                * @param key\r
-                * @return if >0 position of existing entry of same key, <0 insertion position \r
-                * @throws AccessorException \r
-                */\r
+
+               /**
+                * Get insert pos
+                * @param key
+                * @return if >0 position of existing entry of same key, <0 insertion position 
+                * @throws AccessorException 
+                */
                @Override
                long getInsertPos(Object key) throws AccessorException {
                        try {
@@ -1741,18 +1741,18 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                @Override
                Entry last() throws AccessorException {
                        try {
-                               Entry e = lastChildEntry();     \r
-                               long startPos = e!=null ? e.pos : 4L;\r
-                               b.position(startPos);\r
-                               Entry result = e!=null ? new Entry(e.key, e.pos, e.accessor) : new Entry(null, 0, null);\r
+                               Entry e = lastChildEntry();     
+                               long startPos = e!=null ? e.pos : 4L;
+                               b.position(startPos);
+                               Entry result = e!=null ? new Entry(e.key, e.pos, e.accessor) : new Entry(null, 0, null);
                                while (b.position() < b.length()) {
-                                       result.key = ks.deserialize(b, null);\r
+                                       result.key = ks.deserialize(b, null);
                                        result.pos = b.position();                                      
                                        vs.skip(b, null);
                                        long valueLen = b.position() - result.pos;
                                        result.accessor = createSubAccessor(vb.type(), result.pos, valueLen, params);
                                        children.put(result.key, new SoftReference<BinaryObject>( result.accessor ));
-                               }\r
+                               }
                                return (result.key == null) ? null : result;
                        } catch (IOException e) {
                                throw new AccessorException(e);
@@ -1843,16 +1843,16 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                                        pos = b.position();
                                        prevK = k;
                                        k = ks.deserialize(b, null);
-                                       long valuePos = b.position();\r
-                                       \r
+                                       long valuePos = b.position();
+                                       
                                        // Compare current key with search key
-                                       int c = kb.compare(key, k);\r
+                                       int c = kb.compare(key, k);
                                        if (c<=0) {
                                                if (prevK==null) return null;
                                                return new Entry(prevK, prevPos, null);
                                        }
                                        vs.skip(b, null);
-                                       long valueLen = b.position() - valuePos;\r
+                                       long valueLen = b.position() - valuePos;
                                        assert(valueLen>=0);
                                        java.lang.ref.Reference<BinaryObject> ref = children.get(k);
                                        BinaryObject sa = ref!=null?ref.get():null;
@@ -1860,7 +1860,7 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                                                sa = createSubAccessor(vb.type(), valuePos, valueLen, params);
                                                children.put(k, new SoftReference<BinaryObject>(sa));
                                        }                                       
-                               }\r
+                               }
                                // There was no match, return the last entry
                                return new Entry(k, pos, null); 
                        } catch (IOException e) {
@@ -1885,17 +1885,17 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                                long pos = start==null ? 4L : start.pos;
                                long prevPos = 0;
                                Object k = null;
-                               Object prevK = null;\r
-                               BinaryObject prevAccessor = null;\r
+                               Object prevK = null;
+                               BinaryObject prevAccessor = null;
                                b.position(pos);
                                while (b.position()<len) {
                                        prevPos = pos;
                                        pos = b.position();
                                        prevK = k;
                                        k = ks.deserialize(b, null);
-                                       long valuePos = b.position();\r
+                                       long valuePos = b.position();
                                        
-                                       int c = kb.compare(key, k);\r
+                                       int c = kb.compare(key, k);
                                        // Went over
                                        if (c<0) {
                                                if (prevK==null) return null;
@@ -1908,10 +1908,10 @@ public class BinaryMap extends BinaryObject implements MapAccessor, FileMapAcces
                                        if (sa==null) {
                                                prevAccessor = createSubAccessor(vb.type(), valuePos, valueLen, params);
                                                children.put(k, new SoftReference<BinaryObject>(prevAccessor));
-                                       }\r
-                                       // Exact match\r
-                                       if (c==0) {\r
-                                               return new Entry(k, pos, prevAccessor);\r
+                                       }
+                                       // Exact match
+                                       if (c==0) {
+                                               return new Entry(k, pos, prevAccessor);
                                        }                                       
                                }
                                return new Entry(k, pos, prevAccessor);