-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EmojiManager#extractEmojisInOrderWithIndex
- Loading branch information
Showing
3 changed files
with
135 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package net.fellbaum.jemoji; | ||
|
||
/** | ||
* Represents an emoji with character and codepoint indexes. | ||
* | ||
* @see EmojiManager#extractEmojisInOrderWithIndex(String) | ||
*/ | ||
public class IndexedEmoji { | ||
private final Emoji emoji; | ||
private final int charIndex; | ||
private final int codePointIndex; | ||
|
||
IndexedEmoji(Emoji emoji, int charIndex, int codePointIndex) { | ||
this.emoji = emoji; | ||
this.charIndex = charIndex; | ||
this.codePointIndex = codePointIndex; | ||
} | ||
|
||
/** | ||
* Gets the captured {@link Emoji emoji}. | ||
* | ||
* @return The captured emoji | ||
*/ | ||
public Emoji getEmoji() { | ||
return emoji; | ||
} | ||
|
||
/** | ||
* Gets the character index at which the emoji starts. | ||
* | ||
* <p>The index is included in {@code 0 < input <= input.length() - 1} | ||
* | ||
* @return The character index at which the emoji starts | ||
*/ | ||
public int getCharIndex() { | ||
return charIndex; | ||
} | ||
|
||
/** | ||
* Gets the codepoint index at which the emoji starts. | ||
* | ||
* <p>This must not be confused with {@link #getCharIndex()}, | ||
* a codepoint can contain one or two characters, | ||
* which means the codepoint index will likely be lower than the character index. | ||
* | ||
* @return The character index at which the emoji starts | ||
*/ | ||
public int getCodePointIndex() { | ||
return codePointIndex; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters