1 2 /* 3 4 The author of this software is Ian Kaplan 5 Bear Products International 6 www.bearcave.com 7 iank@bearcave.com 8 9 Copyright (c) Ian Kaplan, 1999, 2000 10 11 See copyright file for usage and licensing 12 13 */ 14 15 package util; 16 17 public final class objNameFormat { 18 19 // 20 // toDotSeparator 21 // 22 // This function is passed a String for an object name in internal 23 // form, with slash separators and returns a String for the object 24 // name with dot separators. 25 // 26 // Some objects names may be terminated by a semicolon. I have not 27 // seen this explicitly discussed in the JVM Specification, but an 28 // example is shown in section 4.3.2. In any case, the semicolon 29 // is skipped in the code below. 30 // 31 public static String toDotSeparator( String slashName ) { 32 String newName = null; 33 34 if (slashName != null) { 35 int len; 36 char ch; 37 38 StringBuffer strBuf = new StringBuffer(); 39 40 len = slashName.length(); 41 for (int i = 0; i < len; i++) { 42 ch = slashName.charAt( i ); 43 if (ch == '/') { 44 strBuf.append( '.' ); 45 } 46 else if (ch != ';') { 47 strBuf.append( ch ); 48 } 49 } // for 50 newName = strBuf.toString(); 51 } // if 52 return newName; 53 } // toDotSeparator 54 55 56 /** 57 Return the last name (the leaf) in a "dot" name 58 sequence. For example, in the name 59 java.lang.Character, Character is the leaf name. 60 */ 61 String leafName( String name ) { 62 String leaf = null; 63 64 if (name != null) { 65 int ix; 66 67 ix = name.lastIndexOf( '.' ); 68 if (ix >= 0) { 69 leaf = name.substring( ix ); 70 } 71 } 72 return leaf; 73 } // leafName 74 75 } // objNameFormat 76