alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (TypeCode.java)

This example Java source code file (TypeCode.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

any, badkind, idlentity, string, tckind, typecode

The TypeCode.java Java example source code

/*
 * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

package org.omg.CORBA;

import org.omg.CORBA.TypeCodePackage.*;
import org.omg.CORBA.portable.IDLEntity;

/**
 * A container for information about a specific CORBA data
 * type.
 *<P>
 * <code>TypeCode objects are used:
 * <UL>
 * <LI>in the Dynamic Invocation Interface -- to indicate the types
 * of the actual arguments or the type of the return value.  <BR>
 * <code>NamedValue objects are used to represent arguments and
 * return values.  One of their components is an <code>Any
 * object, which in turn has as one of its components a
 * <code>TypeCode object.
 * <LI>by an Interface Repository to represent the type specifications
 * that are part of many OMG IDL declarations
 * </UL>
 * <P>
 * The representation of a <code>TypeCode object is opaque,
 * but abstractly, a <code>TypeCode object consists of:
 * <UL>
 * <LI>a kind field, which is set to an instance
 * of the class <code>TCKind
 * <LI>zero or more additional fields appropriate
 * for the particular kind. For example, the
 * <code>TypeCode object
 * describing the OMG IDL type <code>1ong has kind
 * <code>TCKind.tk_long and no additional fields.
 * The <code>TypeCode describing OMG IDL type
 * <code>sequence<boolean, 10> has a kind field
 * with the value
 * <code>TCKind.tk_sequence and also fields with the values
 * <code>boolean and 10 for the
 * type of sequence elements and the length of the sequence. <p>
 * </UL>
 *
 * <code>TypeCode objects can be obtained in various ways:
 * <OL>
 * <LI>from a call to the method Any.insert_X, where X is
 * a basic IDL type.  This method creates a <code>TypeCode object
 * for type X and assigns it to the <code>Any object's
 * <code>type field.
 * <LI>from invocations of methods in the ORB class
 * <P>For example, the following creates a TypeCode
 * object for a <code>string with a maximum of 30 characters:
 * <PRE>
 *   org.omg.CORBA.TypeCode tcString = orb.create_string_tc(30);
 * </PRE>
 * <P> The following creates a TypeCode
 * object for an <code>array of five strings:
 * <PRE>
 *   org.omg.CORBA.TypeCode tcArray = orb.create_array_tc(
 *                                       5, TCKind.tk_string);
 * </PRE>
 * <P> The following creates a TypeCode
 * object for an interface named "Account":
 * <PRE>
 *   org.omg.CORBA.TypeCode tcInterface = orb.create_interface_tc(
 *                                                 "thisId", "Account");
 * </PRE>
 * <LI>as the return value from the _type method
 * in <code>Holder classes for user-defined
 * IDL types.  These <code>Holder classes are generated
 * by the <code>idltojava compiler.
 * <LI>from a CORBA Interface Repository
 * </OL>
 * <P>
 * Most of the methods in the class <code>TypeCode
 * are accessors, and the information contained in a <code>TypeCode
 * object is specific to a particular type.  Therefore, methods
 * must be invoked
 * only on the kind of type codes to which they apply.  If an
 * accessor method
 * tries to access information from an inappropriate kind of
 * type code, it will throw
 * the exception <code>TypeCodePackage.BadKind.  For example,
 * if the method <code>discriminator_type is called on anything
 * other than a <code>union, it will throw BadKind
 * because only <code>unions have a discriminator.
 * The following list shows which methods apply to which kinds of
 * type codes:
 * <P>
 * These methods may be invoked on all <code>TypeCode kinds:
 * <UL>
 * <LI>equal
 * <LI>kind
 * </UL>
 * <P>
 * These methods may be invoked on <code>objref, struct,
 * <code>union, enum,
 * <code>alias, exception, value,
 * <code>value_box, native,
 * and <code>abstract_interface:
 * <UL>
 * <LI>id
 * <LI>name
 * </UL>
 * <P>
 * These methods may be invoked on <code>struct,
 * <code>union, enum,
 * and <code>exception:
 * <UL>
 * <LI>member_count
 * <LI>member_name
 * </UL>
 * <P>
 * These methods may be invoked on <code>struct,
 * <code>union, and exception:
 * <UL>
 * <LI>member_type(int index)
 * </UL>
 * <P>
 * These methods may be invoked on <code>union:
 * <UL>
 * <LI>member_label
 * <LI>discriminator_type
 * <LI>default_index
 * </UL>
 * <P>
 * These methods may be invoked on <code>string,
 * <code>sequence, and array:
 * <UL>
 * <LI>length
 * </UL>
 * <P>
 * These methods may be invoked on <code>alias,
 * <code>sequence, array, and value_box:
 * <UL>
 * <LI>content_type
 * </UL>
 * <P>
 * Unlike other CORBA pseudo-objects, <code>TypeCode
 * objects can be passed as general IDL parameters. <p>
 * The methods <code>parameter and param_count,
 * which are deprecated, are not mapped.  <p>
 *
 * Java IDL extends the CORBA specification to allow all operations permitted
 * on a <code>struct TypeCode to be permitted
 * on an <code>exception TypeCode as well. 

* */ public abstract class TypeCode implements IDLEntity { /** * Compares this <code>TypeCode object with the given one, * testing for equality. <code>TypeCode objects are equal if * they are interchangeable and give identical results when * <code>TypeCode operations are applied to them. * * @param tc the <code>TypeCode object to compare against * @return <code>true if the type codes are equal; * <code>false otherwise */ public abstract boolean equal(TypeCode tc); /** * Tests to see if the given <code>TypeCode object is * equivalent to this <code>TypeCode object. * <P> * * * @param tc the typecode to compare with this typecode * * @return <code>true if the given typecode is equivalent to * this typecode; <code>false otherwise * */ public abstract boolean equivalent(TypeCode tc); /** * Strips out all optional name and member name fields, * but leaves all alias typecodes intact. * @return a <code>TypeCode object with optional name and * member name fields stripped out, except for alias typecodes, * which are left intact * @see <a href="package-summary.html#unimpl">CORBA package * comments for unimplemented features</a> */ public abstract TypeCode get_compact_typecode(); /** * Retrieves the kind of this <code>TypeCode object. * The kind of a type code determines which <code>TypeCode * methods may legally be invoked on it. * <P> * The method <code>kind may be invoked on any * <code>TypeCode object. * * @return the <code>TCKind instance indicating the * value of the <code>kind field of this * <code>TypeCode object */ public abstract TCKind kind(); /** * Retrieves the RepositoryId globally identifying the type * of this <code>TypeCode object. * <P> * The method <code>id can be invoked on object reference, * structure, union, enumeration, alias, exception, valuetype, * boxed valuetype, native, and abstract interface type codes. * Object reference, exception, valuetype, boxed valuetype, * native, and abstract interface <code>TypeCode objects * always have a RepositoryId. * Structure, union, enumeration, and alias <code>TypeCode objects * obtained from the Interface Repository or the method * <code>ORB.create_operation_list * also always have a RepositoryId. If there is no RepositoryId, the * method can return an empty string. * * @return the RepositoryId for this <code>TypeCode object * or an empty string if there is no RepositoryID * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method * is invoked on an inappropriate kind of<code>TypeCode * object */ public abstract String id() throws BadKind; /** * Retrieves the simple name identifying this <code>TypeCode * object within its * enclosing scope. Since names are local to a Repository, the * name returned from a <code>TypeCode object * may not match the name of the * type in any particular Repository, and may even be an empty * string. * <P> * The method <code>name can be invoked on object reference, * structure, union, enumeration, alias, exception, valuetype, * boxed valuetype, native, and abstract interface * <code>TypeCode objects. * * @return the name identifying this <code>TypeCode object * or an empty string * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method * is invoked on an inappropriate kind of<code>TypeCode * object */ public abstract String name() throws BadKind; /** * Retrieves the number of members in the type described by * this <code>TypeCode object. * <P> * The method <code>member_count can be invoked on * structure, union, and enumeration <code>TypeCode objects. * Java IDL extends the CORBA specification to allow this method to * operate on exceptions as well. * * @return the number of members constituting the type described * by this <code>TypeCode object * * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method * is invoked on an inappropriate kind of <code>TypeCode * object */ public abstract int member_count() throws BadKind; /** * Retrieves the simple name of the member identified by * the given index. Since names are local to a * Repository, the name returned from a <code>TypeCode object * may not match the name of the member in any particular * Repository, and may even be an empty string. * <P> * The method <code>member_name can be invoked on structure, union, * and enumeration <code>TypeCode objects. * Java IDL extends the CORBA specification to allow this method to * operate on exceptions as well. * * @param index index of the member for which a name is being reqested * @return simple name of the member identified by the * index or an empty string * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is equal * to or greater than * the number of members constituting the type * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method * is invoked on an inappropriate kind of <code>TypeCode * object */ public abstract String member_name(int index) throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds; /** * Retrieves the <code>TypeCode object describing the type * of the member identified by the given index. * <P> * The method <code>member_type can be invoked on structure * and union <code>TypeCode objects. * Java IDL extends the CORBA specification to allow this method to * operate on exceptions as well. * * @param index index of the member for which type information * is begin requested * @return the <code>TypeCode object describing the * member at the given index * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is * equal to or greater than * the number of members constituting the type * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method * is invoked on an inappropriate kind of <code>TypeCode * object */ public abstract TypeCode member_type(int index) throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds; /** * Retrieves the label of the union member * identified by the given index. For the default member, * the label is the zero octet. *<P> * The method <code>member_label can only be invoked on union * <code>TypeCode objects. * * @param index index of the union member for which the * label is being requested * @return an <code>Any object describing the label of * the requested union member or the zero octet for * the default member * @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is * equal to or greater than * the number of members constituting the union * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method * is invoked on a non-union <code>TypeCode * object */ public abstract Any member_label(int index) throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds; /** * Returns a <code>TypeCode object describing * all non-default member labels. * The method <code>discriminator_type can be invoked only * on union <code>TypeCode objects. * * @return the <code>TypeCode object describing * the non-default member labels * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method * is invoked on a non-union <code>TypeCode * object */ public abstract TypeCode discriminator_type() throws BadKind; /** * Returns the index of the * default member, or -1 if there is no default member. * <P> * The method <code>default_index can be invoked only on union * <code>TypeCode objects. * * @return the index of the default member, or -1 if * there is no default member * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method * is invoked on a non-union <code>TypeCode * object */ public abstract int default_index() throws BadKind; /** * Returns the number of elements in the type described by * this <code>TypeCode object. * For strings and sequences, it returns the * bound, with zero indicating an unbounded string or sequence. * For arrays, it returns the number of elements in the array. * <P> * The method <code>length can be invoked on string, sequence, and * array <code>TypeCode objects. * * @return the bound for strings and sequences, or the * number of elements for arrays * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method * is invoked on an inappropriate kind of <code>TypeCode * object */ public abstract int length() throws BadKind; /** * Returns the <code>TypeCode object representing the * IDL type for the members of the object described by this * <code>TypeCode object. * For sequences and arrays, it returns the * element type. For aliases, it returns the original type. Note * that multidimensional arrays are represented by nesting * <code>TypeCode objects, one per dimension. * For boxed valuetypes, it returns the boxed type. *<P> * The method <code>content_type can be invoked on sequence, array, * alias, and boxed valuetype <code>TypeCode objects. * * @return a <code>TypeCode object representing * the element type for sequences and arrays, the * original type for aliases, or the * boxed type for boxed valuetypes. * @throws org.omg.CORBA.TypeCodePackage.BadKind if the method * is invoked on an inappropriate kind of <code>TypeCode * object */ public abstract TypeCode content_type() throws BadKind; /** * Returns the number of digits in the fixed type described by this * <code>TypeCode object. For example, the typecode for * the number 3000.275d could be <code>fixed<7,3>, where * 7 is the precision and 3 is the scale. * * @return the total number of digits * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method * is invoked on an inappropriate kind of <code>TypeCode * object * */ public abstract short fixed_digits() throws BadKind ; /** * Returns the scale of the fixed type described by this * <code>TypeCode object. A positive number indicates the * number of digits to the right of the decimal point. * For example, the number 3000d could have the * typecode <code>fixed<4,0>, where the first number is * the precision and the second number is the scale. * A negative number is also possible and adds zeroes to the * left of the decimal point. In this case, <code>fixed<1,-3>, * could be the typecode for the number 3000d. * * @return the scale of the fixed type that this * <code>TypeCode object describes * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method * is invoked on an inappropriate kind of <code>TypeCode * object */ public abstract short fixed_scale() throws BadKind ; /** * Returns the constant that indicates the visibility of the member * at the given index. * * This operation can only be invoked on non-boxed value * <code>TypeCode objects. * * @param index an <code>int indicating the index into the * value * @return either <code>PRIVATE_MEMBER.value or * <code>PUBLIC_MEMBER.value * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method * is invoked on a non-value type <code>TypeCode * object * @throws org.omg.CORBA.TypeCodePackage.Bounds * if the given index is out of bounds * @see <a href="package-summary.html#unimpl">CORBA package * comments for unimplemented features</a> */ abstract public short member_visibility(int index) throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds ; /** * Returns a constant indicating the modifier of the value type * that this <code>TypeCode object describes. The constant * returned must be one of the following: <code>VM_NONE.value, * <code>VM_ABSTRACT.value, VM_CUSTOM.value, * or <code>VM_TRUNCATABLE.value, * * @return a constant describing the value type * that this <code>TypeCode object describes * @throws org.omg.CORBA.TypeCodePackage.BadKind * if this method * is invoked on a non-value type <code>TypeCode * object * @see <a href="package-summary.html#unimpl">CORBA package * comments for unimplemented features</a> */ abstract public short type_modifier() throws BadKind ; /** * Returns the <code>TypeCode object that describes the concrete base type * of the value type that this <code>TypeCode object describes. * Returns null if it doesn't have a concrete base type. * * @return the <code>TypeCode object that describes the * concrete base type of the value type * that this <code>TypeCode object describes * @throws org.omg.CORBA.TypeCodePackage.BadKind if this method * is invoked on a non-boxed value type <code>TypeCode object * @see <a href="package-summary.html#unimpl">CORBA package * comments for unimplemented features</a> */ abstract public TypeCode concrete_base_type() throws BadKind ; }

Other Java examples (source code examples)

Here is a short list of links related to this Java TypeCode.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.