public IMAPBodySection()

in geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/main/java/org/apache/geronimo/mail/store/imap/connection/IMAPBodySection.java [78:138]


    public IMAPBodySection(IMAPResponseTokenizer source) throws MessagingException {
        
        // this could be just "BODY" alone.  
        if (!source.peek(false, true).isType('[')) {
            // complete body, all other fields take default  
            section = BODY;             
            return; 
        }
        
        // now we need to scan along this, building up the pieces as we go. 
        // NOTE:  The section identifiers use "[", "]", "." as delimiters, which 
        // are normally acceptable in ATOM names.  We need to use the expanded 
        // delimiter set to parse these tokens off. 
        Token token = source.next(false, true); 
        // the first token was the "[", now step to the next token in line. 
        token = source.next(false, true); 
        
        if (token.isType(Token.NUMERIC)) {
            token = parsePartNumber(token, source); 
        }
        
        // have a potential name here?
        if (token.isType(Token.ATOM)) {
            token = parseSectionName(token, source); 
        }
        
        // the HEADER.FIELD and HEADER.FIELD.NOT section types 
        // are followed by a list of header names. 
        if (token.isType('(')) {
            token = parseHeaderList(source); 
        }
        
        // ok, in theory, our current token should be a ']'
        if (!token.isType(']')) {
            throw new ResponseFormatException("Invalid section identifier on FETCH response"); 
        }
        
        // do we have a substring qualifier?
        // that needs to be stripped off too 
        parseSubstringValues(source); 
        
        // now fill in the type information 
        if (sectionName.equals("")) {
            section = BODY; 
        }
        else if (sectionName.equals("HEADER")) {
            section = HEADERS; 
        }
        else if (sectionName.equals("HEADER.FIELDS")) {
            section = HEADERSUBSET; 
        }
        else if (sectionName.equals("HEADER.FIELDS.NOT")) {
            section = HEADERSUBSET; 
        }
        else if (sectionName.equals("TEXT")) {
            section = TEXT; 
        }
        else if (sectionName.equals("MIME")) {
            section = MIME; 
        }
    }