src/share/classes/com/sun/corba/se/impl/dynamicany/DynValueBoxImpl.java

Thu, 31 Aug 2017 18:10:36 +0800

author
aoqi
date
Thu, 31 Aug 2017 18:10:36 +0800
changeset 748
6845b95cba6b
parent 158
91006f157c46
parent 0
7ef37b2cdcad
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.corba.se.impl.dynamicany;
    28 import org.omg.CORBA.TypeCode;
    29 import org.omg.CORBA.TCKind;
    30 import org.omg.CORBA.Any;
    31 import org.omg.CORBA.TypeCodePackage.BadKind;
    32 import org.omg.CORBA.TypeCodePackage.Bounds;
    33 import org.omg.DynamicAny.*;
    34 import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
    35 import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
    36 import org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode;
    38 import com.sun.corba.se.spi.orb.ORB ;
    39 import com.sun.corba.se.spi.logging.CORBALogDomains ;
    40 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
    42 public class DynValueBoxImpl extends DynValueCommonImpl implements DynValueBox
    43 {
    44     //
    45     // Constructors
    46     //
    48     private DynValueBoxImpl() {
    49         this(null, (Any)null, false);
    50     }
    52     protected DynValueBoxImpl(ORB orb, Any any, boolean copyValue) {
    53         super(orb, any, copyValue);
    54     }
    56     protected DynValueBoxImpl(ORB orb, TypeCode typeCode) {
    57         super(orb, typeCode);
    58     }
    60     //
    61     // DynValueBox methods
    62     //
    64     public Any get_boxed_value()
    65         throws org.omg.DynamicAny.DynAnyPackage.InvalidValue
    66     {
    67         if (isNull) {
    68             throw new InvalidValue();
    69         }
    70         checkInitAny();
    71         return any;
    72     }
    74     public void set_boxed_value(org.omg.CORBA.Any boxed)
    75         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
    76     {
    77         if ( ! isNull && ! boxed.type().equal(this.type())) {
    78             throw new TypeMismatch();
    79         }
    80         clearData();
    81         any = boxed;
    82         representations = REPRESENTATION_ANY;
    83         index = 0;
    84         isNull = false;
    85     }
    87     public DynAny get_boxed_value_as_dyn_any()
    88         throws org.omg.DynamicAny.DynAnyPackage.InvalidValue
    89     {
    90         if (isNull) {
    91             throw new InvalidValue();
    92         }
    93         checkInitComponents();
    94         return components[0];
    95     }
    97     public void set_boxed_value_as_dyn_any(DynAny boxed)
    98         throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
    99     {
   100         if ( ! isNull && ! boxed.type().equal(this.type())) {
   101             throw new TypeMismatch();
   102         }
   103         clearData();
   104         components = new DynAny[] {boxed};
   105         representations = REPRESENTATION_COMPONENTS;
   106         index = 0;
   107         isNull = false;
   108     }
   110     protected boolean initializeComponentsFromAny() {
   111         try {
   112             components = new DynAny[] {DynAnyUtil.createMostDerivedDynAny(any, orb, false)};
   113         } catch (InconsistentTypeCode ictc) {
   114             return false; // impossible
   115         }
   116         return true;
   117     }
   119     protected boolean initializeComponentsFromTypeCode() {
   120         try {
   121             any = DynAnyUtil.createDefaultAnyOfType(any.type(), orb);
   122             components = new DynAny[] {DynAnyUtil.createMostDerivedDynAny(any, orb, false)};
   123         } catch (InconsistentTypeCode ictc) {
   124             return false; // impossible
   125         }
   126         return true;
   127     }
   129     protected boolean initializeAnyFromComponents() {
   130         any = getAny(components[0]);
   131         return true;
   132     }
   133 }

mercurial