Source for javax.rmi.CORBA.ValueHandler

   1: /* ValueHandler.java --
   2:    Copyright (C) 2002, 2004, 2005 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 javax.rmi.CORBA;
  40: 
  41: import java.io.Serializable;
  42: 
  43: import org.omg.CORBA.CustomMarshal;
  44: import org.omg.CORBA.portable.InputStream;
  45: import org.omg.CORBA.portable.OutputStream;
  46: import org.omg.CORBA.portable.Streamable;
  47: import org.omg.SendingContext.RunTime;
  48: 
  49: /**
  50:  * Serializes Java objects to and from CDR (GIOP) streams. The working instance
  51:  * of the value handler is returned by {@link Util#createValueHandler} and can
  52:  * be altered by setting the system property "javax.rmi.CORBA.ValueHandlerClass"
  53:  * to the name of the alternative class that must implement ValueHandler.
  54:  *
  55:  * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
  56:  */
  57: public interface ValueHandler
  58: {
  59:   /**
  60:    * Get CORBA repository Id for the given java class.
  61:    *
  62:    * The syntax of the repository ID is the initial ?RMI:?, followed by the Java
  63:    * class name, followed by name, followed by a hash code string, followed
  64:    * optionally by a serialization version UID string.
  65:    *
  66:    * For Java identifiers that contain illegal OMG IDL identifier characters
  67:    * such as ?$?, any such illegal characters are replaced by ?\U? followed by
  68:    * the 4 hexadecimal characters (in upper case) representing the Unicode
  69:    * value.
  70:    *
  71:    * @param clz a class for that the repository Id is required.
  72:    *
  73:    * @return the class repository id.
  74:    */
  75:   String getRMIRepositoryID(Class clz);
  76: 
  77:   /**
  78:    * Returns the CodeBase for this ValueHandler.
  79:    *
  80:    * @return the codebase.
  81:    */
  82:   RunTime getRunTimeCodeBase();
  83: 
  84:   /**
  85:    * Indicates that the given class is responsible itself for writing its
  86:    * content to the stream. Such classes implement either {@link Streamable}
  87:    * (default marshalling, generated by IDL-to-java compiler) or
  88:    * {@link CustomMarshal} (the user-programmed marshalling).
  89:    *
  90:    * @param clz the class being checked.
  91:    * @return true if the class supports custom or default marshalling, false
  92:    * otherwise.
  93:    */
  94:   boolean isCustomMarshaled(Class clz);
  95: 
  96:   /**
  97:    * Read value from the CORBA input stream in the case when the value is not
  98:    * Streamable or CustomMarshall'ed. The fields of the class being written will
  99:    * be accessed using reflection.
 100:    *
 101:    * @param in a CORBA stream to read.
 102:    * @param offset the current position in the input stream.
 103:    * @param clz the type of value being read.
 104:    * @param repositoryID the repository Id of the value being read.
 105:    * @param sender the sending context that should provide data about the
 106:    * message originator.
 107:    *
 108:    * @return the object, extracted from the stream.
 109:    */
 110:   Serializable readValue(InputStream in, int offset, Class clz,
 111:     String repositoryID, RunTime sender);
 112: 
 113:   /**
 114:    * When the value provides the writeReplace method, the result of this method
 115:    * is written. Otherwise, the value itself is written.
 116:    *
 117:    * @param value the value that should be written to the stream.
 118:    *
 119:    * @return the value that will be actually written to the stream.
 120:    */
 121:   Serializable writeReplace(Serializable value);
 122: 
 123:   /**
 124:    * Write value to CORBA output stream using java senmatics.
 125:    *
 126:    * @param out a stream to write into.
 127:    * @param value a java object to write.
 128:    */
 129:   void writeValue(OutputStream out, Serializable value);
 130: }