public class Section extends Object
Represents a section in a PropertySet
.
Modifier and Type | Class and Description |
---|---|
(package private) class |
Section.PropertyListEntry
Represents an entry in the property list and holds a property's ID and
its offset from the section's beginning.
|
Modifier and Type | Field and Description |
---|---|
protected Map |
dictionary
Maps property IDs to section-private PID strings.
|
protected ClassID |
formatID
The section's format ID,
getFormatID() . |
protected long |
offset |
protected Property[] |
properties |
protected int |
size |
private boolean |
wasNull
This member is
true if the last call to getPropertyIntValue(long) or getProperty(long) tried to access a
property that was not available, else false . |
Modifier | Constructor and Description |
---|---|
protected |
Section()
Creates an empty and uninitialized
Section . |
|
Section(byte[] src,
int offset)
Creates a
Section instance from a byte array. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Checks whether this section is equal to another object.
|
int |
getCodepage()
Gets the section's codepage, if any.
|
Map |
getDictionary()
Gets the section's dictionary.
|
ClassID |
getFormatID()
Returns the format ID.
|
long |
getOffset()
Returns the offset of the section in the stream.
|
String |
getPIDString(long pid)
Returns the PID string associated with a property ID.
|
Property[] |
getProperties()
Returns this section's properties.
|
Object |
getProperty(long id)
Returns the value of the property with the specified ID.
|
protected boolean |
getPropertyBooleanValue(int id)
Returns the value of the boolean property with the specified
ID.
|
int |
getPropertyCount()
Returns the number of properties in this section.
|
protected int |
getPropertyIntValue(long id)
Returns the value of the numeric property with the specified
ID.
|
int |
getSize()
Returns the section's size in bytes.
|
int |
hashCode() |
private Property[] |
remove(Property[] pa,
int i)
Removes a field from a property array.
|
String |
toString() |
boolean |
wasNull()
Checks whether the property which the last call to
getPropertyIntValue(long) or getProperty(long) tried to access
was available or not. |
protected Map dictionary
Maps property IDs to section-private PID strings. These strings can be found in the property with ID 0.
protected ClassID formatID
The section's format ID, getFormatID()
.
protected long offset
getOffset()
protected int size
getSize()
protected Property[] properties
getProperties()
private boolean wasNull
This member is true
if the last call to getPropertyIntValue(long)
or getProperty(long)
tried to access a
property that was not available, else false
.
protected Section()
Creates an empty and uninitialized Section
.
public Section(byte[] src, int offset) throws UnsupportedEncodingException
Creates a 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.UnsupportedEncodingException
- if the section's codepage is not
supported.public ClassID getFormatID()
Returns the format ID. The format ID is the "type" of the
section. For example, if the format ID of the first Section
contains the bytes specified by
loci.poi.hpsf.wellknown.SectionIDMap.SUMMARY_INFORMATION_ID
the section (and thus the property set) is a SummaryInformation.
public long getOffset()
Returns the offset of the section in the stream.
public int getSize()
Returns the section's size in bytes.
public int getPropertyCount()
Returns the number of properties in this section.
public Property[] getProperties()
Returns this section's properties.
public Object getProperty(long id)
Returns the value of the property with the specified ID. If
the property is not available, null
is returned
and a subsequent call to wasNull
will return
true
.
id
- The property's IDprotected int getPropertyIntValue(long id)
Returns the value of the numeric property with the specified
ID. If the property is not available, 0 is returned. A
subsequent call to wasNull
will return
true
to let the caller distinguish that case from
a real property value of 0.
id
- The property's IDprotected boolean getPropertyBooleanValue(int id)
Returns the value of the boolean property with the specified
ID. If the property is not available, false
is
returned. A subsequent call to wasNull
will return
true
to let the caller distinguish that case from
a real property value of false
.
id
- The property's IDpublic boolean wasNull()
Checks whether the property which the last call to 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 String getPIDString(long pid)
Returns the PID string associated with a property ID. The ID
is first looked up in the Section
's private
dictionary. If it is not found there, the method calls SectionIDMap.getPIDString(byte[], long)
.
pid
- The property IDpublic boolean equals(Object o)
Checks whether this section is equal to another object. The result is
false
if one of the the following conditions holds:
The other object is not a Section
.
The format IDs of the two sections are not equal.
The sections have a different number of properties. However, properties with ID 1 (codepage) are not counted.
The other object is not a Section
.
The properties have different values. The order of the properties is irrelevant.
private Property[] remove(Property[] pa, int i)
Removes a field from a property array. The resulting array is compactified and returned.
pa
- The property array.i
- The index of the field to be removed.public int hashCode()
hashCode
in class Object
Object.hashCode()
public String toString()
toString
in class Object
Object.toString()
public Map getDictionary()
Gets the section's dictionary. A dictionary allows an application to use human-readable property names instead of numeric property IDs. It contains mappings from property IDs to their associated string values. The dictionary is stored as the property with ID 0. The codepage for the strings in the dictionary is defined by property with ID 1.
null
if the section does not have
a dictionary.public int getCodepage()
Gets the section's codepage, if any.
Copyright © 2016 Open Microscopy Environment