@Test public void testProtocolPrefix() throws Exception { String uri = "http: assertEquals( true, FileManipulator.protocolExists( uri ) ); uri = "uri"; assertEquals( false, FileManipulator.protocolExists( uri ) ); uri = "zip:file:/test"; assertEquals( true, FileManipulator.protocolExists( uri ) ); }
public static boolean protocolExists( String path ) { LOGGER.debug( "Looking for protocol in {}", path ); PatternMatcher matcher = new Perl5Matcher(); PatternCompiler compiler = new Perl5Compiler(); Pattern pattern = null; try { pattern = compiler.compile( FileManipulator.PROTOCOL_REGEX ); } catch ( MalformedPatternException malformedPatternException ) { LOGGER.warn( "URL protocol check failed", malformedPatternException ); return false; } PatternMatcherInput input = new PatternMatcherInput( path ); if ( matcher.contains( input, pattern ) ) { LOGGER.debug( "{} matches the protocol regex" ); return true; } LOGGER.debug( "{} doesn't match the protocol regex" ); return false; }
FileManipulator { public static boolean protocolExists( String path ) { LOGGER.debug( "Looking for protocol in {}", path ); PatternMatcher matcher = new Perl5Matcher(); PatternCompiler compiler = new Perl5Compiler(); Pattern pattern = null; try { pattern = compiler.compile( FileManipulator.PROTOCOL_REGEX ); } catch ( MalformedPatternException malformedPatternException ) { LOGGER.warn( "URL protocol check failed", malformedPatternException ); return false; } PatternMatcherInput input = new PatternMatcherInput( path ); if ( matcher.contains( input, pattern ) ) { LOGGER.debug( "{} matches the protocol regex" ); return true; } LOGGER.debug( "{} doesn't match the protocol regex" ); return false; } }
FileManipulator { public static boolean protocolExists( String path ) { LOGGER.debug( "Looking for protocol in {}", path ); PatternMatcher matcher = new Perl5Matcher(); PatternCompiler compiler = new Perl5Compiler(); Pattern pattern = null; try { pattern = compiler.compile( FileManipulator.PROTOCOL_REGEX ); } catch ( MalformedPatternException malformedPatternException ) { LOGGER.warn( "URL protocol check failed", malformedPatternException ); return false; } PatternMatcherInput input = new PatternMatcherInput( path ); if ( matcher.contains( input, pattern ) ) { LOGGER.debug( "{} matches the protocol regex" ); return true; } LOGGER.debug( "{} doesn't match the protocol regex" ); return false; } FileManipulator(); }
FileManipulator { public static boolean protocolExists( String path ) { LOGGER.debug( "Looking for protocol in {}", path ); PatternMatcher matcher = new Perl5Matcher(); PatternCompiler compiler = new Perl5Compiler(); Pattern pattern = null; try { pattern = compiler.compile( FileManipulator.PROTOCOL_REGEX ); } catch ( MalformedPatternException malformedPatternException ) { LOGGER.warn( "URL protocol check failed", malformedPatternException ); return false; } PatternMatcherInput input = new PatternMatcherInput( path ); if ( matcher.contains( input, pattern ) ) { LOGGER.debug( "{} matches the protocol regex" ); return true; } LOGGER.debug( "{} doesn't match the protocol regex" ); return false; } FileManipulator(); void close(); static String getBaseDir(); FileObject resolveFile( String vfsPath ); boolean exists( String vfsPath ); boolean contentEquals( String src, String dest ); boolean checksumEquals( String src, String dest ); void copy( String src, String dest ); boolean isFolder( String vfsPath ); FileObject[] browse( String vfsPath ); InputStream read( String vfsPath ); OutputStream write( String vfsPath ); static String createEnvironmentCacheDir( Environment environment ); static String createJEEApplicationCacheDir( Environment environment, JEEApplication jeeApplication ); static String createSoftwareCacheDir( Environment environment, Software software ); void createDirectory( String path ); static boolean protocolExists( String path ); static String format( String url ); void delete( String path ); static void searchAndReplace( String path, String regex, String substitute ); }
FileManipulator { public static boolean protocolExists( String path ) { LOGGER.debug( "Looking for protocol in {}", path ); PatternMatcher matcher = new Perl5Matcher(); PatternCompiler compiler = new Perl5Compiler(); Pattern pattern = null; try { pattern = compiler.compile( FileManipulator.PROTOCOL_REGEX ); } catch ( MalformedPatternException malformedPatternException ) { LOGGER.warn( "URL protocol check failed", malformedPatternException ); return false; } PatternMatcherInput input = new PatternMatcherInput( path ); if ( matcher.contains( input, pattern ) ) { LOGGER.debug( "{} matches the protocol regex" ); return true; } LOGGER.debug( "{} doesn't match the protocol regex" ); return false; } FileManipulator(); void close(); static String getBaseDir(); FileObject resolveFile( String vfsPath ); boolean exists( String vfsPath ); boolean contentEquals( String src, String dest ); boolean checksumEquals( String src, String dest ); void copy( String src, String dest ); boolean isFolder( String vfsPath ); FileObject[] browse( String vfsPath ); InputStream read( String vfsPath ); OutputStream write( String vfsPath ); static String createEnvironmentCacheDir( Environment environment ); static String createJEEApplicationCacheDir( Environment environment, JEEApplication jeeApplication ); static String createSoftwareCacheDir( Environment environment, Software software ); void createDirectory( String path ); static boolean protocolExists( String path ); static String format( String url ); void delete( String path ); static void searchAndReplace( String path, String regex, String substitute );  }