public final class Text
extends java.lang.Object
implements java.lang.CharSequence
TextBuilder| Constructor and Description |
|---|
Text(java.lang.String text)
Constructs a text.
|
Text(java.lang.String text,
java.util.List<MessageEntity> entities)
Constructs a text.
|
| Modifier and Type | Method and Description |
|---|---|
static Text |
bold(java.lang.String text)
Creates a bold text.
|
static Text |
botCommand(java.lang.String botCommand)
Creates a bot command.
|
static Text |
cashtag(java.lang.String cashtag)
Creates a cashtag.
|
char |
charAt(int index) |
static Text |
code(java.lang.String text)
Creates a code.
|
static Text |
codeBlock(java.lang.String text)
Creates a code block.
|
Text |
concat(Text other)
Concatenates the specified text to the end of this text.
|
static Text |
email(java.lang.String email)
Creates an email.
|
boolean |
equals(java.lang.Object obj) |
java.util.List<java.lang.String> |
getBoldText()
Returns a list containing all the bold strings in this text.
|
java.util.List<java.lang.String> |
getBotCommands()
Returns a list containing all the bot commands in this text.
|
java.util.List<java.lang.String> |
getCashtags()
Returns a list containing all the cashtags in this text.
|
java.util.List<java.lang.String> |
getCodeBlocks()
Returns a list containing all the code blocks in this text.
|
java.util.List<java.lang.String> |
getCodeText()
Returns a list containing all the codes in this text.
|
java.util.List<java.lang.String> |
getEmails()
Returns a list containing all the emails in this text.
|
java.util.List<MessageEntity> |
getEntities()
Returns the text entities.
|
java.util.List<java.lang.String> |
getHashtags()
Returns a list containing all the hashtags in this text.
|
java.util.List<java.lang.String> |
getItalicText()
Returns a list containing all the italic strings in this text.
|
java.util.List<Link> |
getLinks()
Returns a list containing all the links in this text with their relative urls.
|
java.util.List<java.lang.String> |
getMentions()
Returns a list containing all the mentions in this text.
|
java.util.List<java.lang.String> |
getPhoneNumbers()
Returns a list containing all the phone numbers in this text.
|
java.util.List<Mention> |
getTextMentions()
Returns a list containing all the text mentions in this text with their relative users.
|
java.util.List<java.lang.String> |
getUrls()
Returns a list containing all the urls in this text.
|
int |
hashCode() |
static Text |
hashtag(java.lang.String hashtag)
Creates an hashtag.
|
boolean |
isEmpty()
|
static Text |
italic(java.lang.String text)
Creates an italic text.
|
int |
length() |
static Text |
link(Link link)
Creates a link.
|
static Text |
link(java.lang.String text,
java.lang.String url)
Creates a link.
|
static Text |
mention(java.lang.String mention)
Creates a mention.
|
static Text |
mention(User mention)
Creates a mention.
|
static Text |
parseHtml(java.lang.String text)
Converts an HTML String into a Text.
|
static Text |
parseMarkdown(java.lang.String text)
Converts an Markdown String into a Text.
|
static Text |
phoneNumber(java.lang.String phoneNumber)
Creates a phone number.
|
Text |
subSequence(int start) |
Text |
subSequence(int start,
int end) |
static Text |
textMention(Mention mention)
Creates a text mention.
|
static Text |
textMention(java.lang.String text,
User mention)
Creates a text mention.
|
static Text |
textMention(User mention)
Creates a text mention.
|
java.lang.String |
toHtmlString()
Return this text in HTML format.
|
java.lang.String |
toMarkdownString()
Return this text in Markdown format.
|
java.lang.String |
toString() |
Text |
trim() |
static Text |
url(java.lang.String url)
Creates an url.
|
public static final Text EMPTY
public Text(java.lang.String text,
java.util.List<MessageEntity> entities)
text - the textentities - text entitiesTextBuilderpublic Text(java.lang.String text)
text - the textTextBuilderpublic static Text parseHtml(java.lang.String text) throws TextParseException
<b>bold</b>, <strong>bold</strong> <i>italic</i>, <em>italic</em> <a href="http://www.example.com/">inline URL</a> <a href="tg://user?id=123456789">inline mention of a user</a> <code>inline fixed-width code</code> <pre>pre-formatted fixed-width code block</pre>All <, > and & symbols that are not a part of a tag or an HTML entity must be replaced with the corresponding HTML entities (< with <, > with > and & with &)
text - the string to convertTextParseException - if an error occurs when parsing the stringpublic static Text parseMarkdown(java.lang.String text) throws TextParseException
*bold text* _italic text_ [inline URL](http://www.example.com/) [inline mention of a user](tg://user?id=123456789) `inline fixed-width code` `pre-formatted fixed-width code block`All Markdown symbols that are not a part of a Markdown entity must be escaped with the
\ character.text - the string to convertTextParseException - if an error occurs when parsing the stringpublic static Text bold(java.lang.String text)
text - the bold textpublic static Text italic(java.lang.String text)
text - the italic textpublic static Text code(java.lang.String text)
text - the codepublic static Text codeBlock(java.lang.String text)
text - the code blockpublic static Text link(Link link)
link - the linkpublic static Text link(java.lang.String text, java.lang.String url)
text - the text of the linkurl - the url of the linkpublic static Text url(java.lang.String url)
url - the urlpublic static Text email(java.lang.String email)
email - the emailpublic static Text hashtag(java.lang.String hashtag)
hashtag - the hashtagpublic static Text mention(User mention)
mention - the mentioned userpublic static Text mention(java.lang.String mention)
mention - the mentioned usernamepublic static Text textMention(Mention mention)
mention - the mentionpublic static Text textMention(java.lang.String text, User mention)
text - the text of the mentionmention - the mentioned userpublic static Text textMention(User mention)
mention - the mentioned userpublic static Text botCommand(java.lang.String botCommand)
botCommand - the bot commandpublic static Text phoneNumber(java.lang.String phoneNumber)
phoneNumber - the phone numberpublic static Text cashtag(java.lang.String cashtag)
cashtag - the cashtagpublic boolean isEmpty()
true if text length is 0, otherwise falsepublic Text concat(Text other)
other - the text that is concatenated to the end of this text.public java.util.List<java.lang.String> getBoldText()
public java.util.List<java.lang.String> getItalicText()
public java.util.List<java.lang.String> getCodeText()
public java.util.List<java.lang.String> getCodeBlocks()
public java.util.List<Link> getLinks()
public java.util.List<java.lang.String> getUrls()
public java.util.List<java.lang.String> getEmails()
public java.util.List<java.lang.String> getHashtags()
public java.util.List<java.lang.String> getMentions()
public java.util.List<Mention> getTextMentions()
public java.util.List<java.lang.String> getBotCommands()
public java.util.List<java.lang.String> getPhoneNumbers()
public java.util.List<java.lang.String> getCashtags()
public java.lang.String toHtmlString()
public java.lang.String toMarkdownString()
public Text trim()
public int length()
length in interface java.lang.CharSequencepublic char charAt(int index)
charAt in interface java.lang.CharSequencepublic Text subSequence(int start, int end)
subSequence in interface java.lang.CharSequencepublic Text subSequence(int start)
public java.lang.String toString()
toString in interface java.lang.CharSequencetoString in class java.lang.Objectpublic java.util.List<MessageEntity> getEntities()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object