• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * <p>Provides the highest level of abstraction for Decoders.
22  * This is the sister interface of {@link Encoder}.  All
23  * Decoders implement this common generic interface.</p>
24  *
25  * <p>Allows a user to pass a generic Object to any Decoder
26  * implementation in the codec package.</p>
27  *
28  * <p>One of the two interfaces at the center of the codec package.</p>
29  *
30  * @version $Id: Decoder.java 797690 2009-07-24 23:28:35Z ggregory $
31  */
32 public interface Decoder {
33 
34     /**
35      * Decodes an "encoded" Object and returns a "decoded"
36      * Object.  Note that the implementation of this
37      * interface will try to cast the Object parameter
38      * to the specific type expected by a particular Decoder
39      * implementation.  If a {@link ClassCastException} occurs
40      * this decode method will throw a DecoderException.
41      *
42      * @param pObject an object to "decode"
43      *
44      * @return a 'decoded" object
45      *
46      * @throws DecoderException a decoder exception can
47      * be thrown for any number of reasons.  Some good
48      * candidates are that the parameter passed to this
49      * method is null, a param cannot be cast to the
50      * appropriate type for a specific encoder.
51      */
decode(Object pObject)52     Object decode(Object pObject) throws DecoderException;
53 }
54 
55