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