1 4 package com.tc.object.change.event; 5 6 import com.tc.object.ObjectID; 7 import com.tc.object.change.TCChangeBufferEvent; 8 import com.tc.object.dna.api.DNAWriter; 9 10 public class ArrayElementChangeEvent implements TCChangeBufferEvent { 11 12 private final Object value; 13 private final int index; 14 private final int length; 15 16 public ArrayElementChangeEvent(int index, Object value) { 17 this(index, value, -1); 18 } 19 20 25 public ArrayElementChangeEvent(int index, Object value, int length) { 26 this.index = index; 27 this.value = value; 28 this.length = length; 29 } 30 31 public void write(DNAWriter to) { 32 if (isSubarray()) { 33 to.addSubArrayAction(index, value, length); 34 } else { 35 to.addArrayElementAction(index, value); 36 } 37 } 38 39 public Object getValue() { 40 return value; 41 } 42 43 public int getIndex() { 44 return index; 45 } 46 47 public boolean isReference() { 48 return value instanceof ObjectID; 49 } 50 51 public boolean isSubarray() { 52 return length != -1; 53 } 54 55 public int getLength() { 56 return length; 57 } 58 } 59 | Popular Tags |