Methods Summary |
---|
public void | changeElements(PersistenceElement[] elements, int action)Change the set of elements.
changeElements(Arrays.asList(elements), action);
|
public void | changeElements(java.util.List elements, int action)Change the set of elements.
boolean changed = false;
try
{
PersistenceElement[] oldElements = getElements();
int oldLength = (oldElements == null) ? 0 : oldElements.length;
int newLength = (elements == null) ? 0 : elements.size();
List list = null;
switch (action)
{
case PersistenceElement.Impl.SET:
list = elements;
changed = true;
break;
case PersistenceElement.Impl.ADD:
if (newLength > 0)
{
list = ((oldLength == 0) ? new ArrayList() :
new ArrayList(Arrays.asList(oldElements)));
list.addAll(elements);
changed = true;
}
break;
case PersistenceElement.Impl.REMOVE:
if ((newLength > 0) && (oldLength > 0))
{
list = new ArrayList(Arrays.asList(oldElements));
list.removeAll(elements);
changed = true;
}
break;
}
if (changed)
{
try
{
_owner.fireVetoableChange(_propertyName, null, null);
_elements = (PersistenceElement[])list.toArray(_template);
}
catch (PropertyVetoException e)
{
throw new ModelVetoException(e);
}
}
}
finally
{
if (changed)
_owner.firePropertyChange(_propertyName, null, null);
}
|
public PersistenceElement | getElement(java.lang.String name)Returns the element with the supplied name from the collection of
elements maintained by this collection.
PersistenceElement[] elements = getElements();
int i, count = ((elements != null) ? elements.length : 0);
for (i = 0; i < count; i++)
{
PersistenceElement element = elements[i];
if (name.equals(element.getName()))
return element;
}
return null;
|
public PersistenceElement[] | getElements()Returns the collection of elements maintained by this holder in the form
of an array. return _elements;
|
public PersistenceElementImpl | getOwner()Returns the owner of this collection. This method should only
be used internally and for cloning and archiving. return _owner;
|
public java.lang.String | getPropertyName()Returns the property name of this collection. This method
should only be used internally and for cloning and archiving. return _propertyName;
|
public java.lang.Object[] | getTemplate()Returns the template for the array of this collection. This method
should only be used internally and for cloning and archiving. return _template;
|
public void | setElements(PersistenceElement[] elements)Set the collection of elements maintained by this holder to the
supplied array. This method should only be used internally and for
cloning and archiving.
_elements = elements;
|
public void | setOwner(PersistenceElementImpl owner)Set the owner of this collection to the supplied implementation.
This method should only be used internally and for cloning and
archiving.
_owner = owner;
|
public void | setPropertyName(java.lang.String propertyName)Set the property name of this collection to the supplied name.
This name is used to generate the correct property change event on
changes to the collection. This method should only be used
internally and for cloning and archiving.
_propertyName = propertyName;
|
public void | setTemplate(java.lang.Object[] template)Set the template for the array of this collection to the supplied
array. This template is used so the array returned by getElements is
properly typed. This method should only be used internally and
for cloning and archiving. _template = template;
|