You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by ri...@apache.org on 2007/02/08 16:49:29 UTC

svn commit: r504952 - /incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java

Author: rickmcguire
Date: Thu Feb  8 08:49:28 2007
New Revision: 504952

URL: http://svn.apache.org/viewvc?view=rev&rev=504952
Log:
YOKO-287 IORDump could use some methods that return strings


Modified:
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java?view=diff&rev=504952&r1=504951&r2=504952
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java Thu Feb  8 08:49:28 2007
@@ -17,9 +17,21 @@
 
 package org.apache.yoko.orb.OB;
 
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
 import java.util.Properties;
 
 public class IORDump {
+
+    public static String PrintObjref(org.omg.CORBA.ORB orb,
+            org.omg.IOP.IOR ior) {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        PrintStream ps = new PrintStream(baos);
+        PrintObjref(orb, ps, ior);
+        ps.flush();
+        return baos.toString();
+    }
+
     static public void PrintObjref(org.omg.CORBA.ORB orb, java.io.PrintStream out,
             org.omg.IOP.IOR ior) {
         out.println("type_id: " + ior.type_id);
@@ -86,8 +98,19 @@
     }
 
     static public void DumpIOR(org.omg.CORBA.ORB orb, String ref, boolean hasEndian) {
+        DumpIOR(orb, ref, hasEndian, System.out);
+    }
+
+    static public String DumpIORToString(org.omg.CORBA.ORB orb, String ref, boolean hasEndian) {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        PrintStream ps = new PrintStream(baos);
+        DumpIOR(orb, ref, hasEndian, ps);
+        return baos.toString();
+    }
+
+    static public void DumpIOR(org.omg.CORBA.ORB orb, String ref, boolean hasEndian, PrintStream ps) {
         if (!ref.startsWith("IOR:")) {
-            System.out.println("IOR is invalid");
+            ps.println("IOR is invalid");
             return;
         }
 
@@ -98,19 +121,19 @@
                 buf);
 
         boolean endian = in.read_boolean();
-        in._OB_swap(endian != false);
+        in._OB_swap(endian);
 
         org.omg.IOP.IOR ior = org.omg.IOP.IORHelper.read(in);
 
-        System.out.print("byteorder: ");
+        ps.print("byteorder: ");
         if (hasEndian)
-            System.out.println((endian ? "little" : "big") + " endian");
+            ps.println((endian ? "little" : "big") + " endian");
         else
-            System.out.println("n/a");
+            ps.println("n/a");
 
-        PrintObjref(orb, System.out, ior);
+        PrintObjref(orb, ps, ior);
 
-        System.out.flush();
+        ps.flush();
     }
 
     static void usage() {
@@ -250,7 +273,7 @@
         props.put("org.omg.CORBA.ORBSingletonClass",
                 "org.apache.yoko.orb.CORBA.ORBSingleton");
 
-        int status = 0;
+        int status;
         org.omg.CORBA.ORB orb = null;
 
         try {