Package org.apache.poi.poifs.filesystem

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


    {
        boolean equal = true;
        /* Iterate over d1 and compare each entry with its counterpart in d2. */
        for (final Iterator i = d1.getEntries(); equal && i.hasNext();)
        {
            final Entry e1 = (Entry) i.next();
            final String n1 = e1.getName();
            Entry e2 = null;
            try
            {
                e2 = d2.getEntry(n1);
            }
            catch (FileNotFoundException ex)
            {
                msg.append("Document \"" + e1 + "\" exists, document \"" +
                           e2 + "\" does not.\n");
                equal = false;
                break;
            }

            if (e1.isDirectoryEntry() && e2.isDirectoryEntry())
                equal = equal((DirectoryEntry) e1, (DirectoryEntry) e2, msg);
            else if (e1.isDocumentEntry() && e2.isDocumentEntry())
                equal = equal((DocumentEntry) e1, (DocumentEntry) e2, msg);
            else
            {
                msg.append("One of \"" + e1 + "\" and \"" + e2 + "\" is a " +
                           "document while the other one is a directory.\n");
                equal = false;
            }
        }

        /* Iterate over d2 just to make sure that there are no entries in d2
         * that are not in d1. */
        for (final Iterator i = d2.getEntries(); equal && i.hasNext();)
        {
            final Entry e2 = (Entry) i.next();
            final String n2 = e2.getName();
            Entry e1 = null;
            try
            {
                e1 = d1.getEntry(n2);
            }
            catch (FileNotFoundException ex)
View Full Code Here


            } else {
                if(obj.hasDirectoryEntry()){
                    // The DirectoryEntry is a DocumentNode. Examine its entries to find out what it is
                    DirectoryNode dn = (DirectoryNode) obj.getDirectory();
                    for (Iterator entries = dn.getEntries(); entries.hasNext();) {
                        Entry entry = (Entry) entries.next();
                        //System.out.println(oleName + "." + entry.getName());
                    }
                } else {
                    // There is no DirectoryEntry
                    // Recover the object's data from the HSSFObjectData instance.
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();
View Full Code Here

     (older) Works?
     * If not, it's likely an embedded resource
     */
    private static MediaType processCompObjFormatType(DirectoryEntry root) {
        try {
            Entry e = root.getEntry("\u0001CompObj");
            if (e != null && e.isDocumentEntry()) {
                DocumentNode dn = (DocumentNode)e;
                DocumentInputStream stream = new DocumentInputStream(dn);
                byte [] bytes = IOUtils.toByteArray(stream);
                /*
                 * This array contains a string with a normal ASCII name of the
View Full Code Here

    DirectoryEntry newRoot = target.getRoot();

    Iterator entries = root.getEntries();

    while (entries.hasNext()) {
      Entry entry = (Entry)entries.next();
      if (!isInList(entry.getName(), excepts)) {
        copyNodeRecursively(entry,newRoot);
      }
    }
  }
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

   {
      long byteCount;

      for (Iterator<Entry> iter = dir.getEntries(); iter.hasNext();)
      {
         Entry entry = iter.next();
         if (entry instanceof DirectoryEntry)
         {
            String childIndent = indent;
            if (childIndent != null)
            {
               childIndent += " ";
            }

            String childPrefix = prefix + "[" + entry.getName() + "].";
            pw.println("start dir: " + prefix + entry.getName());
            dumpTree(pw, (DirectoryEntry) entry, childPrefix, showData, hex, childIndent);
            pw.println("end dir: " + prefix + entry.getName());
         }
         else
            if (entry instanceof DocumentEntry)
            {
               if (showData)
               {
                  pw.println("start doc: " + prefix + entry.getName());
                  if (hex == true)
                  {
                     byteCount = hexdump(new DocumentInputStream((DocumentEntry) entry), pw);
                  }
                  else
                  {
                     byteCount = asciidump(new DocumentInputStream((DocumentEntry) entry), pw);
                  }
                  pw.println("end doc: " + prefix + entry.getName() + " (" + byteCount + " bytes read)");
               }
               else
               {
                  if (indent != null)
                  {
                     pw.print(indent);
                  }
                  pw.println("doc: " + prefix + entry.getName());
               }
            }
            else
            {
               pw.println("found unknown: " + prefix + entry.getName());
            }
      }
   }
View Full Code Here

        final InputStream in = request.getSourceInputStream();
        try {
            POIFSFileSystem reader = new POIFSFileSystem(in);
            DirectoryEntry root = reader.getRoot();
            for (Iterator<Entry> it = root.getEntries(); it.hasNext();) {
                Entry entry = it.next();
                String entryName = entry.getName().trim();
   
                boolean needsBinaryMatch = false;
   
                for (ContainerSignatureMatch match : matches.getContainerSignatureMatches()) {
                    match.matchFileEntry(entryName);
                    if (match.needsBinaryMatch(entryName)) {
                        needsBinaryMatch = true;
                    }
                }
               
                if (needsBinaryMatch) {
                    DocumentInputStream docIn = null;
                    ByteReader byteReader = null;
                    try {
                        docIn = reader.createDocumentInputStream(entry.getName());
                        byteReader = newByteReader(docIn);
                        for (ContainerSignatureMatch match : matches.getContainerSignatureMatches()) {
                            match.matchBinaryContent(entryName, byteReader);
                        }
                    } finally {
View Full Code Here

      DirectoryEntry newRoot = target.getRoot();

      Iterator entries = root.getEntries();
      
      while (entries.hasNext()) {
         Entry entry = (Entry)entries.next();
         if (!isInList(entry.getName(), excepts)) {
             copyNodeRecursively(entry,newRoot);
         }
      }
   }
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.