|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Attributable
Represents a class that has attributes. It is usually implemented by a class that also implements Item or Group. Currently, only Element implements it.
Design consideration: Be as similar to Group as possible.
Item
,
Attribute
Method Summary | |
---|---|
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. |
Method Detail |
---|
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 namspace URI if FIND_BY_PREFIX is not specified;
the namespace prefix if FIND_BY_PREFIX specified; null to ingorename
- the local name if FIND_BY_TAGNAME is not sepcified;
the tag name if FIND_BY_TAGNAME specified; null to ignoremode
- the serach mode; zero or any combination of Item.FIND_xxx
int 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 name
java.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 namspace URI if FIND_BY_PREFIX is not specified;
the namespace prefix if FIND_BY_PREFIX specified; null to ingorename
- the local name if FIND_BY_TAGNAME is not sepcified;
the tag name if FIND_BY_TAGNAME specified; null to ignore
java.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 namspace URI if FIND_BY_PREFIX is not specified;
the namespace prefix if FIND_BY_PREFIX specified; null to ingorename
- the local name if FIND_BY_TAGNAME is not sepcified;
the tag name if FIND_BY_TAGNAME specified; null to ignoremode
- the serach mode; zero or any combination of Item.FIND_xxx
Attribute 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 name
java.util.List<Attribute> getAttributes(java.lang.String namespace, java.lang.String name, int mode)
namespace
- the namspace URI if FIND_BY_PREFIX is not specified;
the namespace prefix if FIND_BY_PREFIX specified; null to ingorename
- the local name if FIND_BY_TAGNAME is not sepcified;
the tag name if FIND_BY_TAGNAME specified; null to ignoremode
- the serach mode; zero or any combination of Item.FIND_xxx
Attribute setAttribute(Attribute attr)
attr
- the new attribute to add
Attribute 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |