Package uk.ac.starlink.tfcat

# Class TfcatUtil

java.lang.Object
uk.ac.starlink.tfcat.TfcatUtil

public class TfcatUtil extends Object
Utilities for use with TFCat classes.

Since:
  9 Feb 2022
Author:
  Mark Taylor

## Method Summary

Modifier and Type
Method
Description
`static void`
`checkBoundingBoxes(Reporter reporter, TfcatObject tfcat)`
Performs a global check for a given TfcatObject that any positions listed are within the bounding boxes in whose scope they appear.
`static void`
`checkCrs(Reporter reporter, TfcatObject tfcat)`
Ensure that CRS objects are in place for the tree rooted at the given TFCat Object.
`static void`
`checkOption(Reporter reporter, String token, Collection<String> options)`
Checks whether a given token is in a supplied list of valid options.
`static List<Geometry<?>>`
`getAllGeometries(TfcatObject tfcat)`
Returns all the Geometries that are descendents of a given TFCat object, including itself if applicable.
`static List<Position>`
`getAllPositions(TfcatObject tfcat)`
Returns all the Position objects contained in a TFCat object and its descendents.
`static Bbox`
`getBboxInScope(TfcatObject tfcat)`
Returns a Bounding Box objecct applying to the given TFCat object.
`static TfcatObject[]`
`getChildren(TfcatObject tfcat)`
Returns any direct children of a TfcatObject that are themselves TfcatObjects.
`static Crs`
`getCrsInScope(TfcatObject tfcat)`
Returns a CRS object applying to the given TFCat object.
`static WordChecker`
`getUcdChecker()`
Returns a syntax checker for UCDs.
`static WordChecker`
`getUnitChecker()`
Returns a syntax checker for VOUnits.
`static TfcatObject`
`parseTfcat(String jsonTxt, Reporter reporter)`
Performs a validating parse of a given TFCat text.

### Methods inherited from class java.lang.Object

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

## Method Details

### parseTfcat

public static TfcatObject parseTfcat(String jsonTxt, Reporter reporter)
Performs a validating parse of a given TFCat text.

Parameters:
  `jsonTxt` - TFCat text
  `reporter` - error message destination
Returns:
  TFCat object, or null in case of fatal parse error

### getChildren

public static TfcatObject[] getChildren(TfcatObject tfcat)
Returns any direct children of a TfcatObject that are themselves TfcatObjects. The relationship depends a bit on the object type, but traversing the tree in this way will get you all the TfcatObjects it contains.

Parameters:
  `tfcat` - parent
Returns:
  children

### getAllGeometries

public static List<Geometry<?>> getAllGeometries(TfcatObject tfcat)
Returns all the Geometries that are descendents of a given TFCat object, including itself if applicable.

Parameters:
  `tfcat` - root
Returns:
  all geometries in tree

### getAllPositions

public static List<Position> getAllPositions(TfcatObject tfcat)
Returns all the Position objects contained in a TFCat object and its descendents.

Parameters:
  `tfcat` - TFCat object
Returns:
  all contained positions

### checkBoundingBoxes

public static void checkBoundingBoxes(Reporter reporter, TfcatObject tfcat)
Performs a global check for a given TfcatObject that any positions listed are within the bounding boxes in whose scope they appear.

Parameters:
  `reporter` - error message destination
  `tfcat` - TFCat object

### getCrsInScope

public static Crs getCrsInScope(TfcatObject tfcat)
Returns a CRS object applying to the given TFCat object. This may exist on the object itself or on one of its ancestors. The return value may be null, but probably ought not to be for a legal TFCat object.

Parameters:
  `tfcat` - target object
Returns:
  CRS object, may be null

### getBboxInScope

public static Bbox getBboxInScope(TfcatObject tfcat)
Returns a Bounding Box objecct applying to the given TFCat object. This may exist on the object itself or on one of its ancestors.

Parameters:
  `tfcat` - target object
Returns:
  Bbox object, may be null

### checkCrs

public static void checkCrs(Reporter reporter, TfcatObject tfcat)
Ensure that CRS objects are in place for the tree rooted at the given TFCat Object. Usually that will mean that the given object has a CRS object of its own, but as long as all of its Geometry descendants have CRS objects in scope, it's OK. If CRS objects are missing, a message is written to the reporter.

Parameters:
  `reporter` - message destination
  `tfcat` - object to check

### checkOption

public static void checkOption(Reporter reporter, String token, Collection<String> options)
Checks whether a given token is in a supplied list of valid options. No special handling is performed for null values.

Parameters:
  `reporter` - destination for reports if token is not valid
  `token` - token to test
  `options` - valid token values

### getUcdChecker

public static WordChecker getUcdChecker()
Returns a syntax checker for UCDs.

Returns:
  UCD checker

### getUnitChecker

public static WordChecker getUnitChecker()
Returns a syntax checker for VOUnits.

Returns:
  unit checker