public interface Attributable
Design consideration: Be as similar to Group as possible.
Modifier and Type | Method and Description |
---|---|
int |
getAttributeIndex(int indexFrom,
java.lang.String tname)
Gets the index of the attribute with the giving local name.
|
int |
getAttributeIndex(int indexFrom,
java.lang.String namespace,
java.lang.String name,
int mode)
Gets the index of the first attribute that matches
the specified criteria.
|
Attribute |
getAttributeItem(java.lang.String tname)
Gets the attribute with the tag name.
|
Attribute |
getAttributeItem(java.lang.String namespace,
java.lang.String name,
int mode)
Gets the first attribute that matches the specified criteria.
|
java.util.List<Attribute> |
getAttributeItems()
Returns all attributes of this object.
|
java.util.List<Attribute> |
getAttributes(java.lang.String namespace,
java.lang.String name,
int mode)
Gets a list of attributes of the specified criteria.
|
java.lang.String |
getAttributeValue(java.lang.String tname)
Returns the value of the attribute of the specified tag name,
or null if not specified.
|
java.lang.String |
getAttributeValue(java.lang.String namespace,
java.lang.String name,
int mode)
Gets the value of the first attribute that matches
the giving criteria, or null if not found.
|
Attribute |
setAttribute(Attribute attr)
Adds the giving attribute.
|
Attribute |
setAttributeValue(java.lang.String tname,
java.lang.String value)
Sets the value of the attribute with the giving tag name.
|
java.util.List<Attribute> getAttributeItems()
The returned list is "live". Any modification to it affects the object that owns the attributes.
If the new added attribute has the same tag name as that of any existent attribute, DOMException is thrown. Thus, it is, sometimes, more convenient to ue setAttribute.
Naming reason: we don't call it getAttributes() to avoid the name conflict with Node.getAttributes().
int getAttributeIndex(int indexFrom, java.lang.String namespace, java.lang.String name, int mode)
indexFrom
- the index to start searching from; 0 for beginningnamespace
- the namespace URI if FIND_BY_PREFIX is not specified;
the namespace prefix if FIND_BY_PREFIX specified; null to ignorename
- the local name if FIND_BY_TAGNAME is not specified;
the tag name if FIND_BY_TAGNAME specified; null to ignoremode
- the search mode; zero or any combination of Item.FIND_xxxint getAttributeIndex(int indexFrom, java.lang.String tname)
indexFrom
- the index to start searching from; 0 for beginningtname
- the tag name (i.e., Attribute.getName()
) --
consists of the prefix and the local namejava.lang.String getAttributeValue(java.lang.String namespace, java.lang.String name, int mode)
According to Section 3.3.3 of XML 1.0 spec, the value is normalized, including trimmed.
namespace
- the namespace URI if FIND_BY_PREFIX is not specified;
the namespace prefix if FIND_BY_PREFIX specified; null to ignorename
- the local name if FIND_BY_TAGNAME is not specified;
the tag name if FIND_BY_TAGNAME specified; null to ignorejava.lang.String getAttributeValue(java.lang.String tname)
Note: unlike W3C's getAttribute, which returns empty if not specified, this method returns null if not specified.
Attribute getAttributeItem(java.lang.String namespace, java.lang.String name, int mode)
The name is a bit strange because we have to avoid name conflicts with org.w3c.dom.Node.
namespace
- the namespace URI if FIND_BY_PREFIX is not specified;
the namespace prefix if FIND_BY_PREFIX specified; null to ignorename
- the local name if FIND_BY_TAGNAME is not specified;
the tag name if FIND_BY_TAGNAME specified; null to ignoremode
- the search mode; zero or any combination of Item.FIND_xxxAttribute getAttributeItem(java.lang.String tname)
The name is a bit strange because we have to avoid name conflicts with org.w3c.dom.Node.
tname
- the tag name (i.e., Attribute.getName()
) --
consists of the prefix and the local namejava.util.List<Attribute> getAttributes(java.lang.String namespace, java.lang.String name, int mode)
namespace
- the namespace URI if FIND_BY_PREFIX is not specified;
the namespace prefix if FIND_BY_PREFIX specified; null to ignorename
- the local name if FIND_BY_TAGNAME is not specified;
the tag name if FIND_BY_TAGNAME specified; null to ignoremode
- the search mode; zero or any combination of Item.FIND_xxxAttribute setAttribute(Attribute attr)
attr
- the new attribute to addAttribute setAttributeValue(java.lang.String tname, java.lang.String value)
Note: it looks similar to Attribute(String, String), but this method requires the tag name.
tname
- the tag name (i.e., Attribute.getName)value
- the new value.Copyright © 2005-2018 Potix Corporation. All Rights Reserved.