Package org.apache.poi.poifs.filesystem

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


  /**
   * @param path  the path to the part, eg Contents or Quill, QuillSub, CONTENTS
   */
  public HPBFPart(DirectoryNode baseDir, String[] path) throws IOException {

    DirectoryNode dir = getDir(path, baseDir);
    String name = path[path.length-1];

    DocumentEntry docProps;
    try {
      docProps = (DocumentEntry)dir.getEntry(name);
    } catch (FileNotFoundException e) {
      throw new IllegalArgumentException("File invalid - failed to find document entry '"
          + name + "'");
    }

    // Grab the data from the part stream
    data = new byte[docProps.getSize()];
    dir.createDocumentInputStream(name).read(data);
  }
View Full Code Here


    // Grab the data from the part stream
    data = new byte[docProps.getSize()];
    dir.createDocumentInputStream(name).read(data);
  }
  private DirectoryNode getDir(String[] path, DirectoryNode baseDir) {
    DirectoryNode dir = baseDir;
    for(int i=0; i<path.length-1; i++) {
      try {
        dir = (DirectoryNode)dir.getEntry(path[i]);
      } catch (FileNotFoundException e) {
        throw new IllegalArgumentException("File invalid - failed to find directory entry '"
            + path[i] + "'");
      }
    }
View Full Code Here

  public void writeOut(DirectoryNode baseDir) throws IOException {
    String[] path = getPath();

    // Ensure that all parent directories exist
    DirectoryNode dir = baseDir;
    for(int i=0; i<path.length-1; i++) {
      try {
        dir = (DirectoryNode)dir.getEntry(path[i]);
      } catch(FileNotFoundException e) {
        dir.createDirectory(path[i]);
      }
    }

    // Update the byte array with the latest data
    generateData();

    // Write out
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    dir.createDocument(path[path.length-1], bais);
  }
View Full Code Here

      // Find our top level children
      // Note - we don't handle children of children yet, as
      //  there doesn't seem to be any use of that in Outlook
      for(Entry entry : node) {
         if(entry instanceof DirectoryNode) {
            DirectoryNode dir = (DirectoryNode)entry;
            ChunkGroup group = null;
           
            // Do we know what to do with it?
            if(dir.getName().startsWith(AttachmentChunks.PREFIX)) {
               group = new AttachmentChunks(dir.getName());
            }
            if(dir.getName().startsWith(NameIdChunks.NAME)) {
               group = new NameIdChunks();
            }
            if(dir.getName().startsWith(RecipientChunks.PREFIX)) {
               group = new RecipientChunks(dir.getName());
            }
           
            if(group != null) {
               processChunks(dir, group);
               groups.add(group);
View Full Code Here

  /**
   * Dump out the escher parts of the file.
   * Escher -> EscherStm and EscherDelayStm
   */
  public void dumpEscher() throws IOException {
    DirectoryNode escherDir = (DirectoryNode)
      fs.getRoot().getEntry("Escher");

    dumpEscherStm(escherDir);
    dumpEscherDelayStm(escherDir);
  }
View Full Code Here

  protected void dump001CompObj(DirectoryNode dir) {
    // TODO
  }

  public void dumpQuill() throws IOException {
    DirectoryNode quillDir = (DirectoryNode)
      fs.getRoot().getEntry("Quill");
    DirectoryNode quillSubDir = (DirectoryNode)
      quillDir.getEntry("QuillSub");

    dump001CompObj(quillSubDir);
    dumpCONTENTSraw(quillSubDir);
    dumpCONTENTSguessed(quillSubDir);
View Full Code Here

      // Find our top level children
      // Note - we don't handle children of children yet, as
      //  there doesn't seem to be any use of that in Outlook
      for(Entry entry : node) {
         if(entry instanceof DirectoryNode) {
            DirectoryNode dir = (DirectoryNode)entry;
            ChunkGroup group = null;
           
            // Do we know what to do with it?
            if(dir.getName().startsWith(AttachmentChunks.PREFIX)) {
               group = new AttachmentChunks(dir.getName());
            }
            if(dir.getName().startsWith(NameIdChunks.PREFIX)) {
               group = new NameIdChunks();
            }
            if(dir.getName().startsWith(RecipientChunks.PREFIX)) {
               group = new RecipientChunks(dir.getName());
            }
           
            if(group != null) {
               processChunks(dir, group);
               groups.add(group);
View Full Code Here

      POIFSFileSystem fs = new POIFSFileSystem(
          new FileInputStream(filename3)
      );
      HSLFSlideShow ss;
     
      DirectoryNode dirA = (DirectoryNode)
        fs.getRoot().getEntry("MBD0000A3B6");
    DirectoryNode dirB = (DirectoryNode)
      fs.getRoot().getEntry("MBD0000A3B3");
   
    assertNotNull(dirA.getEntry("PowerPoint Document"));
    assertNotNull(dirB.getEntry("PowerPoint Document"));
     
    // Check the first file
      ss = new HSLFSlideShow(dirA, fs);
    ppe = new PowerPointExtractor(ss);
    assertEquals("Sample PowerPoint file\nThis is the 1st file\nNot much too it\n",
View Full Code Here

      POIFSFileSystem fs = new POIFSFileSystem(
          new FileInputStream(filename3)
      );
      HSLFSlideShow ss;
     
      DirectoryNode dirA = (DirectoryNode)
        fs.getRoot().getEntry("MBD0000A3B6");
    DirectoryNode dirB = (DirectoryNode)
      fs.getRoot().getEntry("MBD0000A3B3");
   
    assertNotNull(dirA.getEntry("PowerPoint Document"));
    assertNotNull(dirB.getEntry("PowerPoint Document"));
     
    // Check the first file
      ss = new HSLFSlideShow(dirA, fs);
    ppe = new PowerPointExtractor(ss);
    assertEquals("Sample PowerPoint file\nThis is the 1st file\nNot much too it\n",
View Full Code Here

    String filename = pdirname + "/word_with_embeded.doc";
    POIFSFileSystem fs = new POIFSFileSystem(
        new FileInputStream(filename)
    );
   
    DirectoryNode objPool = (DirectoryNode) fs.getRoot().getEntry("ObjectPool");
    DirectoryNode dirA = (DirectoryNode) objPool.getEntry("_1269427460");
    DirectoryNode dirB = (DirectoryNode) objPool.getEntry("_1269427461");

    HSSFWorkbook wbA = new HSSFWorkbook(dirA, fs, true);
    HSSFWorkbook wbB = new HSSFWorkbook(dirB, fs, true);
   
    ExcelExtractor exA = new ExcelExtractor(wbA);
View Full Code Here

TOP

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

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.