Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.poi.hpsf
Class Section

    java.lang.Object
      org.apache.poi.hpsf.Section

Direct Known Subclasses:
  MutableSection

    public class Section

extends java.lang.Object

Represents a section in a `PropertySet`.

Author:
  Rainer Klute <klute@rainer-klute.de>, Drew Varner (Drew.Varner allUpIn sc.edu)

Field Summary
`protected java.util.Map<java.lang.Long,java.lang.String>` | `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`

Constructor Summary
`protected` | `Section()` Creates an empty and uninitialized `Section`.
`` | `Section(byte[] src, int offset)` Creates a `Section` instance from a byte array.

Method Summary
`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.
`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()`
`java.lang.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.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### dictionary

    protected java.util.Map<java.lang.Long,java.lang.String> dictionary

  Maps property IDs to section-private PID strings. These strings can be found in the property with ID 0.

### formatID

    protected ClassID formatID

  The section's format ID, `getFormatID()`.

### offset

    protected long offset

See Also:
  `getOffset()`

### size

    protected int size

See Also:
  `getSize()`

### properties

    protected Property[] properties

See Also:
  `getProperties()`

Constructor Detail

### Section

    protected Section()

  Creates an empty and uninitialized `Section`.

### Section

    public Section(byte[] src,
                   int offset)
            throws java.io.UnsupportedEncodingException

  Creates a `Section` instance from a byte array.

  Parameters:
    `src` - Contains the complete property set stream.
    `offset` - The position in the stream that points to the section's format ID.
  Throws:
    `java.io.UnsupportedEncodingException` - if the section's codepage is not supported.

Method Detail

### getFormatID

    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 `org.apache.poi.hpsf.wellknown.SectionIDMap.SUMMARY_INFORMATION_ID` the section (and thus the property set) is a SummaryInformation.

  Returns:
    The format ID

### getOffset

    public long getOffset()

  Returns the offset of the section in the stream.

  Returns:
    The offset of the section in the stream.

### getSize

    public int getSize()

  Returns the section's size in bytes.

  Returns:
    The section's size in bytes.

### getPropertyCount

    public int getPropertyCount()

  Returns the number of properties in this section.

  Returns:
    The number of properties in this section.

### getProperties

    public Property[] getProperties()

  Returns this section's properties.

  Returns:
    This section's properties.

### getProperty

    public java.lang.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`.

  Parameters:
    `id` - The property's ID
  Returns:
    The property's value

### getPropertyIntValue

    protected 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.

  Parameters:
    `id` - The property's ID
  Returns:
    The property's value

### getPropertyBooleanValue

    protected 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`.

  Parameters:
    `id` - The property's ID
  Returns:
    The property's value

### wasNull

    public 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.

  Returns:
    `true` if the last call to `getPropertyIntValue(long)` or `getProperty(long)` tried to access a property that was not available, else `false`.

### getPIDString

    public java.lang.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)`.

  Parameters:
    `pid` - The property ID
  Returns:
    The property ID's string value

### equals

    public boolean equals(java.lang.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.

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `o` - The object to compare this section with
  Returns:
    `true` if the objects are equal, `false` if not

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`
  See Also:
    `Object.hashCode()`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`
  See Also:
    `Object.toString()`

### getDictionary

    public java.util.Map<java.lang.Long,java.lang.String> 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.

  Returns:
    the dictionary or `null` if the section does not have a dictionary.

### getCodepage

    public int getCodepage()

  Gets the section's codepage, if any.

  Returns:
    The section's codepage if one is defined, else -1.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2010 The Apache Software Foundation or its licensors, as applicable.