com.twitter
Class Autolink

java.lang.Object
  extended by com.twitter.Autolink

public class Autolink
extends java.lang.Object

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


Field Summary
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_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_URL_CLASS
          Default CSS class for auto-linked URLs
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 listClass
           
protected  java.lang.String listUrlBase
           
static java.lang.String NO_FOLLOW_HTML_ATTRIBUTE
          HTML attribute to add when noFollow is true (default)
protected  boolean noFollow
           
protected  java.lang.String urlClass
           
protected  java.lang.String usernameClass
           
protected  java.lang.String usernameUrlBase
           
 
Constructor Summary
Autolink()
           
 
Method Summary
 java.lang.String autoLink(java.lang.String text)
          Auto-link hashtags, URLs, usernames and lists.
 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 getHashtagClass()
           
 java.lang.String getHashtagUrlBase()
           
 java.lang.String getListClass()
           
 java.lang.String getListUrlBase()
           
 java.lang.String getUrlClass()
           
 java.lang.String getUsernameClass()
           
 java.lang.String getUsernameUrlBase()
           
 boolean isNoFollow()
           
 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 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 setUrlClass(java.lang.String urlClass)
          Set the CSS class for auto-linked URLs
 void setUsernameClass(java.lang.String usernameClass)
          Set the CSS class for auto-linked username URLs
 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_URL_CLASS

public static final java.lang.String DEFAULT_URL_CLASS
Default CSS class for auto-linked URLs

See Also:
Constant Field Values

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_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

NO_FOLLOW_HTML_ATTRIBUTE

public static final java.lang.String NO_FOLLOW_HTML_ATTRIBUTE
HTML attribute to add when noFollow is true (default)

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

usernameUrlBase

protected java.lang.String usernameUrlBase

listUrlBase

protected java.lang.String listUrlBase

hashtagUrlBase

protected java.lang.String hashtagUrlBase

noFollow

protected boolean noFollow
Constructor Detail

Autolink

public Autolink()
Method Detail

autoLink

public java.lang.String autoLink(java.lang.String text)
Auto-link hashtags, URLs, usernames and lists.

Parameters:
text - 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.

Parameters:
text - of the Tweet to auto-link
Returns:
text with auto-link HTML added

getUrlClass

public java.lang.String getUrlClass()
Returns:
CSS class for auto-linked URLs

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()
Returns:
CSS class for auto-linked list URLs

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()
Returns:
CSS class for auto-linked username URLs

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()
Returns:
CSS class for auto-linked hashtag URLs

setHashtagClass

public void setHashtagClass(java.lang.String hashtagClass)
Set the CSS class for auto-linked hashtag URLs

Parameters:
hashtagClass - new CSS value.

getUsernameUrlBase

public java.lang.String getUsernameUrlBase()
Returns:
the href value for username links (to which the username will be appended)

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()
Returns:
the href value for list links (to which the username/list will be appended)

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()
Returns:
the href value for hashtag links (to which the hashtag will be appended)

setHashtagUrlBase

public void setHashtagUrlBase(java.lang.String hashtagUrlBase)
Set the href base for hashtag links.

Parameters:
hashtagUrlBase - new href base value

isNoFollow

public boolean isNoFollow()
Returns:
if the current URL links will include rel="nofollow" (true by default)

setNoFollow

public void setNoFollow(boolean noFollow)
Set if the current URL links will include rel="nofollow" (true by default)

Parameters:
noFollow - new noFollow value


Copyright © 2010 Twitter, Inc. All Rights Reserved.