Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* ====================================================================
     Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed with
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License, Version 2.0
     (the "License"); you may not use this file except in compliance with
     the License.  You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
 
 package org.apache.poi.hmef;
 
 import java.util.Date;
 import java.util.List;
 
An attachment within a HMEFMessage. Provides both helper methods to get at common parts and attributes of the attachment, and list methods to get all of them.
 
 public final class Attachment {
    private final List<TNEFAttributeattributes = new ArrayList<TNEFAttribute>();
    private final List<MAPIAttributemapiAttributes = new ArrayList<MAPIAttribute>();
    
    protected void addAttribute(TNEFAttribute attr) {
       .add(attr);
       
       if(attr instanceof TNEFMAPIAttribute) {
          TNEFMAPIAttribute tnefMAPI = (TNEFMAPIAttribute)attr;
          .addAlltnefMAPI.getMAPIAttributes() );
       }
    }
   
   
Return the attachment attribute with the given ID, or null if there isn't one.
 
    public TNEFAttribute getAttribute(TNEFProperty id) {
       for(TNEFAttribute attr : ) {
          if(attr.getProperty() == id) {
             return attr;
          }
       }
       return null;
    }
   
   
Return the attachment MAPI Attribute with the given ID, or null if there isn't one.
 
       for(MAPIAttribute attr : ) {
          if(attr.getProperty() == id) {
             return attr;
          }
       }
       return null;
    }
   
   
Returns all HMEF/TNEF attributes of the attachment, such as filename, icon and contents
 
    public List<TNEFAttributegetAttributes() {
       return ;
    }
   
   
Returns all MAPI attributes of the attachment, such as extension, encoding, size and position
 
    public List<MAPIAttributegetMAPIAttributes() {
       return ;
    }
   
   
   
Return the string value of the mapi property, or null if it isn't set
 
    private String getString(MAPIProperty id) {
      return MAPIStringAttribute.getAsStringgetMAPIAttribute(id) );
   }
   
Returns the string value of the TNEF property, or null if it isn't set
   private String getString(TNEFProperty id) {
      return TNEFStringAttribute.getAsStringgetAttribute(id) );
   }
   
   
Returns the short filename
   public String getFilename() {
   }
   
Returns the long filename
   public String getLongFilename() {
   }
   
Returns the file extension
   public String getExtension() {
   }
   
   
Return when the file was last modified, if known.
   public Date getModifiedDate() {
      return TNEFDateAttribute.getAsDate(
      );
   }
   
   
Returns the contents of the attachment.
   public byte[] getContents() {
      if(contents == null) {
         throw new IllegalArgumentException("Attachment corrupt - no Data section");
      }
      return contents.getData();
   }
   
   
Returns the Meta File rendered representation of the attachment, or null if not set.
   public byte[] getRenderedMetaFile() {
      if(meta == nullreturn null;
      return meta.getData();
   }
New to GrepCode? Check out our FAQ X