Class AptUtils


  • public class AptUtils
    extends Object
    A collection of utility methods for dealing with APT documents.
    Since:
    1.1
    Author:
    ltheussl
    • Method Detail

      • encodeFragment

        public static String encodeFragment​(String text)
        Deprecated.
        This method was used for the original apt format, which removed all non alphanumeric characters from anchors. Use encodeAnchor(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.
      • linkToKey

        public static String linkToKey​(String text)
        Deprecated.
        This method was used for the original apt format, which removed all non alphanumeric characters from anchors. Use encodeAnchor(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 String encodeAnchor​(String id)
        Construct a valid anchor. This is a simplified version of DoxiaUtils.encodeId(String) to ensure the anchor is a valid Doxia id. The procedure is identical to the one in HtmlTools.encodeId(String):
        1. Trim the id
        2. If the first character is not a letter, prepend the letter 'a'
        3. Any space is replaced with an underscore '_'
        4. 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.