public class Autolink extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Autolink.LinkAttributeModifier |
static interface |
Autolink.LinkTextModifier |
| Modifier and Type | Field and Description |
|---|---|
protected String |
cashtagClass |
protected String |
cashtagUrlBase |
static String |
DEFAULT_CASHTAG_CLASS
Default CSS class for auto-linked cashtag URLs
|
static String |
DEFAULT_CASHTAG_URL_BASE
Default href for cashtag links (the cashtag without the $ will be appended)
|
static String |
DEFAULT_HASHTAG_CLASS
Default CSS class for auto-linked hashtag URLs
|
static String |
DEFAULT_HASHTAG_URL_BASE
Default href for hashtag links (the hashtag without the # will be appended)
|
static String |
DEFAULT_INVISIBLE_TAG_ATTRS
Default attribute for invisible span tag
|
static String |
DEFAULT_LIST_CLASS
Default CSS class for auto-linked list URLs
|
static String |
DEFAULT_LIST_URL_BASE
Default href for list links (the username/list without the @ will be appended)
|
static String |
DEFAULT_USERNAME_CLASS
Default CSS class for auto-linked username URLs
|
static String |
DEFAULT_USERNAME_URL_BASE
Default href for username links (the username without the @ will be appended)
|
protected String |
hashtagClass |
protected String |
hashtagUrlBase |
protected String |
invisibleTagAttrs |
protected Autolink.LinkAttributeModifier |
linkAttributeModifier |
protected Autolink.LinkTextModifier |
linkTextModifier |
protected String |
listClass |
protected String |
listUrlBase |
protected boolean |
noFollow |
protected String |
symbolTag |
protected String |
textWithSymbolTag |
protected String |
urlClass |
protected String |
urlTarget |
protected String |
usernameClass |
protected boolean |
usernameIncludeSymbol |
protected String |
usernameUrlBase |
| Constructor and Description |
|---|
Autolink() |
| Modifier and Type | Method and Description |
|---|---|
String |
autoLink(String text)
Auto-link hashtags, URLs, usernames and lists.
|
String |
autoLinkCashtags(String text)
Auto-link $cashtag references in the provided Tweet text.
|
String |
autoLinkEntities(String text,
List<Extractor.Entity> entities) |
String |
autoLinkHashtags(String text)
Auto-link #hashtag references in the provided Tweet text.
|
String |
autoLinkURLs(String text)
Auto-link URLs in the Tweet text provided.
|
String |
autoLinkUsernamesAndLists(String text)
Auto-link the @username and @username/list references in the provided text.
|
String |
escapeBrackets(String text) |
String |
getCashtagClass() |
String |
getCashtagUrlBase() |
String |
getHashtagClass() |
String |
getHashtagUrlBase() |
String |
getListClass() |
String |
getListUrlBase() |
String |
getUrlClass() |
String |
getUsernameClass() |
String |
getUsernameUrlBase() |
boolean |
isNoFollow() |
void |
linkToCashtag(Extractor.Entity entity,
String text,
StringBuilder builder) |
void |
linkToHashtag(Extractor.Entity entity,
String text,
StringBuilder builder) |
void |
linkToMentionAndList(Extractor.Entity entity,
String text,
StringBuilder builder) |
void |
linkToText(Extractor.Entity entity,
CharSequence text,
Map<String,String> attributes,
StringBuilder builder) |
void |
linkToTextWithSymbol(Extractor.Entity entity,
CharSequence symbol,
CharSequence text,
Map<String,String> attributes,
StringBuilder builder) |
void |
linkToURL(Extractor.Entity entity,
String text,
StringBuilder builder) |
void |
setCashtagClass(String cashtagClass)
Set the CSS class for auto-linked cashtag URLs
|
void |
setCashtagUrlBase(String cashtagUrlBase)
Set the href base for cashtag links.
|
void |
setHashtagClass(String hashtagClass)
Set the CSS class for auto-linked hashtag URLs
|
void |
setHashtagUrlBase(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(String listClass)
Set the CSS class for auto-linked list URLs
|
void |
setListUrlBase(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(String tag)
Set HTML tag to be applied around #/@/# symbols in hashtags/usernames/lists/cashtag
|
void |
setTextWithSymbolTag(String tag)
Set HTML tag to be applied around text part of hashtags/usernames/lists/cashtag
|
void |
setUrlClass(String urlClass)
Set the CSS class for auto-linked URLs
|
void |
setUrlTarget(String target)
Set the value of the target attribute in auto-linked URLs
|
void |
setUsernameClass(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(String usernameUrlBase)
Set the href base for username links.
|
public static final String DEFAULT_LIST_CLASS
public static final String DEFAULT_USERNAME_CLASS
public static final String DEFAULT_HASHTAG_CLASS
public static final String DEFAULT_CASHTAG_CLASS
public static final String DEFAULT_USERNAME_URL_BASE
public static final String DEFAULT_LIST_URL_BASE
public static final String DEFAULT_HASHTAG_URL_BASE
public static final String DEFAULT_CASHTAG_URL_BASE
public static final String DEFAULT_INVISIBLE_TAG_ATTRS
protected String urlClass
protected String listClass
protected String usernameClass
protected String hashtagClass
protected String cashtagClass
protected String usernameUrlBase
protected String listUrlBase
protected String hashtagUrlBase
protected String cashtagUrlBase
protected String invisibleTagAttrs
protected boolean noFollow
protected boolean usernameIncludeSymbol
protected String symbolTag
protected String textWithSymbolTag
protected String urlTarget
protected Autolink.LinkAttributeModifier linkAttributeModifier
protected Autolink.LinkTextModifier linkTextModifier
public void linkToText(Extractor.Entity entity, CharSequence text, Map<String,String> attributes, StringBuilder builder)
public void linkToTextWithSymbol(Extractor.Entity entity, CharSequence symbol, CharSequence text, Map<String,String> attributes, StringBuilder builder)
public void linkToHashtag(Extractor.Entity entity, String text, StringBuilder builder)
public void linkToCashtag(Extractor.Entity entity, String text, StringBuilder builder)
public void linkToMentionAndList(Extractor.Entity entity, String text, StringBuilder builder)
public void linkToURL(Extractor.Entity entity, String text, StringBuilder builder)
public String autoLinkEntities(String text, List<Extractor.Entity> entities)
public String autoLink(String text)
text - of the Tweet to auto-linkpublic String autoLinkUsernamesAndLists(String text)
text - of the Tweet to auto-linkpublic String autoLinkHashtags(String text)
text - of the Tweet to auto-linkpublic String autoLinkURLs(String text)
text - of the Tweet to auto-linkpublic String autoLinkCashtags(String text)
text - of the Tweet to auto-linkpublic String getUrlClass()
public void setUrlClass(String urlClass)
urlClass - new CSS value.public String getListClass()
public void setListClass(String listClass)
listClass - new CSS value.public String getUsernameClass()
public void setUsernameClass(String usernameClass)
usernameClass - new CSS value.public String getHashtagClass()
public void setHashtagClass(String hashtagClass)
hashtagClass - new CSS value.public String getCashtagClass()
public void setCashtagClass(String cashtagClass)
cashtagClass - new CSS value.public String getUsernameUrlBase()
public void setUsernameUrlBase(String usernameUrlBase)
usernameUrlBase - new href base valuepublic String getListUrlBase()
public void setListUrlBase(String listUrlBase)
listUrlBase - new href base valuepublic String getHashtagUrlBase()
public void setHashtagUrlBase(String hashtagUrlBase)
hashtagUrlBase - new href base valuepublic String getCashtagUrlBase()
public void setCashtagUrlBase(String cashtagUrlBase)
cashtagUrlBase - new href base valuepublic boolean isNoFollow()
public void setNoFollow(boolean noFollow)
noFollow - new noFollow valuepublic void setUsernameIncludeSymbol(boolean usernameIncludeSymbol)
noFollow - new noFollow valuepublic void setSymbolTag(String tag)
tag - HTML tag without bracket. e.g., "b" or "s"public void setTextWithSymbolTag(String tag)
tag - HTML tag without bracket. e.g., "b" or "s"public void setUrlTarget(String target)
target - target value e.g., "_blank"public void setLinkAttributeModifier(Autolink.LinkAttributeModifier modifier)
modifier - LinkAttributeModifier instancepublic void setLinkTextModifier(Autolink.LinkTextModifier modifier)
modifier - LinkTextModifier instanceCopyright © 2015. All rights reserved.