Home | History | Annotate | Download | only in codec
      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  * @author Apache Software Foundation
     31  * @version $Id: Decoder.java 797690 2009-07-24 23:28:35Z ggregory $
     32  */
     33 public interface Decoder {
     34 
     35     /**
     36      * Decodes an "encoded" Object and returns a "decoded"
     37      * Object.  Note that the implementation of this
     38      * interface will try to cast the Object parameter
     39      * to the specific type expected by a particular Decoder
     40      * implementation.  If a {@link ClassCastException} occurs
     41      * this decode method will throw a DecoderException.
     42      *
     43      * @param pObject an object to "decode"
     44      *
     45      * @return a 'decoded" object
     46      *
     47      * @throws DecoderException a decoder exception can
     48      * be thrown for any number of reasons.  Some good
     49      * candidates are that the parameter passed to this
     50      * method is null, a param cannot be cast to the
     51      * appropriate type for a specific encoder.
     52      */
     53     Object decode(Object pObject) throws DecoderException;
     54 }
     55 
     56