public class SitesImpl extends Object implements Sites
Sites
interface that allows sites to be
registered. Objects of this type are not immutable, since they are not data
objects, but the Sites
interface only supports read access.
This object supports protocol-relative URLs by adding the default protocol
DEFAULT_PROTOCOL_PREFIX
for these cases.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_PROTOCOL_PREFIX
MediaWiki supports relative URLs in site configurations, which do not
start with "http://" or "https://", but with "//".
|
Constructor and Description |
---|
SitesImpl() |
Modifier and Type | Method and Description |
---|---|
String |
getFileUrl(String siteKey,
String fileName)
Returns the URL for the file of the given name, or null if the site is
not known.
|
String |
getGroup(String siteKey)
Returns the group for the given site, or null if there is no such data
for this site key.
|
String |
getLanguageCode(String siteKey)
Returns the MediaWiki language code for the given site, or null if there
is no such data for this site key.
|
String |
getPageUrl(String siteKey,
String pageTitle)
Returns the URL for the page of the given name, or null if the site is
not known.
|
String |
getSiteLinkUrl(SiteLink siteLink)
Returns the URL for the given site link, or null if its site key is not
known.
|
String |
getSiteType(String siteKey)
Returns the type for the given site, or null if there is no such data for
this site key.
|
void |
setSiteInformation(String siteKey,
String group,
String languageCode,
String siteType,
String filePath,
String pagePath)
Sets the stored information for the site of the given key to the given
values.
|
public static String DEFAULT_PROTOCOL_PREFIX
public void setSiteInformation(String siteKey, String group, String languageCode, String siteType, String filePath, String pagePath)
Sites
Note that the path URLs given here should be absolute. In MediaWiki, it is common to use protocol-relative paths (starting with "//" rather than with "http://" or "https://"). The code in this class is not prepared to handle this yet (URL-returning methods would need to allow for a preferred protocol to be specified).
setSiteInformation
in interface Sites
siteKey
- the global site key, e.g., "enwiki" or "fawikivoyage"group
- the site group, e.g., "wikipedia" or "wikivoyage"languageCode
- the site MediaWiki language code, e.g., "en" or "fa"siteType
- the site type, typically "mediawiki"filePath
- the file path with $1 as a placeholder for the file name,
e.g., "http://en.wikipedia.org/w/$1" or
"http://fa.wikivoyage.org/w/$1"pagePath
- the page path with $1 as a placeholder for the page title,
e.g., "http://en.wikipedia.org/wiki/$1" or
"http://fa.wikivoyage.org/wiki/$1"public String getLanguageCode(String siteKey)
Sites
The language code follows the MediaWiki conventions for language codes, which do not follow any standard. Most codes agree with those in BCP 47 , but there are a number of exceptions.
getLanguageCode
in interface Sites
siteKey
- the global site keypublic String getGroup(String siteKey)
Sites
public String getPageUrl(String siteKey, String pageTitle)
Sites
getPageUrl
in interface Sites
siteKey
- the global site keypageTitle
- the title of the page, including namespace prefixes if anypublic String getSiteLinkUrl(SiteLink siteLink)
Sites
getSiteLinkUrl
in interface Sites
siteLink
- the SiteLink objectpublic String getFileUrl(String siteKey, String fileName)
Sites
getFileUrl
in interface Sites
siteKey
- the global site keyfileName
- the name of the filepublic String getSiteType(String siteKey)
Sites
getSiteType
in interface Sites
siteKey
- the global site keyCopyright © 2014–2024 Wikidata Toolkit Developers. Generated from source code published under the Apache License 2.0. For more information, see the Wikidata Toolkit homepage