Class WebMapper

java.lang.Object
uk.ac.starlink.ttools.calc.WebMapper

public abstract class WebMapper extends Object
Object that can map some particular sort of string to a URL referencing a web page. "Web page" here is generally intended to mean a resource that it's reasonable to try viewing in a web browser.
Since:
20 Jun 2019
Author:
Mark Taylor
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final WebMapper
    Mapper for an arXiv identifier.
    static final WebMapper
    Mapper that tries various strategies to turn a string into a URL.
    static final WebMapper
    Mapper for a Bibcode.
    static final WebMapper
    Mapper for a Bibcode, using the Classic web pages (deprecated by ADS).
    static final WebMapper
    Mapper for a DOI (Digital Object Identifier).
    static final WebMapper
    Mapper for pathname of a file in the local filesystem.
    static final WebMapper
    Maps a source identifier to its NED web page.
    static final WebMapper
    Maps a source identifier to its classic NED web page.
    static final WebMapper
    Maps a source identifier to its Simbad web page.
    static final WebMapper
    Mapper for a string that's already a URL.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static WebMapper
    Returns a mapper that combines others to come up with a result if any of them can turn a string into a URL.
    static WebMapper
    createPrefixMapper(String name, String urlPrefix)
    Returns a mapper that blindly appends the given location string to a supplied prefix URL, pausing only to URL-encode it.
    static WebMapper[]
    Returns a list of all the known useful mappers.
    Returns the user-visible name for this mapper.
     
    abstract URL
    Returns a URL constructed from the given text according to the knowledge of this WebMapper, if it looks suitable.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • FILE

      public static final WebMapper FILE
      Mapper for pathname of a file in the local filesystem.
    • URL

      public static final WebMapper URL
      Mapper for a string that's already a URL.
    • BIBCODE

      public static final WebMapper BIBCODE
      Mapper for a Bibcode.
    • DOI

      public static final WebMapper DOI
      Mapper for a DOI (Digital Object Identifier).
    • ARXIV

      public static final WebMapper ARXIV
      Mapper for an arXiv identifier.
    • SIMBAD

      public static final WebMapper SIMBAD
      Maps a source identifier to its Simbad web page.
    • NED

      public static final WebMapper NED
      Maps a source identifier to its NED web page.
    • BIBCODE_OLD

      public static final WebMapper BIBCODE_OLD
      Mapper for a Bibcode, using the Classic web pages (deprecated by ADS).
    • NED_CLASSIC

      public static final WebMapper NED_CLASSIC
      Maps a source identifier to its classic NED web page.
    • AUTO

      public static final WebMapper AUTO
      Mapper that tries various strategies to turn a string into a URL.
  • Constructor Details

    • WebMapper

      protected WebMapper(String name)
      Constructor.
      Parameters:
      name - user-visible name for this mapper
  • Method Details

    • toUrl

      public abstract URL toUrl(String txt)
      Returns a URL constructed from the given text according to the knowledge of this WebMapper, if it looks suitable. If the supplied string does not look like the kind of input this mapper is expecting, it should return null.

      Where possible, implementations should do enough checking of the format to tell whether the result is likely to be a resolvable URL (though without taking significant time to do it), rather than just making a best effort to come up with a URL that's unlikely to work.

      Parameters:
      txt - location string
      Returns:
      URL, or null
    • getName

      public String getName()
      Returns the user-visible name for this mapper.
      Returns:
      name
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getMappers

      public static WebMapper[] getMappers()
      Returns a list of all the known useful mappers. The AUTO mapper will be first in the list.
      Returns:
      mapper list
    • createPrefixMapper

      public static WebMapper createPrefixMapper(String name, String urlPrefix)
      Returns a mapper that blindly appends the given location string to a supplied prefix URL, pausing only to URL-encode it. This implementation does not attempt to assess the supplied URL for suitability, so it never returns null except in case of a blank input string.
      Parameters:
      name - mapper name
      Returns:
      new mapper
    • createMultiMapper

      public static WebMapper createMultiMapper(String name, WebMapper[] others)
      Returns a mapper that combines others to come up with a result if any of them can turn a string into a URL.
      Parameters:
      name - mapper name
      others - list of WebMappers to which this one will try delegating in turn
      Returns:
      new mapper