Examples of MutablePropertySet


Examples of org.apache.poi.hpsf.MutablePropertySet

        final File filename = new File(dataDir, POI_FS);
        filename.deleteOnExit();
        final OutputStream out = new FileOutputStream(filename);

        final POIFSFileSystem poiFs = new POIFSFileSystem();
        final MutablePropertySet ps = new MutablePropertySet();
        ps.clearSections();

        final ClassID formatID = new ClassID();
        formatID.setBytes(new byte[]{0, 1234567,
                                     8, 9, 10, 11, 12, 13, 14, 15});
        final MutableSection s1 = new MutableSection();
        s1.setFormatID(formatID);
        s1.setProperty(2, SECTION1);
        ps.addSection(s1);

        final MutableSection s2 = new MutableSection();
        s2.setFormatID(formatID);
        s2.setProperty(2, SECTION2);
        ps.addSection(s2);

        poiFs.createDocument(ps.toInputStream(), STREAM_NAME);
        poiFs.writeFilesystem(out);
        out.close();

        /* Read the POIFS: */
        final PropertySet[] psa = new PropertySet[1];
View Full Code Here

Examples of org.apache.poi.hpsf.MutablePropertySet

     * succeeds.</p>
     */
    public void testUnicodeWrite8Bit()
    {
        final String TITLE = "This is a sample title";
        final MutablePropertySet mps = new MutablePropertySet();
        final MutableSection ms = (MutableSection) mps.getSections().get(0);
        ms.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
        final MutableProperty p = new MutableProperty();
        p.setID(PropertyIDMap.PID_TITLE);
        p.setType(Variant.VT_LPSTR);
        p.setValue(TITLE);
        ms.setProperty(p);

        Throwable t = null;
        try
        {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            mps.write(out);
            out.close();
            byte[] bytes = out.toByteArray();

            PropertySet psr = new PropertySet(bytes);
            assertTrue(psr.isSummaryInformation());
View Full Code Here

Examples of org.apache.poi.hpsf.MutablePropertySet

            for (int i = 0; i < psf1.length; i++)
            {
                final InputStream in =
                    new ByteArrayInputStream(psf1[i].getBytes());
                final PropertySet psIn = PropertySetFactory.create(in);
                final MutablePropertySet psOut = new MutablePropertySet(psIn);
                final ByteArrayOutputStream psStream =
                    new ByteArrayOutputStream();
                psOut.write(psStream);
                psStream.close();
                final byte[] streamData = psStream.toByteArray();
                poiFs.createDocument(new ByteArrayInputStream(streamData),
                                     psf1[i].getName());
                poiFs.writeFilesystem(out);
View Full Code Here

Examples of org.apache.poi.hpsf.MutablePropertySet

            copy.deleteOnExit();

            /* Write: */
            final OutputStream out = new FileOutputStream(copy);
            final POIFSFileSystem poiFs = new POIFSFileSystem();
            final MutablePropertySet ps1 = new MutablePropertySet();
            final MutableSection s = (MutableSection) ps1.getSections().get(0);
            final Map m = new HashMap(3, 1.0f);
            m.put(new Long(1), "String 1");
            m.put(new Long(2), "String 2");
            m.put(new Long(3), "String 3");
            s.setDictionary(m);
            s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[0]);
            int codepage = Constants.CP_UNICODE;
            s.setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2,
                          new Integer(codepage));
            poiFs.createDocument(ps1.toInputStream(), "Test");
            poiFs.writeFilesystem(out);
            out.close();

            /* Read back: */
            final POIFile[] psf = Util.readPropertySets(copy);
View Full Code Here

Examples of org.apache.poi.hpsf.MutablePropertySet

            copy.deleteOnExit();

            /* Write: */
            final OutputStream out = new FileOutputStream(copy);
            final POIFSFileSystem poiFs = new POIFSFileSystem();
            final MutablePropertySet ps1 = new MutablePropertySet();
            final MutableSection s = (MutableSection) ps1.getSections().get(0);
            final Map m = new HashMap(3, 1.0f);
            m.put(new Long(1), "String 1");
            m.put(new Long(2), "String 2");
            m.put(new Long(3), "String 3");
            s.setDictionary(m);
            s.setFormatID(SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[0]);
            int codepage = 12345;
            s.setProperty(PropertyIDMap.PID_CODEPAGE, Variant.VT_I2,
                          new Integer(codepage));
            poiFs.createDocument(ps1.toInputStream(), "Test");
            poiFs.writeFilesystem(out);
            out.close();
            fail("This testcase did not detect the invalid codepage value.");
        }
        catch (IllegalPropertySetDataException ex)
View Full Code Here

Examples of org.apache.poi.hpsf.MutablePropertySet

   * @param set the PropertySet to write out
   * @param outFS the POIFSFileSystem to write the property into
   */
  protected void writePropertySet(String name, PropertySet set, POIFSFileSystem outFS) throws IOException {
    try {
      MutablePropertySet mSet = new MutablePropertySet(set);
      ByteArrayOutputStream bOut = new ByteArrayOutputStream();

      mSet.write(bOut);
      byte[] data = bOut.toByteArray();
      ByteArrayInputStream bIn = new ByteArrayInputStream(data);
      outFS.createDocument(bIn,name);

      logger.log(POILogger.INFO, "Wrote property set " + name + " of size " + data.length);
View Full Code Here

Examples of org.apache.poi.hpsf.MutablePropertySet

   * @param set the PropertySet to write out
   * @param outFS the POIFSFileSystem to write the property into
   */
  protected void writePropertySet(String name, PropertySet set, POIFSFileSystem outFS) throws IOException {
    try {
      MutablePropertySet mSet = new MutablePropertySet(set);
      ByteArrayOutputStream bOut = new ByteArrayOutputStream();

      mSet.write(bOut);
      byte[] data = bOut.toByteArray();
      ByteArrayInputStream bIn = new ByteArrayInputStream(data);
      outFS.createDocument(bIn,name);

      logger.log(POILogger.INFO, "Wrote property set " + name + " of size " + data.length);
View Full Code Here

Examples of org.apache.poi.hpsf.MutablePropertySet

     * @throws IOException if an error when writing to the
     *      {@link POIFSFileSystem} occurs
     */
    protected void writePropertySet(String name, PropertySet set, POIFSFileSystem outFS) throws IOException {
        try {
            MutablePropertySet mSet = new MutablePropertySet(set);
            ByteArrayOutputStream bOut = new ByteArrayOutputStream();

            mSet.write(bOut);
            byte[] data = bOut.toByteArray();
            ByteArrayInputStream bIn = new ByteArrayInputStream(data);
            outFS.createDocument(bIn,name);

            logger.log(POILogger.INFO, "Wrote property set " + name + " of size " + data.length);
View Full Code Here

Examples of org.apache.poi.hpsf.MutablePropertySet

   * @param set the PropertySet to write out
   * @param outFS the POIFSFileSystem to write the property into
   */
  protected void writePropertySet(String name, PropertySet set, POIFSFileSystem outFS) throws IOException {
    try {
      MutablePropertySet mSet = new MutablePropertySet(set);
      ByteArrayOutputStream bOut = new ByteArrayOutputStream();

      mSet.write(bOut);
      byte[] data = bOut.toByteArray();
      ByteArrayInputStream bIn = new ByteArrayInputStream(data);
      outFS.createDocument(bIn,name);

      logger.log(POILogger.INFO, "Wrote property set " + name + " of size " + data.length);
View Full Code Here

Examples of org.apache.poi.hpsf.MutablePropertySet

     * succeeds.</p>
     */
    public void testUnicodeWrite8Bit()
    {
        final String TITLE = "This is a sample title";
        final MutablePropertySet mps = new MutablePropertySet();
        final MutableSection ms = (MutableSection) mps.getSections().get(0);
        ms.setFormatID(SectionIDMap.SUMMARY_INFORMATION_ID);
        final MutableProperty p = new MutableProperty();
        p.setID(PropertyIDMap.PID_TITLE);
        p.setType(Variant.VT_LPSTR);
        p.setValue(TITLE);
        ms.setProperty(p);

        Throwable t = null;
        try
        {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            mps.write(out);
            out.close();
            byte[] bytes = out.toByteArray();

            PropertySet psr = new PropertySet(bytes);
            assertTrue(psr.isSummaryInformation());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.