*/
public org.omg.CosNaming.NameComponent[] to_name(String sn)
throws org.omg.CosNaming.NamingContextPackage.InvalidName {
// must have a argument to parse
if (sn == null || sn.length() == 0) {
throw new InvalidName();
}
List components = new ArrayList();
StringBuffer component = new StringBuffer();
int index = 0;
String id = null;
String kind = null;
while (index < sn.length()) {
char ch = sn.charAt(index++);
// found an escape character or a delimiter?
if (ch == '\\') {
// nothing after the escape? Trouble
if (index >= sn.length()) {
throw new InvalidName();
}
// get the next character
ch = sn.charAt(index++);
component.append(ch);
}
// we need to process the periods here, to avoid getting
// mixed up with unescaped periods.
else if (ch == '.') {
// already seen a period while scanning? That's not allowed
if (id != null) {
throw new InvalidName();
}
// pull off the id piece and reset the buffer
id = component.toString();
component.setLength(0);
}