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