📄 holderlocator.java
字号:
/* HolderLocator.java -- Copyright (C) 2005 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING. If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library. Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule. An independent module is a module which is not derived fromor based on this library. If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so. If you do not wish to do so, delete thisexception statement from your version. */package gnu.CORBA;import org.omg.CORBA.AnyHolder;import org.omg.CORBA.AnySeqHolder;import org.omg.CORBA.BooleanHolder;import org.omg.CORBA.BooleanSeqHolder;import org.omg.CORBA.CharHolder;import org.omg.CORBA.CharSeqHolder;import org.omg.CORBA.DoubleHolder;import org.omg.CORBA.DoubleSeqHolder;import org.omg.CORBA.FixedHolder;import org.omg.CORBA.FloatHolder;import org.omg.CORBA.FloatSeqHolder;import org.omg.CORBA.IntHolder;import org.omg.CORBA.LongHolder;import org.omg.CORBA.LongLongSeqHolder;import org.omg.CORBA.LongSeqHolder;import org.omg.CORBA.OctetSeqHolder;import org.omg.CORBA.PrincipalHolder;import org.omg.CORBA.ShortHolder;import org.omg.CORBA.ShortSeqHolder;import org.omg.CORBA.StringHolder;import org.omg.CORBA.StringSeqHolder;import org.omg.CORBA.TCKind;import org.omg.CORBA.TypeCode;import org.omg.CORBA.TypeCodeHolder;import org.omg.CORBA.ULongLongSeqHolder;import org.omg.CORBA.ULongSeqHolder;import org.omg.CORBA.UShortSeqHolder;import org.omg.CORBA.WCharSeqHolder;import org.omg.CORBA.WStringSeqHolder;import org.omg.CORBA.portable.Streamable;import org.omg.CORBA.ObjectHolder;/** * Creates the suitable holder for storing the value of the given final_type. * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */public class HolderLocator{ /** * The array, sufficiently large to use any {@link TCKind}._tk* constant as * an index. */ private static final Class[] holders; private static final Class[] seqHolders; static { holders = new Class[32]; holders[TCKind._tk_Principal] = PrincipalHolder.class; holders[TCKind._tk_TypeCode] = TypeCodeHolder.class; holders[TCKind._tk_any] = AnyHolder.class; holders[TCKind._tk_boolean] = BooleanHolder.class; holders[TCKind._tk_char] = CharHolder.class; holders[TCKind._tk_double] = DoubleHolder.class; holders[TCKind._tk_float] = FloatHolder.class; holders[TCKind._tk_fixed] = FixedHolder.class; holders[TCKind._tk_long] = IntHolder.class; holders[TCKind._tk_longdouble] = DoubleHolder.class; holders[TCKind._tk_longlong] = LongHolder.class; holders[TCKind._tk_octet] = OctetHolder.class; holders[TCKind._tk_short] = ShortHolder.class; holders[TCKind._tk_string] = StringHolder.class; holders[TCKind._tk_ulong] = IntHolder.class; holders[TCKind._tk_ulonglong] = LongHolder.class; holders[TCKind._tk_ushort] = ShortHolder.class; holders[TCKind._tk_wchar] = WCharHolder.class; holders[TCKind._tk_wstring] = WStringHolder.class; holders[TCKind._tk_objref] = ObjectHolder.class; seqHolders = new Class[32]; seqHolders[TCKind._tk_ulonglong] = ULongLongSeqHolder.class; seqHolders[TCKind._tk_short] = ShortSeqHolder.class; seqHolders[TCKind._tk_octet] = OctetSeqHolder.class; seqHolders[TCKind._tk_any] = AnySeqHolder.class; seqHolders[TCKind._tk_long] = LongSeqHolder.class; seqHolders[TCKind._tk_longlong] = LongLongSeqHolder.class; seqHolders[TCKind._tk_float] = FloatSeqHolder.class; seqHolders[TCKind._tk_double] = DoubleSeqHolder.class; seqHolders[TCKind._tk_char] = CharSeqHolder.class; seqHolders[TCKind._tk_boolean] = BooleanSeqHolder.class; seqHolders[TCKind._tk_wchar] = WCharSeqHolder.class; seqHolders[TCKind._tk_ushort] = UShortSeqHolder.class; seqHolders[TCKind._tk_ulong] = ULongSeqHolder.class; seqHolders[TCKind._tk_string] = StringSeqHolder.class; seqHolders[TCKind._tk_wstring] = WStringSeqHolder.class; } /** * Create a holder for storing the value of the given built-in final_type. This * function returns the defined holders for the built-in primitive types and * they sequences. * * @param t the typecode * * @return an instance of the corresponding built-in holder of null if no such * is defined for this final_type. The holder is created with a parameterless * constructor. */ public static Streamable createHolder(TypeCode t) { try { int kind = t.kind().value(); int componentKind; Streamable holder = null; if (kind < holders.length && holders[kind] != null) holder = (Streamable) holders[kind].newInstance(); if (holder != null) return holder; switch (kind) { case TCKind._tk_sequence: componentKind = t.content_type().kind().value(); if (componentKind < seqHolders.length) return (Streamable) seqHolders[componentKind].newInstance(); break; default: break; } } catch (Exception ex) { throw new Unexpected(ex); } try { Object ox = ObjectCreator.createObject(t.id(), "Holder"); return (Streamable) ox; } catch (Exception ex) { return null; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -