Package hudson
Class AbstractMarkupText
- java.lang.Object
-
- hudson.AbstractMarkupText
-
- Direct Known Subclasses:
MarkupText,MarkupText.SubText
public abstract class AbstractMarkupText extends Object
Common part betweenMarkupTextandMarkupText.SubText.See
MarkupTextfor more discussion about what this class represents.- Since:
- 1.250
- Author:
- Kohsuke Kawaguchi
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddHyperlink(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 voidaddMarkup(int startPos, int endPos, String startTag, String endTag)Adds a start tag and end tag at the specified position.charcharAt(int idx)protected abstract MarkupText.SubTextcreateSubText(Matcher m)MarkupText.SubTextfindToken(Pattern pattern)Find the first occurrence of the given pattern in this text, or null.List<MarkupText.SubText>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.intlength()Length of the plain text.abstract MarkupText.SubTextsubText(int start, int end)Returns a subtext.voidwrapBy(String startTag, String endTag)Adds a start tag and end tag around the entire text
-
-
-
Method Detail
-
getText
public abstract String 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
public abstract MarkupText.SubText subText(int start, int end)
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
public abstract void addMarkup(int startPos, int endPos, String startTag, String endTag)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
public void addHyperlink(int startPos, int endPos, String url)Inserts an A tag that surrounds the given position.- Since:
- 1.349
-
addHyperlinkLowKey
public void addHyperlinkLowKey(int startPos, int endPos, String url)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
public final void wrapBy(String startTag, String endTag)
Adds a start tag and end tag around the entire text
-
findToken
public MarkupText.SubText findToken(Pattern pattern)
Find the first occurrence of the given pattern in this text, or null.- Since:
- 1.349
-
findTokens
public List<MarkupText.SubText> findTokens(Pattern pattern)
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
protected abstract MarkupText.SubText createSubText(Matcher m)
-
-