# Class DatalinkValidator

java.lang.Object
uk.ac.starlink.ttools.taplint.DatalinkValidator

public class DatalinkValidator extends Object
Performs validation of DataLink documents. A `Reporter` instance is supplied at construction time, and all validation reports are reported via that object.

The DataLink document is loaded as a DOM rather than using SAX to stream it. DataLink documents are expected to be of a fairly manageable size, so this should be OK.

Since:
  23 Nov 2017
Author:
  Mark Taylor
See Also:
  - DataLink

## Constructor Summary

Constructors
Constructor
Description
`DatalinkValidator(Reporter reporter, uk.ac.starlink.vo.DatalinkVersion version)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`uk.ac.starlink.vo.datalink.LinksDoc`
`createLinksDoc(uk.ac.starlink.votable.VODocument vodoc, uk.ac.starlink.vo.DatalinkVersion version)`
Parses a VOTable document as a DataLink structure, reporting any validation issues as it does.
`void`
`validateDatalink(InputStream in)`
Performs checks on a DataLink document read from a given input stream.
`void`
`validateDatalink(URL url, boolean isLinksService, boolean mustSucceed)`
Performs checks on a DataLink document obtained from a URL.
`void`
`validateDatalink(uk.ac.starlink.votable.VODocument vodoc, uk.ac.starlink.vo.DatalinkVersion version)`
Performs DataLink-specific validation on a VOTable DOM.
`void`
`validateLinksDoc(uk.ac.starlink.vo.datalink.LinksDoc linksDoc, uk.ac.starlink.vo.DatalinkVersion version)`
Performs checks on a LinksDoc object.

### Methods inherited from class Object

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

## Constructor Details

### DatalinkValidator

public DatalinkValidator(Reporter reporter, uk.ac.starlink.vo.DatalinkVersion version)
Constructor.

Parameters:
  `reporter` - destination for validation methods
  `version` - fixed datalink version to validate against; may be null if not known/specified

## Method Details

### validateDatalink

public void validateDatalink(URL url, boolean isLinksService, boolean mustSucceed)
Performs checks on a DataLink document obtained from a URL.

The supplied URL is assumed to refer to a GET request expected to return a DataLink document, and with no RESPONSEFORMAT parameter (which means that the result must be a TABLEDATA-serialization VOTable). Checks on the HTTP and DALI behaviour are run in addition to the DataLink checks themselves. Additional checks may be performed if the service is asserted to be a DataLink {links} service.

Parameters:
  `url` - document URL
  `isLinksService` - true iff the service is supposed to conform to ivo://ivoa.net/std/DataLink#links-1.0
  `mustSucceed` - if true, the service is not supposed to return an error response

### validateDatalink

public void validateDatalink(InputStream in)
Performs checks on a DataLink document read from a given input stream.

The supplied InputStream is assumed to be the result of a DataLink request with no RESPONSEFORMAT parameter, which means that the result must a TABLEDATA-serialization VOTable.

Parameters:
  `in` - input stream

### validateDatalink

public void validateDatalink(uk.ac.starlink.votable.VODocument vodoc, uk.ac.starlink.vo.DatalinkVersion version)
Performs DataLink-specific validation on a VOTable DOM.

Parameters:
  `vodoc` - DOM assumed to contain a document conforming to the DataLink standard
  `version` - datalink version, not null

### validateLinksDoc

public void validateLinksDoc(uk.ac.starlink.vo.datalink.LinksDoc linksDoc, uk.ac.starlink.vo.DatalinkVersion version)
Performs checks on a LinksDoc object. This performs additional validation on an object which has already been parsed as a DataLink document.

Parameters:
  `linksDoc` - object representing DataLink document
  `version` - datalink specification version, not null

### createLinksDoc

public uk.ac.starlink.vo.datalink.LinksDoc createLinksDoc(uk.ac.starlink.votable.VODocument vodoc, uk.ac.starlink.vo.DatalinkVersion version)
Parses a VOTable document as a DataLink structure, reporting any validation issues as it does.

Parameters:
  `vodoc` - DOM assumed to conform to DataLink rules
  `version` - datalink version
Returns:
  parsed represntation of the DataLink document