1 7 8 package com.sun.corba.se.impl.naming.cosnaming; 9 10 import java.io.*; 11 import org.omg.CosNaming.NameComponent ; 12 13 14 public class NamingUtils { 15 private NamingUtils() {}; 17 18 22 public static boolean debug = false; 23 24 28 public static void dprint(String msg) { 29 if (debug && debugStream != null) 30 debugStream.println(msg); 31 } 32 33 37 public static void errprint(String msg) { 38 if (errStream != null) 39 errStream.println(msg); 40 else 41 System.err.println(msg); 42 } 43 44 48 public static void printException(java.lang.Exception e) { 49 if (errStream != null) 50 e.printStackTrace(errStream); 51 else 52 e.printStackTrace(); 53 } 54 55 60 public static void makeDebugStream(File logFile) 61 throws java.io.IOException { 62 java.io.OutputStream logOStream = 64 new java.io.FileOutputStream (logFile); 65 java.io.DataOutputStream logDStream = 66 new java.io.DataOutputStream (logOStream); 67 debugStream = new java.io.PrintStream (logDStream); 68 69 debugStream.println("Debug Stream Enabled."); 71 } 72 73 78 public static void makeErrStream(File errFile) 79 throws java.io.IOException { 80 if (debug) { 81 java.io.OutputStream errOStream = 83 new java.io.FileOutputStream (errFile); 84 java.io.DataOutputStream errDStream = 85 new java.io.DataOutputStream (errOStream); 86 errStream = new java.io.PrintStream (errDStream); 87 dprint("Error stream setup completed."); 88 } 89 } 90 91 92 97 static String getDirectoryStructuredName( NameComponent [] name ) { 98 StringBuffer directoryStructuredName = new StringBuffer ("/"); 99 for( int i = 0; i < name.length; i++ ) { 100 directoryStructuredName.append( name[i].id + "." + name[i].kind ); 101 } 102 return directoryStructuredName.toString( ); 103 } 104 105 108 public static java.io.PrintStream debugStream; 109 110 113 public static java.io.PrintStream errStream; 114 } 115 | Popular Tags |