@Test public void testDecodeUrl() { String path = "/app/version/img.jpg"; Map.Entry<String,String> entry = IconUtils.decodeIconUrl( path ); Assert.assertEquals( "app", entry.getKey()); Assert.assertEquals( "version", entry.getValue()); path = "app/version/img.jpg"; entry = IconUtils.decodeIconUrl( path ); Assert.assertEquals( "app", entry.getKey()); Assert.assertEquals( "version", entry.getValue()); path = "app/version/oops/"; entry = IconUtils.decodeIconUrl( path ); Assert.assertEquals( "app", entry.getKey()); Assert.assertEquals( "version", entry.getValue()); path = "/app/version/oops/"; entry = IconUtils.decodeIconUrl( path ); Assert.assertEquals( "app", entry.getKey()); Assert.assertEquals( "version", entry.getValue()); path = "app/version/oops.jpg/whatever"; entry = IconUtils.decodeIconUrl( path ); Assert.assertNull( entry.getKey()); Assert.assertNull( entry.getValue()); }
public static Map.Entry<String,String> decodeIconUrl( String path ) { if( path.startsWith( "/" )) path = path.substring( 1 ); String name = null, version = null; String[] parts = path.split( "/" ); switch( parts.length ) { case 2: name = parts[ 0 ]; break; case 3: name = parts[ 0 ]; version = parts[ 1 ]; break; default: break; } return new AbstractMap.SimpleEntry<>( name, version ); }
IconUtils { public static Map.Entry<String,String> decodeIconUrl( String path ) { if( path.startsWith( "/" )) path = path.substring( 1 ); String name = null, version = null; String[] parts = path.split( "/" ); switch( parts.length ) { case 2: name = parts[ 0 ]; break; case 3: name = parts[ 0 ]; version = parts[ 1 ]; break; default: break; } return new AbstractMap.SimpleEntry<>( name, version ); } }
IconUtils { public static Map.Entry<String,String> decodeIconUrl( String path ) { if( path.startsWith( "/" )) path = path.substring( 1 ); String name = null, version = null; String[] parts = path.split( "/" ); switch( parts.length ) { case 2: name = parts[ 0 ]; break; case 3: name = parts[ 0 ]; version = parts[ 1 ]; break; default: break; } return new AbstractMap.SimpleEntry<>( name, version ); } private  IconUtils(); }
IconUtils { public static Map.Entry<String,String> decodeIconUrl( String path ) { if( path.startsWith( "/" )) path = path.substring( 1 ); String name = null, version = null; String[] parts = path.split( "/" ); switch( parts.length ) { case 2: name = parts[ 0 ]; break; case 3: name = parts[ 0 ]; version = parts[ 1 ]; break; default: break; } return new AbstractMap.SimpleEntry<>( name, version ); } private  IconUtils(); static String encodeIconUrl( String name, String version, File iconFile ); static Map.Entry<String,String> decodeIconUrl( String path ); static File findIcon( AbstractApplication app ); static String findIconUrl( AbstractApplication app ); static String findMimeType( File imgFile ); static File findIcon( File rootDirectory ); }
IconUtils { public static Map.Entry<String,String> decodeIconUrl( String path ) { if( path.startsWith( "/" )) path = path.substring( 1 ); String name = null, version = null; String[] parts = path.split( "/" ); switch( parts.length ) { case 2: name = parts[ 0 ]; break; case 3: name = parts[ 0 ]; version = parts[ 1 ]; break; default: break; } return new AbstractMap.SimpleEntry<>( name, version ); } private  IconUtils(); static String encodeIconUrl( String name, String version, File iconFile ); static Map.Entry<String,String> decodeIconUrl( String path ); static File findIcon( AbstractApplication app ); static String findIconUrl( AbstractApplication app ); static String findMimeType( File imgFile ); static File findIcon( File rootDirectory ); static final String MIME_JPG; static final String MIME_PNG; static final String MIME_SVG; static final String MIME_GIF; static final String MIME_BINARY; }