FileDocCategorySizeDatePackage
PropertySetDescriptorRenderer.javaAPI DocApache Poi 3.0.17029Mon Jan 01 12:39:34 GMT 2007org.apache.poi.contrib.poibrowser

PropertySetDescriptorRenderer

public class PropertySetDescriptorRenderer extends DocumentDescriptorRenderer

Renders a {@link PropertySetDescriptor} by more or less dumping the stuff into a {@link JTextArea}.

author
Rainer Klute <klute@rainer-klute.de>
version
$Id: PropertySetDescriptorRenderer.java 489730 2006-12-22 19:18:16Z bayard $
since
2002-02-05

Fields Summary
Constructors Summary
Methods Summary
public java.awt.ComponentgetTreeCellRendererComponent(javax.swing.JTree tree, java.lang.Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)

        final PropertySetDescriptor d = (PropertySetDescriptor)
            ((DefaultMutableTreeNode) value).getUserObject();
        final PropertySet ps = d.getPropertySet();
        final JPanel p = new JPanel();
        final JTextArea text = new JTextArea();
        text.setBackground(new Color(200, 255, 200));
        text.setFont(new Font("Monospaced", Font.PLAIN, 10));
        text.append(renderAsString(d));
        text.append("\nByte order: " +
                    Codec.hexEncode((short) ps.getByteOrder()));
        text.append("\nFormat: " +
                    Codec.hexEncode((short) ps.getFormat()));
        text.append("\nOS version: " +
                    Codec.hexEncode(ps.getOSVersion()));
        text.append("\nClass ID: " +
                    Codec.hexEncode(ps.getClassID()));
        text.append("\nSection count: " + ps.getSectionCount());
        text.append(sectionsToString(ps.getSections()));
        p.add(text);

        if (ps instanceof SummaryInformation)
        {
            /* Use the convenience methods. */
            final SummaryInformation si = (SummaryInformation) ps;
            text.append("\n");
            text.append("\nTitle:               " + si.getTitle());
            text.append("\nSubject:             " + si.getSubject());
            text.append("\nAuthor:              " + si.getAuthor());
            text.append("\nKeywords:            " + si.getKeywords());
            text.append("\nComments:            " + si.getComments());
            text.append("\nTemplate:            " + si.getTemplate());
            text.append("\nLast Author:         " + si.getLastAuthor());
            text.append("\nRev. Number:         " + si.getRevNumber());
            text.append("\nEdit Time:           " + si.getEditTime());
            text.append("\nLast Printed:        " + si.getLastPrinted());
            text.append("\nCreate Date/Time:    " + si.getCreateDateTime());
            text.append("\nLast Save Date/Time: " + si.getLastSaveDateTime());
            text.append("\nPage Count:          " + si.getPageCount());
            text.append("\nWord Count:          " + si.getWordCount());
            text.append("\nChar Count:          " + si.getCharCount());
            // text.append("\nThumbnail:           " + si.getThumbnail());
            text.append("\nApplication Name:    " + si.getApplicationName());
            text.append("\nSecurity:            " + si.getSecurity());
        }

        if (selected)
            Util.invert(text);
        return p;
    
protected java.lang.StringsectionsToString(java.util.List sections)

Returns a string representation of a list of {@link Section}s.

        final StringBuffer b = new StringBuffer();
        int count = 1;
        for (Iterator i = sections.iterator(); i.hasNext();)
        {
            Section s = (Section) i.next();
            String d = toString(s, "Section " + count++);
            b.append(d);
        }
        return b.toString();
    
protected java.lang.StringtoString(org.apache.poi.hpsf.Section s, java.lang.String name)

Returns a string representation of a {@link Section}.

param
s the section
param
name the section's name
return
a string representation of the {@link Section}

        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();