public static int run()

in yoko-core/src/main/java/org/apache/yoko/orb/OB/IORDump.java [149:265]


    public static int run(org.omg.CORBA.ORB orb, String[] args)
            throws org.omg.CORBA.UserException {
        //
        // Get options
        //
        boolean files = false;
        int i;
        for (i = 0; i < args.length && args[i].charAt(0) == '-'; i++) {
            if (args[i].equals("--help") || args[i].equals("-h")) {
                usage();
                return 0;
            } else if (args[i].equals("--version") || args[i].equals("-v")) {
                System.out.println("Yoko " + Version.getVersion());
                return 0;
            } else if (args[i].equals("-f")) {
                files = true;
            } else {
                System.err.println("IORDump: unknown option `" + args[i] + "'");
                usage();
                return 1;
            }
        }

        if (i == args.length) {
            System.err.println("IORDump: no IORs");
            System.err.println();
            usage();
            return 1;
        }

        if (!files) {
            if (!args[i].startsWith("IOR:") && !args[i].startsWith("corbaloc:")
                    && !args[i].startsWith("corbaname:")
                    && !args[i].startsWith("file:")
                    && !args[i].startsWith("relfile:")) {
                System.err.println("[No valid IOR found on the command "
                        + "line, assuming -f]");
                files = true;
            }
        }

        if (!files) {
            //
            // Dump all IORs given as arguments
            //
            int count = 0;
            for (; i < args.length; i++) {
                if (count > 0)
                    System.out.println();
                System.out.println("IOR #" + (++count) + ':');

                try {
                    //
                    // The byte order can only be preserved for IOR: URLs
                    //
                    if (args[i].startsWith("IOR:"))
                        DumpIOR(orb, args[i], true);
                    else {
                        //
                        // Let string_to_object do the dirty work
                        //
                        org.omg.CORBA.Object obj = orb
                                .string_to_object(args[i]);
                        String s = orb.object_to_string(obj);
                        DumpIOR(orb, s, false);
                    }
                } catch (org.omg.CORBA.BAD_PARAM ex) {
                    System.err.println("IOR is invalid");
                }
            }
        } else {
            //
            // Dump all IORs from the specified files
            //
            int count = 0;
            for (; i < args.length; i++) {
                try {
                    java.io.FileReader fin = new java.io.FileReader(args[i]);
                    java.io.BufferedReader in = new java.io.BufferedReader(fin);
                    String line;
                    while ((line = in.readLine()) != null) {
                        if (line.length() > 0) {
                            if (count > 0)
                                System.out.println();
                            System.out.println("IOR #" + (++count) + ':');

                            //
                            // The byte order can only be preserved for
                            // IOR: URLs
                            //
                            if (line.startsWith("IOR:"))
                                DumpIOR(orb, line, true);
                            else {
                                //
                                // Let string_to_object do the dirty work
                                //
                                org.omg.CORBA.Object obj = orb
                                        .string_to_object(line);
                                String s = orb.object_to_string(obj);
                                DumpIOR(orb, s, false);
                            }
                        }
                    }
                } catch (java.io.FileNotFoundException ex) {
                    System.err.println("IORDump: can't open `" + args[i]
                            + "': " + ex);
                    return 1;
                } catch (java.io.IOException ex) {
                    System.err.println("IORDump: can't read `" + args[i]
                            + "': " + ex);
                    return 1;
                }
            }
        }

        return 0;
    }