|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthudson.AbstractMarkupText
hudson.MarkupText
public class MarkupText
Mutable representation of string with HTML mark up.
This class is used to put mark up on plain text.
See MarkupTextTest
for a typical usage and its result.
Nested Class Summary | |
---|---|
class |
MarkupText.SubText
Represents a substring of a MarkupText . |
Constructor Summary | |
---|---|
MarkupText(String text)
|
Method Summary | |
---|---|
void |
addMarkup(int startPos,
int endPos,
String startTag,
String endTag)
Adds a start tag and end tag at the specified position. |
void |
addMarkup(int pos,
String tag)
|
protected MarkupText.SubText |
createSubText(Matcher m)
|
List<MarkupText.SubText> |
findTokens(Pattern pattern)
Find all "tokens" that match the given pattern in this text. |
String |
getText()
Returns the plain text portion of this MarkupText without
any markup, nor any escape. |
MarkupText.SubText |
subText(int start,
int end)
Returns a subtext. |
String |
toString()
Deprecated. as of 1.350. Use toString(boolean) to be explicit about the escape mode. |
String |
toString(boolean preEscape)
Returns the fully marked-up text. |
Methods inherited from class hudson.AbstractMarkupText |
---|
addHyperlink, addHyperlinkLowKey, charAt, findToken, hide, length, wrapBy |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MarkupText(String text)
text
- Plain text. This shouldn't include any markup nor escape. Those are done later in toString(boolean)
.Method Detail |
---|
public String getText()
AbstractMarkupText
MarkupText
without
any markup, nor any escape.
getText
in class AbstractMarkupText
public MarkupText.SubText subText(int start, int end)
subText
in class AbstractMarkupText
end
- If negative, -N means "trim the last N-1 chars". That is, (s,-1) is the same as (s,length)public void addMarkup(int startPos, int endPos, String startTag, String endTag)
AbstractMarkupText
For example, if the text was "abc", then addMarkup(1,2,"<b>","</b>") would generate "a<b>b</b>c"
addMarkup
in class AbstractMarkupText
public void addMarkup(int pos, String tag)
public String toString()
toString(boolean)
to be explicit about the escape mode.
toString
in class Object
public String toString(boolean preEscape)
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>public List<MarkupText.SubText> findTokens(Pattern pattern)
AbstractMarkupText
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.
findTokens
in class AbstractMarkupText
protected MarkupText.SubText createSubText(Matcher m)
createSubText
in class AbstractMarkupText
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |