CodecOperations.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* CodecOperations.java --
  2. Copyright (C) 2005, 2006 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package org.omg.IOP;
  32. import org.omg.CORBA.Any;
  33. import org.omg.CORBA.TypeCode;
  34. import org.omg.IOP.CodecPackage.FormatMismatch;
  35. import org.omg.IOP.CodecPackage.InvalidTypeForEncoding;
  36. import org.omg.IOP.CodecPackage.TypeMismatch;
  37. /**
  38. * Defines the operations, applicable to
  39. * the Codec.
  40. *
  41. * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
  42. */
  43. public interface CodecOperations
  44. {
  45. /**
  46. * Encode the value, stored inside the given {@link Any}, into array of
  47. * bytes. The returned byte array contains the data structure typecode,
  48. * followed by the data structure itself.
  49. *
  50. * @param that the {@link Any}, containing the data structure, required to
  51. * encode.
  52. *
  53. * @return the array of bytes, containing the encoded data structure.
  54. *
  55. * @throws InvalidTypeForEncoding if the data structure is not supported
  56. * by this {@link Codec} (wide char and wide string are not supported
  57. * by ENCODING_CDR_ENCAPS v 1.0).
  58. *
  59. * @see #decode(byte[])
  60. */
  61. byte[] encode(Any that)
  62. throws InvalidTypeForEncoding;
  63. /**
  64. * Decode the given array of bytes and return the decoded value, inserted
  65. * into {@link Any}. This methods expects that the byte array contains
  66. * the CDR-encoded data structure {@link TypeCode}, followed by the data
  67. * structure itself.
  68. *
  69. * @param them an array of bytes to decode.
  70. * @return the {@link Any}, containing the decoded structure. The structure
  71. * can be extracted from the Any with the appropriate helper.
  72. *
  73. * @throws FormatMismatch on the invalid structure of the byte array.
  74. *
  75. * @see #encode(Any)
  76. */
  77. Any decode(byte[] them)
  78. throws FormatMismatch;
  79. /**
  80. * Encode the value (without the typecode), stored in the passed {@link Any},
  81. * into the given byte array.
  82. *
  83. * @param that_value the {@link Any}, holding the value to encode.
  84. * @return the array, containing the encoded value alone (no preceeding
  85. * typecode).
  86. *
  87. * @see #decode_value(byte[], TypeCode)
  88. */
  89. byte[] encode_value(Any that_value)
  90. throws InvalidTypeForEncoding;
  91. /**
  92. * Decode the given array of bytes, supposing that they contain the
  93. * given data structure, and return the decoded value.
  94. *
  95. * @param them the array of bytes to decode. Should contain the data type,
  96. * matching the structure, defined in the <code>type</code> parameter.
  97. * Does not contain the typecode itself.
  98. *
  99. * @param type the typecode of the data structure, stored in the byte
  100. * array.
  101. *
  102. * @return the {@link Any}, containing the decoded structure. The
  103. * structure can be extracted from the Any with the appropriate helper.
  104. *
  105. * @throws FormatMismatch on the invalid structure of the byte array.
  106. * @throws TypeMismatch if discovered that the the byte array defines a
  107. * different structure.
  108. *
  109. * @see #encode_value(Any)
  110. */
  111. Any decode_value(byte[] them, TypeCode type)
  112. throws FormatMismatch, TypeMismatch;
  113. }