[Gephi-plugins] variable length/ modifiable lists as attribute values?
chris.esposito at gmail.com
Tue Oct 4 01:28:12 CEST 2011
I've been digging through the attribute API & implementation, as I
wanted to know what the limits and possibilities are for supporting variable
length (i.e., ArrayList-like containers) lists as attribute values. In
particular, I'd like to be able to add and delete values from a
variable-length list that is itself an attribute value. The existing API has
a lengthy list of attribute value types that it supports, including lists of
Integers, lists of Strings, etc., each of which is implemented as it's own
class derived from a base class (from memory, this is AbstractList).
However, I've noticed 2 things in the implementation code:
1) the underlying data container for a list of values is declared as a
'protected final' generic array, which (if I understand this correctly)
means that it can be assigned exactly once; the constructor does this
assignment, so I take this to mean that once created, the size of the
underlying 'list' array is fixed.
2) While there is a method to retrieve an element from one of these arrays
there is no method provided to change or set an element, even though you
could range-check the index or catch the array bounds exception should one
be thrown as a result of a bad index.
Both of these restrictions / omissions strike me as curious enough that I
think there may be reasons for them that aren't obvious at first glance. For
example I've read that declaring arrays as final can provide some measure of
thread-safety. Maybe there's some issues with serialization that I simply
haven't found yet. Assuming both my (1) and (2) observations are correct,
does anybody have any insight as to why these decisions were made?
If I did my own new attribute value list type / implementation, would
replacing the array with an ArrayList or CopyOnWriteArrayList cause problems
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gephi-plugins