Package org.apache.poi.hsmf.datatypes

Examples of org.apache.poi.hsmf.datatypes.Chunk


   * Gets a string value based on the passed chunk.
   * @param chunk
   * @throws ChunkNotFoundException
   */
  public String getStringFromChunk(StringChunk chunk) throws ChunkNotFoundException {
    Chunk out = this.chunkParser.getDocumentNode(chunk);
    StringChunk strchunk = (StringChunk)out;
    return strchunk.toString();
  }
View Full Code Here


    }
    for (Iterator iterator = attachmentList.iterator(); iterator.hasNext();) {
      HashMap AttachmentChunkMap = (HashMap) iterator.next();
      AttachmentChunks attachmentChunks = this.identifyAttachmentChunks(AttachmentChunkMap);
      try {
        Chunk fileName = this.getDocumentNode(AttachmentChunkMap, attachmentChunks.attachLongFileName);
        Chunk content = this.getDocumentNode(AttachmentChunkMap, attachmentChunks.attachData);
        attachments.put(fileName.toString(), new ByteArrayInputStream(content.getValueByteArray().toByteArray()));
      } catch (ChunkNotFoundException e) {
        System.err.println("Invalid attachment chunk");
      }
    }
    return attachments;
View Full Code Here

      // Now try to turn it into id + type
      try {
         int chunkId = Integer.parseInt(ids.substring(0, 4), 16);
         int type    = Integer.parseInt(ids.substring(4, 8), 16);
        
         Chunk chunk = null;
        
         // Special cases based on the ID
         if(chunkId == MAPIProperty.MESSAGE_SUBMISSION_ID.id) {
            chunk = new MessageSubmissionChunk(namePrefix, chunkId, type);
         }
         else {
            // Nothing special about this ID
            // So, do the usual thing which is by type
            switch(type) {
            case Types.BINARY:
               chunk = new ByteChunk(namePrefix, chunkId, type);
               break;
            case Types.DIRECTORY:
               if(entry instanceof DirectoryNode) {
                   chunk = new DirectoryChunk((DirectoryNode)entry, namePrefix, chunkId, type);
               }
               break;
            case Types.ASCII_STRING:
            case Types.UNICODE_STRING:
               chunk = new StringChunk(namePrefix, chunkId, type);
               break;
            }
         }
        
         if(chunk != null) {
             if(entry instanceof DocumentNode) {
                try {
                   DocumentInputStream inp = new DocumentInputStream((DocumentNode)entry);
                   chunk.readValue(inp);
                   grouping.record(chunk);
                } catch(IOException e) {
                   System.err.println("Error reading from part " + entry.getName() + " - " + e.toString());
                }
             } else {
View Full Code Here

               header(xhtml, "Recipients", msg.getRecipientEmailAddress());
           } catch(ChunkNotFoundException e) {}
           xhtml.endElement("dl");
  
           // Get the message body. Preference order is: html, rtf, text
           Chunk htmlChunk = null;
           Chunk rtfChunk = null;
           Chunk textChunk = null;
           for(Chunk chunk : msg.getMainChunks().getAll()) {
              if(chunk.getChunkId() == MAPIProperty.BODY_HTML.id) {
                 htmlChunk = chunk;
              }
              if(chunk.getChunkId() == MAPIProperty.RTF_COMPRESSED.id) {
View Full Code Here

   * @param chunk
   * @return
   * @throws ChunkNotFoundException
   */
  public String getStringFromChunk(StringChunk chunk) throws ChunkNotFoundException {
    Chunk out = this.chunkParser.getDocumentNode(chunk);
    StringChunk strchunk = (StringChunk)out;
    return strchunk.toString();
  }
View Full Code Here

    StringChunk chunk = new StringChunk(0x0E02);
    TestCase.assertEquals(chunk.getEntryName(), Chunks.getInstance().displayBCCChunk.getEntryName());
  }
 
  public void testSubjectChunk() {
    Chunk chunk = new StringChunk(0x0037);
    TestCase.assertEquals(chunk.getEntryName(), Chunks.getInstance().subjectChunk.getEntryName());
  }
View Full Code Here

   /**
    * Creates a chunk, and gives it to its parent group
    */
   protected static void process(Entry entry, ChunkGroup grouping) {
      String entryName = entry.getName();
      Chunk chunk = null;
     
      // Is it a properties chunk? (They have special names)
      if (entryName.equals(PropertiesChunk.NAME)) {
         if (grouping instanceof Chunks) {
            // These should be the properties for the message itself
            chunk = new MessagePropertiesChunk(grouping);
         } else {
            // Will be properties on an attachment or recipient
            chunk = new StoragePropertiesChunk(grouping);
         }
      } else {
         // Check it's a regular chunk
         if(entryName.length() < 9) {
            // Name in the wrong format
            return;
         }
         if(entryName.indexOf('_') == -1) {
            // Name in the wrong format
            return;
         }
        
         // Split it into its parts
         int splitAt = entryName.lastIndexOf('_');
         String namePrefix = entryName.substring(0, splitAt+1);
         String ids = entryName.substring(splitAt+1);
        
         // Make sure we got what we expected, should be of
         //  the form __<name>_<id><type>
         if(namePrefix.equals("Olk10SideProps") ||
            namePrefix.equals("Olk10SideProps_")) {
            // This is some odd Outlook 2002 thing, skip
            return;
         } else if(splitAt <= entryName.length()-8) {
            // In the right form for a normal chunk
            // We'll process this further in a little bit
         } else {
            // Underscores not the right place, something's wrong
            throw new IllegalArgumentException("Invalid chunk name " + entryName);
         }
        
         // Now try to turn it into id + type
         try {
            int chunkId = Integer.parseInt(ids.substring(0, 4), 16);
            int typeId  = Integer.parseInt(ids.substring(4, 8), 16);
           
            MAPIType type = Types.getById(typeId);
            if (type == null) {
               type = Types.createCustom(typeId);
            }
           
            // Special cases based on the ID
            if(chunkId == MAPIProperty.MESSAGE_SUBMISSION_ID.id) {
               chunk = new MessageSubmissionChunk(namePrefix, chunkId, type);
            }
            else {
               // Nothing special about this ID
               // So, do the usual thing which is by type
               if (type == Types.BINARY) {
                  chunk = new ByteChunk(namePrefix, chunkId, type);
               }
               else if (type == Types.DIRECTORY) {
                  if(entry instanceof DirectoryNode) {
                      chunk = new DirectoryChunk((DirectoryNode)entry, namePrefix, chunkId, type);
                  }
               }
               else if (type == Types.ASCII_STRING ||
                        type == Types.UNICODE_STRING) {
                  chunk = new StringChunk(namePrefix, chunkId, type);
               }
               else {
                  // Type of an unsupported type! Skipping...
               }
            }
         } catch(NumberFormatException e) {
            // Name in the wrong format
            return;
         }
      }
        
      if(chunk != null) {
          if(entry instanceof DocumentNode) {
             try {
                DocumentInputStream inp = new DocumentInputStream((DocumentNode)entry);
                chunk.readValue(inp);
                grouping.record(chunk);
             } catch(IOException e) {
               logger.log(POILogger.ERROR, "Error reading from part " + entry.getName() + " - " + e.toString());
             }
          } else {
View Full Code Here

   * Gets a string value based on the passed chunk.
   * @param chunk
   * @throws ChunkNotFoundException
   */
  public String getStringFromChunk(StringChunk chunk) throws ChunkNotFoundException {
    Chunk out = this.chunkParser.getDocumentNode(chunk);
    StringChunk strchunk = (StringChunk)out;
    return strchunk.toString();
  }
View Full Code Here

    StringChunk chunk = new StringChunk(0x0E02, false);
    TestCase.assertEquals(chunk.getEntryName(), chunks.displayBCCChunk.getEntryName());
  }

  public void testSubjectChunk() {
    Chunk chunk = new StringChunk(0x0037, false);
    TestCase.assertEquals(chunk.getEntryName(), chunks.subjectChunk.getEntryName());
  }
View Full Code Here

   * Gets a string value based on the passed chunk.
   * @param chunk
   * @throws ChunkNotFoundException
   */
  public String getStringFromChunk(StringChunk chunk) throws ChunkNotFoundException {
    Chunk out = this.chunkParser.getDocumentNode(chunk);
    StringChunk strchunk = (StringChunk)out;
    return strchunk.toString();
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.hsmf.datatypes.Chunk

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.