Class AptUtils
- java.lang.Object
-
- org.apache.maven.doxia.module.apt.AptUtils
-
public class AptUtils extends java.lang.Object
A collection of utility methods for dealing with APT documents.- Since:
- 1.1
- Version:
- $Id$
-
-
Constructor Summary
Constructors Modifier Constructor Description private
AptUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.String
encodeAnchor(java.lang.String id)
Construct a valid anchor.static java.lang.String
encodeFragment(java.lang.String text)
Deprecated.This method was used for the original apt format, which removed all non alphanumeric characters from anchors.static boolean
isExternalLink(java.lang.String link)
Checks if the given string corresponds to an external URI, ie is not a link within the same document nor a link to another document within the same site.static boolean
isInternalLink(java.lang.String link)
Checks if the given string corresponds to an internal link, ie it is a link to an anchor within the same document.static boolean
isLocalLink(java.lang.String link)
Checks if the given string corresponds to a relative link to another document within the same site.static java.lang.String
linkToKey(java.lang.String text)
Deprecated.This method was used for the original apt format, which removed all non alphanumeric characters from anchors.
-
-
-
Method Detail
-
encodeFragment
public static java.lang.String encodeFragment(java.lang.String text)
Deprecated.This method was used for the original apt format, which removed all non alphanumeric characters from anchors. UseencodeAnchor(String)
instead.Replace all characters in a text.AptTools.encodeFragment( null ) = null AptTools.encodeFragment( "" ) = "" AptTools.encodeFragment( "http://www.google.com" ) = "httpwwwgooglecom"
- Parameters:
text
- the String to check, may be null.- Returns:
- the text with only letter and digit, null if null String input.
-
isExternalLink
public static boolean isExternalLink(java.lang.String link)
Checks if the given string corresponds to an external URI, ie is not a link within the same document nor a link to another document within the same site. This forwards toDoxiaUtils.isExternalLink(String)
.- Parameters:
link
- The link to check.- Returns:
- True if DoxiaUtils.isExternalLink(link) returns true.
- See Also:
DoxiaUtils.isExternalLink(String)
,isInternalLink(String)
,isLocalLink(String)
-
isInternalLink
public static boolean isInternalLink(java.lang.String link)
Checks if the given string corresponds to an internal link, ie it is a link to an anchor within the same document.- Parameters:
link
- The link to check.- Returns:
- True if link is neither an
external
nor alocal
link. - See Also:
DoxiaUtils.isInternalLink(String)
,isExternalLink(String)
,isLocalLink(String)
-
isLocalLink
public static boolean isLocalLink(java.lang.String link)
Checks if the given string corresponds to a relative link to another document within the same site.- Parameters:
link
- The link to check.- Returns:
- True if the link starts with either "/", "./" or "../".
- See Also:
DoxiaUtils.isLocalLink(String)
,isExternalLink(String)
,isInternalLink(String)
-
linkToKey
public static java.lang.String linkToKey(java.lang.String text)
Deprecated.This method was used for the original apt format, which removed all non alphanumeric characters from anchors. UseencodeAnchor(String)
instead.Transforms the given text such that it can be used as a link. All non-LetterOrDigit characters are removed and the remaining characters are transformed to lower-case.- Parameters:
text
- The text to transform.- Returns:
- The text with all non-LetterOrDigit characters removed.
-
encodeAnchor
public static java.lang.String encodeAnchor(java.lang.String id)
Construct a valid anchor. This is a simplified version ofDoxiaUtils.encodeId(String)
to ensure the anchor is a valid Doxia id. The procedure is identical to the one inHtmlTools.encodeId(String)
:- Trim the id
- If the first character is not a letter, prepend the letter 'a'
- Any space is replaced with an underscore '_'
- Remove any non alphanumeric characters except ':', '_', '.', '-'.
- Parameters:
id
- The id to be encoded.- Returns:
- The trimmed and encoded id, or null if id is null.
-
-