List of usage examples for org.apache.poi.hpsf.wellknown PropertyIDMap PID_HEADINGPAIR
int PID_HEADINGPAIR
To view the source code for org.apache.poi.hpsf.wellknown PropertyIDMap PID_HEADINGPAIR.
Click Source Link
From source file:org.ddt.listener.dsi.DocumentSummaryInfoListener.java
License:Apache License
public void processPOIFSReaderEvent(POIFSReaderEvent event) { log.log(Level.FINEST, "reading {0}{1}", new Object[] { event.getPath(), event.getName() }); DocumentInputStream is = event.getStream(); try {/*from www .j a va2 s . c o m*/ PropertySet ps = PropertySetFactory.create(is); if (!(ps instanceof DocumentSummaryInformation)) return; Property docparts = null; Property headings = null; for (Property prop : ps.getProperties()) { if (prop.getID() == PropertyIDMap.PID_HEADINGPAIR) // == 12 headings = prop; else if (prop.getID() == PropertyIDMap.PID_DOCPARTS) docparts = prop; } if (docparts == null) { log.log(Level.FINE, "No DOCPARTS section"); return; } if (headings == null) return; HeadingPairVector hdv = new HeadingPairVector((byte[]) headings.getValue(), 0); StringVector docpartsVector = new StringVector((byte[]) docparts.getValue(), 0, docparts.getType()); HeadingPairProperty linkHeader = hdv.getHeadingPairByName("Links"); //*NOT* null terminated if (linkHeader == null) { log.log(Level.INFO, "No 'Links' header found."); return; } else { log.log(Level.FINEST, "Found {0} link parts", linkHeader.getPartsCount()); } //need to iterate through all of the ones if there's more than one //docpart for the header. int part = linkHeader.getOffset(); for (int i = 0; i < linkHeader.getPartsCount(); i++) { String url = docpartsVector.get(part).getValue(); log.log(Level.FINEST, "adding {0} to list of links.", url); url = url.trim(); Link l = new Link(3); l.addUnkownPath(url); this.add(l); part++; } } catch (NoPropertySetStreamException ex) { log.log(Level.INFO, "Not a PropertySetStream {0}{1}", new Object[] { event.getPath(), event.getName() }); } catch (MarkUnsupportedException ex) { log.log(Level.INFO, "Couldn't create PropertySet: {0}", ex.getLocalizedMessage()); } catch (UnsupportedEncodingException ex) { log.log(Level.INFO, null, ex); } catch (IOException ex) { log.log(Level.INFO, null, ex); } catch (HPSFException ex) { log.log(Level.WARNING, "Couldn't construct HeadingPair vector.", ex); } finally { is.close(); } }