Package uk.ac.starlink.ttools.calc
Class WebMapper
java.lang.Object
uk.ac.starlink.ttools.calc.WebMapper
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
FieldsModifier and TypeFieldDescriptionstatic 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.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.getName()
Returns the user-visible name for this mapper.toString()
abstract URL
Returns a URL constructed from the given text according to the knowledge of this WebMapper, if it looks suitable.
-
Field Details
-
FILE
Mapper for pathname of a file in the local filesystem. -
URL
Mapper for a string that's already a URL. -
BIBCODE
Mapper for a Bibcode. -
DOI
Mapper for a DOI (Digital Object Identifier). -
ARXIV
Mapper for an arXiv identifier. -
SIMBAD
Maps a source identifier to its Simbad web page. -
NED
Maps a source identifier to its NED web page. -
BIBCODE_OLD
Mapper for a Bibcode, using the Classic web pages (deprecated by ADS). -
NED_CLASSIC
Maps a source identifier to its classic NED web page. -
AUTO
Mapper that tries various strategies to turn a string into a URL.
-
-
Constructor Details
-
WebMapper
Constructor.- Parameters:
name
- user-visible name for this mapper
-
-
Method Details
-
toUrl
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
Returns the user-visible name for this mapper.- Returns:
- name
-
toString
-
getMappers
Returns a list of all the known useful mappers. TheAUTO
mapper will be first in the list.- Returns:
- mapper list
-
createPrefixMapper
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
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 nameothers
- list of WebMappers to which this one will try delegating in turn- Returns:
- new mapper
-