1 | /**************************************************************** |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one * |
---|
3 | * or more contributor license agreements. See the NOTICE file * |
---|
4 | * distributed with this work for additional information * |
---|
5 | * regarding copyright ownership. The ASF licenses this file * |
---|
6 | * to you under the Apache License, Version 2.0 (the * |
---|
7 | * "License"); you may not use this file except in compliance * |
---|
8 | * with the License. You may obtain a copy of the License at * |
---|
9 | * * |
---|
10 | * http://www.apache.org/licenses/LICENSE-2.0 * |
---|
11 | * * |
---|
12 | * Unless required by applicable law or agreed to in writing, * |
---|
13 | * software distributed under the License is distributed on an * |
---|
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * |
---|
15 | * KIND, either express or implied. See the License for the * |
---|
16 | * specific language governing permissions and limitations * |
---|
17 | * under the License. * |
---|
18 | ****************************************************************/ |
---|
19 | |
---|
20 | package org.apache.james.mime4j.stream; |
---|
21 | |
---|
22 | |
---|
23 | import java.io.InputStream; |
---|
24 | |
---|
25 | /** |
---|
26 | * Raw MIME entity. Such entities will not be parsed into elements |
---|
27 | * by the parser. They are meant to be consumed as a raw data stream |
---|
28 | * by the caller. |
---|
29 | */ |
---|
30 | public class RawEntity implements EntityStateMachine { |
---|
31 | |
---|
32 | private final InputStream stream; |
---|
33 | |
---|
34 | private EntityState state; |
---|
35 | |
---|
36 | RawEntity(InputStream stream) { |
---|
37 | this.stream = stream; |
---|
38 | this.state = EntityState.T_RAW_ENTITY; |
---|
39 | } |
---|
40 | |
---|
41 | public EntityState getState() { |
---|
42 | return state; |
---|
43 | } |
---|
44 | |
---|
45 | /** |
---|
46 | * This method has no effect. |
---|
47 | */ |
---|
48 | public void setRecursionMode(RecursionMode recursionMode) { |
---|
49 | } |
---|
50 | |
---|
51 | public EntityStateMachine advance() { |
---|
52 | state = EntityState.T_END_OF_STREAM; |
---|
53 | return null; |
---|
54 | } |
---|
55 | |
---|
56 | /** |
---|
57 | * Returns raw data stream. |
---|
58 | */ |
---|
59 | public InputStream getContentStream() { |
---|
60 | return stream; |
---|
61 | } |
---|
62 | |
---|
63 | /** |
---|
64 | * This method has no effect and always returns <code>null</code>. |
---|
65 | */ |
---|
66 | public BodyDescriptor getBodyDescriptor() { |
---|
67 | return null; |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | * This method has no effect and always returns <code>null</code>. |
---|
72 | */ |
---|
73 | public RawField getField() { |
---|
74 | return null; |
---|
75 | } |
---|
76 | |
---|
77 | /** |
---|
78 | * This method has no effect and always returns <code>null</code>. |
---|
79 | */ |
---|
80 | public String getFieldName() { |
---|
81 | return null; |
---|
82 | } |
---|
83 | |
---|
84 | /** |
---|
85 | * This method has no effect and always returns <code>null</code>. |
---|
86 | */ |
---|
87 | public String getFieldValue() { |
---|
88 | return null; |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | * @see org.apache.james.mime4j.stream.EntityStateMachine#getDecodedContentStream() |
---|
93 | */ |
---|
94 | public InputStream getDecodedContentStream() throws IllegalStateException { |
---|
95 | throw new IllegalStateException("Raw entity does not support stream decoding"); |
---|
96 | } |
---|
97 | |
---|
98 | } |
---|