Package org.apache.poi.hpsf

Examples of org.apache.poi.hpsf.DocumentSummaryInformation


   public HPSFPropertiesExtractor(NPOIFSFileSystem fs) {
      super(new PropertiesOnlyDocument(fs));
   }

  public String getDocumentSummaryInformationText() {
    DocumentSummaryInformation dsi = document.getDocumentSummaryInformation();
    StringBuffer text = new StringBuffer();

    // Normal properties
    text.append( getPropertiesText(dsi) );

    // Now custom ones
    CustomProperties cps = dsi == null ? null : dsi.getCustomProperties();
    if(cps != null) {
      Iterator<String> keys = cps.nameSet().iterator();
      while(keys.hasNext()) {
        String key = keys.next();
        String val = getPropertyValueText( cps.get(key) );
View Full Code Here


  public HPSFPropertiesExtractor(POIFSFileSystem fs) {
    super(new PropertiesOnlyDocument(fs));
  }

  public String getDocumentSummaryInformationText() {
    DocumentSummaryInformation dsi = document.getDocumentSummaryInformation();
    StringBuffer text = new StringBuffer();

    // Normal properties
    text.append( getPropertiesText(dsi) );

    // Now custom ones
    CustomProperties cps = dsi == null ? null : dsi.getCustomProperties();
    if(cps != null) {
      Iterator<String> keys = cps.nameSet().iterator();
      while(keys.hasNext()) {
        String key = keys.next();
        String val = getPropertyValueText( cps.get(key) );
View Full Code Here

  public HPSFPropertiesExtractor(POIFSFileSystem fs) {
    super(new PropertiesOnlyDocument(fs));
  }
 
  public String getDocumentSummaryInformationText() {
    DocumentSummaryInformation dsi = document.getDocumentSummaryInformation();
    StringBuffer text = new StringBuffer();

    // Normal properties
    text.append( getPropertiesText(dsi) );
   
    // Now custom ones
    CustomProperties cps = dsi.getCustomProperties();
    Iterator keys = cps.keySet().iterator();
    while(keys.hasNext()) {
      String key = (String)keys.next();
      String val = getPropertyValueText( cps.get(key) );
      text.append(key + " = " + val + "\n");
View Full Code Here

        /* Handling the document summary information is analogous to handling
         * the summary information. An additional feature, however, are the
         * custom properties. */

        /* Read the document summary information. */
        DocumentSummaryInformation dsi;
        try
        {
            DocumentEntry dsiEntry = (DocumentEntry)
                dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
            DocumentInputStream dis = new DocumentInputStream(dsiEntry);
            PropertySet ps = new PropertySet(dis);
            dis.close();
            dsi = new DocumentSummaryInformation(ps);
        }
        catch (FileNotFoundException ex)
        {
            /* There is no document summary information yet. We have to create a
             * new one. */
            dsi = PropertySetFactory.newDocumentSummaryInformation();
        }

        /* Change the category to "POI example". Any former category value will
         * be lost. If there has been no category yet, it will be created. */
        dsi.setCategory("POI example");
        System.out.println("Category changed to " + dsi.getCategory() + ".");

        /* Read the custom properties. If there are no custom properties yet,
         * the application has to create a new CustomProperties object. It will
         * serve as a container for custom properties. */
        CustomProperties customProperties = dsi.getCustomProperties();
        if (customProperties == null)
            customProperties = new CustomProperties();

        /* Insert some custom properties into the container. */
        customProperties.put("Key 1", "Value 1");
        customProperties.put("Schl\u00fcssel 2", "Wert 2");
        customProperties.put("Sample Number", new Integer(12345));
        customProperties.put("Sample Boolean", Boolean.TRUE);
        customProperties.put("Sample Date", new Date());

        /* Read a custom property. */
        Object value = customProperties.get("Sample Number");

        /* Write the custom properties back to the document summary
         * information. */
        dsi.setCustomProperties(customProperties);

        /* Write the summary information and the document summary information
         * to the POI filesystem. */
        si.write(dir, SummaryInformation.DEFAULT_STREAM_NAME);
        dsi.write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);

        /* Write the POI filesystem back to the original file. Please note that
         * in production code you should never write directly to the origin
         * file! In case of a writing error everything would be lost. */
        OutputStream out = new FileOutputStream(poiFilesystem);
View Full Code Here

   public HPSFPropertiesExtractor(NPOIFSFileSystem fs) {
      super(new PropertiesOnlyDocument(fs));
   }

  public String getDocumentSummaryInformationText() {
    DocumentSummaryInformation dsi = document.getDocumentSummaryInformation();
    StringBuffer text = new StringBuffer();

    // Normal properties
    text.append( getPropertiesText(dsi) );

    // Now custom ones
    CustomProperties cps = dsi == null ? null : dsi.getCustomProperties();
    if(cps != null) {
      Iterator<String> keys = cps.nameSet().iterator();
      while(keys.hasNext()) {
        String key = keys.next();
        String val = getPropertyValueText( cps.get(key) );
View Full Code Here

      writePropertySet(SummaryInformation.DEFAULT_STREAM_NAME, si, outFS);
      if(writtenEntries != null) {
        writtenEntries.add(SummaryInformation.DEFAULT_STREAM_NAME);
      }
    }
        DocumentSummaryInformation dsi = getDocumentSummaryInformation();
        if(dsi != null) {
      writePropertySet(DocumentSummaryInformation.DEFAULT_STREAM_NAME, dsi, outFS);
      if(writtenEntries != null) {
        writtenEntries.add(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
      }
View Full Code Here

      DocumentEntry dsiEntry = (DocumentEntry) dir
          .getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
      DocumentInputStream dis = new DocumentInputStream(dsiEntry);
      PropertySet ps = new PropertySet(dis);
      dis.close();
      dsi = new DocumentSummaryInformation(ps);

    } catch (FileNotFoundException ex) {
      /*
       * There is no document summary information yet. We have to create a
       * new one.
View Full Code Here

      DocumentEntry dsiEntry = (DocumentEntry) dir
          .getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
      DocumentInputStream dis = new DocumentInputStream(dsiEntry);
      PropertySet ps = new PropertySet(dis);
      dis.close();
      dsi = new DocumentSummaryInformation(ps);
    } catch (FileNotFoundException ex) {
      fail();
    } catch (Exception e) {
      e.printStackTrace();
      fail();
View Full Code Here

  class DocumentSummaryReader implements POIFSReaderListener {
    DocumentSummaryReader() {
    }

    public void processPOIFSReaderEvent(POIFSReaderEvent event) {
      DocumentSummaryInformation si = null;
      try {
        si = (DocumentSummaryInformation) PropertySetFactory
            .create(event.getStream());
      } catch (Exception ex) {
        throw new RuntimeException("Property set stream \""
View Full Code Here

  class DocumentSummaryReader implements POIFSReaderListener {
    DocumentSummaryReader() {
    }

    public void processPOIFSReaderEvent(POIFSReaderEvent event) {
      DocumentSummaryInformation si = null;
      try {
        si = (DocumentSummaryInformation) PropertySetFactory
            .create(event.getStream());
      } catch (Exception ex) {
        throw new RuntimeException("Property set stream \""
View Full Code Here

TOP

Related Classes of org.apache.poi.hpsf.DocumentSummaryInformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.