001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.geronimo.javamail.store.imap.connection; 019 020 import java.io.ByteArrayInputStream; 021 022 import javax.mail.MessagingException; 023 import javax.mail.internet.InternetHeaders; 024 025 public class IMAPInternetHeader extends IMAPFetchBodyPart { 026 // the parsed headers 027 public InternetHeaders headers; 028 029 /** 030 * Construct a top-level HEADER data item. 031 * 032 * @param data The data for the InternetHeaders. 033 * 034 * @exception MessagingException 035 */ 036 public IMAPInternetHeader(byte[] data) throws MessagingException { 037 this(new IMAPBodySection(IMAPBodySection.HEADERS), data); 038 } 039 040 041 /** 042 * Construct a HEADER request data item. 043 * 044 * @param section The Section identifier information. 045 * @param data The raw data for the internet headers. 046 * 047 * @exception MessagingException 048 */ 049 public IMAPInternetHeader(IMAPBodySection section, byte[] data) throws MessagingException { 050 super(HEADER, section); 051 052 // and convert these into real headers 053 ByteArrayInputStream in = new ByteArrayInputStream(data); 054 headers = new InternetHeaders(in); 055 } 056 057 /** 058 * Test if this is a complete header fetch, or just a partial list fetch. 059 * 060 * @return 061 */ 062 public boolean isComplete() { 063 return section.section == IMAPBodySection.HEADERS; 064 } 065 } 066