Package hudson
Class MarkupText
- java.lang.Object
-
- hudson.AbstractMarkupText
-
- hudson.MarkupText
-
public class MarkupText extends AbstractMarkupText
Mutable representation of string with HTML mark up.This class is used to put mark up on plain text. See
MarkupTextTestfor a typical usage and its result.- Since:
- 1.70
- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classMarkupText.SubTextRepresents a substring of aMarkupText.
-
Constructor Summary
Constructors Constructor Description MarkupText(String text)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddMarkup(int startPos, int endPos, String startTag, String endTag)Adds a start tag and end tag at the specified position.voidaddMarkup(int pos, String tag)protected MarkupText.SubTextcreateSubText(Matcher m)List<MarkupText.SubText>findTokens(Pattern pattern)Find all "tokens" that match the given pattern in this text.StringgetText()Returns the plain text portion of thisMarkupTextwithout any markup, nor any escape.MarkupText.SubTextsubText(int start, int end)Returns a subtext.StringtoString()Deprecated.as of 1.350.StringtoString(boolean preEscape)Returns the fully marked-up text.-
Methods inherited from class hudson.AbstractMarkupText
addHyperlink, addHyperlinkLowKey, charAt, findToken, hide, length, wrapBy
-
-
-
-
Constructor Detail
-
MarkupText
public MarkupText(String text)
- Parameters:
text- Plain text. This shouldn't include any markup nor escape. Those are done later intoString(boolean).
-
-
Method Detail
-
getText
public String getText()
Description copied from class:AbstractMarkupTextReturns the plain text portion of thisMarkupTextwithout any markup, nor any escape.- Specified by:
getTextin classAbstractMarkupText
-
subText
public MarkupText.SubText subText(int start, int end)
Returns a subtext.- Specified by:
subTextin classAbstractMarkupText- Parameters:
end- If negative, -N means "trim the last N-1 chars". That is, (s,-1) is the same as (s,length)
-
addMarkup
public void addMarkup(int startPos, int endPos, String startTag, String endTag)Description copied from class:AbstractMarkupTextAdds 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"- Specified by:
addMarkupin classAbstractMarkupText
-
addMarkup
public void addMarkup(int pos, String tag)
-
toString
@Deprecated public String toString()
Deprecated.as of 1.350. UsetoString(boolean)to be explicit about the escape mode.Returns the fully marked-up text.
-
toString
public String toString(boolean preEscape)
Returns the fully marked-up text.- Parameters:
preEscape- If true, the escaping is for the<PRE>context. This leave SP and CR/LF intact. If false, the escape is for the normal HTML, thus SP becomes and CR/LF becomes<BR>
-
findTokens
public List<MarkupText.SubText> findTokens(Pattern pattern)
Description copied from class:AbstractMarkupTextFind 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.- Overrides:
findTokensin classAbstractMarkupText
-
createSubText
protected MarkupText.SubText createSubText(Matcher m)
- Specified by:
createSubTextin classAbstractMarkupText
-
-