List of usage examples for org.apache.poi.hpsf PropertySet getSectionCount
public int getSectionCount()
From source file:org.opf_labs.aqua.OfficeAnalyser.java
License:Apache License
public static void dump(DirectoryEntry root) throws IOException { System.out.println(root.getName() + " : storage CLSID " + root.getStorageClsid()); for (Iterator it = root.getEntries(); it.hasNext();) { Entry entry = (Entry) it.next(); if (entry instanceof DocumentNode) { DocumentNode node = (DocumentNode) entry; System.out.println("Node name: " + node.getName()); System.out.println("Node desc: " + node.getShortDescription()); System.out.println("Node size: " + node.getSize()); DocumentInputStream is = new DocumentInputStream(node); try { PropertySet ps = new PropertySet(is); if (ps.getSectionCount() != 0) { for (Property p : ps.getProperties()) { System.out.println("Prop: " + p.getID() + " " + p.getValue()); }/*from ww w .j a v a2s . co m*/ } } catch (NoPropertySetStreamException e) { // TODO Auto-generated catch block //e.printStackTrace(); } catch (MarkUnsupportedException e) { // TODO Auto-generated catch block //e.printStackTrace(); } //byte[] bytes = new byte[node.getSize()]; //is.read(bytes); //is.close(); //FileOutputStream out = new FileOutputStream(new File(parent, node.getName().trim())); //out.write(bytes); //out.close(); //System.out.println("Node: "+new String(bytes).substring(0, 10)); } else if (entry instanceof DirectoryEntry) { DirectoryEntry dir = (DirectoryEntry) entry; dump(dir); } else { System.err.println("Skipping unsupported POIFS entry: " + entry); } } }
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));/*from www .ja v a 2 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; }
From source file:uk.bl.wa.tika.parser.ole2.OLE2Parser.java
License:Open Source License
public static void dump(DirectoryEntry root) throws IOException { System.out.println(root.getName() + " : storage CLSID " + root.getStorageClsid()); for (Iterator it = root.getEntries(); it.hasNext();) { Entry entry = (Entry) it.next(); if (entry instanceof DocumentNode) { DocumentNode node = (DocumentNode) entry; System.out.println("Node name: " + node.getName()); System.out.println("Node desc: " + node.getShortDescription()); System.out.println("Node size: " + node.getSize()); DocumentInputStream is = new DocumentInputStream(node); try { PropertySet ps = new PropertySet(is); if (ps.getSectionCount() != 0) { for (Property p : ps.getProperties()) { System.out.println("Prop: " + p.getID() + " " + p.getValue()); }// w ww . j a v a 2s . co m } } catch (NoPropertySetStreamException e) { // TODO Auto-generated catch block //e.printStackTrace(); } //byte[] bytes = new byte[node.getSize()]; //is.read(bytes); //is.close(); //FileOutputStream out = new FileOutputStream(new File(parent, node.getName().trim())); //out.write(bytes); //out.close(); //System.out.println("Node: "+new String(bytes).substring(0, 10)); } else if (entry instanceof DirectoryEntry) { DirectoryEntry dir = (DirectoryEntry) entry; dump(dir); } else { System.err.println("Skipping unsupported POIFS entry: " + entry); } } }