14fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy/****************************************************************
24fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * Licensed to the Apache Software Foundation (ASF) under one   *
34fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * or more contributor license agreements.  See the NOTICE file *
44fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * distributed with this work for additional information        *
54fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * regarding copyright ownership.  The ASF licenses this file   *
64fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * to you under the Apache License, Version 2.0 (the            *
74fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * "License"); you may not use this file except in compliance   *
84fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * with the License.  You may obtain a copy of the License at   *
94fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy *                                                              *
104fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy *   http://www.apache.org/licenses/LICENSE-2.0                 *
114fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy *                                                              *
124fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * Unless required by applicable law or agreed to in writing,   *
134fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * software distributed under the License is distributed on an  *
144fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
154fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * KIND, either express or implied.  See the License for the    *
164fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * specific language governing permissions and limitations      *
174fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy * under the License.                                           *
184fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy ****************************************************************/
194fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy
204fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedypackage org.apache.james.mime4j.field;
214fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy
224fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy//BEGIN android-changed: Stubbing out logging
234fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedyimport org.apache.james.mime4j.Log;
244fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedyimport org.apache.james.mime4j.LogFactory;
254fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy//END android-changed
264fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedyimport org.apache.james.mime4j.field.address.AddressList;
274fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedyimport org.apache.james.mime4j.field.address.parser.ParseException;
284fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy
294fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedypublic class AddressListField extends Field {
304fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy    private AddressList addressList;
314fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy    private ParseException parseException;
324fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy
334fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy    protected AddressListField(String name, String body, String raw, AddressList addressList, ParseException parseException) {
344fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy        super(name, body, raw);
354fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy        this.addressList = addressList;
364fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy        this.parseException = parseException;
374fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy    }
384fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy
394fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy    public AddressList getAddressList() {
404fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy        return addressList;
414fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy    }
424fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy
434fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy    public ParseException getParseException() {
444fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy        return parseException;
454fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy    }
464fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy
474fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy    public static class Parser implements FieldParser {
484fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy        private static Log log = LogFactory.getLog(Parser.class);
494fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy
504fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy        public Field parse(final String name, final String body, final String raw) {
514fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy            AddressList addressList = null;
524fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy            ParseException parseException = null;
534fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy            try {
544fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy                addressList = AddressList.parse(body);
554fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy            }
564fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy            catch (ParseException e) {
574fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy                if (log.isDebugEnabled()) {
584fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy                    log.debug("Parsing value '" + body + "': "+ e.getMessage());
594fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy                }
604fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy                parseException = e;
614fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy            }
624fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy            return new AddressListField(name, body, raw, addressList, parseException);
634fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy        }
644fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy    }
654fa0a3295bcacbdcd6a9e7709cf17aa5adb90356Scott Kennedy}
66