public abstract class AbstractSVGList
extends java.lang.Object
This class provides support for an SVG list representation of an
attribute. It implements basic list functionality that is common to all
of the SVG*List
interfaces.
For a specific attribute, it requires an attribute value
, a parser
,
and a method to create items
.
Whenever the attribute changes outside of the control of the list, this
list must be invalidated
.
Modifier and Type | Field and Description |
---|---|
protected java.util.List |
itemList
The list of items.
|
protected boolean |
valid
Whether this list is valid.
|
Constructor and Description |
---|
AbstractSVGList() |
Modifier and Type | Method and Description |
---|---|
protected SVGItem |
appendItemImpl(java.lang.Object newItem)
Inserts a new item at the end of the list.
|
protected abstract void |
checkItemType(java.lang.Object newItem)
Asserts that the given object is an appropriate SVG object for this list.
|
void |
clear()
Removes all items from the list.
|
protected void |
clear(java.util.List list)
Clears the list and sets the parent of the former list items to null.
|
protected abstract DOMException |
createDOMException(short type,
java.lang.String key,
java.lang.Object[] args)
Create a DOM Exception.
|
protected abstract SVGItem |
createSVGItem(java.lang.Object newItem)
Creates an
SVGItem object that has the same values as those
in the specified SVG object. |
protected abstract void |
doParse(java.lang.String value,
ListHandler builder)
Parses the given attribute value and informs the specified
ListHandler of the parsed list items. |
protected SVGItem |
getItemImpl(int index)
Returns the item from the list at the specified index.
|
protected abstract java.lang.String |
getItemSeparator()
Returns the separator string to use when constructing a string
representation of the entire list.
|
int |
getNumberOfItems()
Returns the number of items in the list.
|
protected abstract java.lang.String |
getValueAsString()
Returns the value of the DOM attribute containing the list.
|
protected SVGItem |
initializeImpl(java.lang.Object newItem)
Removes all items from the list and adds the specified item to
the list.
|
protected SVGItem |
insertItemBeforeImpl(java.lang.Object newItem,
int index)
Inserts a new item into the list at the specified position.
|
void |
invalidate()
Invalidates this list.
|
void |
itemChanged()
Method to be called by a member
SVGItem object when its value
changes. |
protected SVGItem |
removeIfNeeded(java.lang.Object newItem)
Removes the specified object from its parent list if it is an item, or
creates a new item if the specified object is not an item.
|
protected void |
removeItem(SVGItem item)
Removes an item from the list.
|
protected SVGItem |
removeItemImpl(int index)
Removes an existing item from the list.
|
protected SVGItem |
replaceItemImpl(java.lang.Object newItem,
int index)
Replaces an existing item in the list with a new item.
|
protected void |
resetAttribute()
Resets the value of the associated attribute.
|
protected void |
resetAttribute(SVGItem item)
Appends the string representation of the given
SVGItem to
the DOM attribute. |
protected void |
revalidate()
Initializes the list, if needed.
|
protected abstract void |
setAttributeValue(java.lang.String value)
Sets the DOM attribute value containing the number list.
|
protected void |
setValueAsString(java.util.List value)
Sets the DOM attribute value to be the string representation of the
given list.
|
protected boolean valid
protected java.util.List itemList
protected abstract java.lang.String getItemSeparator()
protected abstract SVGItem createSVGItem(java.lang.Object newItem)
SVGItem
object that has the same values as those
in the specified SVG object.newItem
- the SVG objectSVGItem
objectprotected abstract void doParse(java.lang.String value, ListHandler builder) throws ParseException
ListHandler
of the parsed list items.value
- the attribute value to be parsedbuilder
- the object to be informed of the parsed list itemsParseException
protected abstract void checkItemType(java.lang.Object newItem) throws org.w3c.dom.svg.SVGException
org.w3c.dom.svg.SVGException
protected abstract java.lang.String getValueAsString()
protected abstract void setAttributeValue(java.lang.String value)
value
- the String representation of the list, or null
if the list contains no itemsprotected abstract DOMException createDOMException(short type, java.lang.String key, java.lang.Object[] args)
public int getNumberOfItems()
public void clear() throws DOMException
DOMException
- NO_MODIFICATION_ALLOWED_ERR:
Raised when the list cannot be modified.protected SVGItem initializeImpl(java.lang.Object newItem) throws DOMException, org.w3c.dom.svg.SVGException
newItem
- the item which should become the only member of the list.DOMException
- NO_MODIFICATION_ALLOWED_ERR:
Raised when the list cannot be modified.org.w3c.dom.svg.SVGException
- SVG_WRONG_TYPE_ERR:
Raised if parameter newItem is the wrong type of object for the given
list.protected SVGItem getItemImpl(int index) throws DOMException
index
- The index of the item from the list which is to be returned.
The first item is number 0.DOMException
- INDEX_SIZE_ERR:
Raised if the index number is negative or greater than or equal to
numberOfItems
.protected SVGItem insertItemBeforeImpl(java.lang.Object newItem, int index) throws DOMException, org.w3c.dom.svg.SVGException
The first item is number 0. If newItem
is already in a
list, it is removed from its previous list before it is inserted into
this list.
newItem
- The item which is to be inserted
into the list.index
- The index of the item before which
the new item is to be inserted. The first item
is number 0. If the index is equal to 0, then
the new item is inserted at the front of the
list. If the index is greater than or equal to
numberOfItems
, then the new item is appended
to the end of the list.DOMException
- NO_MODIFICATION_ALLOWED_ERR:
Raised when the list cannot be modified.org.w3c.dom.svg.SVGException
- SVG_WRONG_TYPE_ERR:
Raised if parameter newItem
is the wrong type of
object for the given list.protected SVGItem replaceItemImpl(java.lang.Object newItem, int index) throws DOMException, org.w3c.dom.svg.SVGException
If newItem
is already in a list, it is removed from its
previous list before it is inserted into this list.
newItem
- The item which is to be inserted
into the list.index
- The index of the item which is to
be replaced. The first item is number 0.DOMException
- NO_MODIFICATION_ALLOWED_ERR:
Raised when the list cannot be modified.DOMException
- INDEX_SIZE_ERR:
Raised if the index number is negative or greater
than or equal to numberOfItems
.org.w3c.dom.svg.SVGException
- SVG_WRONG_TYPE_ERR:
Raised if parameter newItem is the wrong type
of object for the given list.protected SVGItem removeItemImpl(int index) throws DOMException
index
- The index of the item which
is to be removed. The first item is number 0.DOMException
- NO_MODIFICATION_ALLOWED_ERR:
Raised when the list cannot be modified.DOMException
- INDEX_SIZE_ERR:
Raised if the index number is negative or greater
than or equal to numberOfItems
.protected SVGItem appendItemImpl(java.lang.Object newItem) throws DOMException, org.w3c.dom.svg.SVGException
newItem
- The item which is to be inserted into the list. The
first item is number 0.DOMException
- NO_MODIFICATION_ALLOWED_ERR:
Raised when the list cannot be modified.org.w3c.dom.svg.SVGException
- SVG_WRONG_TYPE_ERR:
Raised if parameter newItem is the wrong type of object for the given
list.protected SVGItem removeIfNeeded(java.lang.Object newItem)
protected void revalidate()
protected void setValueAsString(java.util.List value) throws DOMException
DOMException
public void itemChanged()
SVGItem
object when its value
changes. This causes the DOM attribute to be reset.protected void resetAttribute()
protected void resetAttribute(SVGItem item)
SVGItem
to
the DOM attribute. This is called in response to an append to
the list.public void invalidate()
protected void removeItem(SVGItem item)
protected void clear(java.util.List list)
Copyright © 2022 Apache Software Foundation. All Rights Reserved.