@Test public void testSplitIntoPackageVersions() { Set<String> pkgs = OsgiUtils.splitIntoPackages( "org.ops4j.store.intern;uses:=\"org.ops4j.store,org.ops4j.io,org.apache.commons.logging\";" + "version=\"1.2.2\",org.ops4j.store;uses:=\"org.ops4j.store.intern\";version=\"1.2.2", null ); assertTrue( pkgs.contains( "org.ops4j.store.intern" ), "org.ops4j.store.intern" ); assertTrue( pkgs.contains( "org.ops4j.store" ), "org.ops4j.store" ); assertEquals( 2, pkgs.size(), "Expecting 2 packages" ); }
public static Set<String> splitIntoPackages( String exports, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } int index = 0; boolean inPkg = true; boolean inProps = false; StringBuilder pkg = new StringBuilder(); while ( index < exports.length() ) { if ( inPkg && exports.charAt( index ) != ';' ) { pkg.append( exports.charAt( index ) ); index++; } else if ( inPkg && exports.charAt( index ) == ';' ) { inPkg = false; inProps = true; pkgs.add( pkg.toString() ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17002_ADDED_PACKAGE, pkg.toString() ) ); } pkg.setLength( 0 ); index += 8; } else if ( inProps && exports.charAt( index ) == '"' && index + 1 < exports.length() && exports.charAt( index + 1 ) == ',' ) { inPkg = true; inProps = false; index += 2; } else if ( inProps ) { index++; } else { LOG.error( I18n.err( I18n.ERR_17000_UNEXPECTED_PARSER_CONDITION ) ); throw new IllegalStateException( I18n.err( I18n.ERR_17068_SHOULD_NOT_GET_HERE ) ); } } return pkgs; }
OsgiUtils { public static Set<String> splitIntoPackages( String exports, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } int index = 0; boolean inPkg = true; boolean inProps = false; StringBuilder pkg = new StringBuilder(); while ( index < exports.length() ) { if ( inPkg && exports.charAt( index ) != ';' ) { pkg.append( exports.charAt( index ) ); index++; } else if ( inPkg && exports.charAt( index ) == ';' ) { inPkg = false; inProps = true; pkgs.add( pkg.toString() ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17002_ADDED_PACKAGE, pkg.toString() ) ); } pkg.setLength( 0 ); index += 8; } else if ( inProps && exports.charAt( index ) == '"' && index + 1 < exports.length() && exports.charAt( index + 1 ) == ',' ) { inPkg = true; inProps = false; index += 2; } else if ( inProps ) { index++; } else { LOG.error( I18n.err( I18n.ERR_17000_UNEXPECTED_PARSER_CONDITION ) ); throw new IllegalStateException( I18n.err( I18n.ERR_17068_SHOULD_NOT_GET_HERE ) ); } } return pkgs; } }
OsgiUtils { public static Set<String> splitIntoPackages( String exports, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } int index = 0; boolean inPkg = true; boolean inProps = false; StringBuilder pkg = new StringBuilder(); while ( index < exports.length() ) { if ( inPkg && exports.charAt( index ) != ';' ) { pkg.append( exports.charAt( index ) ); index++; } else if ( inPkg && exports.charAt( index ) == ';' ) { inPkg = false; inProps = true; pkgs.add( pkg.toString() ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17002_ADDED_PACKAGE, pkg.toString() ) ); } pkg.setLength( 0 ); index += 8; } else if ( inProps && exports.charAt( index ) == '"' && index + 1 < exports.length() && exports.charAt( index + 1 ) == ',' ) { inPkg = true; inProps = false; index += 2; } else if ( inProps ) { index++; } else { LOG.error( I18n.err( I18n.ERR_17000_UNEXPECTED_PARSER_CONDITION ) ); throw new IllegalStateException( I18n.err( I18n.ERR_17068_SHOULD_NOT_GET_HERE ) ); } } return pkgs; } private  OsgiUtils(); }
OsgiUtils { public static Set<String> splitIntoPackages( String exports, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } int index = 0; boolean inPkg = true; boolean inProps = false; StringBuilder pkg = new StringBuilder(); while ( index < exports.length() ) { if ( inPkg && exports.charAt( index ) != ';' ) { pkg.append( exports.charAt( index ) ); index++; } else if ( inPkg && exports.charAt( index ) == ';' ) { inPkg = false; inProps = true; pkgs.add( pkg.toString() ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17002_ADDED_PACKAGE, pkg.toString() ) ); } pkg.setLength( 0 ); index += 8; } else if ( inProps && exports.charAt( index ) == '"' && index + 1 < exports.length() && exports.charAt( index + 1 ) == ',' ) { inPkg = true; inProps = false; index += 2; } else if ( inProps ) { index++; } else { LOG.error( I18n.err( I18n.ERR_17000_UNEXPECTED_PARSER_CONDITION ) ); throw new IllegalStateException( I18n.err( I18n.ERR_17068_SHOULD_NOT_GET_HERE ) ); } } return pkgs; } private  OsgiUtils(); static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ); static Set<String> splitIntoPackages( String exports, Set<String> pkgs ); static Set<File> getClasspathCandidates( FileFilter filter ); static String getBundleExports( File bundle ); }
OsgiUtils { public static Set<String> splitIntoPackages( String exports, Set<String> pkgs ) { if ( pkgs == null ) { pkgs = new HashSet<>(); } int index = 0; boolean inPkg = true; boolean inProps = false; StringBuilder pkg = new StringBuilder(); while ( index < exports.length() ) { if ( inPkg && exports.charAt( index ) != ';' ) { pkg.append( exports.charAt( index ) ); index++; } else if ( inPkg && exports.charAt( index ) == ';' ) { inPkg = false; inProps = true; pkgs.add( pkg.toString() ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_17002_ADDED_PACKAGE, pkg.toString() ) ); } pkg.setLength( 0 ); index += 8; } else if ( inProps && exports.charAt( index ) == '"' && index + 1 < exports.length() && exports.charAt( index + 1 ) == ',' ) { inPkg = true; inProps = false; index += 2; } else if ( inProps ) { index++; } else { LOG.error( I18n.err( I18n.ERR_17000_UNEXPECTED_PARSER_CONDITION ) ); throw new IllegalStateException( I18n.err( I18n.ERR_17068_SHOULD_NOT_GET_HERE ) ); } } return pkgs; } private  OsgiUtils(); static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs ); static Set<String> splitIntoPackages( String exports, Set<String> pkgs ); static Set<File> getClasspathCandidates( FileFilter filter ); static String getBundleExports( File bundle );  }