001/* DynAnyFactoryOperations.java --
002   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
003
004This file is part of GNU Classpath.
005
006GNU Classpath is free software; you can redistribute it and/or modify
007it under the terms of the GNU General Public License as published by
008the Free Software Foundation; either version 2, or (at your option)
009any later version.
010
011GNU Classpath is distributed in the hope that it will be useful, but
012WITHOUT ANY WARRANTY; without even the implied warranty of
013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014General Public License for more details.
015
016You should have received a copy of the GNU General Public License
017along with GNU Classpath; see the file COPYING.  If not, write to the
018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
01902110-1301 USA.
020
021Linking this library statically or dynamically with other modules is
022making a combined work based on this library.  Thus, the terms and
023conditions of the GNU General Public License cover the whole
024combination.
025
026As a special exception, the copyright holders of this library give you
027permission to link this library with independent modules to produce an
028executable, regardless of the license terms of these independent
029modules, and to copy and distribute the resulting executable under
030terms of your choice, provided that you also meet, for each linked
031independent module, the terms and conditions of the license of that
032module.  An independent module is a module which is not derived from
033or based on this library.  If you modify this library, you may extend
034this exception to your version of the library, but you are not
035obligated to do so.  If you do not wish to do so, delete this
036exception statement from your version. */
037
038
039package org.omg.DynamicAny;
040
041import org.omg.CORBA.Any;
042import org.omg.CORBA.TCKind;
043import org.omg.CORBA.TypeCode;
044import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
045
046/**
047 * Defines the operations, applicable for DynAnyFactory. These operations
048 * produce new DynAny's either from Any, serving as a template and value
049 * provider, or from the given typecode.
050 *
051 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
052 */
053public interface DynAnyFactoryOperations
054{
055  /**
056   * Create DynAny for holding the data of the given type. The returned DynAny
057   * is initialised to its agreed default value. The agreed default values are:
058   * <table border='1'>
059   * <tr>
060   * <th>Type</th>
061   * <th>Value</th>
062   * <th>Creates</th>
063   * </tr>
064   *
065   * <tr>
066   * <td>boolean</td>
067   * <td>false</td>
068   * <td>{@link DynAny}</td>
069   * </tr>
070   * <tr>
071   * <td>numeric types, octet, fixed</td>
072   * <td>0</td>
073   * <td>{@link DynAny}</td>
074   * </tr>
075   * <tr>
076   * <td>char, wchar</td>
077   * <td>(char) 0</td>
078   * <td>{@link DynAny}</td>
079   * </tr>
080   * <tr>
081   * <td>string, wstring</td>
082   * <td>empty string ("", not <code>null<code>)</td>
083   * <td>{@link DynAny}</td>
084   * </tr>
085   * <tr>
086   * <td>{@link Any}</td>
087   * <td>{@link Any} with no value and typecode of kind {@link TCKind#tk_null}</td>
088   * <td>{@link DynAny}</td>
089   * </tr>
090   * <tr>
091   * <td>Sequence</td>
092   * <td>Empty (zero size) sequence</td>
093   * <td>{@link DynSequence}</td>
094   * </tr>
095   * <tr>
096   * <td>Array</td>
097   * <td>All members of array are recursively initialised to default values.</td>
098   * <td>{@link DynArray}</td>
099   * </tr>
100   * <tr>
101   * <td>Structure, exception</td>
102   * <td>All fields of the structure (if any) are recursively initialised to
103   * default values.</td>
104   * <td>{@link DynStruct}</td>
105   * </tr>
106   * <tr>
107   * <td>Enumeration</td>
108   * <td>Default value, indicated by typecode.</td>
109   * <td>{@link DynEnum}</td>
110   * </tr>
111   * <tr>
112   * <td>Union</td>
113   * <td>Default variant (indicated by typecode), recursively initialised to
114   * its default value.</td>
115   * <td>{@link DynUnion}</td>
116   * </tr>
117   * <tr>
118   * <td>Value, ValueBox</td>
119   * <td>null</td>
120   * <td>{@link DynValue}, {@link DynValueBox}</td>
121   * </tr>
122   * <tr>
123   * <td>TypeCode</td>
124   * <td>Typecode of kind <code>TCKind.tk_null</code></td>
125   * <td>{@link DynValue}, {@link DynValueBox}</td>
126   * </tr>
127   *
128   * </table>
129   *
130   * @param type the type of the data being stored.
131   *
132   * @return the created DynAny, having the passed type.
133   *
134   * @throws InconsistentTypeCode if type.kind() is tk_Principal, tk_native or
135   * tk_abstract_interface. These types cannot be stored in DynAny.
136   */
137  DynAny create_dyn_any_from_type_code(TypeCode type)
138    throws InconsistentTypeCode;
139
140  /**
141   * Create DynAny using the given Any as template.
142   *
143   * @param value the Any, providing type and value for the DynAny being
144   * created.
145   *
146   * @return the created DynAny, having the same type and storing the same value
147   * as the passed Any.
148   *
149   * @throws InconsistentTypeCode if value.type().kind() is tk_Principal,
150   * tk_native or tk_abstract_interface. These types cannot be stored in DynAny.
151   */
152  DynAny create_dyn_any(Any value)
153    throws InconsistentTypeCode;
154}