From: Alex Blewitt Date: Thu, 3 Jun 2010 23:38:50 +0000 (+0100) Subject: Provide a public entry method to determine whether a URI protocol is supported X-Git-Tag: v0.9.1~212 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=046d1a2ef6ddea2a9521ac49ae339e05c1cc0acd;p=jgit.git Provide a public entry method to determine whether a URI protocol is supported --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java index c0b2eedc00..2fe3cb9326 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/Transport.java @@ -318,6 +318,38 @@ public abstract class Transport { return cfg.getURIs().isEmpty() && cfg.getPushURIs().isEmpty(); } + /** + * Determines whether the transport can handle the given URIish. + * + * @param remote + * location of the remote repository. + * @return true if the protocol is supported. + */ + public static boolean canHandleProtocol(final URIish remote) { + if (TransportGitSsh.canHandle(remote)) + return true; + + else if (TransportHttp.canHandle(remote)) + return true; + + else if (TransportSftp.canHandle(remote)) + return true; + + else if (TransportGitAnon.canHandle(remote)) + return true; + + else if (TransportAmazonS3.canHandle(remote)) + return true; + + else if (TransportBundleFile.canHandle(remote)) + return true; + + else if (TransportLocal.canHandle(remote)) + return true; + + return false; + } + /** * Open a new transport instance to connect two repositories. *