com.twitter.twittertext

## Class Autolink

- java.lang.Object
- - com.twitter.twittertext.Autolink

-     public class Autolink
      extends java.lang.Object

  A class for adding HTML links to hashtag, username and list references in Tweet text.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `Autolink.LinkAttributeModifier`
    `static interface` | `Autolink.LinkTextModifier`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `cashtagClass`
    `protected java.lang.String` | `cashtagUrlBase`
    `static java.lang.String` | `DEFAULT_CASHTAG_CLASS` Default CSS class for auto-linked cashtag URLs
    `static java.lang.String` | `DEFAULT_CASHTAG_URL_BASE` Default href for cashtag links (the cashtag without the $ will be appended)
    `static java.lang.String` | `DEFAULT_HASHTAG_CLASS` Default CSS class for auto-linked hashtag URLs
    `static java.lang.String` | `DEFAULT_HASHTAG_URL_BASE` Default href for hashtag links (the hashtag without the # will be appended)
    `static java.lang.String` | `DEFAULT_INVISIBLE_TAG_ATTRS` Default attribute for invisible span tag
    `static java.lang.String` | `DEFAULT_LIST_CLASS` Default CSS class for auto-linked list URLs
    `static java.lang.String` | `DEFAULT_LIST_URL_BASE` Default href for list links (the username/list without the @ will be appended)
    `static java.lang.String` | `DEFAULT_USERNAME_CLASS` Default CSS class for auto-linked username URLs
    `static java.lang.String` | `DEFAULT_USERNAME_URL_BASE` Default href for username links (the username without the @ will be appended)
    `protected java.lang.String` | `hashtagClass`
    `protected java.lang.String` | `hashtagUrlBase`
    `protected java.lang.String` | `invisibleTagAttrs`
    `protected Autolink.LinkAttributeModifier` | `linkAttributeModifier`
    `protected Autolink.LinkTextModifier` | `linkTextModifier`
    `protected java.lang.String` | `listClass`
    `protected java.lang.String` | `listUrlBase`
    `protected boolean` | `noFollow`
    `protected java.lang.String` | `symbolTag`
    `protected java.lang.String` | `textWithSymbolTag`
    `protected java.lang.String` | `urlClass`
    `protected java.lang.String` | `urlTarget`
    `protected java.lang.String` | `usernameClass`
    `protected boolean` | `usernameIncludeSymbol`
    `protected java.lang.String` | `usernameUrlBase`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Autolink()`
    `Autolink(boolean noFollow)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `autoLink(java.lang.String originalText)` Auto-link hashtags, URLs, usernames and lists.
    `java.lang.String` | `autoLinkCashtags(java.lang.String text)` Auto-link $cashtag references in the provided Tweet text.
    `java.lang.String` | `autoLinkEntities(java.lang.String text, java.util.List<Extractor.Entity> entities)`
    `java.lang.String` | `autoLinkHashtags(java.lang.String text)` Auto-link #hashtag references in the provided Tweet text.
    `java.lang.String` | `autoLinkURLs(java.lang.String text)` Auto-link URLs in the Tweet text provided.
    `java.lang.String` | `autoLinkUsernamesAndLists(java.lang.String text)` Auto-link the @username and @username/list references in the provided text.
    `java.lang.String` | `escapeBrackets(java.lang.String text)`
    `java.lang.String` | `getCashtagClass()` Get CSS class for auto-linked cashtag URLs
    `java.lang.String` | `getCashtagUrlBase()` Get the href value for cashtag links (to which the cashtag will be appended)
    `java.lang.String` | `getHashtagClass()` Get CSS class for auto-linked hashtag URLs
    `java.lang.String` | `getHashtagUrlBase()` Get the href value for hashtag links (to which the hashtag will be appended)
    `java.lang.String` | `getListClass()` Get CSS class for auto-linked list URLs
    `java.lang.String` | `getListUrlBase()` Get the href value for list links (to which the username/list will be appended)
    `java.lang.String` | `getUrlClass()` Get CSS class for auto-linked URLs
    `java.lang.String` | `getUsernameClass()` Get CSS class for auto-linked username URLs
    `java.lang.String` | `getUsernameUrlBase()` Get the href value for username links (to which the username will be appended)
    `boolean` | `isNoFollow()` Checks if the current URL links will include rel="nofollow" (true by default)
    `void` | `linkToCashtag(Extractor.Entity entity, java.lang.String text, java.lang.StringBuilder builder)`
    `void` | `linkToHashtag(Extractor.Entity entity, java.lang.String text, java.lang.StringBuilder builder)`
    `void` | `linkToMentionAndList(Extractor.Entity entity, java.lang.String text, java.lang.StringBuilder builder)`
    `void` | `linkToText(Extractor.Entity entity, java.lang.CharSequence originalText, java.util.Map<java.lang.String,java.lang.String> attributes, java.lang.StringBuilder builder)`
    `void` | `linkToTextWithSymbol(Extractor.Entity entity, java.lang.CharSequence symbol, java.lang.CharSequence originalText, java.util.Map<java.lang.String,java.lang.String> attributes, java.lang.StringBuilder builder)`
    `void` | `linkToURL(Extractor.Entity entity, java.lang.String text, java.lang.StringBuilder builder)`
    `void` | `setCashtagClass(java.lang.String cashtagClass)` Set the CSS class for auto-linked cashtag URLs
    `void` | `setCashtagUrlBase(java.lang.String cashtagUrlBase)` Set the href base for cashtag links.
    `void` | `setHashtagClass(java.lang.String hashtagClass)` Set the CSS class for auto-linked hashtag URLs
    `void` | `setHashtagUrlBase(java.lang.String hashtagUrlBase)` Set the href base for hashtag links.
    `void` | `setLinkAttributeModifier(Autolink.LinkAttributeModifier modifier)` Set a modifier to modify attributes of a link based on an entity
    `void` | `setLinkTextModifier(Autolink.LinkTextModifier modifier)` Set a modifier to modify text of a link based on an entity
    `void` | `setListClass(java.lang.String listClass)` Set the CSS class for auto-linked list URLs
    `void` | `setListUrlBase(java.lang.String listUrlBase)` Set the href base for list links.
    `void` | `setNoFollow(boolean noFollow)` Set if the current URL links will include rel="nofollow" (true by default)
    `void` | `setSymbolTag(java.lang.String tag)` Set HTML tag to be applied around #/@/# symbols in hashtags/usernames/lists/cashtag
    `void` | `setTextWithSymbolTag(java.lang.String tag)` Set HTML tag to be applied around text part of hashtags/usernames/lists/cashtag
    `void` | `setUrlClass(java.lang.String urlClass)` Set the CSS class for auto-linked URLs
    `void` | `setUrlTarget(java.lang.String target)` Set the value of the target attribute in auto-linked URLs
    `void` | `setUsernameClass(java.lang.String usernameClass)` Set the CSS class for auto-linked username URLs
    `void` | `setUsernameIncludeSymbol(boolean usernameIncludeSymbol)` Set if the at mark '@' should be included in the link (false by default)
    `void` | `setUsernameUrlBase(java.lang.String usernameUrlBase)` Set the href base for username links.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_LIST_CLASS

          public static final java.lang.String DEFAULT_LIST_CLASS

      Default CSS class for auto-linked list URLs
      See Also:
        Constant Field Values

    - #### DEFAULT_USERNAME_CLASS

          public static final java.lang.String DEFAULT_USERNAME_CLASS

      Default CSS class for auto-linked username URLs
      See Also:
        Constant Field Values

    - #### DEFAULT_HASHTAG_CLASS

          public static final java.lang.String DEFAULT_HASHTAG_CLASS

      Default CSS class for auto-linked hashtag URLs
      See Also:
        Constant Field Values

    - #### DEFAULT_CASHTAG_CLASS

          public static final java.lang.String DEFAULT_CASHTAG_CLASS

      Default CSS class for auto-linked cashtag URLs
      See Also:
        Constant Field Values

    - #### DEFAULT_USERNAME_URL_BASE

          public static final java.lang.String DEFAULT_USERNAME_URL_BASE

      Default href for username links (the username without the @ will be appended)
      See Also:
        Constant Field Values

    - #### DEFAULT_LIST_URL_BASE

          public static final java.lang.String DEFAULT_LIST_URL_BASE

      Default href for list links (the username/list without the @ will be appended)
      See Also:
        Constant Field Values

    - #### DEFAULT_HASHTAG_URL_BASE

          public static final java.lang.String DEFAULT_HASHTAG_URL_BASE

      Default href for hashtag links (the hashtag without the # will be appended)
      See Also:
        Constant Field Values

    - #### DEFAULT_CASHTAG_URL_BASE

          public static final java.lang.String DEFAULT_CASHTAG_URL_BASE

      Default href for cashtag links (the cashtag without the $ will be appended)
      See Also:
        Constant Field Values

    - #### DEFAULT_INVISIBLE_TAG_ATTRS

          public static final java.lang.String DEFAULT_INVISIBLE_TAG_ATTRS

      Default attribute for invisible span tag
      See Also:
        Constant Field Values

    - #### urlClass

          protected java.lang.String urlClass

    - #### listClass

          protected java.lang.String listClass

    - #### usernameClass

          protected java.lang.String usernameClass

    - #### hashtagClass

          protected java.lang.String hashtagClass

    - #### cashtagClass

          protected java.lang.String cashtagClass

    - #### usernameUrlBase

          protected java.lang.String usernameUrlBase

    - #### listUrlBase

          protected java.lang.String listUrlBase

    - #### hashtagUrlBase

          protected java.lang.String hashtagUrlBase

    - #### cashtagUrlBase

          protected java.lang.String cashtagUrlBase

    - #### invisibleTagAttrs

          protected java.lang.String invisibleTagAttrs

    - #### noFollow

          protected boolean noFollow

    - #### usernameIncludeSymbol

          protected boolean usernameIncludeSymbol

    - #### symbolTag

          protected java.lang.String symbolTag

    - #### textWithSymbolTag

          protected java.lang.String textWithSymbolTag

    - #### urlTarget

          protected java.lang.String urlTarget

    - #### linkAttributeModifier

          protected Autolink.LinkAttributeModifier linkAttributeModifier

    - #### linkTextModifier

          protected Autolink.LinkTextModifier linkTextModifier

  - ### Constructor Detail

    - #### Autolink

          public Autolink()

    - #### Autolink

          public Autolink(boolean noFollow)

  - ### Method Detail

    - #### escapeBrackets

          public java.lang.String escapeBrackets(java.lang.String text)

    - #### linkToText

          public void linkToText(Extractor.Entity entity,
                                 java.lang.CharSequence originalText,
                                 java.util.Map<java.lang.String,java.lang.String> attributes,
                                 java.lang.StringBuilder builder)

    - #### linkToTextWithSymbol

          public void linkToTextWithSymbol(Extractor.Entity entity,
                                           java.lang.CharSequence symbol,
                                           java.lang.CharSequence originalText,
                                           java.util.Map<java.lang.String,java.lang.String> attributes,
                                           java.lang.StringBuilder builder)

    - #### linkToHashtag

          public void linkToHashtag(Extractor.Entity entity,
                                    java.lang.String text,
                                    java.lang.StringBuilder builder)

    - #### linkToCashtag

          public void linkToCashtag(Extractor.Entity entity,
                                    java.lang.String text,
                                    java.lang.StringBuilder builder)

    - #### linkToMentionAndList

          public void linkToMentionAndList(Extractor.Entity entity,
                                           java.lang.String text,
                                           java.lang.StringBuilder builder)

    - #### linkToURL

          public void linkToURL(Extractor.Entity entity,
                                java.lang.String text,
                                java.lang.StringBuilder builder)

    - #### autoLinkEntities

          public java.lang.String autoLinkEntities(java.lang.String text,
                                                   java.util.List<Extractor.Entity> entities)

    - #### autoLink

          public java.lang.String autoLink(java.lang.String originalText)

      Auto-link hashtags, URLs, usernames and lists.
      Parameters:
        `originalText` - of the Tweet to auto-link
      Returns:
        text with auto-link HTML added

    - #### autoLinkUsernamesAndLists

          public java.lang.String autoLinkUsernamesAndLists(java.lang.String text)

      Auto-link the @username and @username/list references in the provided text. Links to @username references will have the usernameClass CSS classes added. Links to @username/list references will have the listClass CSS class added.
      Parameters:
        `text` - of the Tweet to auto-link
      Returns:
        text with auto-link HTML added

    - #### autoLinkHashtags

          public java.lang.String autoLinkHashtags(java.lang.String text)

      Auto-link #hashtag references in the provided Tweet text. The #hashtag links will have the hashtagClass CSS class added.
      Parameters:
        `text` - of the Tweet to auto-link
      Returns:
        text with auto-link HTML added

    - #### autoLinkURLs

          public java.lang.String autoLinkURLs(java.lang.String text)

      Auto-link URLs in the Tweet text provided. This only auto-links URLs with protocol.
      Parameters:
        `text` - of the Tweet to auto-link
      Returns:
        text with auto-link HTML added

    - #### autoLinkCashtags

          public java.lang.String autoLinkCashtags(java.lang.String text)

      Auto-link $cashtag references in the provided Tweet text. The $cashtag links will have the cashtagClass CSS class added.
      Parameters:
        `text` - of the Tweet to auto-link
      Returns:
        text with auto-link HTML added

    - #### getUrlClass

          public java.lang.String getUrlClass()

      Get CSS class for auto-linked URLs
      Returns:
        String that represents the CSS class

    - #### setUrlClass

          public void setUrlClass(java.lang.String urlClass)

      Set the CSS class for auto-linked URLs
      Parameters:
        `urlClass` - new CSS value.

    - #### getListClass

          public java.lang.String getListClass()

      Get CSS class for auto-linked list URLs
      Returns:
        String that represents the CSS class

    - #### setListClass

          public void setListClass(java.lang.String listClass)

      Set the CSS class for auto-linked list URLs
      Parameters:
        `listClass` - new CSS value.

    - #### getUsernameClass

          public java.lang.String getUsernameClass()

      Get CSS class for auto-linked username URLs
      Returns:
        String that represents the CSS class

    - #### setUsernameClass

          public void setUsernameClass(java.lang.String usernameClass)

      Set the CSS class for auto-linked username URLs
      Parameters:
        `usernameClass` - new CSS value.

    - #### getHashtagClass

          public java.lang.String getHashtagClass()

      Get CSS class for auto-linked hashtag URLs
      Returns:
        String that represents the CSS class

    - #### setHashtagClass

          public void setHashtagClass(java.lang.String hashtagClass)

      Set the CSS class for auto-linked hashtag URLs
      Parameters:
        `hashtagClass` - new CSS value.

    - #### getCashtagClass

          public java.lang.String getCashtagClass()

      Get CSS class for auto-linked cashtag URLs
      Returns:
        String that represents the CSS class

    - #### setCashtagClass

          public void setCashtagClass(java.lang.String cashtagClass)

      Set the CSS class for auto-linked cashtag URLs
      Parameters:
        `cashtagClass` - new CSS value.

    - #### getUsernameUrlBase

          public java.lang.String getUsernameUrlBase()

      Get the href value for username links (to which the username will be appended)
      Returns:
        String that represents the href value of username link

    - #### setUsernameUrlBase

          public void setUsernameUrlBase(java.lang.String usernameUrlBase)

      Set the href base for username links.
      Parameters:
        `usernameUrlBase` - new href base value

    - #### getListUrlBase

          public java.lang.String getListUrlBase()

      Get the href value for list links (to which the username/list will be appended)
      Returns:
        String that represents the href value of username/list link

    - #### setListUrlBase

          public void setListUrlBase(java.lang.String listUrlBase)

      Set the href base for list links.
      Parameters:
        `listUrlBase` - new href base value

    - #### getHashtagUrlBase

          public java.lang.String getHashtagUrlBase()

      Get the href value for hashtag links (to which the hashtag will be appended)
      Returns:
        String that represents the href value of hashtag link

    - #### setHashtagUrlBase

          public void setHashtagUrlBase(java.lang.String hashtagUrlBase)

      Set the href base for hashtag links.
      Parameters:
        `hashtagUrlBase` - new href base value

    - #### getCashtagUrlBase

          public java.lang.String getCashtagUrlBase()

      Get the href value for cashtag links (to which the cashtag will be appended)
      Returns:
        String that represents the href value of cashtag link

    - #### setCashtagUrlBase

          public void setCashtagUrlBase(java.lang.String cashtagUrlBase)

      Set the href base for cashtag links.
      Parameters:
        `cashtagUrlBase` - new href base value

    - #### isNoFollow

          public boolean isNoFollow()

      Checks if the current URL links will include rel="nofollow" (true by default)
      Returns:
        Boolean indicating if there's a rel=nofollow

    - #### setNoFollow

          public void setNoFollow(boolean noFollow)

      Set if the current URL links will include rel="nofollow" (true by default)
      Parameters:
        `noFollow` - new noFollow value

    - #### setUsernameIncludeSymbol

          public void setUsernameIncludeSymbol(boolean usernameIncludeSymbol)

      Set if the at mark '@' should be included in the link (false by default)
      Parameters:
        `usernameIncludeSymbol` - if username includes symbol

    - #### setSymbolTag

          public void setSymbolTag(java.lang.String tag)

      Set HTML tag to be applied around #/@/# symbols in hashtags/usernames/lists/cashtag
      Parameters:
        `tag` - HTML tag without bracket. e.g., "b" or "s"

    - #### setTextWithSymbolTag

          public void setTextWithSymbolTag(java.lang.String tag)

      Set HTML tag to be applied around text part of hashtags/usernames/lists/cashtag
      Parameters:
        `tag` - HTML tag without bracket. e.g., "b" or "s"

    - #### setUrlTarget

          public void setUrlTarget(java.lang.String target)

      Set the value of the target attribute in auto-linked URLs
      Parameters:
        `target` - target value e.g., "_blank"

    - #### setLinkAttributeModifier

          public void setLinkAttributeModifier(Autolink.LinkAttributeModifier modifier)

      Set a modifier to modify attributes of a link based on an entity
      Parameters:
        `modifier` - LinkAttributeModifier instance

    - #### setLinkTextModifier

          public void setLinkTextModifier(Autolink.LinkTextModifier modifier)

      Set a modifier to modify text of a link based on an entity
      Parameters:
        `modifier` - LinkTextModifier instance