@Test public void testSplitIntoPackages() { Set<String> pkgs = OsgiUtils.splitIntoPackages( "org.apache.log4j.net;uses:=\"org.apache.log4j,org.apache.log4j.spi," + "javax.naming,org.apache.log4j.helpers,javax.jms,org.apache.log4j.xml," + "javax.mail,javax.mail.internet,org.w3c.dom,javax.jmdns\"," + "org.apache.log4j.jmx;uses:=\"org.apache.log4j,javax.management," + "com.sun.jdmk.comm,org.apache.log4j.helpers,org.apache.log4j.spi\"," + "org.apache.log4j.jdbc;uses:=\"org.apache.log4j,org.apache.log4j.spi\"," + "org.apache.log4j.config;uses:=\"org.apache.log4j.helpers,org.apache.log4j," + "org.apache.log4j.spi\",org.apache.log4j.helpers;uses:=\"org.apache.log4j," + "org.apache.log4j.spi,org.apache.log4j.pattern\",org.apache.log4j;uses:=\"" + "org.apache.log4j.spi,org.apache.log4j.helpers,org.apache.log4j.pattern," + "org.apache.log4j.or,org.apache.log4j.config\",org.apache.log4j.or.jms;" + "uses:=\"org.apache.log4j.helpers,javax.jms,org.apache.log4j.or\"," + "org.apache.log4j.nt;uses:=\"org.apache.log4j.helpers,org.apache.log4j," + "org.apache.log4j.spi\",org.apache.log4j.or.sax;uses:=\"org.apache.log4j.or," + "org.xml.sax\",org.apache.log4j.pattern;uses:=\"org.apache.log4j.helpers," + "org.apache.log4j.spi,org.apache.log4j,org.apache.log4j.or\"," + "org.apache.log4j.spi;uses:=\"org.apache.log4j,org.apache.log4j.helpers," + "com.ibm.uvm.tools,org.apache.log4j.or\",org.apache.log4j.or;uses:=\"" + "org.apache.log4j.helpers,org.apache.log4j.spi,org.apache.log4j\"," + "org.apache.log4j.xml;uses:=\"javax.xml.parsers,org.w3c.dom,org.xml.sax," + "org.apache.log4j.config,org.apache.log4j.helpers,org.apache.log4j," + "org.apache.log4j.spi,org.apache.log4j.or\",org.apache.log4j.varia;uses:=\"" + "org.apache.log4j.spi,org.apache.log4j,org.apache.log4j.helpers\"", null ); assertTrue( pkgs.contains( "org.apache.log4j.net" ), "org.apache.log4j.net" ); assertTrue( pkgs.contains( "org.apache.log4j.jmx" ), "org.apache.log4j.jmx" ); assertTrue( pkgs.contains( "org.apache.log4j.jdbc" ), "org.apache.log4j.jdbc" ); assertTrue( pkgs.contains( "org.apache.log4j.config" ), "org.apache.log4j.config" ); assertTrue( pkgs.contains( "org.apache.log4j.helpers" ), "org.apache.log4j.helpers" ); assertTrue( pkgs.contains( "org.apache.log4j" ), "org.apache.log4j" ); assertTrue( pkgs.contains( "org.apache.log4j.or" ), "org.apache.log4j.or" ); assertTrue( pkgs.contains( "org.apache.log4j.or.jms" ), "org.apache.log4j.or.jms" ); assertTrue( pkgs.contains( "org.apache.log4j.or.sax" ), "org.apache.log4j.or.sax" ); assertTrue( pkgs.contains( "org.apache.log4j.nt" ), "org.apache.log4j.nt" ); assertTrue( pkgs.contains( "org.apache.log4j.spi" ), "org.apache.log4j.spi" ); assertTrue( pkgs.contains( "org.apache.log4j.pattern" ), "org.apache.log4j.pattern" ); assertTrue( pkgs.contains( "org.apache.log4j.xml" ), "org.apache.log4j.xml" ); assertTrue( pkgs.contains( "org.apache.log4j.varia" ), "org.apache.log4j.varia" ); assertEquals( 14, pkgs.size(), "Expecting 14 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 );  }