001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.commons.codec;
019
020 /**
021 * <p>Provides the highest level of abstraction for Decoders.
022 * This is the sister interface of {@link Encoder}. All
023 * Decoders implement this common generic interface.</p>
024 *
025 * <p>Allows a user to pass a generic Object to any Decoder
026 * implementation in the codec package.</p>
027 *
028 * <p>One of the two interfaces at the center of the codec package.</p>
029 *
030 * @author Apache Software Foundation
031 * @version $Id: Decoder.java 797690 2009-07-24 23:28:35Z ggregory $
032 */
033 public interface Decoder {
034
035 /**
036 * Decodes an "encoded" Object and returns a "decoded"
037 * Object. Note that the implementation of this
038 * interface will try to cast the Object parameter
039 * to the specific type expected by a particular Decoder
040 * implementation. If a {@link ClassCastException} occurs
041 * this decode method will throw a DecoderException.
042 *
043 * @param pObject an object to "decode"
044 *
045 * @return a 'decoded" object
046 *
047 * @throws DecoderException a decoder exception can
048 * be thrown for any number of reasons. Some good
049 * candidates are that the parameter passed to this
050 * method is null, a param cannot be cast to the
051 * appropriate type for a specific encoder.
052 */
053 Object decode(Object pObject) throws DecoderException;
054 }
055