Package org.apache.poi.poifs.filesystem

Examples of org.apache.poi.poifs.filesystem.Entry


    if (dir.getEntryCount() == 0) {
      return;
    }

    for (Iterator iter = dir.getEntries(); iter.hasNext();) {
      Entry entry = (Entry) iter.next();
      System.out.println("found entry: " + entry.getName());
      if (entry instanceof DirectoryEntry) {
        // .. recurse into this directory
        readDirectory(fs, (DirectoryEntry) entry);
      } else if (entry instanceof DocumentEntry) {
        // entry is a document, which you can read
View Full Code Here


    if (dir.getEntryCount() == 0) {
      return;
    }

    for (Iterator iter = dir.getEntries(); iter.hasNext();) {
      Entry entry = (Entry) iter.next();
      if (entry instanceof DirectoryEntry) {
        // .. recurse into this directory
        readDirectory(fs, (DirectoryEntry) entry);
      } else if (entry instanceof DocumentEntry) {
        // entry is a document, which you can read
View Full Code Here

    if (dir.getEntryCount() == 0) {
      return;
    }

    for (Iterator iter = dir.getEntries(); iter.hasNext();) {
      Entry entry = (Entry) iter.next();
      // System.out.println("found entry: " + entry.getName());
      if (entry instanceof DirectoryEntry) {
        // .. recurse into this directory
        // System.out.println(" > Directory...");
        readDirectory(fs, (DirectoryEntry) entry, ctx);
      } else if (entry instanceof DocumentEntry) {
        // entry is a document, which you can read
        // System.out.println(" > Document");
        DocumentEntry doc = (DocumentEntry) entry;
        ArrayList list = readDocument(fs, doc);

        if (entry.getName().endsWith("CompObj")) {
          writeCompObjProps(list, ctx);
        }
      } else {
        // currently, either an Entry is a DirectoryEntry or a
        // DocumentEntry,
View Full Code Here

        boolean objectPoolWritten = false;
        boolean tableWritten = false;
        boolean propertiesWritten = false;
        for ( Iterator<Entry> iter = directory.getEntries(); iter.hasNext(); )
        {
            Entry entry = iter.next();
            if ( entry.getName().equals( STREAM_WORD_DOCUMENT ) )
            {
                if ( !docWritten )
                {
                    pfs.createDocument( new ByteArrayInputStream( mainBuf ),
                            STREAM_WORD_DOCUMENT );
                    docWritten = true;
                }
            }
            else if ( entry.getName().equals( STREAM_OBJECT_POOL ) )
            {
                if ( !objectPoolWritten )
                {
                    _objectPool.writeTo( pfs.getRoot() );
                    objectPoolWritten = true;
                }
            }
            else if ( entry.getName().equals( STREAM_TABLE_0 )
                    || entry.getName().equals( STREAM_TABLE_1 ) )
            {
                if ( !tableWritten )
                {
                    pfs.createDocument( new ByteArrayInputStream( tableBuf ),
                            STREAM_TABLE_1 );
                    tableWritten = true;
                }
            }
            else if ( entry.getName().equals(
                    SummaryInformation.DEFAULT_STREAM_NAME )
                    || entry.getName().equals(
                            DocumentSummaryInformation.DEFAULT_STREAM_NAME ) )
            {
                if ( !propertiesWritten )
                {
                    writeProperties( pfs );
                    propertiesWritten = true;
                }
            }
            else if ( entry.getName().equals( STREAM_DATA ) )
            {
                if ( !dataWritten )
                {
                    pfs.createDocument( new ByteArrayInputStream( dataBuf ),
                            STREAM_DATA );
View Full Code Here

        result.append( "+ " );
        result.append( directory.getName() );
        for ( Iterator<Entry> iterator = directory.getEntries(); iterator
                .hasNext(); )
        {
            Entry entry = iterator.next();
            String entryToString = "\n" + dumpFileSystem( entry );
            entryToString = entryToString.replaceAll( "\n", "\n+---" );
            result.append( entryToString );
        }
        result.append( "\n" );
View Full Code Here

    }

    private boolean processOle2( HWPFDocument doc, CharacterRun characterRun,
            Element block )
    {
        Entry entry = doc.getObjectsPool().getObjectById(
                "_" + characterRun.getPicOffset() );
        if ( entry == null )
        {
            logger.log( POILogger.WARN, "Referenced OLE2 object '",
                    Integer.valueOf( characterRun.getPicOffset() ),
View Full Code Here

            throws IOException
    {
        Iterator<Entry> entries = sourceRoot.getEntries();
        while ( entries.hasNext() )
        {
            Entry entry = entries.next();
            if ( !excepts.contains( entry.getName() ) )
            {
                copyNodeRecursively( entry, targetRoot );
            }
        }
    }
View Full Code Here

        // Is it an embedded OLE2 document, or an embedded OOXML document?

        if (dir.hasEntry("Package")) {
            // It's OOXML (has a ZipFile):
            Entry ooxml = dir.getEntry("Package");

            TikaInputStream stream = TikaInputStream.get(
                    new DocumentInputStream((DocumentEntry) ooxml));
            try {
                ZipContainerDetector detector = new ZipContainerDetector();
                MediaType type = detector.detect(stream, new Metadata());
                handleEmbeddedResource(stream, null, type.toString(), xhtml, true);
                return;
            } finally {
                stream.close();
            }
        }

        // It's regular OLE2:

        // What kind of document is it?
        Metadata metadata = new Metadata();
        POIFSDocumentType type = POIFSDocumentType.detectType(dir);
        TikaInputStream embedded = null;

        try {
            if (type == POIFSDocumentType.OLE10_NATIVE) {
                Entry entry = dir.getEntry(Ole10Native.OLE10_NATIVE);
                ByteArrayOutputStream bos = new ByteArrayOutputStream();

                // TODO: once we upgrade to POI 3.8 beta 5
                // we can avoid this full copy/serialize by
                // passing the DirectoryNode instead:
View Full Code Here

  }
  public static POIOLE2TextExtractor createExtractor(DirectoryNode poifsDir, POIFSFileSystem fs) throws IOException {
    // Look for certain entries in the stream, to figure it
    //  out from
    for(Iterator entries = poifsDir.getEntries(); entries.hasNext(); ) {
      Entry entry = (Entry)entries.next();
     
      if(entry.getName().equals("Workbook")) {
        return new ExcelExtractor(poifsDir, fs);
      }
      if(entry.getName().equals("WordDocument")) {
        return new WordExtractor(poifsDir, fs);
      }
      if(entry.getName().equals("PowerPoint Document")) {
        return new PowerPointExtractor(poifsDir, fs);
      }
      if(entry.getName().equals("VisioDocument")) {
        return new VisioTextExtractor(poifsDir, fs);
      }
    }
    throw new IllegalArgumentException("No supported documents found in the OLE2 stream");
  }
View Full Code Here

   
    if(ext instanceof ExcelExtractor) {
      // These are in MBD... under the root
      Iterator it = fs.getRoot().getEntries();
      while(it.hasNext()) {
        Entry entry = (Entry)it.next();
        if(entry.getName().startsWith("MBD")) {
          dirs.add(entry);
        }
      }
    } else if(ext instanceof WordExtractor) {
      // These are in ObjectPool -> _... under the root
      try {
        DirectoryEntry op = (DirectoryEntry)
          fs.getRoot().getEntry("ObjectPool");
        Iterator it = op.getEntries();
        while(it.hasNext()) {
          Entry entry = (Entry)it.next();
          if(entry.getName().startsWith("_")) {
            dirs.add(entry);
          }
        }
      } catch(FileNotFoundException e) {}
    } else if(ext instanceof PowerPointExtractor) {
View Full Code Here

TOP

Related Classes of org.apache.poi.poifs.filesystem.Entry

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.