List of usage examples for org.apache.poi.hpsf PropertySet getSections
public List<Section> getSections()
From source file:com.villemos.ispace.aperture.enricher.MicrosoftPropertyReader.java
License:Open Source License
public void processPOIFSReaderEvent(final POIFSReaderEvent event) { PropertySet ps = null; try {//from w ww .jav a 2s .c om ps = PropertySetFactory.create(event.getStream()); } catch (NoPropertySetStreamException ex) { LOG.debug("No property set stream: \"" + event.getPath() + event.getName() + "\""); return; } catch (Exception ex) { LOG.error("Exception while processing microsoft property set " + ex); } /* Print the name of the property set stream: */ LOG.debug("Property set stream \"" + event.getPath() + event.getName() + "\":"); /* Print the list of sections: */ List<Section> sections = ps.getSections(); int nr = 0; for (Section sec : sections) { String s = HexDump.dump(sec.getFormatID().getBytes(), 0L, 0); s = s.substring(0, s.length() - 1); /* Print the number of properties in this section. */ int propertyCount = sec.getPropertyCount(); /* Print the properties: */ Property[] properties = sec.getProperties(); for (int i2 = 0; i2 < properties.length; i2++) { /* Print a single property: */ Property p = properties[i2]; long id = p.getID(); long type = p.getType(); Object value = p.getValue(); String propertyName = sec.getPIDString(id); if (msProperties.containsKey(propertyName) == false) { String valueStr = value.toString(); if (valueStr.equals("") == false) { msProperties.put(propertyName, valueStr); } } } } }
From source file:net.sf.mpxj.mpp.SummaryInformation.java
License:Open Source License
/** * This method reads the contents of a property set and returns * a map relating property IDs and values together. * * @param ps property set//from w ww . j a v a2 s . c o m * @return map */ @SuppressWarnings("unchecked") private HashMap<Integer, Object> getPropertyMap(PropertySet ps) { HashMap<Integer, Object> map = new HashMap<Integer, Object>(); Property[] properties; Property property; List<Section> sections = ps.getSections(); int index = 100; for (Section section : sections) { properties = section.getProperties(); for (int loop = 0; loop < properties.length; loop++) { property = properties[loop]; // the following causes an "unnecessary cast" warning in JDK1.4 // this is in place to ensure compatibility with JDK1.5 map.put(Integer.valueOf(index + (int) property.getID()), property.getValue()); //System.out.println ("id="+(index+property.getID())+" value="+property.getValue()); } index += 100; } return (map); }
From source file:poi.poifs.poibrowser.PropertySetDescriptorRenderer.java
License:Apache License
public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final 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));// www . j av a2 s . c om 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; }