Example usage for org.apache.poi.hpsf Section getOffset

List of usage examples for org.apache.poi.hpsf Section getOffset

Introduction

In this page you can find the example usage for org.apache.poi.hpsf Section getOffset.

Prototype

public long getOffset() 

Source Link

Document

Returns the offset of the section in the stream.

Usage

From source file:poi.poifs.poibrowser.PropertySetDescriptorRenderer.java

License:Apache License

/**
 * <p>Returns a string representation of a {@link Section}.</p>
 * @param s the section//w  ww.  java 2 s .c o m
 * @param name the section's name
 * @return a string representation of the {@link Section}
 */
protected String toString(final Section s, final String name) {
    final StringBuffer b = new StringBuffer();
    b.append("\n" + name + " Format ID: ");
    b.append(Codec.hexEncode(s.getFormatID()));
    b.append("\n" + name + " Offset: " + s.getOffset());
    b.append("\n" + name + " Section size: " + s.getSize());
    b.append("\n" + name + " Property count: " + s.getPropertyCount());

    final Property[] properties = s.getProperties();
    for (int i = 0; i < properties.length; i++) {
        final Property p = properties[i];
        final long id = p.getID();
        final long type = p.getType();
        final Object value = p.getValue();
        b.append('\n');
        b.append(name);
        b.append(", Name: ");
        b.append(id);
        b.append(" (");
        b.append(s.getPIDString(id));
        b.append("), Type: ");
        b.append(type);
        b.append(", Value: ");
        if (value instanceof byte[]) {
            byte[] b2 = (byte[]) value;
            b.append("0x" + Codec.hexEncode(b2, 0, 4));
            b.append(' ');
            b.append("0x" + Codec.hexEncode(b2, 4, b2.length - 4));
        } else if (value != null)
            b.append(value.toString());
        else
            b.append("null");
    }
    return b.toString();
}