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    public class IMAPFetchBodyPart extends IMAPFetchDataItem {
021        // the parse body section information. 
022        protected IMAPBodySection section; 
023    
024        /**
025         * Construct a base BODY section subpiece.
026         * 
027         * @param type    The fundamental type of the body section.  This will be either BODY, TEXT,
028         *                or HEADER, depending on the subclass.
029         * @param section The section information.  This will contain the section numbering information,
030         *                the section name, and and substring information if this was a partial fetch
031         *                request.
032         */
033        public IMAPFetchBodyPart(int type, IMAPBodySection section) {
034            super(type); 
035            this.section = section; 
036        }
037        
038        /**
039         * Get the part number information associated with this request.
040         * 
041         * @return The string form of the part number. 
042         */
043        public String getPartNumber() {
044            return section.partNumber;
045        }
046        
047        /**
048         * Get the section type information.  This is the qualifier that appears
049         * within the "[]" of the body sections.
050         * 
051         * @return The numeric identifier for the type from the IMAPBodySection.
052         */
053        public int getSectionType() {
054            return section.section; 
055        }
056        
057        /**
058         * Get the substring start location.  
059         * 
060         * @return The start location for the substring.  Returns -1 if this is not a partial 
061         *         fetch.
062         */
063        public int getSubstringStart() {
064            return section.start; 
065        }
066        
067        /**
068         * Returns the length of the substring section.  
069         * 
070         * @return The length of the substring section.  Returns -1 if this was not a partial 
071         *         fetch.
072         */
073        public int getSubstringLength() {
074            return section.length; 
075        }
076    }