Java Code Examples for org.omg.CORBA.StringValueHelper

The following are top voted examples for showing how to use org.omg.CORBA.StringValueHelper. 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: Vio.java   View source code 4 votes vote down vote up
/**
 * Fill in the instance fields by the data from the input stream. The method
 * assumes that the value header, if any, is already behind. The information
 * from the stream is stored into the passed ox parameter.
 *
 * @param input an input stream to read from.
 *
 * @param value a pre-instantiated value type object, must be either
 * Streamable or CustomMarshal. If the helper is used, this parameter is
 * ignored and should be null.
 *
 * @param value_tag the tag that must be read previously.
 * @param helper the helper for read object specific part; may be null to read
 * in using other methods.
 *
 * @return the value that was read.
 */
static Object read_instance(InputStream input, final int position,
  Object value, int value_tag, BoxedValueHelper helper, String id,
  String[] ids, String codebase)
{
  if (helper != m_StringValueHelper && id != null)
    if (id.equals(StringValueHelper.id()))
      {
        value = null;
        helper = m_StringValueHelper;
      }

  try
    {
      if ((value_tag & vf_CHUNKING) != 0)
        {
          BufferedCdrOutput output = createBuffer(input, 1024);
          // Read the current (not a nested one) value in this spec case.
          readNestedValue(value_tag, input, output, -1);
          BufferredCdrInput ci = new BufferredCdrInput(output.buffer.getBuffer());
          ci.setRunTime(output.getRunTime());

          input = new HeadlessInput(ci, input);
        }
      else
        {
          if (input instanceof BufferredCdrInput)
            {
              // Highly probable case.
              input = new HeadlessInput((BufferredCdrInput) input, null);
            }
          else if (input instanceof HeadlessInput)
            {
              // There is no need to instantiate one more HeadlessInput
              // as we can just reset.
              ((HeadlessInput) input).subsequentCalls = false;
            }
          else
            {
              BufferedCdrOutput bout = new BufferedCdrOutput();
              int c;
              while ((c = input.read()) >= 0)
                bout.write((byte) c);
              input = new HeadlessInput(
                (BufferredCdrInput) bout.create_input_stream(), input);
            }
        }
    }
  catch (IOException ex)
    {
      MARSHAL m = new MARSHAL("Unable to read chunks");
      m.minor = Minor.Value;
      m.initCause(ex);
      throw m;
    }

  return readValue(input, position, value, helper, id, ids, codebase);
}
 
Example 2
Project: javify   File: Vio.java   View source code 4 votes vote down vote up
static Object _createInstance(String id, String codebase)
{
  if (id == null)
    return null;
  if (id.equals(StringValueHelper.id()))
    return "";
  StringTokenizer st = new StringTokenizer(id, ":");

  String prefix = st.nextToken();
  if (prefix.equalsIgnoreCase("IDL"))
    return ObjectCreator.Idl2Object(id);
  else if (prefix.equalsIgnoreCase("RMI"))
    {
      String className = st.nextToken();
      String hashCode = st.nextToken();
      String sid = null;
      if (st.hasMoreElements())
        sid = st.nextToken();

      try
        {
          Class objectClass = Util.loadClass(className, codebase,
            Vio.class.getClassLoader());

          String rid = ObjectCreator.getRepositoryId(objectClass);

          if (!rid.equals(id))
            {
              // If direct string comparison fails, compare by meaning.
              StringTokenizer st2 = new StringTokenizer(rid, ":");
              if (!st2.nextToken().equals("RMI"))
                throw new InternalError("RMI format expected: '" + rid + "'");
              if (!st2.nextToken().equals(className))
                throwIt("Class name mismatch", id, rid, null);

              try
                {
                  long h1 = Long.parseLong(hashCode, 16);
                  long h2 = Long.parseLong(st2.nextToken(), 16);
                  if (h1 != h2)
                    throwIt("Hashcode mismatch", id, rid, null);

                  if (sid != null && st2.hasMoreTokens())
                    {
                      long s1 = Long.parseLong(hashCode, 16);
                      long s2 = Long.parseLong(st2.nextToken(), 16);
                      if (s1 != s2)
                        throwIt("serialVersionUID mismatch", id, rid, null);
                    }
                }
              catch (NumberFormatException e)
                {
                  throwIt("Invalid hashcode or svuid format: ", id, rid, e);
                }
            }

          // Low - level instantiation required here.
          return instantiateAnyWay(objectClass);
        }
      catch (Exception ex)
        {
          MARSHAL m = new MARSHAL("Unable to instantiate " + id);
          m.minor = Minor.Instantiation;
          m.initCause(ex);
          throw m;
        }
    }
  else
    throw new NO_IMPLEMENT("Unsupported prefix " + prefix + ":");
}
 
Example 3
Project: jvm-stm   File: Vio.java   View source code 4 votes vote down vote up
/**
 * Fill in the instance fields by the data from the input stream. The method
 * assumes that the value header, if any, is already behind. The information
 * from the stream is stored into the passed ox parameter.
 * 
 * @param input an input stream to read from.
 * 
 * @param value a pre-instantiated value type object, must be either
 * Streamable or CustomMarshal. If the helper is used, this parameter is
 * ignored and should be null.
 * 
 * @param value_tag the tag that must be read previously.
 * @param helper the helper for read object specific part; may be null to read
 * in using other methods.
 * 
 * @return the value that was read.
 */
static Object read_instance(InputStream input, final int position,
  Object value, int value_tag, BoxedValueHelper helper, String id,
  String[] ids, String codebase)
{
  if (helper != m_StringValueHelper && id != null)
    if (id.equals(StringValueHelper.id()))
      {
        value = null;
        helper = m_StringValueHelper;
      }

  try
    {
      if ((value_tag & vf_CHUNKING) != 0)
        {
          BufferedCdrOutput output = createBuffer(input, 1024);
          // Read the current (not a nested one) value in this spec case.
          readNestedValue(value_tag, input, output, -1);
          BufferredCdrInput ci = new BufferredCdrInput(output.buffer.getBuffer());
          ci.setRunTime(output.getRunTime());

          input = new HeadlessInput(ci, input);
        }
      else
        {
          if (input instanceof BufferredCdrInput)
            {
              // Highly probable case.
              input = new HeadlessInput((BufferredCdrInput) input, null);
            }
          else if (input instanceof HeadlessInput)
            {
              // There is no need to instantiate one more HeadlessInput
              // as we can just reset.
              ((HeadlessInput) input).subsequentCalls = false;
            }
          else
            {
              BufferedCdrOutput bout = new BufferedCdrOutput();
              int c;
              while ((c = input.read()) >= 0)
                bout.write((byte) c);
              input = new HeadlessInput(
                (BufferredCdrInput) bout.create_input_stream(), input);
            }
        }
    }
  catch (IOException ex)
    {
      MARSHAL m = new MARSHAL("Unable to read chunks");
      m.minor = Minor.Value;
      m.initCause(ex);
      throw m;
    }

  return readValue(input, position, value, helper, id, ids, codebase);
}
 
Example 4
Project: jvm-stm   File: Vio.java   View source code 4 votes vote down vote up
static Object _createInstance(String id, String codebase)
{
  if (id == null)
    return null;
  if (id.equals(StringValueHelper.id()))
    return "";
  StringTokenizer st = new StringTokenizer(id, ":");

  String prefix = st.nextToken();
  if (prefix.equalsIgnoreCase("IDL"))
    return ObjectCreator.Idl2Object(id);
  else if (prefix.equalsIgnoreCase("RMI"))
    {
      String className = st.nextToken();
      String hashCode = st.nextToken();
      String sid = null;
      if (st.hasMoreElements())
        sid = st.nextToken();

      try
        {
          Class objectClass = Util.loadClass(className, codebase,
            Vio.class.getClassLoader());

          String rid = ObjectCreator.getRepositoryId(objectClass);

          if (!rid.equals(id))
            {
              // If direct string comparison fails, compare by meaning.
              StringTokenizer st2 = new StringTokenizer(rid, ":");
              if (!st2.nextToken().equals("RMI"))
                throw new InternalError("RMI format expected: '" + rid + "'");
              if (!st2.nextToken().equals(className))
                throwIt("Class name mismatch", id, rid, null);

              try
                {
                  long h1 = Long.parseLong(hashCode, 16);
                  long h2 = Long.parseLong(st2.nextToken(), 16);
                  if (h1 != h2)
                    throwIt("Hashcode mismatch", id, rid, null);

                  if (sid != null && st2.hasMoreTokens())
                    {
                      long s1 = Long.parseLong(hashCode, 16);
                      long s2 = Long.parseLong(st2.nextToken(), 16);
                      if (s1 != s2)
                        throwIt("serialVersionUID mismatch", id, rid, null);
                    }
                }
              catch (NumberFormatException e)
                {
                  throwIt("Invalid hashcode or svuid format: ", id, rid, e);
                }
            }

          // Low - level instantiation required here.
          return instantiateAnyWay(objectClass);
        }
      catch (Exception ex)
        {
          MARSHAL m = new MARSHAL("Unable to instantiate " + id);
          m.minor = Minor.Instantiation;
          m.initCause(ex);
          throw m;
        }
    }
  else
    throw new NO_IMPLEMENT("Unsupported prefix " + prefix + ":");
}
 
Example 5
Project: JamVM-PH   File: Vio.java   View source code 4 votes vote down vote up
/**
 * Fill in the instance fields by the data from the input stream. The method
 * assumes that the value header, if any, is already behind. The information
 * from the stream is stored into the passed ox parameter.
 * 
 * @param input an input stream to read from.
 * 
 * @param value a pre-instantiated value type object, must be either
 * Streamable or CustomMarshal. If the helper is used, this parameter is
 * ignored and should be null.
 * 
 * @param value_tag the tag that must be read previously.
 * @param helper the helper for read object specific part; may be null to read
 * in using other methods.
 * 
 * @return the value that was read.
 */
static Object read_instance(InputStream input, final int position,
  Object value, int value_tag, BoxedValueHelper helper, String id,
  String[] ids, String codebase)
{
  if (helper != m_StringValueHelper && id != null)
    if (id.equals(StringValueHelper.id()))
      {
        value = null;
        helper = m_StringValueHelper;
      }

  try
    {
      if ((value_tag & vf_CHUNKING) != 0)
        {
          BufferedCdrOutput output = createBuffer(input, 1024);
          // Read the current (not a nested one) value in this spec case.
          readNestedValue(value_tag, input, output, -1);
          BufferredCdrInput ci = new BufferredCdrInput(output.buffer.getBuffer());
          ci.setRunTime(output.getRunTime());

          input = new HeadlessInput(ci, input);
        }
      else
        {
          if (input instanceof BufferredCdrInput)
            {
              // Highly probable case.
              input = new HeadlessInput((BufferredCdrInput) input, null);
            }
          else if (input instanceof HeadlessInput)
            {
              // There is no need to instantiate one more HeadlessInput
              // as we can just reset.
              ((HeadlessInput) input).subsequentCalls = false;
            }
          else
            {
              BufferedCdrOutput bout = new BufferedCdrOutput();
              int c;
              while ((c = input.read()) >= 0)
                bout.write((byte) c);
              input = new HeadlessInput(
                (BufferredCdrInput) bout.create_input_stream(), input);
            }
        }
    }
  catch (IOException ex)
    {
      MARSHAL m = new MARSHAL("Unable to read chunks");
      m.minor = Minor.Value;
      m.initCause(ex);
      throw m;
    }

  return readValue(input, position, value, helper, id, ids, codebase);
}
 
Example 6
Project: JamVM-PH   File: Vio.java   View source code 4 votes vote down vote up
static Object _createInstance(String id, String codebase)
{
  if (id == null)
    return null;
  if (id.equals(StringValueHelper.id()))
    return "";
  StringTokenizer st = new StringTokenizer(id, ":");

  String prefix = st.nextToken();
  if (prefix.equalsIgnoreCase("IDL"))
    return ObjectCreator.Idl2Object(id);
  else if (prefix.equalsIgnoreCase("RMI"))
    {
      String className = st.nextToken();
      String hashCode = st.nextToken();
      String sid = null;
      if (st.hasMoreElements())
        sid = st.nextToken();

      try
        {
          Class objectClass = Util.loadClass(className, codebase,
            Vio.class.getClassLoader());

          String rid = ObjectCreator.getRepositoryId(objectClass);

          if (!rid.equals(id))
            {
              // If direct string comparison fails, compare by meaning.
              StringTokenizer st2 = new StringTokenizer(rid, ":");
              if (!st2.nextToken().equals("RMI"))
                throw new InternalError("RMI format expected: '" + rid + "'");
              if (!st2.nextToken().equals(className))
                throwIt("Class name mismatch", id, rid, null);

              try
                {
                  long h1 = Long.parseLong(hashCode, 16);
                  long h2 = Long.parseLong(st2.nextToken(), 16);
                  if (h1 != h2)
                    throwIt("Hashcode mismatch", id, rid, null);

                  if (sid != null && st2.hasMoreTokens())
                    {
                      long s1 = Long.parseLong(hashCode, 16);
                      long s2 = Long.parseLong(st2.nextToken(), 16);
                      if (s1 != s2)
                        throwIt("serialVersionUID mismatch", id, rid, null);
                    }
                }
              catch (NumberFormatException e)
                {
                  throwIt("Invalid hashcode or svuid format: ", id, rid, e);
                }
            }

          // Low - level instantiation required here.
          return instantiateAnyWay(objectClass);
        }
      catch (Exception ex)
        {
          MARSHAL m = new MARSHAL("Unable to instantiate " + id);
          m.minor = Minor.Instantiation;
          m.initCause(ex);
          throw m;
        }
    }
  else
    throw new NO_IMPLEMENT("Unsupported prefix " + prefix + ":");
}
 
Example 7
Project: classpath   File: Vio.java   View source code 4 votes vote down vote up
/**
 * Fill in the instance fields by the data from the input stream. The method
 * assumes that the value header, if any, is already behind. The information
 * from the stream is stored into the passed ox parameter.
 *
 * @param input an input stream to read from.
 *
 * @param value a pre-instantiated value type object, must be either
 * Streamable or CustomMarshal. If the helper is used, this parameter is
 * ignored and should be null.
 *
 * @param value_tag the tag that must be read previously.
 * @param helper the helper for read object specific part; may be null to read
 * in using other methods.
 *
 * @return the value that was read.
 */
static Object read_instance(InputStream input, final int position,
  Object value, int value_tag, BoxedValueHelper helper, String id,
  String[] ids, String codebase)
{
  if (helper != m_StringValueHelper && id != null)
    if (id.equals(StringValueHelper.id()))
      {
        value = null;
        helper = m_StringValueHelper;
      }

  try
    {
      if ((value_tag & vf_CHUNKING) != 0)
        {
          BufferedCdrOutput output = createBuffer(input, 1024);
          // Read the current (not a nested one) value in this spec case.
          readNestedValue(value_tag, input, output, -1);
          BufferredCdrInput ci = new BufferredCdrInput(output.buffer.getBuffer());
          ci.setRunTime(output.getRunTime());

          input = new HeadlessInput(ci, input);
        }
      else
        {
          if (input instanceof BufferredCdrInput)
            {
              // Highly probable case.
              input = new HeadlessInput((BufferredCdrInput) input, null);
            }
          else if (input instanceof HeadlessInput)
            {
              // There is no need to instantiate one more HeadlessInput
              // as we can just reset.
              ((HeadlessInput) input).subsequentCalls = false;
            }
          else
            {
              BufferedCdrOutput bout = new BufferedCdrOutput();
              int c;
              while ((c = input.read()) >= 0)
                bout.write((byte) c);
              input = new HeadlessInput(
                (BufferredCdrInput) bout.create_input_stream(), input);
            }
        }
    }
  catch (IOException ex)
    {
      MARSHAL m = new MARSHAL("Unable to read chunks");
      m.minor = Minor.Value;
      m.initCause(ex);
      throw m;
    }

  return readValue(input, position, value, helper, id, ids, codebase);
}
 
Example 8
Project: classpath   File: Vio.java   View source code 4 votes vote down vote up
static Object _createInstance(String id, String codebase)
{
  if (id == null)
    return null;
  if (id.equals(StringValueHelper.id()))
    return "";
  StringTokenizer st = new StringTokenizer(id, ":");

  String prefix = st.nextToken();
  if (prefix.equalsIgnoreCase("IDL"))
    return ObjectCreator.Idl2Object(id);
  else if (prefix.equalsIgnoreCase("RMI"))
    {
      String className = st.nextToken();
      String hashCode = st.nextToken();
      String sid = null;
      if (st.hasMoreElements())
        sid = st.nextToken();

      try
        {
          Class objectClass = Util.loadClass(className, codebase,
            Vio.class.getClassLoader());

          String rid = ObjectCreator.getRepositoryId(objectClass);

          if (!rid.equals(id))
            {
              // If direct string comparison fails, compare by meaning.
              StringTokenizer st2 = new StringTokenizer(rid, ":");
              if (!st2.nextToken().equals("RMI"))
                throw new InternalError("RMI format expected: '" + rid + "'");
              if (!st2.nextToken().equals(className))
                throwIt("Class name mismatch", id, rid, null);

              try
                {
                  long h1 = Long.parseLong(hashCode, 16);
                  long h2 = Long.parseLong(st2.nextToken(), 16);
                  if (h1 != h2)
                    throwIt("Hashcode mismatch", id, rid, null);

                  if (sid != null && st2.hasMoreTokens())
                    {
                      long s1 = Long.parseLong(hashCode, 16);
                      long s2 = Long.parseLong(st2.nextToken(), 16);
                      if (s1 != s2)
                        throwIt("serialVersionUID mismatch", id, rid, null);
                    }
                }
              catch (NumberFormatException e)
                {
                  throwIt("Invalid hashcode or svuid format: ", id, rid, e);
                }
            }

          // Low - level instantiation required here.
          return instantiateAnyWay(objectClass);
        }
      catch (Exception ex)
        {
          MARSHAL m = new MARSHAL("Unable to instantiate " + id);
          m.minor = Minor.Instantiation;
          m.initCause(ex);
          throw m;
        }
    }
  else
    throw new NO_IMPLEMENT("Unsupported prefix " + prefix + ":");
}