public final class MarkupText.SubText extends AbstractMarkupText
MarkupText.| Constructor and Description |
|---|
SubText(int start,
int end) |
SubText(Matcher m,
int textOffset) |
| Modifier and Type | Method and Description |
|---|---|
void |
addMarkup(int startPos,
int endPos,
String startTag,
String endTag)
Adds a start tag and end tag at the specified position.
|
protected MarkupText.SubText |
createSubText(Matcher m) |
int |
end()
Gets the end index of this subtext within
MarkupText.getText(). |
int |
end(int groupIndex)
Gets the end index of the captured group within
MarkupText.getText(). |
String |
getText()
Returns the plain text portion of this
MarkupText without
any markup, nor any escape. |
String |
group(int groupIndex)
Gets the text that represents the captured group.
|
int |
groupCount()
How many captured groups are in this subtext.
|
void |
href(String url)
Surrounds this subtext with <a>...</a>.
|
String |
replace(String s)
Replaces the group tokens like "$0", "$1", and etc with their actual matches.
|
int |
start()
Gets the start index of this subtext within
MarkupText.getText(). |
int |
start(int groupIndex)
Gets the start index of the captured group within
MarkupText.getText(). |
MarkupText.SubText |
subText(int start,
int end)
Returns a subtext.
|
void |
surroundWith(String startTag,
String endTag)
Surrounds this subtext with the specified start tag and the end tag.
|
void |
surroundWithLiteral(String startTag,
String endTag)
Works like
surroundWith(String, String) except
that the token replacement is not performed on parameters. |
addHyperlink, addHyperlinkLowKey, charAt, findToken, findTokens, hide, length, wrapBypublic SubText(Matcher m, int textOffset)
public SubText(int start,
int end)
public MarkupText.SubText subText(int start, int end)
AbstractMarkupTextsubText in class AbstractMarkupTextend - If negative, -N means "trim the last N-1 chars". That is, (s,-1) is the same as (s,length)public String getText()
AbstractMarkupTextMarkupText without
any markup, nor any escape.getText in class AbstractMarkupTextpublic void addMarkup(int startPos,
int endPos,
String startTag,
String endTag)
AbstractMarkupTextFor example, if the text was "abc", then addMarkup(1,2,"<b>","</b>") would generate "a<b>b</b>c"
addMarkup in class AbstractMarkupTextpublic void surroundWith(String startTag, String endTag)
Start/end tag text can contain special tokens "$0", "$1", ...
and they will be replaced by their group match.
"\$" can be used to escape characters.
public void surroundWithLiteral(String startTag, String endTag)
surroundWith(String, String) except
that the token replacement is not performed on parameters.public void href(String url)
public int start(int groupIndex)
MarkupText.getText().groupIndex - 0 means the start of the whole subtext. 1, 2, ... are
groups captured by '(...)' in the regexp.public int start()
MarkupText.getText().public int end(int groupIndex)
MarkupText.getText().public int end()
MarkupText.getText().public String group(int groupIndex)
public int groupCount()
public String replace(String s)
protected MarkupText.SubText createSubText(Matcher m)
createSubText in class AbstractMarkupTextCopyright © 2019. All rights reserved.