-\r
- void addRepeatNoflush(int index, Binding rcb, Object obj, int repeatCount) throws AccessorException {\r
- if (index<0||index>size()) throw new AccessorException("Index out of bounds");\r
- assert b.isOpen();\r
- writeLock();\r
- try {\r
- Serializer rcs = params.serializerScheme.getSerializer( rcb ); \r
- // Write \r
- b.position(0L);\r
- int oldCount = b.readInt();\r
- int newCount = oldCount + repeatCount;\r
- if (index>oldCount) throw new AccessorException("Index out of range");\r
- b.position(0L);\r
- b.writeInt(newCount);\r
- boolean lastEntry = index == oldCount;\r
- \r
- int size = rcs.getSize(obj) * repeatCount;\r
- long pos = getStartPosition(index);\r
- b.position(pos);\r
- b.insertBytes(size, ByteSide.Right);\r
- \r
- b.position(pos);\r
- for (int i=0; i<repeatCount; i++) {\r
- rcs.serialize(b, obj); \r
- }\r
- \r
- // Update child map keys\r
- if (!lastEntry && !children.isEmpty()) {\r
- Integer key = children.lastKey();\r
- while (key!=null && key >= index) {\r
- java.lang.ref.Reference<BinaryObject> value = children.remove(key);\r
- if (value.get()!=null) children.put(key+repeatCount, value);\r
- key = children.lowerKey(key);\r
- }\r
- }\r
- \r
- // Notify Listeners\r
- ListenerEntry le = listeners;\r
- while (le!=null) { \r
- ArrayInterestSet is = le.getInterestSet();\r
- if (is.inNotifications()) {\r
- for (int i=0; i<repeatCount; i++) {\r
- MutableVariant newValue = null;\r
- if (is.inValues()) newValue = new MutableVariant(rcb, obj/*rcb.isImmutable() ? obj : cb.clone(obj)*/); \r
- ArrayElementAdded e = new ArrayElementAdded(index, newValue);\r
- emitEvent(le, e);\r
- }\r
- }\r
- \r
- // Update indices of interest sets\r
- if (is.componentInterests!=null) {\r
- Map<Integer, InterestSet> oldCis = is.componentInterests;\r
- boolean needUpdates = false;\r
- for (Integer i : oldCis.keySet()) {\r
- needUpdates |= i>=index;\r
- if (needUpdates) break;\r
- }\r
- \r
- if (needUpdates) {\r
- Map<Integer, InterestSet> newCis = new HashMap<Integer, InterestSet>(oldCis.size()); \r
- for (Integer i : oldCis.keySet())\r
- {\r
- Integer oldKey = i;\r
- Integer newKey = i>=index ? i+repeatCount : i;\r
- InterestSet oldValue = oldCis.get(oldKey);\r
- newCis.put(newKey, oldValue); \r
- }\r
- is.componentInterests = newCis;\r
- }\r
- \r
- }\r
- \r
- le = le.next;\r
- }\r
- \r
- } catch (IOException e) {\r
- throw new AccessorException(e);\r
- } catch (SerializerConstructionException e) {\r
- throw new AccessorException(e);\r
- } finally {\r
- writeUnlock();\r
- }\r
- }\r