1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.commons.codec;
19
20 /**
21 * Provides the highest level of abstraction for Decoders.
22 * <p>
23 * This is the sister interface of {@link Encoder}. All Decoders implement this common generic interface.
24 * Allows a user to pass a generic Object to any Decoder implementation in the codec package.
25 * <p>
26 * One of the two interfaces at the center of the codec package.
27 *
28 * @version $Id: Decoder.html 891688 2013-12-24 20:49:46Z ggregory $
29 */
30 public interface Decoder {
31
32 /**
33 * Decodes an "encoded" Object and returns a "decoded" Object. Note that the implementation of this interface will
34 * try to cast the Object parameter to the specific type expected by a particular Decoder implementation. If a
35 * {@link ClassCastException} occurs this decode method will throw a DecoderException.
36 *
37 * @param source
38 * the object to decode
39 * @return a 'decoded" object
40 * @throws DecoderException
41 * a decoder exception can be thrown for any number of reasons. Some good candidates are that the
42 * parameter passed to this method is null, a param cannot be cast to the appropriate type for a
43 * specific encoder.
44 */
45 Object decode(Object source) throws DecoderException;
46 }
47