| java.lang.Object org.jamwiki.utils.LinkUtil
LinkUtil | public class LinkUtil (Code) | | General utility methods for handling both wiki topic links such as
"Topic#Section?query=param", as well as HTML links of the form
http://example.com/.
|
Method Summary | |
public static String | appendQueryParam(String query, String param, String value) Build a query parameter. | public static String | buildEditLinkUrl(String context, String virtualWiki, String topic, String query, int section) Utility method for building a URL link to a wiki edit page for a
specified topic.
Parameters: context - The servlet context for the link that is being created. Parameters: virtualWiki - The virtual wiki for the link that is being created. Parameters: topic - The name of the topic for which an edit link is beingcreated. Parameters: query - Any existing query parameters to append to the edit link.This value may be either null or empty. Parameters: section - The section defined by the name parameter within theHTML page for the topic being edited. | public static String | buildImageLinkHtml(String context, String virtualWiki, String topicName, boolean frame, boolean thumb, String align, String caption, int maxDimension, boolean suppressLink, String style, boolean escapeHtml) Utility method for building an anchor tag that links to an image page
and includes the HTML image tag to display the image.
Parameters: context - The servlet context for the link that is being created. Parameters: virtualWiki - The virtual wiki for the link that is being created. Parameters: topicName - The name of the image for which a link is beingcreated. Parameters: frame - Set to true if the image should display witha frame border. Parameters: thumb - Set to true if the image should display as athumbnail. Parameters: align - Indicates how the image should horizontally align on thepage. | public static String | buildInternalLinkHtml(String context, String virtualWiki, WikiLink wikiLink, String text, String style, String target, boolean escapeHtml) Build the HTML anchor link to a topic page for a given WikLink object.
Parameters: context - The servlet context for the link that is being created. Parameters: virtualWiki - The virtual wiki for the link that is being created. Parameters: wikiLink - The WikiLink object containing all relevant informationabout the link being generated. Parameters: text - The text to display as the link content. Parameters: style - The CSS class to use with the anchor HTML tag. | public static String | buildInternalLinkUrl(String context, String virtualWiki, String topic) Build a URL to the topic page for a given topic.
Parameters: context - The servlet context path. | public static String | buildInternalLinkUrl(String context, String virtualWiki, WikiLink wikiLink) Build a URL to the topic page for a given topic.
Parameters: context - The servlet context path. | public static String | interWiki(WikiLink wikiLink) Generate the HTML for an interwiki anchor link.
Parameters: wikiLink - The WikiLink object containing all relevant informationabout the link being generated. | public static boolean | isExistingArticle(String virtualWiki, String articleName) Utility method for determining if an article name corresponds to a valid
wiki link. | public static WikiLink | parseWikiLink(String raw) Parse a topic name of the form "Topic#Section?Query", and return a WikiLink
object representing the link.
Parameters: raw - The raw topic link text. |
appendQueryParam | public static String appendQueryParam(String query, String param, String value)(Code) | | Build a query parameter. If root is empty, this method returns
"?param=value". If root is not empty this method returns root +
"¶m=value". Note that param and value will be URL encoded,
and if "query" does not start with a "?" then one will be pre-pended.
Parameters: query - The existing query parameter, if one is available. If thequery parameter does not start with "?" then one will be pre-pended. Parameters: param - The name of the query parameter being appended. Thisvalue will be URL encoded. Parameters: value - The value of the query parameter being appended. Thisvalue will be URL encoded. The full query string generated using the input parameters. |
buildEditLinkUrl | public static String buildEditLinkUrl(String context, String virtualWiki, String topic, String query, int section) throws Exception(Code) | | Utility method for building a URL link to a wiki edit page for a
specified topic.
Parameters: context - The servlet context for the link that is being created. Parameters: virtualWiki - The virtual wiki for the link that is being created. Parameters: topic - The name of the topic for which an edit link is beingcreated. Parameters: query - Any existing query parameters to append to the edit link.This value may be either null or empty. Parameters: section - The section defined by the name parameter within theHTML page for the topic being edited. If provided then the edit linkwill allow editing of only the specified section. A url that links to the edit page for the specified topic.Note that this method returns only the URL, not a fully-formed HTMLanchor tag. throws: Exception - Thrown if any error occurs while builing the link URL. |
buildImageLinkHtml | public static String buildImageLinkHtml(String context, String virtualWiki, String topicName, boolean frame, boolean thumb, String align, String caption, int maxDimension, boolean suppressLink, String style, boolean escapeHtml) throws Exception(Code) | | Utility method for building an anchor tag that links to an image page
and includes the HTML image tag to display the image.
Parameters: context - The servlet context for the link that is being created. Parameters: virtualWiki - The virtual wiki for the link that is being created. Parameters: topicName - The name of the image for which a link is beingcreated. Parameters: frame - Set to true if the image should display witha frame border. Parameters: thumb - Set to true if the image should display as athumbnail. Parameters: align - Indicates how the image should horizontally align on thepage. Valid values are "left", "right" and "center". Parameters: caption - An optional text caption to display for the image. Ifno caption is used then this value should be either empty ornull . Parameters: maxDimension - A value in pixels indicating the maximum width orheight value allowed for the image. Images will be resized so thatneither the width or height exceeds this value. Parameters: suppressLink - If this value is true then thegenerated HTML will include the image tag without a link to the imagetopic page. Parameters: style - The CSS class to use with the img HTML tag. This valuecan be null or empty if no custom style is used. Parameters: escapeHtml - Set to true if the caption should beHTML escaped. This value should be true in any casewhere the caption is not guaranteed to be free from potentiallymalicious HTML code. The full HTML required to display an image enclosed within anHTML anchor tag that links to the image topic page. throws: Exception - Thrown if any error occurs while builing the imageHTML. |
buildInternalLinkHtml | public static String buildInternalLinkHtml(String context, String virtualWiki, WikiLink wikiLink, String text, String style, String target, boolean escapeHtml) throws Exception(Code) | | Build the HTML anchor link to a topic page for a given WikLink object.
Parameters: context - The servlet context for the link that is being created. Parameters: virtualWiki - The virtual wiki for the link that is being created. Parameters: wikiLink - The WikiLink object containing all relevant informationabout the link being generated. Parameters: text - The text to display as the link content. Parameters: style - The CSS class to use with the anchor HTML tag. This valuecan be null or empty if no custom style is used. Parameters: target - The anchor link target, or null or empty ifno target is needed. Parameters: escapeHtml - Set to true if the link caption shouldbe HTML escaped. This value should be true in any casewhere the caption is not guaranteed to be free from potentiallymalicious HTML code. An HTML anchor link that matches the given input parameters. throws: Exception - Thrown if any error occurs while builing the linkHTML. |
buildInternalLinkUrl | public static String buildInternalLinkUrl(String context, String virtualWiki, String topic) throws Exception(Code) | | Build a URL to the topic page for a given topic.
Parameters: context - The servlet context path. If this value isnull then the resulting URL will NOT include context path,which breaks HTML links but is useful for servlet redirection URLs. Parameters: virtualWiki - The virtual wiki for the link that is being created. Parameters: topic - The topic name for the URL that is being generated. throws: Exception - Thrown if any error occurs while builing the linkURL. |
buildInternalLinkUrl | public static String buildInternalLinkUrl(String context, String virtualWiki, WikiLink wikiLink) throws Exception(Code) | | Build a URL to the topic page for a given topic.
Parameters: context - The servlet context path. If this value isnull then the resulting URL will NOT include context path,which breaks HTML links but is useful for servlet redirection URLs. Parameters: virtualWiki - The virtual wiki for the link that is being created. Parameters: wikiLink - The WikiLink object containing all relevant informationabout the link being generated. throws: Exception - Thrown if any error occurs while builing the linkURL. |
interWiki | public static String interWiki(WikiLink wikiLink)(Code) | | Generate the HTML for an interwiki anchor link.
Parameters: wikiLink - The WikiLink object containing all relevant informationabout the link being generated. The HTML anchor tag for the interwiki link. |
isExistingArticle | public static boolean isExistingArticle(String virtualWiki, String articleName) throws Exception(Code) | | Utility method for determining if an article name corresponds to a valid
wiki link. In this case an "article name" could be an existing topic, a
"Special:" page, a user page, an interwiki link, etc. This method will
return true if the given name corresponds to a valid special page, user
page, topic, or other existing article.
Parameters: virtualWiki - The virtual wiki for the topic being checked. Parameters: articleName - The name of the article that is being checked. true if there is an article that exists for the givenname and virtual wiki. throws: Exception - Thrown if any error occurs during lookup. |
parseWikiLink | public static WikiLink parseWikiLink(String raw)(Code) | | Parse a topic name of the form "Topic#Section?Query", and return a WikiLink
object representing the link.
Parameters: raw - The raw topic link text. A WikiLink object that represents the link. |
|
|