# Class ElementHandler

java.lang.Object
uk.ac.starlink.ttools.votlint.ElementHandler

Direct Known Subclasses:
  `DataHandler, ParamHandler, StreamHandler, StreamingHandler, TableHandler, TdHandler, TrHandler`

public class ElementHandler extends Object
Provides checking of a VOTable element during a SAX parse. There is one ElementHandler for each element encountered by the SAX parser; it is manipulated chiefly by the `VotLintContentHandler` which calls various methods on it in a controlled sequence as its life cycle progresses to handle the current state of the parse. Element-specific subclasses should generally override only the `startElement()`, `endElement()` and `characters(char[], int, int)` methods, which are invoked by the ContentHandler's similarly named methods.

The checking done by an ElementHandler does not attempt to repeat or replace that done by validating against a DTD, it provides additional semantic checks based on what it knows about VOTables.

Since:
  7 Apr 2005
Author:
  Mark Taylor (Starlink)

## Constructor Summary

Constructors
Constructor
Description
`ElementHandler()`

## Method Summary

Modifier and Type
Method
Description
`void`
`characters(char[] ch, int start, int length)`
Called when character content is found in the element.
`void`
`configure(String localName, VotLintContext context)`
Sets this handler up ready for use.
`void`
`endElement()`
Called when the element has ended.
`void`
`error(VotLintCode code, String msg)`
Writes an error message through the context.
`Ancestry`
`getAncestry()`
Returns an object containing the family relationships of this handler.
`String`
`getAttribute(String name)`
Returns the value of a named attribute.
`VotLintContext`
`getContext()`
Returns this handler's context.
`String`
`getName()`
Returns the localName for this element.
`ElementRef`
`getRef()`
Returns a reference for this element.
`void`
`info(VotLintCode code, String msg)`
Writes an info message through the context.
`void`
`registerChildName(ElementRef child, String name)`
Called to indicate that a child of this element has a "name" attribute.
`void`
`setAncestry(Ancestry ancestry)`
Sets the ancestry of this handler.
`void`
`setAttributes(Map<String,String> atts)`
Sets this handler's attributes.
`void`
`startElement()`
Called after the attributes have been set and checked.
`String`
`toString()`
`void`
`warning(VotLintCode code, String msg)`
Writes a warning message through the context.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### ElementHandler

public ElementHandler()

## Method Details

### configure

public void configure(String localName, VotLintContext context)
Sets this handler up ready for use. Must be called before most of the other methods can be used.

Parameters:
  `localName` - local name of the element this handler knows about
  `context` - lint context

### setAncestry

public void setAncestry(Ancestry ancestry)
Sets the ancestry of this handler.

Parameters:
  `ancestry` - family values

### getAncestry

public Ancestry getAncestry()
Returns an object containing the family relationships of this handler. This will only return a non-null value while the element is active (between its startElement and endElement calls). An ancestry object should not be used outside of this context.

Returns:
  ancestry

### getRef

public ElementRef getRef()
Returns a reference for this element.

Returns:
  reference

### getName

public String getName()
Returns the localName for this element.

Returns:
  element name

### setAttributes

public void setAttributes(Map<String,String> atts)
Sets this handler's attributes.

Parameters:
  `atts` - name -> value map representing this element's attributes

### getAttribute

public String getAttribute(String name)
Returns the value of a named attribute.

Parameters:
  `name` - attribute name
Returns:
  attribute value

### startElement

public void startElement()
Called after the attributes have been set and checked. The default implementation does nothing.

### endElement

public void endElement()
Called when the element has ended. The default implementation does nothing.

### characters

public void characters(char[] ch, int start, int length)
Called when character content is found in the element. The default implementation does nothing.

### registerChildName

public void registerChildName(ElementRef child, String name)
Called to indicate that a child of this element has a "name" attribute.

Parameters:
  `child` - child element
  `name` - value of child's name attribute

### getContext

public VotLintContext getContext()
Returns this handler's context.

Returns:
  context

### info

public void info(VotLintCode code, String msg)
Writes an info message through the context.

Parameters:
  `code` - message identifier
  `msg` - message text

### warning

public void warning(VotLintCode code, String msg)
Writes a warning message through the context.

Parameters:
  `code` - message identifier
  `msg` - message text

### error

public void error(VotLintCode code, String msg)
Writes an error message through the context.

Parameters:
  `code` - message identifier
  `msg` - message text

### toString

public String toString()

Overrides:
  `toString` in class `Object`