Top Description Fields Constructors Methods
org.apache.poi.hssf.record.common

public Class UnicodeString

extends Object
implements Comparable<UnicodeString>, Duplicatable, GenericRecord
Class Inheritance
All Implemented Interfaces
org.apache.poi.common.usermodel.GenericRecord, org.apache.poi.common.Duplicatable, java.lang.Comparable
Imports
java.util.ArrayList, .Collections, .Iterator, .List, .Map, .Objects, .Spliterator, java.util.function.Supplier, java.util.stream.Collectors, org.apache.logging.log4j.LogManager, .Logger, org.apache.poi.common.Duplicatable, org.apache.poi.common.usermodel.GenericRecord, org.apache.poi.hssf.record.RecordInputStream, org.apache.poi.hssf.record.cont.ContinuableRecordInput, .ContinuableRecordOutput, org.apache.poi.util.BitField, .BitFieldFactory, .GenericRecordUtil

Unicode String - just standard fields that are in several records. It is considered more desirable than repeating it in all of them.

This is often called a XLUnicodeRichExtendedString in MS documentation.

Field Summary

Modifier and TypeField and Description
private static final BitField
private short
private byte
private String
private List<FormatRun>
private ExtRst
private static final BitField
private static final Logger
private static final BitField

Constructor Summary

AccessConstructor and Description
private
public
public
UnicodeString(RecordInputStream
the RecordInputStream to read the record from
in
)

construct a unicode string record and fill its fields, ID is ignored

Method Summary

Modifier and TypeMethod and Description
public void
addFormatRun(FormatRun r)

Adds a font run to the formatted string.

public void
public int
compareTo(UnicodeString
the object to be compared.
str
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public UnicodeString
public boolean

Returns:

true if the object is actually equal.
equals
(Object
The object to compare.
o
)

Overrides java.lang.Object.equals.

Our handling of equals is inconsistent with compareTo.

private int
findFormatRunAt(int characterPos)

public Iterator<FormatRun>
public Spliterator<FormatRun>
public int

Returns:

number of characters
getCharCount
()

get the number of characters in the string, as an un-wrapped int

public short

Returns:

number of characters
getCharCountShort
()

get the number of characters in the string, wrapped as needed to fit within a short

public String

Returns:

String of output for biffviewer etc.
getDebugInfo
()

return a character representation of the fields of this record

public ExtRst
public FormatRun
getFormatRun(int index)

public int
public Map<String, Supplier<?>>
public byte

Returns:

optionflags bitmask
getOptionFlags
()

get the option flags which among other things return if this is a 16-bit or 8 bit string

public String

Returns:

the actual string this contains as a java String object
getString
()

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private boolean
private boolean
public void
public void
serialize(ContinuableRecordOutput out)

Serialises out the String.

public void
setCharCount(short
- number of characters
cc
)

set the number of characters in the string

pack-priv void
public void
setOptionFlags(byte
optionflags bitmask
of
)

set the option flags which among other things return if this is a 16-bit or 8 bit string

public void
setString(String
the text
string
)

set the actual string this contains

public void
swapFontUse(short oldFontIndex, short newFontIndex)

Swaps all use in the string of one font index for use of a different font index.

public String

Returns:

String value of the record
toString
()

Overrides java.lang.Object.toString.

unlike the real records we return the same as "getString()" rather than debug info

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

extBitback to summary
private static final BitField extBit
field_1_charCountback to summary
private short field_1_charCount
field_2_optionflagsback to summary
private byte field_2_optionflags
field_3_stringback to summary
private String field_3_string
field_4_format_runsback to summary
private List<FormatRun> field_4_format_runs
field_5_ext_rstback to summary
private ExtRst field_5_ext_rst
highByteback to summary
private static final BitField highByte
LOGback to summary
private static final Logger LOG
richTextback to summary
private static final BitField richText

Constructor Detail

UnicodeStringback to summary
private UnicodeString(UnicodeString other)
UnicodeStringback to summary
public UnicodeString(String str)
UnicodeStringback to summary
public UnicodeString(RecordInputStream in)

construct a unicode string record and fill its fields, ID is ignored

Parameters
in:RecordInputStream

the RecordInputStream to read the record from

Method Detail

addFormatRunback to summary
public void addFormatRun(FormatRun r)

Adds a font run to the formatted string. If a font run exists at the current charcter location, then it is replaced with the font run to be added.

clearFormattingback to summary
public void clearFormatting()
compareToback to summary
public int compareTo(UnicodeString str)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
str:UnicodeString

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
copyback to summary
public UnicodeString copy()

Implements org.apache.poi.common.Duplicatable.copy.

Returns:UnicodeString

Doc from org.apache.poi.common.Duplicatable.copy.

a deep copy of the implementing class / instance

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Our handling of equals is inconsistent with compareTo. The trouble is because we don't truly understand rich text fields, yet it's difficult to make a sound comparison.

Parameters
o:Object

The object to compare.

Returns:boolean

true if the object is actually equal.

findFormatRunAtback to summary
private int findFormatRunAt(int characterPos)
formatIteratorback to summary
public Iterator<FormatRun> formatIterator()
formatSpliteratorback to summary
public Spliterator<FormatRun> formatSpliterator()
Since
POI 5.2.0
getCharCountback to summary
public int getCharCount()

get the number of characters in the string, as an un-wrapped int

Returns:int

number of characters

getCharCountShortback to summary
public short getCharCountShort()

get the number of characters in the string, wrapped as needed to fit within a short

Returns:short

number of characters

getDebugInfoback to summary
public String getDebugInfo()

return a character representation of the fields of this record

Returns:String

String of output for biffviewer etc.

getExtendedRstback to summary
public ExtRst getExtendedRst()
getFormatRunback to summary
public FormatRun getFormatRun(int index)
getFormatRunCountback to summary
public int getFormatRunCount()
getGenericPropertiesback to summary
public Map<String, Supplier<?>> getGenericProperties()

Implements org.apache.poi.common.usermodel.GenericRecord.getGenericProperties.

Annotations
@Override
getOptionFlagsback to summary
public byte getOptionFlags()

get the option flags which among other things return if this is a 16-bit or 8 bit string

Returns:byte

optionflags bitmask

getStringback to summary
public String getString()
Returns:String

the actual string this contains as a java String object

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

isExtendedTextback to summary
private boolean isExtendedText()
isRichTextback to summary
private boolean isRichText()
removeFormatRunback to summary
public void removeFormatRun(FormatRun r)
serializeback to summary
public void serialize(ContinuableRecordOutput out)

Serialises out the String. There are special rules about where we can and can't split onto Continue records.

setCharCountback to summary
public void setCharCount(short cc)

set the number of characters in the string

Parameters
cc:short

- number of characters

setExtendedRstback to summary
pack-priv void setExtendedRst(ExtRst ext_rst)
setOptionFlagsback to summary
public void setOptionFlags(byte of)

set the option flags which among other things return if this is a 16-bit or 8 bit string

Parameters
of:byte

optionflags bitmask

setStringback to summary
public void setString(String string)

set the actual string this contains

Parameters
string:String

the text

swapFontUseback to summary
public void swapFontUse(short oldFontIndex, short newFontIndex)

Swaps all use in the string of one font index for use of a different font index. Normally only called when fonts have been removed / re-ordered

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

unlike the real records we return the same as "getString()" rather than debug info

Returns:String

String value of the record

See Also
getDebugInfo()