hudson
Class MarkupText.SubText

java.lang.Object
  extended by hudson.AbstractMarkupText
      extended by hudson.MarkupText.SubText
Enclosing class:
MarkupText

public final class MarkupText.SubText
extends AbstractMarkupText

Represents a substring of a MarkupText.


Constructor Summary
MarkupText.SubText(int start, int end)
           
MarkupText.SubText(Matcher m, int textOffset)
           
 
Method Summary
 void addMarkup(int startPos, int endPos, String startTag, String endTag)
          Adds a start tag and end tag at the specified position.
protected  MarkupText.SubText createSubText(Matcher m)
           
 int end()
          Gets the end index of this subtext within MarkupText.getText().
 int end(int groupIndex)
          Gets the end index of the captured group within MarkupText.getText().
 String getText()
          Returns the plain text portion of this MarkupText without any markup, nor any escape.
 String group(int groupIndex)
          Gets the text that represents the captured group.
 int groupCount()
          How many captured groups are in this subtext.
 void href(String url)
          Surrounds this subtext with <a>...</a>.
 String replace(String s)
          Replaces the group tokens like "$0", "$1", and etc with their actual matches.
 int start()
          Gets the start index of this subtext within MarkupText.getText().
 int start(int groupIndex)
          Gets the start index of the captured group within MarkupText.getText().
 MarkupText.SubText subText(int start, int end)
          Returns a subtext.
 void surroundWith(String startTag, String endTag)
          Surrounds this subtext with the specified start tag and the end tag.
 void surroundWithLiteral(String startTag, String endTag)
          Works like surroundWith(String, String) except that the token replacement is not performed on parameters.
 
Methods inherited from class hudson.AbstractMarkupText
addHyperlink, addHyperlinkLowKey, charAt, findToken, findTokens, hide, length, wrapBy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarkupText.SubText

public MarkupText.SubText(Matcher m,
                          int textOffset)

MarkupText.SubText

public MarkupText.SubText(int start,
                          int end)
Method Detail

subText

public MarkupText.SubText subText(int start,
                                  int end)
Description copied from class: AbstractMarkupText
Returns a subtext.

Specified by:
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)

getText

public String getText()
Description copied from class: AbstractMarkupText
Returns the plain text portion of this MarkupText without any markup, nor any escape.

Specified by:
getText in class AbstractMarkupText

addMarkup

public void addMarkup(int startPos,
                      int endPos,
                      String startTag,
                      String endTag)
Description copied from class: AbstractMarkupText
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"

Specified by:
addMarkup in class AbstractMarkupText

surroundWith

public void surroundWith(String startTag,
                         String endTag)
Surrounds this subtext with the specified start tag and the end tag.

Start/end tag text can contain special tokens "$0", "$1", ... and they will be replaced by their group match. "\$" can be used to escape characters.


surroundWithLiteral

public void surroundWithLiteral(String startTag,
                                String endTag)
Works like surroundWith(String, String) except that the token replacement is not performed on parameters.


href

public void href(String url)
Surrounds this subtext with <a>...</a>.


start

public int start(int groupIndex)
Gets the start index of the captured group within MarkupText.getText().

Parameters:
groupIndex - 0 means the start of the whole subtext. 1, 2, ... are groups captured by '(...)' in the regexp.

start

public int start()
Gets the start index of this subtext within MarkupText.getText().


end

public int end(int groupIndex)
Gets the end index of the captured group within MarkupText.getText().


end

public int end()
Gets the end index of this subtext within MarkupText.getText().


group

public String group(int groupIndex)
Gets the text that represents the captured group.


groupCount

public int groupCount()
How many captured groups are in this subtext.

Since:
1.357

replace

public String replace(String s)
Replaces the group tokens like "$0", "$1", and etc with their actual matches.


createSubText

protected MarkupText.SubText createSubText(Matcher m)
Specified by:
createSubText in class AbstractMarkupText


Copyright © 2004-2013. All Rights Reserved.