private static NameComponent parseComponent(String compStr) throws InvalidNameException {
  NameComponent comp=new NameComponent();
  int kindSep=-1;
  int len=compStr.length();
  int j=0;
  char[] newStr=new char[len];
  boolean escaped=false;
  for (int i=0; i < len && kindSep < 0; i++) {
    if (escaped) {
      newStr[j++]=compStr.charAt(i);
      escaped=false;
    }
 else     if (compStr.charAt(i) == escapeChar) {
      if (i + 1 >= len) {
        throw new InvalidNameException(compStr + ": unescaped \\ at end of component");
      }
 else       if (isMeta(compStr.charAt(i + 1))) {
        escaped=true;
      }
 else {
        throw new InvalidNameException(compStr + ": invalid character being escaped");
      }
    }
 else     if (compStr.charAt(i) == kindSeparator) {
      kindSep=i;
    }
 else {
      newStr[j++]=compStr.charAt(i);
    }
  }
  comp.id=new String(newStr,0,j);
  if (kindSep < 0) {
    comp.kind="";
  }
 else {
    j=0;
    escaped=false;
    for (int i=kindSep + 1; i < len; i++) {
      if (escaped) {
        newStr[j++]=compStr.charAt(i);
        escaped=false;
      }
 else       if (compStr.charAt(i) == escapeChar) {
        if (i + 1 >= len) {
          throw new InvalidNameException(compStr + ": unescaped \\ at end of component");
        }
 else         if (isMeta(compStr.charAt(i + 1))) {
          escaped=true;
        }
 else {
          throw new InvalidNameException(compStr + ": invalid character being escaped");
        }
      }
 else {
        newStr[j++]=compStr.charAt(i);
      }
    }
    comp.kind=new String(newStr,0,j);
  }
  return comp;
}

private static NameComponent parseComponent ( String compStr ) throws InvalidNameException { NameComponent comp = new NameComponent ( ) ; int kindSep = - 1 ; int len = compStr . length ( ) ; int j = 0 ; char [ ] newStr = new char [ len ] ; boolean escaped = false ; for ( int i = 0 ; i < len && kindSep < 0 ; i ++ ) { if ( escaped ) { newStr [ j ++ ] = compStr . charAt ( i ) ; escaped = false ; } else if ( compStr . charAt ( i ) == escapeChar ) { if ( i + 1 >= len ) { throw new InvalidNameException ( compStr + ": unescaped \\ at end of component" ) ; } else if ( isMeta ( compStr . charAt ( i + 1 ) ) ) { escaped = true ; } else { throw new InvalidNameException ( compStr + ": invalid character being escaped" ) ; } } else if ( compStr . charAt ( i ) == kindSeparator ) { kindSep = i ; } else { newStr [ j ++ ] = compStr . charAt ( i ) ; } } comp . id = new String ( newStr , 0 , j ) ; if ( kindSep < 0 ) { comp . kind = "" ; } else { j = 0 ; escaped = false ; for ( int i = kindSep + 1 ; i < len ; i ++ ) { if ( escaped ) { newStr [ j ++ ] = compStr . charAt ( i ) ; escaped = false ; } else if ( compStr . charAt ( i ) == escapeChar ) { if ( i + 1 >= len ) { throw new InvalidNameException ( compStr + ": unescaped \\ at end of component" ) ; } else if ( isMeta ( compStr . charAt ( i + 1 ) ) ) { escaped = true ; } else { throw new InvalidNameException ( compStr + ": invalid character being escaped" ) ; } } else { newStr [ j ++ ] = compStr . charAt ( i ) ; } } comp . kind = new String ( newStr , 0 , j ) ; } return comp ; }
return a namecomponent given its stringified form .
