Package hudson
Class AbstractMarkupText
java.lang.Object
hudson.AbstractMarkupText
- Direct Known Subclasses:
MarkupText
,MarkupText.SubText
Common part between
MarkupText
and MarkupText.SubText
.
See MarkupText
for more discussion about what this class represents.
- Since:
- 1.250
- Author:
- Kohsuke Kawaguchi
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addHyperlink
(int startPos, int endPos, String url) Inserts an A tag that surrounds the given position.void
addHyperlinkLowKey
(int startPos, int endPos, String url) Inserts an A tag that surrounds the given position.abstract void
Adds a start tag and end tag at the specified position.char
charAt
(int idx) protected abstract MarkupText.SubText
Find the first occurrence of the given pattern in this text, or null.findTokens
(Pattern pattern) Find all "tokens" that match the given pattern in this text.abstract String
getText()
Returns the plain text portion of thisMarkupText
without any markup, nor any escape.void
hide
(int startPos, int endPos) Hides the given text.final int
length()
Length of the plain text.abstract MarkupText.SubText
subText
(int start, int end) Returns a subtext.final void
Adds a start tag and end tag around the entire text
-
Method Details
-
getText
Returns the plain text portion of thisMarkupText
without any markup, nor any escape. -
charAt
public char charAt(int idx) -
length
public final int length()Length of the plain text. -
subText
Returns a subtext.- Parameters:
end
- If negative, -N means "trim the last N-1 chars". That is, (s,-1) is the same as (s,length)
-
addMarkup
Adds a start tag and end tag at the specified position.For example, if the text was "abc", then
addMarkup(1,2,"<b>","</b>")
would generate"a<b>b</b>c"
-
addHyperlink
Inserts an A tag that surrounds the given position.- Since:
- 1.349
-
addHyperlinkLowKey
Inserts an A tag that surrounds the given position. But this hyperlink is less visible.- Since:
- 1.395
-
hide
public void hide(int startPos, int endPos) Hides the given text. -
wrapBy
Adds a start tag and end tag around the entire text -
findToken
Find the first occurrence of the given pattern in this text, or null.- Since:
- 1.349
-
findTokens
Find all "tokens" that match the given pattern in this text.A token is like a substring, except that it's aware of word boundaries. For example, while "bc" is a string of "abc", calling
findTokens
with "bc" as a pattern on string "abc" won't match anything.This method is convenient for finding keywords that follow a certain syntax from natural text. You can then use
MarkupText.SubText.surroundWith(String,String)
to put mark up around such text. -
createSubText
-