/** * @return the <a href="http://en.wikipedia.org/wiki/InterWiki">Inter Wiki</a> alias to which the resource is * pointing to or null if not defined. Mappings between Inter Wiki aliases and actual locations are defined * in the Inter Wiki Map. Example: "wikipedia" */ public String getInterWikiAlias() { return getParameter(INTERWIKI_ALIAS); } }
/** * @param interWikiAlias see {@link #getInterWikiAlias()} */ public void setInterWikiAlias(String interWikiAlias) { setParameter(INTERWIKI_ALIAS, interWikiAlias); }
/** * @param reference see {@link #getReference()} */ public InterWikiResourceReference(String reference) { super(reference, ResourceType.INTERWIKI); setTyped(true); }
/** * {@inheritDoc} * * @see AbstractURIResourceReferenceTypeParser#parse(String) */ @Override public ResourceReference parse(String reference) { ResourceReference resultReference = null; // Try to find an interwiki separator to extract the interwiki alias from the interwiki suffix. // If no separator is found it means the interwiki link syntax is invalid. In this case consider that the // reference is not an interwiki link. int pos = reference.indexOf(INTERWIKI_ALIAS_SEPARATOR); if (pos > -1) { InterWikiResourceReference interWikiReference = new InterWikiResourceReference(reference.substring(pos + INTERWIKI_ALIAS_SEPARATOR.length())); interWikiReference.setInterWikiAlias(reference.substring(0, pos + INTERWIKI_ALIAS_SEPARATOR.length() - 1)); resultReference = interWikiReference; } return resultReference; } }
/** * Check if the passed link references is an interwiki link reference. * * @param content the original content to parse * @return the parsed Link object or null if the passed reference is not an interwiki link reference */ private ResourceReference parseInterWikiLinks(StringBuffer content) { ResourceReference result = null; String interWikiAlias = parseElementAfterString(content, SEPARATOR_INTERWIKI); if (interWikiAlias != null) { InterWikiResourceReference link = new InterWikiResourceReference(removeEscapes(content.toString())); link.setInterWikiAlias(removeEscapes(interWikiAlias)); result = link; } return result; }