public class Section
extends java.lang.Object
PropertySet
.Constructor and Description |
---|
Section()
Creates an empty
Section . |
Section(byte[] src,
int offset)
Creates a
Section instance from a byte array. |
Section(Section s)
Constructs a
Section by doing a deep copy of an
existing Section . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all properties from the section including 0 (dictionary) and 1 (codepage).
|
boolean |
equals(java.lang.Object o)
Checks whether this section is equal to another object.
|
int |
getCodepage()
Gets the section's codepage, if any.
|
java.util.Map<java.lang.Long,java.lang.String> |
getDictionary()
Gets the section's dictionary.
|
ClassID |
getFormatID()
Returns the format ID.
|
long |
getOffset()
Returns the offset of the section in the stream.
|
java.lang.String |
getPIDString(long pid)
Returns the PID string associated with a property ID.
|
Property[] |
getProperties()
Returns this section's properties.
|
java.lang.Object |
getProperty(long id)
Returns the value of the property with the specified ID.
|
int |
getPropertyCount()
Returns the number of properties in this section.
|
int |
getSize() |
int |
hashCode() |
void |
removeProperty(long id)
Removes a property.
|
void |
setCodepage(int codepage)
Sets the codepage.
|
void |
setDictionary(java.util.Map<java.lang.Long,java.lang.String> dictionary)
Sets the section's dictionary.
|
void |
setFormatID(byte[] formatID)
Sets the section's format ID.
|
void |
setFormatID(ClassID formatID)
Sets the section's format ID.
|
void |
setProperties(Property[] properties)
Sets this section's properties.
|
void |
setProperty(int id,
boolean value)
Sets the boolean value of the property with the specified ID.
|
void |
setProperty(int id,
int value)
Sets the int value of the property with the specified ID.
|
void |
setProperty(int id,
long value)
Sets the long value of the property with the specified ID.
|
void |
setProperty(int id,
long variantType,
java.lang.Object value)
Sets the value and the variant type of the property with the
specified ID.
|
void |
setProperty(int id,
java.lang.Object value)
Sets a property.
|
void |
setProperty(int id,
java.lang.String value)
Sets the string value of the property with the specified ID.
|
void |
setProperty(Property p)
Sets a property.
|
protected void |
setPropertyBooleanValue(int id,
boolean value)
Sets the value of the boolean property with the specified
ID.
|
java.lang.String |
toString() |
java.lang.String |
toString(PropertyIDMap idMap) |
boolean |
wasNull()
Checks whether the property which the last call to
getPropertyIntValue(long) or getProperty(long) tried to access
was available or not. |
int |
write(java.io.OutputStream out)
Writes this section into an output stream.
|
public Section()
Section
.public Section(Section s)
Section
by doing a deep copy of an
existing Section
. All nested Property
instances, will be their mutable counterparts in the new
MutableSection
.s
- The section set to copypublic Section(byte[] src, int offset) throws java.io.UnsupportedEncodingException
Section
instance from a byte array.src
- Contains the complete property set stream.offset
- The position in the stream that points to the
section's format ID.java.io.UnsupportedEncodingException
- if the section's codepage is not
supported.public ClassID getFormatID()
Section
contains the bytes specified by
org.apache.poi.hpsf.wellknown.SectionIDMap.SUMMARY_INFORMATION_ID
the section (and thus the property set) is a SummaryInformation.public void setFormatID(ClassID formatID)
formatID
- The section's format IDpublic void setFormatID(byte[] formatID)
formatID
- The section's format ID as a byte array. It components
are in big-endian format.public long getOffset()
public int getPropertyCount()
public Property[] getProperties()
public void setProperties(Property[] properties)
properties
- This section's new properties.public java.lang.Object getProperty(long id)
null
is returned
and a subsequent call to wasNull
will return
true
.id
- The property's IDpublic void setProperty(int id, java.lang.String value)
id
- The property's IDvalue
- The property's value.public void setProperty(int id, int value)
id
- The property's IDvalue
- The property's value.setProperty(int, long, Object)
,
getProperty(long)
public void setProperty(int id, long value)
id
- The property's IDvalue
- The property's value.setProperty(int, long, Object)
,
getProperty(long)
public void setProperty(int id, boolean value)
id
- The property's IDvalue
- The property's value.setProperty(int, long, Object)
,
getProperty(long)
public void setProperty(int id, long variantType, java.lang.Object value)
id
- The property's ID.variantType
- The property's variant type.value
- The property's value.setProperty(int, String)
,
getProperty(long)
,
Variant
public void setProperty(Property p)
p
- The property to be set.setProperty(int, long, Object)
,
getProperty(long)
,
Variant
public void setProperty(int id, java.lang.Object value)
id
- The property ID.value
- The property's value. The value's class must be one of those
supported by HPSF.protected void setPropertyBooleanValue(int id, boolean value)
id
- The property's IDvalue
- The property's valuesetProperty(int, long, Object)
,
getProperty(long)
,
Variant
public int getSize()
public boolean wasNull()
getPropertyIntValue(long)
or getProperty(long)
tried to access
was available or not. This information might be important for
callers of getPropertyIntValue(long)
since the latter
returns 0 if the property does not exist. Using wasNull
the caller can distiguish this case from a property's
real value of 0.true
if the last call to getPropertyIntValue(long)
or getProperty(long)
tried to access a
property that was not available, else false
.public java.lang.String getPIDString(long pid)
Sections
private dictionary.
If it is not found there, the property PID string is taken
from sections format IDs namespace.
If the PID is also undefined there, i.e. it is not well-known,
"[undefined]"
is returned.pid
- The property IDpid
public void clear()
public boolean equals(java.lang.Object o)
false
if one of the the following conditions holds:
Section
.
Section
.
equals
in class java.lang.Object
o
- The object to compare this section withtrue
if the objects are equal, false
if
notpublic void removeProperty(long id)
id
- The ID of the property to be removedpublic int write(java.io.OutputStream out) throws WritingNotSupportedException, java.io.IOException
Internally this is done by writing into three byte array output streams: one for the properties, one for the property list and one for the section as such. The two former are appended to the latter when they have received all their data.
out
- The stream to write into.java.io.IOException
- if an I/O error occursWritingNotSupportedException
- if HPSF does not yet support
writing a property's variant type.public void setDictionary(java.util.Map<java.lang.Long,java.lang.String> dictionary) throws IllegalPropertySetDataException
Long
instances, all values must be
String
s. This method overwrites the properties with IDs
0 and 1 since they are reserved for the dictionary and the dictionary's
codepage. Setting these properties explicitly might have surprising
effects. An application should never do this but always use this
method.dictionary
- The dictionaryIllegalPropertySetDataException
- if the dictionary's key and
value types are not correct.getDictionary()
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public java.lang.String toString(PropertyIDMap idMap)
public java.util.Map<java.lang.Long,java.lang.String> getDictionary()
null
if the section does not have
a dictionary.public int getCodepage()
public void setCodepage(int codepage)
codepage
- the codepageCopyright 2020 The Apache Software Foundation or its licensors, as applicable.