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 TypeMethodDescriptionvoidaddHyperlink(int startPos, int endPos, String url) Inserts an A tag that surrounds the given position.voidaddHyperlinkLowKey(int startPos, int endPos, String url) Inserts an A tag that surrounds the given position.abstract voidAdds a start tag and end tag at the specified position.charcharAt(int idx) protected abstract MarkupText.SubTextFind 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 StringgetText()Returns the plain text portion of thisMarkupTextwithout any markup, nor any escape.voidhide(int startPos, int endPos) Hides the given text.final intlength()Length of the plain text.abstract MarkupText.SubTextsubText(int start, int end) Returns a subtext.final voidAdds a start tag and end tag around the entire text
-
Method Details
-
getText
Returns the plain text portion of thisMarkupTextwithout 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
findTokenswith "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
-