Package loci.poi.hssf.usermodel
Class HSSFRichTextString
- java.lang.Object
-
- loci.poi.hssf.usermodel.HSSFRichTextString
-
- All Implemented Interfaces:
java.lang.Comparable
public class HSSFRichTextString extends java.lang.Object implements java.lang.ComparableRich text unicode string. These strings can have fonts applied to arbitary parts of the string.- Author:
- Glen Stampoultzis (glens at apache.org), Jason Height (jheight at apache.org)
-
-
Field Summary
Fields Modifier and Type Field Description static shortNO_FONTPlace holder for indicating that NO_FONT has been applied here
-
Constructor Summary
Constructors Constructor Description HSSFRichTextString()HSSFRichTextString(java.lang.String string)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyFont(int startIndex, int endIndex, short fontIndex)Applies a font to the specified characters of a string.voidapplyFont(int startIndex, int endIndex, HSSFFont font)Applies a font to the specified characters of a string.voidapplyFont(short fontIndex)Applies the specified font to the entire string.voidapplyFont(HSSFFont font)Sets the font of the entire string.voidclearFormatting()Removes any formatting that may have been applied to the string.intcompareTo(java.lang.Object o)Compares one rich text string to another.booleanequals(java.lang.Object o)shortgetFontAtIndex(int index)Returns the font in use at a particular index.shortgetFontOfFormattingRun(int index)Gets the font used in a particular formatting run.intgetIndexOfFormattingRun(int index)The index within the string to which the specified formatting run applies.java.lang.StringgetString()Returns the plain string representation.intlength()intnumFormattingRuns()java.lang.StringtoString()
-
-
-
Field Detail
-
NO_FONT
public static final short NO_FONT
Place holder for indicating that NO_FONT has been applied here- See Also:
- Constant Field Values
-
-
Method Detail
-
applyFont
public void applyFont(int startIndex, int endIndex, short fontIndex)Applies a font to the specified characters of a string.- Parameters:
startIndex- The start index to apply the font to (inclusive)endIndex- The end index to apply the font to (exclusive)fontIndex- The font to use.
-
applyFont
public void applyFont(int startIndex, int endIndex, HSSFFont font)Applies a font to the specified characters of a string.- Parameters:
startIndex- The start index to apply the font to (inclusive)endIndex- The end index to apply to font to (exclusive)font- The index of the font to use.
-
applyFont
public void applyFont(HSSFFont font)
Sets the font of the entire string.- Parameters:
font- The font to use.
-
clearFormatting
public void clearFormatting()
Removes any formatting that may have been applied to the string.
-
getString
public java.lang.String getString()
Returns the plain string representation.
-
length
public int length()
- Returns:
- the number of characters in the font.
-
getFontAtIndex
public short getFontAtIndex(int index)
Returns the font in use at a particular index.- Parameters:
index- The index.- Returns:
- The font that's currently being applied at that index or null if no font is being applied or the index is out of range.
-
numFormattingRuns
public int numFormattingRuns()
- Returns:
- The number of formatting runs used. There will always be at least one of font NO_FONT.
- See Also:
NO_FONT
-
getIndexOfFormattingRun
public int getIndexOfFormattingRun(int index)
The index within the string to which the specified formatting run applies.- Parameters:
index- the index of the formatting run- Returns:
- the index within the string.
-
getFontOfFormattingRun
public short getFontOfFormattingRun(int index)
Gets the font used in a particular formatting run.- Parameters:
index- the index of the formatting run- Returns:
- the font number used.
-
compareTo
public int compareTo(java.lang.Object o)
Compares one rich text string to another.- Specified by:
compareToin interfacejava.lang.Comparable
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- the plain text representation of this string.
-
applyFont
public void applyFont(short fontIndex)
Applies the specified font to the entire string.- Parameters:
fontIndex- the font to apply.
-
-