public static String packageName(IPath pkgPath,String sourceLevel,String complianceLevel){
  StringBuffer pkgName=new StringBuffer(IPackageFragment.DEFAULT_PACKAGE_NAME);
  for (int j=0, max=pkgPath.segmentCount(); j < max; j++) {
    String segment=pkgPath.segment(j);
    if (!isValidFolderNameForPackage(segment,sourceLevel,complianceLevel)) {
      return null;
    }
    pkgName.append(segment);
    if (j < pkgPath.segmentCount() - 1) {
      pkgName.append(".");
    }
  }
  return pkgName.toString();
}

public static String packageName ( IPath pkgPath , String sourceLevel , String complianceLevel ) { StringBuffer pkgName = new StringBuffer ( IPackageFragment . DEFAULT_PACKAGE_NAME ) ; for ( int j = 0 , max = pkgPath . segmentCount ( ) ; j < max ; j ++ ) { String segment = pkgPath . segment ( j ) ; if ( ! isValidFolderNameForPackage ( segment , sourceLevel , complianceLevel ) ) { return null ; } pkgName . append ( segment ) ; if ( j < pkgPath . segmentCount ( ) - 1 ) { pkgName . append ( "." ) ; } } return pkgName . toString ( ) ; }
converts the given relative path into a package name . returns null if the path is not a valid package name .
