001    /****************************************************************
002     * Licensed to the Apache Software Foundation (ASF) under one   *
003     * or more contributor license agreements.  See the NOTICE file *
004     * distributed with this work for additional information        *
005     * regarding copyright ownership.  The ASF licenses this file   *
006     * to you under the Apache License, Version 2.0 (the            *
007     * "License"); you may not use this file except in compliance   *
008     * with the License.  You may obtain a copy of the License at   *
009     *                                                              *
010     *   http://www.apache.org/licenses/LICENSE-2.0                 *
011     *                                                              *
012     * Unless required by applicable law or agreed to in writing,   *
013     * software distributed under the License is distributed on an  *
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
015     * KIND, either express or implied.  See the License for the    *
016     * specific language governing permissions and limitations      *
017     * under the License.                                           *
018     ****************************************************************/
019    
020    package org.apache.james.mime4j.parser;
021    
022    import org.apache.james.mime4j.descriptor.BodyDescriptor;
023    
024    import java.io.InputStream;
025    
026    /**
027     * Raw MIME entity. Such entities will not be parsed into elements 
028     * by the parser. They are meant to be consumed as a raw data stream
029     * by the caller.  
030     */
031    public class RawEntity implements EntityStateMachine {
032    
033        private final InputStream stream;
034    
035        private int state;
036        
037        RawEntity(InputStream stream) {
038            this.stream = stream;
039            this.state = EntityStates.T_RAW_ENTITY;
040        }
041        
042        public int getState() {
043            return state;
044        }
045    
046        /**
047         * This method has no effect.
048         */
049        public void setRecursionMode(int recursionMode) {
050        }
051    
052        public EntityStateMachine advance() {
053            state = EntityStates.T_END_OF_STREAM;
054            return null;
055        }
056        
057        /**
058         * Returns raw data stream.
059         */
060        public InputStream getContentStream() {
061            return stream;
062        }
063    
064        /**
065         * This method has no effect and always returns <code>null</code>.
066         */
067        public BodyDescriptor getBodyDescriptor() {
068            return null;
069        }
070    
071        /**
072         * This method has no effect and always returns <code>null</code>.
073         */
074        public Field getField() {
075            return null;
076        }
077    
078        /**
079         * This method has no effect and always returns <code>null</code>.
080         */
081        public String getFieldName() {
082            return null;
083        }
084    
085        /**
086         * This method has no effect and always returns <code>null</code>.
087         */
088        public String getFieldValue() {
089            return null;
090        }
091        
092    }