1 /*******************************************************************************
2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 *******************************************************************************/
18 package jalview.ws.io.mime;
20 import jalview.io.packed.DataProvider;
21 import jalview.io.packed.JalviewDataset;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.util.ArrayList;
26 import java.util.List;
28 import org.apache.james.mime4j.MimeException;
29 import org.apache.james.mime4j.descriptor.BodyDescriptor;
30 import org.apache.james.mime4j.parser.ContentHandler;
31 import org.apache.james.mime4j.parser.Field;
34 * ContentHandler for parsing mime encoded messages into Jalview objects.
35 * TODO: complete implementation
36 * TODO: test implementation
37 * TODO: hook in to Jalview IO and service response parser.
41 public class JalviewMimeContentHandler implements ContentHandler
44 * context for data parsed from multi-part mime document
46 JalviewDataset context;
49 * create a new handler to process a Jalview mime message.
52 public JalviewMimeContentHandler(JalviewDataset ds)
57 * type of data pack being parsed currently
61 * name of data pack being parsed currently
66 * sources for data to be parsed
68 List<DataProvider> dataItems = new ArrayList<DataProvider>();
71 public void body(BodyDescriptor arg0, InputStream arg1)
72 throws MimeException, IOException
75 // TODO Auto-generated method stub
80 public void endBodyPart() throws MimeException
82 // TODO Auto-generated method stub
87 public void endHeader() throws MimeException
89 // TODO Auto-generated method stub
94 public void endMessage() throws MimeException
96 // TODO Auto-generated method stub
101 public void endMultipart() throws MimeException
103 // TODO Auto-generated method stub
108 public void epilogue(InputStream arg0) throws MimeException, IOException
110 // TODO Auto-generated method stub
115 public void field(Field arg0) throws MimeException
117 // TODO Auto-generated method stub
122 public void preamble(InputStream arg0) throws MimeException, IOException
124 // TODO Auto-generated method stub
129 public void raw(InputStream arg0) throws MimeException, IOException
131 // TODO Auto-generated method stub
136 public void startBodyPart() throws MimeException
138 // TODO Auto-generated method stub
143 public void startHeader() throws MimeException
145 // TODO Auto-generated method stub
150 public void startMessage() throws MimeException
152 // TODO Auto-generated method stub
157 public void startMultipart(BodyDescriptor arg0) throws MimeException
159 // TODO Auto-generated method stub
165 * @return data providers to parse each data file extracted from the mime stream.
167 public Iterable<DataProvider> getJalviewDataProviders()
169 // TODO Auto-generated method stub