|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.ac.starlink.votable.VOElement
Generic element in a VOTable document. This class is extended to provide the classes associated with specific VOTable elements. It provides handling for some of the characteristics common to various VOTable elements, for instance DESCRIPTION elements.
This element and its subclasses provide some methods for returning
the values of specific attributes from the element in question, such as
getName, getID. This is either for convenience
or in order to return some non-String object from these attributes.
For attribute values which are not covered by specific methods in
this way, the getAttribute(java.lang.String)
method can be used.
The recommended way of navigating round a VOTable document tree
is by using the getChild* and getParent methods
which return other VOElement objects. If you like doing things
the hard way however, you can access the DOM Element
underlying each VOElement and navigate round the underlying DOM
structure itself, creating a new VOElement when you get to the
node you're after so you can use the methods provided by VOElement
(such as TableElement's TableElement.getData()
method).
You should in general get instances of VOElement using the
VOElementFactory
class.
Note: An alternative implementation would have VOElement
implement the Element
interface itself.
There are a couple of reasons this would be a bit problematic, but
is probably doable. If anyone can persuade me it's a useful thing
to do, I might go ahead).
Constructor Summary | |
|
VOElement(Element el,
String systemId)
Constructs a VOElement from a DOM element. |
protected |
VOElement(Element el,
String systemId,
String tagname)
Constructs a VOElement from a DOM element which is required to have a given tagname. |
Method Summary | |
boolean |
equals(Object other)
Indicates whether this VOElement is equivalent to another. |
String |
getAttribute(String attname)
Returns the value of a named attribute for this element, or null if there is no such attribute. |
String |
getAttribute(String attname,
String implied)
Returns the value of a named attribute for this element, or a default ('#IMPLIED') value if the attribute is not present. |
VOElement |
getChildByName(String tagname)
Returns the first child element of this element which has a given name. |
VOElement[] |
getChildren()
Returns the child elements of this element. |
VOElement[] |
getChildrenByName(String tagname)
Returns all the child elements of this element which have a given name. |
URL |
getContext()
Returns the base URL associated with this VOElement. |
VOElement[] |
getDescendantsByName(String tagname)
Returns all the descendants of this element which have a given name. |
String |
getDescription()
Returns the text of a DESCRIPTION element associated with this object, or null if none exists. |
Element |
getElement()
Returns the DOM element on which this VOElement object is based. |
String |
getHandle()
Returns something that can be used informally as a name for this element. |
String |
getID()
Returns the ID attribute value for this element, or null if none exists. |
String |
getName()
Returns the name attribute value for this element, or null if none exists. |
VOElement |
getParent()
Returns the parent element of this element as a VOElement. |
Source |
getSource()
Returns an XML Source corresponding to this element. |
String |
getSystemId()
Returns the system identifier against which relative URIs should be resolved. |
String |
getTagName()
Returns the tagname of the Element on which this object is based, that is the element's name, like "RESOURCE" or "FIELD". |
String |
getTextContent()
Returns the text contained in this element. |
boolean |
hasAttribute(String attname)
Indicates whether this element has a value for a given attribute. |
int |
hashCode()
Returns the hash code of the DOM Element. |
String |
toString()
Returns the same value as getHandle() . |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public VOElement(Element el, String systemId)
VOElementFactory
in preference to this constructor.
el
- DOM element on which the new object will be basedsystemId
- the location of the documentprotected VOElement(Element el, String systemId, String tagname)
el
- DOM element on which the new object will be basedsystemId
- the location of the documenttagname
- the name that el is required to have
IllegalArgumentException
- if el
has a name other than tagnameMethod Detail |
public String getDescription()
public String getID()
public String getName()
public String getAttribute(String attname)
attname
- the name of the attribute to retrieve
public String getAttribute(String attname, String implied)
attname
- the name of the attribute to retrieveimplied
- the default value
public boolean hasAttribute(String attname)
attname
- the name of an attribute
public VOElement getParent()
public VOElement[] getChildren()
public VOElement[] getChildrenByName(String tagname)
tagname
- the element name required
public VOElement getChildByName(String tagname)
tagname
- the element name required
public VOElement[] getDescendantsByName(String tagname)
tagname
- the element name required
public String getTagName()
public Element getElement()
public Source getSource()
public String getSystemId()
public URL getContext()
public String toString()
getHandle()
.
toString
in class Object
public String getHandle()
public String getTextContent()
public boolean equals(Object other)
equals
in class Object
other
- comparison object
Element
as this ispublic int hashCode()
hashCode
in class Object
|
Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |