Package uk.ac.starlink.registry

# Class AbstractRegistryClient<R>

java.lang.Object
uk.ac.starlink.registry.AbstractRegistryClient<R>

Direct Known Subclasses:
  `BasicRegistryClient`

public abstract class AbstractRegistryClient<R> extends Object
Can submit ADQL queries to a registry and return the result as a list of resources. This class uses custom SAX parsing of the SOAP response to ensure that even a large response (not uncommon) can be processed without large client-side resource usage. For this reason, no use is made of the maximum record limit options provided by RI 1.0; there's no client-side need for it.

Author:
  Mark Taylor
See Also:
  - IVOA Registry Interfaces

## Constructor Summary

Constructors
Constructor
Description
`AbstractRegistryClient(SoapClient soapClient)`
Constructs a AbstractRegistryClient given a SOAP client.

## Method Summary

Modifier and Type
Method
Description
`protected abstract ContentHandler`
`createResourceHandler(ResourceSink<R> sink)`
Returns a SAX ContentHandler which can parse a VOResources element and feed items of some type R to a ResourceSink object.
`URL`
`getEndpoint()`
Returns the SOAP endpoint this client talks to.
`Iterator<R>`
`getResourceIterator(SoapRequest request)`
Returns an iterator over resources corresponding to a given SOAP request.
`List<R>`
`getResourceList(SoapRequest request)`
Returns a list of resources corresponding to a given SOAP request.

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

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

## Constructor Details

### AbstractRegistryClient

public AbstractRegistryClient(SoapClient soapClient)
Constructs a AbstractRegistryClient given a SOAP client.

Parameters:
  `soapClient` - SOAP client which talks to an RI-compliant registry service

## Method Details

### createResourceHandler

protected abstract ContentHandler createResourceHandler(ResourceSink<R> sink)
Returns a SAX ContentHandler which can parse a VOResources element and feed items of some type R to a ResourceSink object. R presumably represents a resource.

Parameters:
  `sink` - receiver of resource objects
Returns:
  new resource handler

### getEndpoint

public URL getEndpoint()
Returns the SOAP endpoint this client talks to.

Returns:
  registry endpoint

### getResourceList

public List<R> getResourceList(SoapRequest request) throws IOException
Returns a list of resources corresponding to a given SOAP request. The list is the result of feeding the SOAP response to the handler created by `createResourceHandler(uk.ac.starlink.registry.ResourceSink<R>)`.

Parameters:
  `request` - SOAP request
Returns:
  list of resources
Throws:
  `IOException`

### getResourceIterator

public Iterator<R> getResourceIterator(SoapRequest request) throws IOException
Returns an iterator over resources corresponding to a given SOAP request. The resources are the result of feeding the SOAP response to the handler created by `createResourceHandler(uk.ac.starlink.registry.ResourceSink<R>)`.

The iterator's `next` or `hasNext` method may throw a `RegistryQueryException`.

The writing thread will only read resources from the SAX response as they are read out by the thread iterating over this iterator, so memory used by this class remains very small regardless of the number of records processed.

Parameters:
  `request` - SOAP request
Returns:
  iterator over resources; its `next` method may throw a `RegistryQueryException`
Throws:
  `IOException`