435 Context cctx = NamingManager.getContinuationContext(e); 436 answer = cctx.getNameParser(e.getRemainingName()); 437 } 438 return answer; 439 } 440 441 public String composeName(String name, String prefix) 442 throws NamingException { 443 Name fullName = composeName(new CompositeName(name), 444 new CompositeName(prefix)); 445 return fullName.toString(); 446 } 447 448 /** 449 * This default implementation simply concatenates the two names. 450 * There's one twist when the "java.naming.provider.compose.elideEmpty" 451 * environment setting is set to "true": if each name contains a 452 * nonempty component, and if 'prefix' ends with an empty component or 453 * 'name' starts with one, then one empty component is dropped. 454 * For example: 455 * <pre> 456 * elideEmpty=false elideEmpty=true 457 * {"a"} + {"b"} => {"a", "b"} {"a", "b"} 458 * {"a"} + {""} => {"a", ""} {"a", ""} 459 * {"a"} + {"", "b"} => {"a", "", "b"} {"a", "b"} 460 * {"a", ""} + {"b", ""} => {"a", "", "b", ""} {"a", "b", ""} 461 * {"a", ""} + {"", "b"} => {"a", "", "", "b"} {"a", "", "b"} 462 * </pre> 463 */ 464 public Name composeName(Name name, Name prefix) throws NamingException { 465 Name res = (Name)prefix.clone(); 466 if (name == null) { 467 return res; 468 } 469 res.addAll(name); 470 471 String elide = (String) 472 p_getEnvironment().get("java.naming.provider.compose.elideEmpty"); 473 if (elide == null || !elide.equalsIgnoreCase("true")) { 474 return res; 475 } 476 477 int len = prefix.size(); 478 479 if (!allEmpty(prefix) && !allEmpty(name)) { 480 if (res.get(len - 1).equals("")) { 481 res.remove(len - 1); 482 } else if (res.get(len).equals("")) { | 435 Context cctx = NamingManager.getContinuationContext(e); 436 answer = cctx.getNameParser(e.getRemainingName()); 437 } 438 return answer; 439 } 440 441 public String composeName(String name, String prefix) 442 throws NamingException { 443 Name fullName = composeName(new CompositeName(name), 444 new CompositeName(prefix)); 445 return fullName.toString(); 446 } 447 448 /** 449 * This default implementation simply concatenates the two names. 450 * There's one twist when the "java.naming.provider.compose.elideEmpty" 451 * environment setting is set to "true": if each name contains a 452 * nonempty component, and if 'prefix' ends with an empty component or 453 * 'name' starts with one, then one empty component is dropped. 454 * For example: 455 * <pre>{@code 456 * elideEmpty=false elideEmpty=true 457 * {"a"} + {"b"} => {"a", "b"} {"a", "b"} 458 * {"a"} + {""} => {"a", ""} {"a", ""} 459 * {"a"} + {"", "b"} => {"a", "", "b"} {"a", "b"} 460 * {"a", ""} + {"b", ""} => {"a", "", "b", ""} {"a", "b", ""} 461 * {"a", ""} + {"", "b"} => {"a", "", "", "b"} {"a", "", "b"} 462 * }</pre> 463 */ 464 public Name composeName(Name name, Name prefix) throws NamingException { 465 Name res = (Name)prefix.clone(); 466 if (name == null) { 467 return res; 468 } 469 res.addAll(name); 470 471 String elide = (String) 472 p_getEnvironment().get("java.naming.provider.compose.elideEmpty"); 473 if (elide == null || !elide.equalsIgnoreCase("true")) { 474 return res; 475 } 476 477 int len = prefix.size(); 478 479 if (!allEmpty(prefix) && !allEmpty(name)) { 480 if (res.get(len - 1).equals("")) { 481 res.remove(len - 1); 482 } else if (res.get(len).equals("")) { |