Java Code Examples for gnu.CORBA.Unexpected

The following are top voted examples for showing how to use gnu.CORBA.Unexpected. 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: javify   File: gnuDynSequence.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new gnuDynSequence with the given typecode.
 *
 * @throws BAD_PARAM if the passed typecode is probably not a sequence
 * typecode.
 */
public gnuDynSequence(TypeCode oType, TypeCode aType,
                      gnuDynAnyFactory aFactory, ORB anOrb
                     )
               throws BAD_PARAM
{
  super(oType, aType, aFactory, anOrb, false);
  array = new DynAny[ 0 ];
  try
    {
      bound = final_type.length();
    }
  catch (BadKind ex)
    {
      throw new Unexpected(ex);
    }
}
 
Example 2
Project: javify   File: RecordAny.java   Source Code and License 6 votes vote down vote up
/**
 * Get content of the structure. This method must be defined on a different
 * name because get_members_as_dyn_any() throws exception only in some of the
 * supported interfaces.
 */
public NameDynAnyPair[] gnu_get_members_as_dyn_any()
{
  NameDynAnyPair[] r = new NameDynAnyPair[ array.length ];
  for (int i = 0; i < r.length; i++)
    {
      try
        {
          r [ i ] = new NameDynAnyPair(fNames [ i ], array [ i ]);
        }
      catch (Exception ex)
        {
          throw new Unexpected(ex);
        }
    }
  return r;
}
 
Example 3
Project: javify   File: RecordAny.java   Source Code and License 6 votes vote down vote up
/**
 * Get content of the structure. This method must be defined on a different
 * name because get_members_as_dyn_any() throws exception only in some of the
 * supported interfaces.
 */
public NameValuePair[] gnu_get_members()
{
  NameValuePair[] r = new NameValuePair[ array.length ];
  for (int i = 0; i < r.length; i++)
    {
      try
        {
          r [ i ] = new NameValuePair(fNames [ i ], array [ i ].to_any());
        }
      catch (Exception ex)
        {
          throw new Unexpected(ex);
        }
    }
  return r;
}
 
Example 4
Project: javify   File: gnuDynStruct.java   Source Code and License 6 votes vote down vote up
/**
 * Create an instance.
 */
public gnuDynStruct(TypeCode oType, TypeCode aType,
                    gnuDynAnyFactory aFactory, ORB anOrb)
{
  super(oType, aType, aFactory, anOrb);

  // Initialise fields.
  try
    {
      array = new DynAny[ final_type.member_count() ];
      fNames = new String[ array.length ];
      for (int i = 0; i < array.length; i++)
        {
          array [ i ] =
            factory.create_dyn_any_from_type_code(final_type.member_type(i));
          fNames [ i ] = final_type.member_name(i);
        }
    }
  catch (Exception e)
    {
      throw new Unexpected(e);
    }
}
 
Example 5
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 6
Project: javify   File: gnuDynEnum.java   Source Code and License 6 votes vote down vote up
/**
 * Set value from any that must contain enumeration.
 */
public void from_any(Any an_any) throws TypeMismatch, InvalidValue
{
  checkType(official_type, an_any.type());
  try
    {
      InputStream in = an_any.create_input_stream();
      set_as_ulong(in.read_long());
      in.close();
    }
  catch (MARSHAL eof)
    {
      throw new InvalidValue();
    }
  catch (IOException ex)
    {
      throw new Unexpected(ex);
    }
}
 
Example 7
Project: javify   File: gnuDynValueBox.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new instance of gnuDynValueBox.
 */
public gnuDynValueBox(TypeCode oType, TypeCode aType,
                      gnuDynAnyFactory aFactory, ORB anOrb
                     )
{
  super(oType, aType, aFactory, anOrb);
  try
    {
      content = final_type.content_type();
      array = new DynAny[] { factory.create_dyn_any_from_type_code(content) };
      set_to_null();
    }
  catch (Exception e)
    {
      throw new Unexpected(e);
    }
}
 
Example 8
Project: javify   File: gnuDynValueBox.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public DynAny copy()
{
  gnuDynValueBox other =
    new gnuDynValueBox(official_type, final_type, factory, orb);
  if (is_null())
    other.set_to_null();
  else
    {
      try
        {
          other.array = new DynAny[] { array [ 0 ].copy() };
        }
      catch (Exception e)
        {
          throw new Unexpected(e);
        }
    }
  return other;
}
 
Example 9
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 10
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 11
Project: javify   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the lower byte of the passed parameter.
 * @param x the char to write
 *
 * It is effective to write more characters at once.
 */
public void write_char(char x)
{
  try
    {
      if (narrow_native)
        b.write(x);
      else
        {
          OutputStreamWriter ow =
            new OutputStreamWriter((OutputStream) b, narrow_charset);
          ow.write(x);
          ow.flush();
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 12
Project: javify   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the lower bytes of the passed array members.
 *
 * @param chars an array
 * @param offset offset
 * @param length length
 */
public void write_char_array(char[] chars, int offset, int length)
{
  try
    {
      if (narrow_native)
        {
          for (int i = offset; i < offset + length; i++)
            {
              b.write(chars [ i ]);
            }
        }
      else
        {
          OutputStreamWriter ow =
            new OutputStreamWriter((OutputStream) b, narrow_charset);
          ow.write(chars, offset, length);
          ow.flush();
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 13
Project: javify   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the array of double values.
 */
public void write_double_array(double[] x, int ofs, int len)
{
  try
    {
      align(8);
      for (int i = ofs; i < ofs + len; i++)
        {
          b.writeDouble(x [ i ]);
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 14
Project: javify   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 *  Writes an array of the float values.
 */
public void write_float_array(float[] x, int ofs, int len)
{
  try
    {
      align(4);
      for (int i = ofs; i < ofs + len; i++)
        {
          b.writeFloat(x [ i ]);
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 15
Project: javify   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the array of integer (CORBA long) values.
 *
 * @param x value
 * @param ofs offset
 * @param len length
 */
public void write_long_array(int[] x, int ofs, int len)
{
  try
    {
      align(4);
      for (int i = ofs; i < ofs + len; i++)
        {
          b.writeInt(x [ i ]);
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 16
Project: javify   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the array of longs (CORBA long longs) values.
 *
 * @param x value
 * @param ofs offset
 * @param len length
 */
public void write_longlong_array(long[] x, int ofs, int len)
{
  try
    {
      align(8);
      for (int i = ofs; i < ofs + len; i++)
        {
          b.writeLong(x [ i ]);
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 17
Project: javify   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the array of short (two byte integer) values.
 *
 * @param x value
 * @param ofs offset
 * @param len length
 */
public void write_short_array(short[] x, int ofs, int len)
{
  try
    {
      align(2);
      for (int i = ofs; i < ofs + len; i++)
        {
          b.writeShort(x [ i ]);
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 18
Project: javify   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the string. This implementation first calls
 * String.getBytes() and then writes the length of the returned
 * array (as CORBA ulong) and the returned array itself.
 *
 * The encoding information, if previously set, is taken
 * into consideration.
 *
 * @param x the string to write.
 */
public void write_string(String x)
{
  try
    {
      byte[] ab = x.getBytes(narrow_charset);
      write_long(ab.length + 1);
      write(ab);

      // write null terminator.
      write(0);
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 19
Project: javify   File: gnuClientRequestInfo.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public String received_exception_id()
{
  try
    {
      if (m_wrapped_exception != null)
        {
          return m_wrapped_exception.type().id();
        }
      else
        {
          return request.received_exception_id();
        }
    }
  catch (BadKind e)
    {
      throw new Unexpected(e);
    }
}
 
Example 20
Project: javify   File: gnuClientRequestInfo.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public TypeCode[] exceptions()
{
  request.checkDii();

  ExceptionList ex = request.exceptions();
  TypeCode[] et = new TypeCode[ ex.count() ];
  try
    {
      for (int i = 0; i < et.length; i++)
        {
          et [ i ] = ex.item(i);
        }
    }
  catch (Bounds e)
    {
      throw new Unexpected(e);
    }
  return et;
}
 
Example 21
Project: jvm-stm   File: gnuDynSequence.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new gnuDynSequence with the given typecode.
 *
 * @throws BAD_PARAM if the passed typecode is probably not a sequence
 * typecode.
 */
public gnuDynSequence(TypeCode oType, TypeCode aType,
                      gnuDynAnyFactory aFactory, ORB anOrb
                     )
               throws BAD_PARAM
{
  super(oType, aType, aFactory, anOrb, false);
  array = new DynAny[ 0 ];
  try
    {
      bound = final_type.length();
    }
  catch (BadKind ex)
    {
      throw new Unexpected(ex);
    }
}
 
Example 22
Project: jvm-stm   File: RecordAny.java   Source Code and License 6 votes vote down vote up
/**
 * Get content of the structure. This method must be defined on a different
 * name because get_members_as_dyn_any() throws exception only in some of the
 * supported interfaces.
 */
public NameDynAnyPair[] gnu_get_members_as_dyn_any()
{
  NameDynAnyPair[] r = new NameDynAnyPair[ array.length ];
  for (int i = 0; i < r.length; i++)
    {
      try
        {
          r [ i ] = new NameDynAnyPair(fNames [ i ], array [ i ]);
        }
      catch (Exception ex)
        {
          throw new Unexpected(ex);
        }
    }
  return r;
}
 
Example 23
Project: jvm-stm   File: RecordAny.java   Source Code and License 6 votes vote down vote up
/**
 * Get content of the structure. This method must be defined on a different
 * name because get_members_as_dyn_any() throws exception only in some of the
 * supported interfaces.
 */
public NameValuePair[] gnu_get_members()
{
  NameValuePair[] r = new NameValuePair[ array.length ];
  for (int i = 0; i < r.length; i++)
    {
      try
        {
          r [ i ] = new NameValuePair(fNames [ i ], array [ i ].to_any());
        }
      catch (Exception ex)
        {
          throw new Unexpected(ex);
        }
    }
  return r;
}
 
Example 24
Project: jvm-stm   File: gnuDynStruct.java   Source Code and License 6 votes vote down vote up
/**
 * Create an instance.
 */
public gnuDynStruct(TypeCode oType, TypeCode aType,
                    gnuDynAnyFactory aFactory, ORB anOrb)
{
  super(oType, aType, aFactory, anOrb);

  // Initialise fields.
  try
    {
      array = new DynAny[ final_type.member_count() ];
      fNames = new String[ array.length ];
      for (int i = 0; i < array.length; i++)
        {
          array [ i ] =
            factory.create_dyn_any_from_type_code(final_type.member_type(i));
          fNames [ i ] = final_type.member_name(i);
        }
    }
  catch (Exception e)
    {
      throw new Unexpected(e);
    }
}
 
Example 25
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 26
Project: jvm-stm   File: gnuDynEnum.java   Source Code and License 6 votes vote down vote up
/**
 * Set value from any that must contain enumeration.
 */
public void from_any(Any an_any) throws TypeMismatch, InvalidValue
{
  checkType(official_type, an_any.type());
  try
    {
      InputStream in = an_any.create_input_stream();
      set_as_ulong(in.read_long());
      in.close();
    }
  catch (MARSHAL eof)
    {
      throw new InvalidValue();
    }
  catch (IOException ex)
    {
      throw new Unexpected(ex);
    }
}
 
Example 27
Project: jvm-stm   File: gnuDynValueBox.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new instance of gnuDynValueBox.
 */
public gnuDynValueBox(TypeCode oType, TypeCode aType,
                      gnuDynAnyFactory aFactory, ORB anOrb
                     )
{
  super(oType, aType, aFactory, anOrb);
  try
    {
      content = final_type.content_type();
      array = new DynAny[] { factory.create_dyn_any_from_type_code(content) };
      set_to_null();
    }
  catch (Exception e)
    {
      throw new Unexpected(e);
    }
}
 
Example 28
Project: jvm-stm   File: gnuDynValueBox.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public DynAny copy()
{
  gnuDynValueBox other =
    new gnuDynValueBox(official_type, final_type, factory, orb);
  if (is_null())
    other.set_to_null();
  else
    {
      try
        {
          other.array = new DynAny[] { array [ 0 ].copy() };
        }
      catch (Exception e)
        {
          throw new Unexpected(e);
        }
    }
  return other;
}
 
Example 29
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 30
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 31
Project: jvm-stm   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the lower byte of the passed parameter.
 * @param x the char to write
 *
 * It is effective to write more characters at once.
 */
public void write_char(char x)
{
  try
    {
      if (narrow_native)
        b.write(x);
      else
        {
          OutputStreamWriter ow =
            new OutputStreamWriter((OutputStream) b, narrow_charset);
          ow.write(x);
          ow.flush();
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 32
Project: jvm-stm   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the lower bytes of the passed array members.
 *
 * @param chars an array
 * @param offset offset
 * @param length length
 */
public void write_char_array(char[] chars, int offset, int length)
{
  try
    {
      if (narrow_native)
        {
          for (int i = offset; i < offset + length; i++)
            {
              b.write(chars [ i ]);
            }
        }
      else
        {
          OutputStreamWriter ow =
            new OutputStreamWriter((OutputStream) b, narrow_charset);
          ow.write(chars, offset, length);
          ow.flush();
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 33
Project: jvm-stm   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the array of double values.
 */
public void write_double_array(double[] x, int ofs, int len)
{
  try
    {
      align(8);
      for (int i = ofs; i < ofs + len; i++)
        {
          b.writeDouble(x [ i ]);
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 34
Project: jvm-stm   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 *  Writes an array of the float values.
 */
public void write_float_array(float[] x, int ofs, int len)
{
  try
    {
      align(4);
      for (int i = ofs; i < ofs + len; i++)
        {
          b.writeFloat(x [ i ]);
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 35
Project: jvm-stm   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the array of integer (CORBA long) values.
 *
 * @param x value
 * @param ofs offset
 * @param len length
 */
public void write_long_array(int[] x, int ofs, int len)
{
  try
    {
      align(4);
      for (int i = ofs; i < ofs + len; i++)
        {
          b.writeInt(x [ i ]);
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 36
Project: jvm-stm   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the array of longs (CORBA long longs) values.
 *
 * @param x value
 * @param ofs offset
 * @param len length
 */
public void write_longlong_array(long[] x, int ofs, int len)
{
  try
    {
      align(8);
      for (int i = ofs; i < ofs + len; i++)
        {
          b.writeLong(x [ i ]);
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 37
Project: jvm-stm   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the array of short (two byte integer) values.
 *
 * @param x value
 * @param ofs offset
 * @param len length
 */
public void write_short_array(short[] x, int ofs, int len)
{
  try
    {
      align(2);
      for (int i = ofs; i < ofs + len; i++)
        {
          b.writeShort(x [ i ]);
        }
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 38
Project: jvm-stm   File: AbstractCdrOutput.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the string. This implementation first calls
 * String.getBytes() and then writes the length of the returned
 * array (as CORBA ulong) and the returned array itself.
 *
 * The encoding information, if previously set, is taken
 * into consideration.
 *
 * @param x the string to write.
 */
public void write_string(String x)
{
  try
    {
      byte[] ab = x.getBytes(narrow_charset);
      write_long(ab.length + 1);
      write(ab);

      // write null terminator.
      write(0);
    }
  catch (IOException ex)
    {
      Unexpected.error(ex);
    }
}
 
Example 39
Project: jvm-stm   File: gnuClientRequestInfo.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public String received_exception_id()
{
  try
    {
      if (m_wrapped_exception != null)
        {
          return m_wrapped_exception.type().id();
        }
      else
        {
          return request.received_exception_id();
        }
    }
  catch (BadKind e)
    {
      throw new Unexpected(e);
    }
}
 
Example 40
Project: jvm-stm   File: gnuClientRequestInfo.java   Source Code and License 6 votes vote down vote up
/** @inheritDoc */
public TypeCode[] exceptions()
{
  request.checkDii();

  ExceptionList ex = request.exceptions();
  TypeCode[] et = new TypeCode[ ex.count() ];
  try
    {
      for (int i = 0; i < et.length; i++)
        {
          et [ i ] = ex.item(i);
        }
    }
  catch (Bounds e)
    {
      throw new Unexpected(e);
    }
  return et;
}