# Class CompareMetadataStage

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

All Implemented Interfaces:
  `Stage`

public class CompareMetadataStage extends Object implements Stage
Validation stage for checking that two sets of table metadata (presumably obtained via different routes) are equivalent to each other.

Since:
  7 Jun 2011
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`CompareMetadataStage(String srcDesc1, String srcDesc2, MetadataHolder metaHolder1, MetadataHolder metaHolder2)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`compatibleDataTypes(String dt1, String dt2)`
Indicates whether two datatypes are compatible with each other.
`static CompareMetadataStage`
`createStage(TableMetadataStage stage1, TableMetadataStage stage2)`
Utility method to construct a CompareMetadataStage instance given two TableMetadataStage objects.
`String`
`getDescription()`
Returns a short one-line description of this stage.
`void`
`run(Reporter reporter, uk.ac.starlink.vo.TapService tapService)`
Performs the validation checks for this stage.
`static String`
`stripAdqlType(String dtype)`
Takes a string which may be an ADQL type and strips off confusing parts including any "adql:" prefix and trailing parenthesis.

### Methods inherited from class Object

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

## Constructor Details

### CompareMetadataStage

public CompareMetadataStage(String srcDesc1, String srcDesc2, MetadataHolder metaHolder1, MetadataHolder metaHolder2)
Constructor.

Parameters:
  `srcDesc1` - short description of source of first metadata set
  `srcDesc2` - short description of source of second metadata set
  `metaHolder1` - supplies first metadata set at comparison time
  `metaHolder2` - supplies second metadata set at comparison time

## Method Details

### getDescription

public String getDescription()
Description copied from interface: `Stage`
Returns a short one-line description of this stage.

Specified by:
  `getDescription` in interface `Stage`
Returns:
  description in imperative mood

### run

public void run(Reporter reporter, uk.ac.starlink.vo.TapService tapService)
Description copied from interface: `Stage`
Performs the validation checks for this stage.

Specified by:
  `run` in interface `Stage`
Parameters:
  `reporter` - destination for validation messages
  `tapService` - TAP service description

### compatibleDataTypes

public static boolean compatibleDataTypes(String dt1, String dt2)
Indicates whether two datatypes are compatible with each other. Datatypes may be either VOTable or TAP/adql type. See VODataService v1.1 section 3.5.3 and TAP v1.0 section 2.5. The logic is somewhat sloppy.

Note however that, as clarified by TAP 1.0 Erratum #3, TAP/ADQL has no type system, so any comparison involving the types listed in TAP v1.0 section 2.5 cannot be normative. So any report issued on failure of this test should only be a Warning and not an Error.

Parameters:
  `dt1` - first data type
  `dt2` - second data type
Returns:
  true iff it looks like the submitted types are compatible

### stripAdqlType

public static String stripAdqlType(String dtype)
Takes a string which may be an ADQL type and strips off confusing parts including any "adql:" prefix and trailing parenthesis.

Parameters:
  `dtype` - string which may be an ADQL datatype
Returns:
  base ADQL data type if appropriate, else input string

### createStage

public static CompareMetadataStage createStage(TableMetadataStage stage1, TableMetadataStage stage2)
Utility method to construct a CompareMetadataStage instance given two TableMetadataStage objects.

Parameters:
  `stage1` - first metadata producing stage
  `stage2` - second metadata producing stage
Returns:
  comparison stage