|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jett.util.RichTextStringUtil
public class RichTextStringUtil
The RichTextStringUtil utility class provides methods for
RichTextString manipulation.
| Constructor Summary | |
|---|---|
RichTextStringUtil()
|
|
| Method Summary | |
|---|---|
static void |
applyFont(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.Cell cell)
Take the first Font from the given
RichTextString and apply it to the given Cell's
CellStyle. |
static org.apache.poi.ss.usermodel.RichTextString |
createFormattedString(int numFormattingRuns,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.lang.String value,
java.util.ArrayList<java.lang.Integer> beginList,
java.util.ArrayList<java.lang.Integer> newLengthList,
java.util.ArrayList<java.lang.Object> fontList)
Construct a RichTextString of the same type as
richTextString, format it, and return it. |
static void |
determineFormattingRunStats(org.apache.poi.ss.usermodel.RichTextString richTextString,
java.util.ArrayList<java.lang.Integer> beginList,
java.util.ArrayList<java.lang.Integer> lengthList,
java.util.ArrayList<java.lang.Object> fontList)
Determine formatting run statistics for the given RichTextString. |
static void |
formatString(org.apache.poi.ss.usermodel.RichTextString string,
int numFormattingRuns,
java.util.ArrayList<java.lang.Integer> beginList,
java.util.ArrayList<java.lang.Integer> newLengthList,
java.util.ArrayList<java.lang.Object> fontList)
Format a RichTextString that has already been created. |
static java.lang.Object |
getFontAtIndex(org.apache.poi.ss.usermodel.RichTextString richTextString,
int fmtIndex)
Gets the font index of the Font in use at the specified
position in the given RichTextString. |
static org.apache.poi.ss.usermodel.RichTextString |
replaceAll(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.lang.String target,
java.lang.String replacement)
Replaces all occurrences of the given target string with the replacement string. |
static org.apache.poi.ss.usermodel.RichTextString |
replaceAll(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.lang.String target,
java.lang.String replacement,
boolean firstOnly)
Replaces all occurrences of the given target string with the replacement string. |
static org.apache.poi.ss.usermodel.RichTextString |
replaceAll(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.lang.String target,
java.lang.String replacement,
boolean firstOnly,
int startIdx)
Replaces all occurrences of the given target string with the replacement string. |
static org.apache.poi.ss.usermodel.RichTextString |
replaceValues(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.util.List<java.lang.String> targets,
java.util.List<java.lang.String> replacements)
Replaces all strings in the given List of strings to replace
with the corresponding replacement string in the given List. |
static org.apache.poi.ss.usermodel.RichTextString |
substring(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
int beginIndex,
int endIndex)
Extracts a substring of a RichTextString as another
RichTextString. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RichTextStringUtil()
| Method Detail |
|---|
public static org.apache.poi.ss.usermodel.RichTextString replaceAll(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.lang.String target,
java.lang.String replacement)
richTextString - The RichTextString to manipulate.helper - A CreationHelper that can create the proper
RichTextString.target - The string to replace.replacement - The replacement string.
RichTextString with replaced values, or the
same RichTextString if replace is
null or empty.
public static org.apache.poi.ss.usermodel.RichTextString replaceAll(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.lang.String target,
java.lang.String replacement,
boolean firstOnly)
richTextString - The RichTextString to manipulate.helper - A CreationHelper that can create the proper
RichTextString.target - The string to replace.replacement - The replacement string.firstOnly - Whether to stop after replacing the first found instance
of target.
RichTextString with replaced values, or the
same RichTextString if replace is
null or empty.
public static org.apache.poi.ss.usermodel.RichTextString replaceAll(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.lang.String target,
java.lang.String replacement,
boolean firstOnly,
int startIdx)
richTextString - The RichTextString to manipulate.helper - A CreationHelper that can create the proper
RichTextString.target - The string to replace.replacement - The replacement string.firstOnly - Whether to stop after replacing the first found instance
of target.startIdx - Start replacing after this 0-based index into the
richTextString.
RichTextString with replaced values, or the
same RichTextString if replace is
null or empty.
public static org.apache.poi.ss.usermodel.RichTextString replaceValues(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.util.List<java.lang.String> targets,
java.util.List<java.lang.String> replacements)
List of strings to replace
with the corresponding replacement string in the given List.
Preserves rich text formatting as much as possible.
richTextString - The RichTextString to manipulate.helper - A CreationHelper that can create the proper
RichTextString.targets - The List of strings to replace.replacements - The corresponding List of replacement
strings.
RichTextString with replaced values, or the
same RichTextString if replace is
null or empty.
public static org.apache.poi.ss.usermodel.RichTextString substring(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.CreationHelper helper,
int beginIndex,
int endIndex)
RichTextString as another
RichTextString. Preserves the formatting that is in place
from the given string.
richTextString - The RichTextString of which to take a
substring.helper - A CreationHelper that can create the proper
RichTextString.beginIndex - The beginning index, inclusive.endIndex - The ending index, exclusive.
RichTextString, with
the original formatting from the original string intact.
public static void determineFormattingRunStats(org.apache.poi.ss.usermodel.RichTextString richTextString,
java.util.ArrayList<java.lang.Integer> beginList,
java.util.ArrayList<java.lang.Integer> lengthList,
java.util.ArrayList<java.lang.Object> fontList)
RichTextString. Adds elements to the arrays.
richTextString - The RichTextString.beginList - Adds to this List the beginning indexes of
all formatting runs found.lengthList - Adds to this List the length of all
formatting runs found.fontList - Adds to this List the fonts of all
formatting runs found. If HSSF, stores short font
indexes. If XSSF, stores XSSFFont objects.
public static org.apache.poi.ss.usermodel.RichTextString createFormattedString(int numFormattingRuns,
org.apache.poi.ss.usermodel.CreationHelper helper,
java.lang.String value,
java.util.ArrayList<java.lang.Integer> beginList,
java.util.ArrayList<java.lang.Integer> newLengthList,
java.util.ArrayList<java.lang.Object> fontList)
RichTextString of the same type as
richTextString, format it, and return it.
numFormattingRuns - The number of formatting runs.value - The new string value of the new RichTextString
to construct.helper - A CreationHelper that can create the proper
RichTextString.beginList - A List of beginning indexes of formatting
runs.newLengthList - A List of run lengths of formatting
runs.fontList - A List of fonts of formatting runs. If
HSSF, the items are shorts. If XSSF, the items are
XSSFFonts.
RichTextString, the same type as
richTextString, with value as it contents,
formatted as specified.
public static void formatString(org.apache.poi.ss.usermodel.RichTextString string,
int numFormattingRuns,
java.util.ArrayList<java.lang.Integer> beginList,
java.util.ArrayList<java.lang.Integer> newLengthList,
java.util.ArrayList<java.lang.Object> fontList)
RichTextString that has already been created.
string - A RichTextString.numFormattingRuns - The number of formatting runs.beginList - A List of beginning indexes of formatting
runs.newLengthList - A List of run lengths of formatting
runs.fontList - A List of fonts of formatting runs. If
HSSF, the items are shorts. If XSSF, the items are
XSSFFonts.
public static java.lang.Object getFontAtIndex(org.apache.poi.ss.usermodel.RichTextString richTextString,
int fmtIndex)
Font in use at the specified
position in the given RichTextString.
richTextString - The RichTextString.fmtIndex - The 0-based index of the formatting run.
short. If XSSF, an
XSSFFont.
public static void applyFont(org.apache.poi.ss.usermodel.RichTextString richTextString,
org.apache.poi.ss.usermodel.Cell cell)
Font from the given
RichTextString and apply it to the given Cell's
CellStyle.
cell - The Cell.richTextString - The RichTextString that contains the
desired Font.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||