FileDocCategorySizeDatePackage
NamingUtils.javaAPI DocJava SE 5 API3388Fri Aug 26 14:54:26 BST 2005com.sun.corba.se.impl.naming.cosnaming

NamingUtils

public class NamingUtils extends Object

Fields Summary
public static boolean
debug
Debug flag which must be true for debug streams to be created and dprint output to be generated.
public static PrintStream
debugStream
The debug printstream.
public static PrintStream
errStream
The error printstream.
Constructors Summary
private NamingUtils()

Methods Summary
public static voiddprint(java.lang.String msg)
Prints the message to the debug stream if debugging is enabled.

param
msg the debug message to print.


                            
         
	if (debug && debugStream != null)
	    debugStream.println(msg);
    
public static voiderrprint(java.lang.String msg)
Prints the message to the error stream (System.err is default).

param
msg the error message to print.

	if (errStream != null)
	    errStream.println(msg);
	else
	    System.err.println(msg);
    
static java.lang.StringgetDirectoryStructuredName(org.omg.CosNaming.NameComponent[] name)
A utility method that takes Array of NameComponent and converts into a directory structured name in the format of /id1.kind1/id2.kind2.. This is used mainly for Logging.

        StringBuffer directoryStructuredName = new StringBuffer("/"); 
        for( int i = 0; i < name.length; i++ ) {
            directoryStructuredName.append( name[i].id + "." + name[i].kind );
        }
        return directoryStructuredName.toString( );
    
public static voidmakeDebugStream(java.io.File logFile)
Create a debug print stream to the supplied log file.

param
logFile the file to which debug output will go.
exception
IOException thrown if the file cannot be opened for output.

	// Create an outputstream for debugging
	java.io.OutputStream logOStream =
	    new java.io.FileOutputStream(logFile);
	java.io.DataOutputStream logDStream =
	    new java.io.DataOutputStream(logOStream);
	debugStream = new java.io.PrintStream(logDStream);
      
	// Emit first message
	debugStream.println("Debug Stream Enabled.");
    
public static voidmakeErrStream(java.io.File errFile)
Create a error print stream to the supplied file.

param
logFile the file to which error messages will go.
exception
IOException thrown if the file cannot be opened for output.

	if (debug) {
	    // Create an outputstream for errors
	    java.io.OutputStream errOStream =
		new java.io.FileOutputStream(errFile);
	    java.io.DataOutputStream errDStream =
		new java.io.DataOutputStream(errOStream);
	    errStream = new java.io.PrintStream(errDStream);
	    dprint("Error stream setup completed.");
	}
    
public static voidprintException(java.lang.Exception e)
Prints the stacktrace of the supplied exception to the error stream.

param
e any Java exception.

	if (errStream != null)
	    e.printStackTrace(errStream);
	else
	    e.printStackTrace();