public class EmojiParser extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
EmojiParser.EmojiTransformer |
static class |
EmojiParser.FitzpatrickAction
Enum used to indicate what should be done when a Fitzpatrick modifier is
found.
|
static class |
EmojiParser.UnicodeCandidate |
Constructor and Description |
---|
EmojiParser() |
Modifier and Type | Method and Description |
---|---|
static List<String> |
extractEmojis(String input) |
static String |
parseFromUnicode(String input,
EmojiParser.EmojiTransformer transformer)
Detects all unicode emojis in input string and replaces them with the
return value of transformer.transform()
|
static String |
parseToAliases(String input)
See
parseToAliases(String, FitzpatrickAction) with the action
"PARSE" |
static String |
parseToAliases(String input,
EmojiParser.FitzpatrickAction fitzpatrickAction)
Replaces the emoji's unicode occurrences by one of their alias
(between 2 ':').
Example: 😄 will be replaced by :smile: When a fitzpatrick modifier is present with a PARSE action, a "|" will be appendend to the alias, with the fitzpatrick type. Example: 👦🏿 will be replaced by
:boy|type_6: The fitzpatrick types are: type_1_2, type_3, type_4, type_5, type_6 When a fitzpatrick modifier is present with a REMOVE action, the modifier will be deleted. Example: 👦🏿 will be replaced by :boy: When a fitzpatrick modifier is present with a IGNORE action, the modifier will be ignored. Example: 👦🏿 will be replaced by :boy:🏿 |
static String |
parseToHtmlDecimal(String input)
See
parseToHtmlDecimal(String, FitzpatrickAction) with the action
"PARSE" |
static String |
parseToHtmlDecimal(String input,
EmojiParser.FitzpatrickAction fitzpatrickAction)
Replaces the emoji's unicode occurrences by their html representation.
Example: 😄 will be replaced by 😄 When a fitzpatrick modifier is present with a PARSE or REMOVE action, the modifier will be deleted from the string. Example: 👦🏿 will be replaced by
👦 When a fitzpatrick modifier is present with a IGNORE action, the modifier will be ignored and will remain in the string. Example: 👦🏿 will be replaced by
👦🏿 |
static String |
parseToHtmlHexadecimal(String input)
See
parseToHtmlHexadecimal(String, FitzpatrickAction) with the
action "PARSE" |
static String |
parseToHtmlHexadecimal(String input,
EmojiParser.FitzpatrickAction fitzpatrickAction)
Replaces the emoji's unicode occurrences by their html hex
representation.
Example: 👦 will be replaced by 👦 When a fitzpatrick modifier is present with a PARSE or REMOVE action, the modifier will be deleted. Example: 👦🏿 will be replaced by
👦 When a fitzpatrick modifier is present with a IGNORE action, the modifier will be ignored and will remain in the string. Example: 👦🏿 will be replaced by
👦🏿 |
static String |
parseToUnicode(String input)
Replaces the emoji's aliases (between 2 ':') occurrences and the html
representations by their unicode.
Examples: :smile: will be replaced by 😄 😄 will be replaced by 😄 :boy|type_6: will be replaced by 👦🏿 |
static String |
removeAllEmojis(String str)
Removes all emojis from a String
|
static String |
removeAllEmojisExcept(String str,
Collection<Emoji> emojisToKeep)
Removes all the emojis in a String except a provided set
|
static String |
removeEmojis(String str,
Collection<Emoji> emojisToRemove)
Removes a set of emojis from a String
|
static String |
replaceAllEmojis(String str,
String replacementString)
Replace all emojis with character
|
public static String parseToAliases(String input)
parseToAliases(String, FitzpatrickAction)
with the action
"PARSE"input
- the string to parsepublic static String parseToAliases(String input, EmojiParser.FitzpatrickAction fitzpatrickAction)
😄
will be replaced by :smile:
👦🏿
will be replaced by
:boy|type_6:
👦🏿
will be replaced by :boy:
👦🏿
will be replaced by :boy:🏿
input
- the string to parsefitzpatrickAction
- the action to apply for the fitzpatrick modifierspublic static String replaceAllEmojis(String str, String replacementString)
str
- the string to processreplacementString
- replacement the string that will replace all the emojispublic static String parseToUnicode(String input)
:smile:
will be replaced by 😄
😄
will be replaced by 😄
:boy|type_6:
will be replaced by 👦🏿
input
- the string to parsepublic static String parseToHtmlDecimal(String input)
parseToHtmlDecimal(String, FitzpatrickAction)
with the action
"PARSE"input
- the string to parsepublic static String parseToHtmlDecimal(String input, EmojiParser.FitzpatrickAction fitzpatrickAction)
😄
will be replaced by 😄
👦🏿
will be replaced by
👦
👦🏿
will be replaced by
👦🏿
input
- the string to parsefitzpatrickAction
- the action to apply for the fitzpatrick modifierspublic static String parseToHtmlHexadecimal(String input)
parseToHtmlHexadecimal(String, FitzpatrickAction)
with the
action "PARSE"input
- the string to parsepublic static String parseToHtmlHexadecimal(String input, EmojiParser.FitzpatrickAction fitzpatrickAction)
👦
will be replaced by 👦
👦🏿
will be replaced by
👦
👦🏿
will be replaced by
👦🏿
input
- the string to parsefitzpatrickAction
- the action to apply for the fitzpatrick modifierspublic static String removeAllEmojis(String str)
str
- the string to processpublic static String removeEmojis(String str, Collection<Emoji> emojisToRemove)
str
- the string to processemojisToRemove
- the emojis to remove from this stringpublic static String removeAllEmojisExcept(String str, Collection<Emoji> emojisToKeep)
str
- the string to processemojisToKeep
- the emojis to keep in this stringpublic static String parseFromUnicode(String input, EmojiParser.EmojiTransformer transformer)
input
- the string to processtransformer
- emoji transformer to apply to each emojiCopyright © 2019. All rights reserved.