public class URLs extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
arxivUrl(String arxivId)
Maps an arXiv identifier to the URL that will display its
arXiv web page.
|
static String |
bibcodeUrl(String bibcode)
Maps a bibcode to the URL that will display the relevant entry in
ADS.
|
static String |
doiUrl(String doi)
Maps a DOI (Digital Object Identifier) to its display URL.
|
static String |
hips2fitsUrl(String hipsId,
String fmt,
double raDeg,
double decDeg,
double fovDeg,
int npix)
Returns the URL of a cutout from the Hips2Fits service operated
by CDS.
|
static String |
nedUrl(String sourceId)
Maps a source identifier to the URL of its
NED web page.
|
static String |
paramsUrl(String baseUrl,
String... nameValuePairs)
Builds a query-type URL string given a base URL and a list of
name, value pairs.
|
static String |
simbadUrl(String sourceId)
Maps a source identifier to the URL of its
SIMBAD web page.
|
static String |
urlDecode(String txt)
Reverses the quoting performed by
urlEncode. |
static String |
urlEncode(String txt)
Performs necessary quoting of a string for it to be included
safely in the data part of a URL.
|
public static String urlEncode(String txt)
_"),
minus sign ("-"),
period (".") and
tilde ("~") are passed through unchanged,
and any other 7-bit ASCII character is represented by a percent sign
("%") followed by its 2-digit hexadecimal code.
Characters with values of 128 or greater are simply dropped.txt - input (unencoded) stringpublic static String urlDecode(String txt)
urlEncode.
Percent-encoded sequences (%xx) are replaced
by the ASCII character with the hexadecimal code xx.txt - input (encoded) stringpublic static String paramsUrl(String baseUrl, String... nameValuePairs)
The parameters are encoded on the command line according to the
"application/x-www-form-urlencoded" convention,
which appends a "?" to the base URL, and then adds name=value pairs
separated by "&" characters, with percent-encoding of
non-URL-friendly characters.
This format is used by many services that require a list of parameters
to be conveyed on the URL.
baseUrl - basic URL (may or may not already contain a "?")nameValuePairs - an even number of arguments
(or an even-length string array) giving
parameter name1,value1,name2,value2,...nameN,valueNpublic static String bibcodeUrl(String bibcode)
If the supplied string appears to be a bibcode,
it just prepends the string
"https://ui.adsabs.harvard.edu/abs/"
and performs any character escaping that is required.
bibcode - ADS-style bibcode stringpublic static String doiUrl(String doi)
If the supplied string appears to be a DOI,
it strips any "doi:" prefix if present,
prepends the string "https://doi.org/",
and performs any character escaping that is required.
doi - DOI string, with or without "doi:" prefixpublic static String arxivUrl(String arxivId)
If the supplied string appears to be an arXiv identifier,
it strips any "arXiv: prefix
and prepends the string "https://arxiv.org/abs/".
arxivId - arXiv identifier, with or without "arXiv:" prefixpublic static String simbadUrl(String sourceId)
The string
"http://simbad.u-strasbg.fr/simbad/sim-id?Ident="
is prepended to the given id string, and any necessary character
escaping is applied.
No attempt is made to validate whether the supplied string is
a real source identifier, so there is no guarantee that the
returned URL will contain actual results.
sourceId - free text assumed to represent a source identifier
known by SIMBADpublic static String nedUrl(String sourceId)
The string
"http://ned.ipac.caltech.edu/byname?objname="
is prepended to the given id string, and any necessary character
escaping is applied.
No attempt is made to validate whether the supplied string is
a real source identifier, so there is no guarantee that the
returned URL will contain actual results.
sourceId - free text assumed to represent a source identifier
known by NEDpublic static String hips2fitsUrl(String hipsId, String fmt, double raDeg, double decDeg, double fovDeg, int npix)
This function requests a square cutout using the SIN projection, which is suitable for small cutouts. If the details of this function don't suit your purposes, you can construct the URL yourself.
hipsId - identifier or partial identifier for the HiPS surveyfmt - required output format, for instance
"fits", "png",
"jpg"raDeg - central Right Ascension (longitude) in degreesdecDeg - central Declination (latitude) in degreesfovDeg - field of view; extent of the cutout in degreesnpix - extent of the cutout in pixels (width=height=npix)Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.