Java Code Examples for org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode

The following are top voted examples for showing how to use org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: DynUnionImpl.java   Source Code and License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 2
Project: OpenJSharp   File: DynAnyBasicImpl.java   Source Code and License 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example 3
Project: openjdk-jdk10   File: DynUnionImpl.java   Source Code and License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 4
Project: openjdk-jdk10   File: DynAnyBasicImpl.java   Source Code and License 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example 5
Project: openjdk9   File: DynUnionImpl.java   Source Code and License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 6
Project: openjdk9   File: DynAnyBasicImpl.java   Source Code and License 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example 7
Project: lookaside_java-1.8.0-openjdk   File: DynUnionImpl.java   Source Code and License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 8
Project: lookaside_java-1.8.0-openjdk   File: DynAnyBasicImpl.java   Source Code and License 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example 9
Project: jdk8u_corba   File: DynUnionImpl.java   Source Code and License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 10
Project: jdk8u_corba   File: DynAnyBasicImpl.java   Source Code and License 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example 11
Project: javify   File: gnuDynAnyFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Create the DynAny using the passed value as template and assign this value.
 */
public DynAny create_dyn_any(Any value)
                      throws InconsistentTypeCode
{
  DynAny created = create_dyn_any_from_type_code(value.type());
  try
    {
      created.from_any(value);
    }
  catch (UserException uex)
    {
      InconsistentTypeCode t = new InconsistentTypeCode("Inconsistent Any");
      t.initCause(uex);
      throw t;
    }
  catch (Exception e)
    {
      throw new Unexpected(e);
    }
  return created;
}
 
Example 12
Project: javify   File: gnuDynValueBox.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public void set_to_value()
{
  try
    {
      if (array.length == 0)
        {
          array =
            new DynAny[] { factory.create_dyn_any_from_type_code(content) };
        }
    }
  catch (InconsistentTypeCode e)
    {
      throw new Unexpected(e);
    }
  valueChanged();
}
 
Example 13
Project: javify   File: gnuDynArray.java   Source Code and License 6 votes vote down vote up
/**
 * Set elements when array of ordinary anys is provided.
 */
public void set_elements(Any[] value)
                  throws InvalidValue, TypeMismatch
{
  if (value.length != array.length)
    throw new InvalidValue(sizeMismatch(array.length, value.length));

  for (int i = 0; i < value.length; i++)
    {
      checkType(official_components, value [ i ].type());
      try
        {
          array [ i ] = factory.create_dyn_any(value [ i ]);
        }
      catch (InconsistentTypeCode e)
        {
          TypeMismatch t = new TypeMismatch();
          t.initCause(e);
          throw t;
        }
    }
  pos = 0;
  valueChanged();
}
 
Example 14
Project: javify   File: gnuDynUnion.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new instance with the given typecode.
 *
 * @param aType the final_type, must be final_type of the union.
 */
public gnuDynUnion(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
                   ORB anOrb
                  )
            throws InconsistentTypeCode
{
  super(oType, aType, aFactory, anOrb);
  try
    {
      discriminator =
        factory.create_dyn_any_from_type_code(final_type.discriminator_type());

      ((AbstractAny) discriminator).listener = this;

      if (final_type.default_index() >= 0)
        set_to_default_member();
      else
        set_to_no_active_member();
    }
  catch (Exception ex)
    {
      InconsistentTypeCode inc = new InconsistentTypeCode("discriminator");
      inc.initCause(ex);
      throw inc;
    }
}
 
Example 15
Project: javify   File: gnuDynUnion.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public DynAny copy()
{
  try
    {
      gnuDynUnion other =
        new gnuDynUnion(official_type, final_type, factory, orb);
      other.discriminator = discriminator.copy();
      ((AbstractAny) other.discriminator).listener = other;
      if (array.length == 1)
        {
          other.array = new DynAny[] { other.discriminator };
        }
      else
        {
          other.array =
            new DynAny[] { other.discriminator, array [ 1 ].copy() };
        }
      return other;
    }
  catch (InconsistentTypeCode ex)
    {
      throw new Unexpected(ex);
    }
}
 
Example 16
Project: jvm-stm   File: gnuDynAnyFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Create the DynAny using the passed value as template and assign this value.
 */
public DynAny create_dyn_any(Any value)
                      throws InconsistentTypeCode
{
  DynAny created = create_dyn_any_from_type_code(value.type());
  try
    {
      created.from_any(value);
    }
  catch (UserException uex)
    {
      InconsistentTypeCode t = new InconsistentTypeCode("Inconsistent Any");
      t.initCause(uex);
      throw t;
    }
  catch (Exception e)
    {
      throw new Unexpected(e);
    }
  return created;
}
 
Example 17
Project: jvm-stm   File: gnuDynValueBox.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public void set_to_value()
{
  try
    {
      if (array.length == 0)
        {
          array =
            new DynAny[] { factory.create_dyn_any_from_type_code(content) };
        }
    }
  catch (InconsistentTypeCode e)
    {
      throw new Unexpected(e);
    }
  valueChanged();
}
 
Example 18
Project: jvm-stm   File: gnuDynArray.java   Source Code and License 6 votes vote down vote up
/**
 * Set elements when array of ordinary anys is provided.
 */
public void set_elements(Any[] value)
                  throws InvalidValue, TypeMismatch
{
  if (value.length != array.length)
    throw new InvalidValue(sizeMismatch(array.length, value.length));

  for (int i = 0; i < value.length; i++)
    {
      checkType(official_components, value [ i ].type());
      try
        {
          array [ i ] = factory.create_dyn_any(value [ i ]);
        }
      catch (InconsistentTypeCode e)
        {
          TypeMismatch t = new TypeMismatch();
          t.initCause(e);
          throw t;
        }
    }
  pos = 0;
  valueChanged();
}
 
Example 19
Project: jvm-stm   File: gnuDynUnion.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new instance with the given typecode.
 *
 * @param aType the final_type, must be final_type of the union.
 */
public gnuDynUnion(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
                   ORB anOrb
                  )
            throws InconsistentTypeCode
{
  super(oType, aType, aFactory, anOrb);
  try
    {
      discriminator =
        factory.create_dyn_any_from_type_code(final_type.discriminator_type());

      ((AbstractAny) discriminator).listener = this;

      if (final_type.default_index() >= 0)
        set_to_default_member();
      else
        set_to_no_active_member();
    }
  catch (Exception ex)
    {
      InconsistentTypeCode inc = new InconsistentTypeCode("discriminator");
      inc.initCause(ex);
      throw inc;
    }
}
 
Example 20
Project: jvm-stm   File: gnuDynUnion.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public DynAny copy()
{
  try
    {
      gnuDynUnion other =
        new gnuDynUnion(official_type, final_type, factory, orb);
      other.discriminator = discriminator.copy();
      ((AbstractAny) other.discriminator).listener = other;
      if (array.length == 1)
        {
          other.array = new DynAny[] { other.discriminator };
        }
      else
        {
          other.array =
            new DynAny[] { other.discriminator, array [ 1 ].copy() };
        }
      return other;
    }
  catch (InconsistentTypeCode ex)
    {
      throw new Unexpected(ex);
    }
}
 
Example 21
Project: infobip-open-jdk-8   File: DynUnionImpl.java   Source Code and License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 22
Project: infobip-open-jdk-8   File: DynAnyBasicImpl.java   Source Code and License 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example 23
Project: openjdk-source-code-learn   File: DynUnionImpl.java   Source Code and License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 24
Project: openjdk-source-code-learn   File: DynAnyBasicImpl.java   Source Code and License 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example 25
Project: OLD-OpenJDK8   File: DynUnionImpl.java   Source Code and License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 26
Project: OLD-OpenJDK8   File: DynAnyBasicImpl.java   Source Code and License 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example 27
Project: JamVM-PH   File: gnuDynAnyFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Create the DynAny using the passed value as template and assign this value.
 */
public DynAny create_dyn_any(Any value)
                      throws InconsistentTypeCode
{
  DynAny created = create_dyn_any_from_type_code(value.type());
  try
    {
      created.from_any(value);
    }
  catch (UserException uex)
    {
      InconsistentTypeCode t = new InconsistentTypeCode("Inconsistent Any");
      t.initCause(uex);
      throw t;
    }
  catch (Exception e)
    {
      throw new Unexpected(e);
    }
  return created;
}
 
Example 28
Project: JamVM-PH   File: gnuDynValueBox.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public void set_to_value()
{
  try
    {
      if (array.length == 0)
        {
          array =
            new DynAny[] { factory.create_dyn_any_from_type_code(content) };
        }
    }
  catch (InconsistentTypeCode e)
    {
      throw new Unexpected(e);
    }
  valueChanged();
}
 
Example 29
Project: JamVM-PH   File: gnuDynArray.java   Source Code and License 6 votes vote down vote up
/**
 * Set elements when array of ordinary anys is provided.
 */
public void set_elements(Any[] value)
                  throws InvalidValue, TypeMismatch
{
  if (value.length != array.length)
    throw new InvalidValue(sizeMismatch(array.length, value.length));

  for (int i = 0; i < value.length; i++)
    {
      checkType(official_components, value [ i ].type());
      try
        {
          array [ i ] = factory.create_dyn_any(value [ i ]);
        }
      catch (InconsistentTypeCode e)
        {
          TypeMismatch t = new TypeMismatch();
          t.initCause(e);
          throw t;
        }
    }
  pos = 0;
  valueChanged();
}
 
Example 30
Project: JamVM-PH   File: gnuDynUnion.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new instance with the given typecode.
 *
 * @param aType the final_type, must be final_type of the union.
 */
public gnuDynUnion(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
                   ORB anOrb
                  )
            throws InconsistentTypeCode
{
  super(oType, aType, aFactory, anOrb);
  try
    {
      discriminator =
        factory.create_dyn_any_from_type_code(final_type.discriminator_type());

      ((AbstractAny) discriminator).listener = this;

      if (final_type.default_index() >= 0)
        set_to_default_member();
      else
        set_to_no_active_member();
    }
  catch (Exception ex)
    {
      InconsistentTypeCode inc = new InconsistentTypeCode("discriminator");
      inc.initCause(ex);
      throw inc;
    }
}
 
Example 31
Project: JamVM-PH   File: gnuDynUnion.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public DynAny copy()
{
  try
    {
      gnuDynUnion other =
        new gnuDynUnion(official_type, final_type, factory, orb);
      other.discriminator = discriminator.copy();
      ((AbstractAny) other.discriminator).listener = other;
      if (array.length == 1)
        {
          other.array = new DynAny[] { other.discriminator };
        }
      else
        {
          other.array =
            new DynAny[] { other.discriminator, array [ 1 ].copy() };
        }
      return other;
    }
  catch (InconsistentTypeCode ex)
    {
      throw new Unexpected(ex);
    }
}
 
Example 32
Project: openjdk-orb   File: DynUnionImpl.java   Source Code and License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 33
Project: openjdk-orb   File: DynAnyBasicImpl.java   Source Code and License 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example 34
Project: classpath   File: gnuDynAnyFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Create the DynAny using the passed value as template and assign this value.
 */
public DynAny create_dyn_any(Any value)
                      throws InconsistentTypeCode
{
  DynAny created = create_dyn_any_from_type_code(value.type());
  try
    {
      created.from_any(value);
    }
  catch (UserException uex)
    {
      InconsistentTypeCode t = new InconsistentTypeCode("Inconsistent Any");
      t.initCause(uex);
      throw t;
    }
  catch (Exception e)
    {
      throw new Unexpected(e);
    }
  return created;
}
 
Example 35
Project: classpath   File: gnuDynValueBox.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public void set_to_value()
{
  try
    {
      if (array.length == 0)
        {
          array =
            new DynAny[] { factory.create_dyn_any_from_type_code(content) };
        }
    }
  catch (InconsistentTypeCode e)
    {
      throw new Unexpected(e);
    }
  valueChanged();
}
 
Example 36
Project: classpath   File: gnuDynArray.java   Source Code and License 6 votes vote down vote up
/**
 * Set elements when array of ordinary anys is provided.
 */
public void set_elements(Any[] value)
                  throws InvalidValue, TypeMismatch
{
  if (value.length != array.length)
    throw new InvalidValue(sizeMismatch(array.length, value.length));

  for (int i = 0; i < value.length; i++)
    {
      checkType(official_components, value [ i ].type());
      try
        {
          array [ i ] = factory.create_dyn_any(value [ i ]);
        }
      catch (InconsistentTypeCode e)
        {
          TypeMismatch t = new TypeMismatch();
          t.initCause(e);
          throw t;
        }
    }
  pos = 0;
  valueChanged();
}
 
Example 37
Project: classpath   File: gnuDynUnion.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new instance with the given typecode.
 *
 * @param aType the final_type, must be final_type of the union.
 */
public gnuDynUnion(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory,
                   ORB anOrb
                  )
            throws InconsistentTypeCode
{
  super(oType, aType, aFactory, anOrb);
  try
    {
      discriminator =
        factory.create_dyn_any_from_type_code(final_type.discriminator_type());

      ((AbstractAny) discriminator).listener = this;

      if (final_type.default_index() >= 0)
        set_to_default_member();
      else
        set_to_no_active_member();
    }
  catch (Exception ex)
    {
      InconsistentTypeCode inc = new InconsistentTypeCode("discriminator");
      inc.initCause(ex);
      throw inc;
    }
}
 
Example 38
Project: classpath   File: gnuDynUnion.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public DynAny copy()
{
  try
    {
      gnuDynUnion other =
        new gnuDynUnion(official_type, final_type, factory, orb);
      other.discriminator = discriminator.copy();
      ((AbstractAny) other.discriminator).listener = other;
      if (array.length == 1)
        {
          other.array = new DynAny[] { other.discriminator };
        }
      else
        {
          other.array =
            new DynAny[] { other.discriminator, array [ 1 ].copy() };
        }
      return other;
    }
  catch (InconsistentTypeCode ex)
    {
      throw new Unexpected(ex);
    }
}
 
Example 39
Project: openjdk-icedtea7   File: DynUnionImpl.java   Source Code and License 6 votes vote down vote up
public void set_to_default_member ()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    int defaultIndex = defaultIndex();
    if (defaultIndex == -1) {
        throw new TypeMismatch();
    }
    try {
        clearData();
        index = 1;
        currentMemberIndex = defaultIndex;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(defaultIndex), orb);
        components = new DynAny[] {discriminator, currentMember};
        Any discriminatorAny = orb.create_any();
        discriminatorAny.insert_octet((byte)0);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        representations = REPRESENTATION_COMPONENTS;
    } catch (InconsistentTypeCode ictc) {}
}
 
Example 40
Project: openjdk-icedtea7   File: DynAnyBasicImpl.java   Source Code and License 6 votes vote down vote up
public org.omg.DynamicAny.DynAny get_dyn_any()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_any)
        throw new TypeMismatch();
    // _REVISIT_ Copy value here?
    try {
        return DynAnyUtil.createMostDerivedDynAny(any.extract_any(), orb, true);
    } catch (InconsistentTypeCode ictc) {
        // The spec doesn't allow us to throw back this exception
        // incase the anys any if of type Principal, native or abstract interface.
        return null;
    }
}
 
Example 41
Project: OpenJSharp   File: DynAnyConstructedImpl.java   Source Code and License 5 votes vote down vote up
public org.omg.DynamicAny.DynAny copy() {
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    checkInitAny();
    try {
        return DynAnyUtil.createMostDerivedDynAny(any, orb, true);
    } catch (InconsistentTypeCode ictc) {
        return null; // impossible
    }
}
 
Example 42
Project: OpenJSharp   File: DynArrayImpl.java   Source Code and License 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_array.
    TypeCode typeCode = any.type();
    int length = getBound();
    TypeCode contentType = getContentType();
    InputStream input;

    try {
        input = any.create_input_stream();
    } catch (BAD_OPERATION e) {
        return false;
    }

    components = new DynAny[length];
    anys = new Any[length];

    for (int i=0; i<length; i++) {
        // _REVISIT_ Could use read_xxx_array() methods on InputStream for efficiency
        // but only for primitive types
        anys[i] = DynAnyUtil.extractAnyFromStream(contentType, input, orb);
        try {
            // Creates the appropriate subtype without copying the Any
            components[i] = DynAnyUtil.createMostDerivedDynAny(anys[i], orb, false);
        } catch (InconsistentTypeCode itc) { // impossible
        }
    }
    return true;
}
 
Example 43
Project: OpenJSharp   File: DynUnionImpl.java   Source Code and License 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    try {
        InputStream input = any.create_input_stream();
        Any discriminatorAny = DynAnyUtil.extractAnyFromStream(discriminatorType(), input, orb);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        currentMemberIndex = currentUnionMemberIndex(discriminatorAny);
        Any memberAny = DynAnyUtil.extractAnyFromStream(memberType(currentMemberIndex), input, orb);
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberAny, orb, false);
        components = new DynAny[] {discriminator, currentMember};
    } catch (InconsistentTypeCode ictc) { // impossible
    }
    return true;
}
 
Example 44
Project: OpenJSharp   File: DynUnionImpl.java   Source Code and License 5 votes vote down vote up
protected boolean initializeComponentsFromTypeCode() {
    //System.out.println(this + " initializeComponentsFromTypeCode");
    try {
        // We can be sure that memberCount() > 0 according to the IDL language spec
        discriminator = DynAnyUtil.createMostDerivedDynAny(memberLabel(0), orb, false);
        index = 0;
        currentMemberIndex = 0;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(0), orb);
        components = new DynAny[] {discriminator, currentMember};
    } catch (InconsistentTypeCode ictc) { // impossible
    }
    return true;
}
 
Example 45
Project: OpenJSharp   File: DynUnionImpl.java   Source Code and License 5 votes vote down vote up
public void set_discriminator (org.omg.DynamicAny.DynAny newDiscriminator)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if ( ! newDiscriminator.type().equal(discriminatorType())) {
        throw new TypeMismatch();
    }
    newDiscriminator = DynAnyUtil.convertToNative(newDiscriminator, orb);
    Any newDiscriminatorAny = getAny(newDiscriminator);
    int newCurrentMemberIndex = currentUnionMemberIndex(newDiscriminatorAny);
    if (newCurrentMemberIndex == NO_INDEX) {
        clearData();
        index = 0;
    } else {
        // _REVISIT_ Could possibly optimize here if we don't need to initialize components
        checkInitComponents();
        if (currentMemberIndex == NO_INDEX || newCurrentMemberIndex != currentMemberIndex) {
            clearData();
            index = 1;
            currentMemberIndex = newCurrentMemberIndex;
            try {
            currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(currentMemberIndex), orb);
            } catch (InconsistentTypeCode ictc) {}
            discriminator = newDiscriminator;
            components = new DynAny[] { discriminator, currentMember };
            representations = REPRESENTATION_COMPONENTS;
        }
    }
}
 
Example 46
Project: OpenJSharp   File: DynValueBoxImpl.java   Source Code and License 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    try {
        components = new DynAny[] {DynAnyUtil.createMostDerivedDynAny(any, orb, false)};
    } catch (InconsistentTypeCode ictc) {
        return false; // impossible
    }
    return true;
}
 
Example 47
Project: OpenJSharp   File: DynValueBoxImpl.java   Source Code and License 5 votes vote down vote up
protected boolean initializeComponentsFromTypeCode() {
    try {
        any = DynAnyUtil.createDefaultAnyOfType(any.type(), orb);
        components = new DynAny[] {DynAnyUtil.createMostDerivedDynAny(any, orb, false)};
    } catch (InconsistentTypeCode ictc) {
        return false; // impossible
    }
    return true;
}
 
Example 48
Project: OpenJSharp   File: DynAnyCollectionImpl.java   Source Code and License 5 votes vote down vote up
protected void createDefaultComponentAt(int i, TypeCode contentType) {
    try {
        components[i] = DynAnyUtil.createMostDerivedDynAny(contentType, orb);
    } catch (InconsistentTypeCode itc) { // impossible
    }
    // get a hold of the default initialized Any without copying
    anys[i] = getAny(components[i]);
}
 
Example 49
Project: OpenJSharp   File: DynAnyCollectionImpl.java   Source Code and License 5 votes vote down vote up
public void set_elements (org.omg.CORBA.Any[] value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    checkValue(value);

    components = new DynAny[value.length];
    anys = value;

    // We know that this is of kind tk_sequence or tk_array
    TypeCode expectedTypeCode = getContentType();
    for (int i=0; i<value.length; i++) {
        if (value[i] != null) {
            if (! value[i].type().equal(expectedTypeCode)) {
                clearData();
                // _REVISIT_ More info
                throw new TypeMismatch();
            }
            try {
                // Creates the appropriate subtype without copying the Any
                components[i] = DynAnyUtil.createMostDerivedDynAny(value[i], orb, false);
                //System.out.println(this + " created component " + components[i]);
            } catch (InconsistentTypeCode itc) {
                throw new InvalidValue();
            }
        } else {
            clearData();
            // _REVISIT_ More info
            throw new InvalidValue();
        }
    }
    index = (value.length == 0 ? NO_INDEX : 0);
    // Other representations are invalidated by this operation
    representations = REPRESENTATION_COMPONENTS;
}
 
Example 50
Project: OpenJSharp   File: DynSequenceImpl.java   Source Code and License 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_sequence.
    TypeCode typeCode = any.type();
    int length;
    TypeCode contentType = getContentType();
    InputStream input;

    try {
        input = any.create_input_stream();
    } catch (BAD_OPERATION e) {
        return false;
    }

    length = input.read_long();
    components = new DynAny[length];
    anys = new Any[length];

    for (int i=0; i<length; i++) {
        // _REVISIT_ Could use read_xxx_array() methods on InputStream for efficiency
        // but only for primitive types
        anys[i] = DynAnyUtil.extractAnyFromStream(contentType, input, orb);
        try {
            // Creates the appropriate subtype without copying the Any
            components[i] = DynAnyUtil.createMostDerivedDynAny(anys[i], orb, false);
        } catch (InconsistentTypeCode itc) { // impossible
        }
    }
    return true;
}
 
Example 51
Project: OpenJSharp   File: DynAnyUtil.java   Source Code and License 5 votes vote down vote up
static DynAny createMostDerivedDynAny(Any any, ORB orb, boolean copyValue)
    throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode
{
    if (any == null || ! DynAnyUtil.isConsistentType(any.type()))
        throw new org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode();

    switch (any.type().kind().value()) {
        case TCKind._tk_sequence:
            return new DynSequenceImpl(orb, any, copyValue);
        case TCKind._tk_struct:
            return new DynStructImpl(orb, any, copyValue);
        case TCKind._tk_array:
            return new DynArrayImpl(orb, any, copyValue);
        case TCKind._tk_union:
            return new DynUnionImpl(orb, any, copyValue);
        case TCKind._tk_enum:
            return new DynEnumImpl(orb, any, copyValue);
        case TCKind._tk_fixed:
            return new DynFixedImpl(orb, any, copyValue);
        case TCKind._tk_value:
            return new DynValueImpl(orb, any, copyValue);
        case TCKind._tk_value_box:
            return new DynValueBoxImpl(orb, any, copyValue);
        default:
            return new DynAnyBasicImpl(orb, any, copyValue);
    }
}
 
Example 52
Project: OpenJSharp   File: DynAnyUtil.java   Source Code and License 5 votes vote down vote up
static DynAny createMostDerivedDynAny(TypeCode typeCode, ORB orb)
    throws org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode
{
    if (typeCode == null || ! DynAnyUtil.isConsistentType(typeCode))
        throw new org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode();

    switch (typeCode.kind().value()) {
        case TCKind._tk_sequence:
            return new DynSequenceImpl(orb, typeCode);
        case TCKind._tk_struct:
            return new DynStructImpl(orb, typeCode);
        case TCKind._tk_array:
            return new DynArrayImpl(orb, typeCode);
        case TCKind._tk_union:
            return new DynUnionImpl(orb, typeCode);
        case TCKind._tk_enum:
            return new DynEnumImpl(orb, typeCode);
        case TCKind._tk_fixed:
            return new DynFixedImpl(orb, typeCode);
        case TCKind._tk_value:
            return new DynValueImpl(orb, typeCode);
        case TCKind._tk_value_box:
            return new DynValueBoxImpl(orb, typeCode);
        default:
            return new DynAnyBasicImpl(orb, typeCode);
    }
}
 
Example 53
Project: OpenJSharp   File: DynAnyUtil.java   Source Code and License 5 votes vote down vote up
static DynAny convertToNative(DynAny dynAny, ORB orb) {
    if (dynAny instanceof DynAnyImpl) {
        return dynAny;
    } else {
        // if copy flag wasn't true we would be using our DynAny with
        // a foreign Any in it.
        try {
            return createMostDerivedDynAny(dynAny.to_any(), orb, true);
        } catch (InconsistentTypeCode ictc) {
            return null;
        }
    }
}
 
Example 54
Project: OpenJSharp   File: DynAnyBasicImpl.java   Source Code and License 5 votes vote down vote up
public org.omg.DynamicAny.DynAny copy() {
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    // The flag "true" indicates copying the Any value
    try {
        return DynAnyUtil.createMostDerivedDynAny(any, orb, true);
    } catch (InconsistentTypeCode ictc) {
        return null; // impossible
    }
}
 
Example 55
Project: openjdk-jdk10   File: DynAnyConstructedImpl.java   Source Code and License 5 votes vote down vote up
public org.omg.DynamicAny.DynAny copy() {
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    checkInitAny();
    try {
        return DynAnyUtil.createMostDerivedDynAny(any, orb, true);
    } catch (InconsistentTypeCode ictc) {
        return null; // impossible
    }
}
 
Example 56
Project: openjdk-jdk10   File: DynArrayImpl.java   Source Code and License 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_array.
    TypeCode typeCode = any.type();
    int length = getBound();
    TypeCode contentType = getContentType();
    InputStream input;

    try {
        input = any.create_input_stream();
    } catch (BAD_OPERATION e) {
        return false;
    }

    components = new DynAny[length];
    anys = new Any[length];

    for (int i=0; i<length; i++) {
        // _REVISIT_ Could use read_xxx_array() methods on InputStream for efficiency
        // but only for primitive types
        anys[i] = DynAnyUtil.extractAnyFromStream(contentType, input, orb);
        try {
            // Creates the appropriate subtype without copying the Any
            components[i] = DynAnyUtil.createMostDerivedDynAny(anys[i], orb, false);
        } catch (InconsistentTypeCode itc) { // impossible
        }
    }
    return true;
}
 
Example 57
Project: openjdk-jdk10   File: DynUnionImpl.java   Source Code and License 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    try {
        InputStream input = any.create_input_stream();
        Any discriminatorAny = DynAnyUtil.extractAnyFromStream(discriminatorType(), input, orb);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        currentMemberIndex = currentUnionMemberIndex(discriminatorAny);
        Any memberAny = DynAnyUtil.extractAnyFromStream(memberType(currentMemberIndex), input, orb);
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberAny, orb, false);
        components = new DynAny[] {discriminator, currentMember};
    } catch (InconsistentTypeCode ictc) { // impossible
    }
    return true;
}
 
Example 58
Project: openjdk-jdk10   File: DynUnionImpl.java   Source Code and License 5 votes vote down vote up
protected boolean initializeComponentsFromTypeCode() {
    //System.out.println(this + " initializeComponentsFromTypeCode");
    try {
        // We can be sure that memberCount() > 0 according to the IDL language spec
        discriminator = DynAnyUtil.createMostDerivedDynAny(memberLabel(0), orb, false);
        index = 0;
        currentMemberIndex = 0;
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(0), orb);
        components = new DynAny[] {discriminator, currentMember};
    } catch (InconsistentTypeCode ictc) { // impossible
    }
    return true;
}
 
Example 59
Project: openjdk-jdk10   File: DynUnionImpl.java   Source Code and License 5 votes vote down vote up
public void set_discriminator (org.omg.DynamicAny.DynAny newDiscriminator)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if ( ! newDiscriminator.type().equal(discriminatorType())) {
        throw new TypeMismatch();
    }
    newDiscriminator = DynAnyUtil.convertToNative(newDiscriminator, orb);
    Any newDiscriminatorAny = getAny(newDiscriminator);
    int newCurrentMemberIndex = currentUnionMemberIndex(newDiscriminatorAny);
    if (newCurrentMemberIndex == NO_INDEX) {
        clearData();
        index = 0;
    } else {
        // _REVISIT_ Could possibly optimize here if we don't need to initialize components
        checkInitComponents();
        if (currentMemberIndex == NO_INDEX || newCurrentMemberIndex != currentMemberIndex) {
            clearData();
            index = 1;
            currentMemberIndex = newCurrentMemberIndex;
            try {
            currentMember = DynAnyUtil.createMostDerivedDynAny(memberType(currentMemberIndex), orb);
            } catch (InconsistentTypeCode ictc) {}
            discriminator = newDiscriminator;
            components = new DynAny[] { discriminator, currentMember };
            representations = REPRESENTATION_COMPONENTS;
        }
    }
}
 
Example 60
Project: openjdk-jdk10   File: DynValueBoxImpl.java   Source Code and License 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    try {
        components = new DynAny[] {DynAnyUtil.createMostDerivedDynAny(any, orb, false)};
    } catch (InconsistentTypeCode ictc) {
        return false; // impossible
    }
    return true;
}