< prev index next >

src/java.corba/share/classes/com/sun/jndi/cosnaming/CNNameParser.java

Print this page
rev 10947 : 8055723: Replace concat String to append in StringBuilder parameters


 239                         throw new InvalidNameException(compStr +
 240                             ": unescaped \\ at end of component");
 241                     } else if (isMeta(compStr.charAt(i+1))) {
 242                         escaped = true;
 243                     } else {
 244                         throw new InvalidNameException(compStr +
 245                             ": invalid character being escaped");
 246                     }
 247                 } else {
 248                     newStr[j++] = compStr.charAt(i);
 249                 }
 250             }
 251             comp.kind = new String(newStr, 0, j);
 252         }
 253         return comp;
 254     }
 255 
 256     private static String stringifyComponent(NameComponent comp) {
 257         StringBuilder one = new StringBuilder(escape(comp.id));
 258         if (comp.kind != null && !comp.kind.equals("")) {
 259             one.append(kindSeparator + escape(comp.kind));
 260         }
 261         if (one.length() == 0) {
 262             return ""+kindSeparator;  // if neither id nor kind specified
 263         } else {
 264             return one.toString();
 265         }
 266     }
 267 
 268     /**
 269      * Returns a string with '.', '\', '/' escaped. Used when
 270      * stringifying the name into its INS stringified form.
 271      */
 272     private static String escape(String str) {
 273         if (str.indexOf(kindSeparator) < 0 &&
 274             str.indexOf(compSeparator) < 0 &&
 275             str.indexOf(escapeChar) < 0) {
 276             return str;                         // no meta characters to escape
 277         } else {
 278             int len = str.length();
 279             int j = 0;




 239                         throw new InvalidNameException(compStr +
 240                             ": unescaped \\ at end of component");
 241                     } else if (isMeta(compStr.charAt(i+1))) {
 242                         escaped = true;
 243                     } else {
 244                         throw new InvalidNameException(compStr +
 245                             ": invalid character being escaped");
 246                     }
 247                 } else {
 248                     newStr[j++] = compStr.charAt(i);
 249                 }
 250             }
 251             comp.kind = new String(newStr, 0, j);
 252         }
 253         return comp;
 254     }
 255 
 256     private static String stringifyComponent(NameComponent comp) {
 257         StringBuilder one = new StringBuilder(escape(comp.id));
 258         if (comp.kind != null && !comp.kind.equals("")) {
 259             one.append(kindSeparator).append(escape(comp.kind));
 260         }
 261         if (one.length() == 0) {
 262             return ""+kindSeparator;  // if neither id nor kind specified
 263         } else {
 264             return one.toString();
 265         }
 266     }
 267 
 268     /**
 269      * Returns a string with '.', '\', '/' escaped. Used when
 270      * stringifying the name into its INS stringified form.
 271      */
 272     private static String escape(String str) {
 273         if (str.indexOf(kindSeparator) < 0 &&
 274             str.indexOf(compSeparator) < 0 &&
 275             str.indexOf(escapeChar) < 0) {
 276             return str;                         // no meta characters to escape
 277         } else {
 278             int len = str.length();
 279             int j = 0;


< prev index next >