Package org.apache.poi.hpsf

Examples of org.apache.poi.hpsf.PropertySet


     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();
         assertNotNull(dsi);
     } catch (IOException e) {
    e.printStackTrace();
    fail();
  } catch (NoPropertySetStreamException e) {
    e.printStackTrace();
    fail();
  } catch (MarkUnsupportedException e) {
    e.printStackTrace();
    fail();
  } catch (UnexpectedPropertySetTypeException e) {
    e.printStackTrace();
    fail();
  }
    assertNotNull(dsi);
    try
    {
        DocumentEntry dsiEntry = (DocumentEntry)
            dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
        DocumentInputStream dis = new DocumentInputStream(dsiEntry);
        PropertySet ps = new PropertySet(dis);
        dis.close();
        si = new SummaryInformation(ps);
     
       
    }
View Full Code Here


       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)
       {
           fail();
       } catch (IOException e) {
      e.printStackTrace();
      fail();
    } catch (NoPropertySetStreamException e) {
      e.printStackTrace();
      fail();
    } catch (MarkUnsupportedException e) {
      e.printStackTrace();
      fail();
    } catch (UnexpectedPropertySetTypeException e) {
      e.printStackTrace();
      fail();
    }
      try
        {
            DocumentEntry dsiEntry = (DocumentEntry)
                dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
            DocumentInputStream dis = new DocumentInputStream(dsiEntry);
            PropertySet ps = new PropertySet(dis);
            dis.close();
            si = new SummaryInformation(ps);
         
           
        }
View Full Code Here

    {
        /* Loop over the two property sets. */
        for (int i = 0; i < 2; i++)
        {
            byte[] b = poiFiles[i].getBytes();
            PropertySet ps =
                PropertySetFactory.create(new ByteArrayInputStream(b));
            Assert.assertEquals(ps.getByteOrder(), BYTE_ORDER);
            Assert.assertEquals(ps.getFormat(), FORMAT);
            Assert.assertEquals(ps.getOSVersion(), OS_VERSION);
            Assert.assertEquals(new String(ps.getClassID().getBytes()),
                                new String(CLASS_ID));
            Assert.assertEquals(ps.getSectionCount(), SECTION_COUNT[i]);
            Assert.assertEquals(ps.isSummaryInformation(),
                                IS_SUMMARY_INFORMATION[i]);
            Assert.assertEquals(ps.isDocumentSummaryInformation(),
                                IS_DOCUMENT_SUMMARY_INFORMATION[i]);
        }
    }
View Full Code Here

            POIFSFileSystem filesystem, String entryName, Metadata metadata)
            throws IOException, TikaException {
        try {
            DocumentEntry entry =
                (DocumentEntry) filesystem.getRoot().getEntry(entryName);
            PropertySet properties =
                new PropertySet(new DocumentInputStream(entry));
            if (properties.isSummaryInformation()) {
                parse(new SummaryInformation(properties), metadata);
            }
            if (properties.isDocumentSummaryInformation()) {
                parse(new DocumentSummaryInformation(properties), metadata);
            }
        } catch (FileNotFoundException e) {
            // entry does not exist, just skip it
        } catch (NoPropertySetStreamException e) {
View Full Code Here

        }
    }

    private void getMetadata(InputStream stream, Metadata metadata)
            throws HPSFException, IOException {
        PropertySet set = PropertySetFactory.create(stream);
        if (set instanceof SummaryInformation) {
            getMetadata((SummaryInformation) set, metadata);
        } else if (set instanceof DocumentSummaryInformation) {
            getMetadata((DocumentSummaryInformation) set, metadata);
        }
View Full Code Here

                                                  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));
        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. */
 
View Full Code Here

                 * stream or not. */
                if (PropertySet.isPropertySetStream(stream))
                {
                    /* Yes, the current document is a property set stream.
                     * Let's create a PropertySet instance from it. */
                    PropertySet ps = null;
                    try
                    {
                        ps = PropertySetFactory.create(stream);
                    }
                    catch (NoPropertySetStreamException ex)
                    {
                        /* This exception will not be thrown because we already
                         * checked above. */
                    }

                    /* Now we know that we really have a property set. The next
                     * step is to find out whether it is a summary information
                     * or not. */
                    if (ps.isSummaryInformation())
                        /* Yes, it is a summary information. We will modify it
                         * and write the result to the destination POIFS. */
                        editSI(poiFs, path, name, ps);
                    else
                        /* No, it is not a summary information. We don't care
View Full Code Here

        final DocumentInputStream dis1 = new DocumentInputStream(d1);
        final DocumentInputStream dis2 = new DocumentInputStream(d2);
        if (PropertySet.isPropertySetStream(dis1) &&
            PropertySet.isPropertySetStream(dis2))
        {
            final PropertySet ps1 = PropertySetFactory.create(dis1);
            final PropertySet ps2 = PropertySetFactory.create(dis2);
            equal = ps1.equals(ps2);
            if (!equal)
            {
                msg.append("Property sets are not equal.\n");
                return equal;
View Full Code Here

                 * stream or not. */
                if (PropertySet.isPropertySetStream(stream))
                {
                    /* Yes, the current document is a property set stream.
                     * Let's create a PropertySet instance from it. */
                    PropertySet ps = null;
                    try
                    {
                        ps = PropertySetFactory.create(stream);
                    }
                    catch (NoPropertySetStreamException ex)
View Full Code Here

      return null;
    }

    try {
      // Create the Property Set
      PropertySet set = PropertySetFactory.create(dis);
      return set;
    } catch(IOException ie) {
      // Must be corrupt or something like that
      System.err.println("Error creating property set with name " + setName + "\n" + ie);
    } catch(org.apache.poi.hpsf.HPSFException he) {
View Full Code Here

TOP

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

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.