@Test public void testCustomProvider() throws Exception { final CommandLineParser parser = new PosixParser(); final CommandLine input = parser.parse(new Options(), new String[]{}); final ProtocolFactory factory = new ProtocolFactory(new LinkedHashSet<>(Collections.singletonList(new SwiftProtocol()))); final Profile rackspace = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Rackspace US.cyberduckprofile")); assertEquals(new SwiftProtocol(), rackspace.getProtocol()); factory.register(rackspace); final Profile generic = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Openstack Swift (Keystone 2).cyberduckprofile")); assertEquals(new SwiftProtocol(), generic.getProtocol()); factory.register(generic); assertEquals(rackspace, new CommandLineUriParser(input, factory).parse("rackspace: assertEquals(0, new Host(rackspace, "identity.api.rackspacecloud.com", 443, "/container") .compareTo(new CommandLineUriParser(input, factory).parse("rackspace: assertEquals(generic, new CommandLineUriParser(input, factory).parse("swift: assertEquals(0, new Host(generic, "auth.cloud.ovh.net", 443, "/container") .compareTo(new CommandLineUriParser(input, factory).parse("swift: }
public Host parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(input.hasOption(TerminalOptionsBuilder.Params.region.name())) { host.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name())); } final Path directory = new CommandLinePathParser(input, factory).parse(uri); if(directory.isDirectory()) { host.setDefaultPath(directory.getAbsolute()); } else { host.setDefaultPath(directory.getParent().getAbsolute()); } if(input.hasOption(TerminalOptionsBuilder.Params.udt.name())) { host.setTransfer(Host.TransferType.udt); } if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", uri, host)); } return host; }
CommandLineUriParser { public Host parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(input.hasOption(TerminalOptionsBuilder.Params.region.name())) { host.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name())); } final Path directory = new CommandLinePathParser(input, factory).parse(uri); if(directory.isDirectory()) { host.setDefaultPath(directory.getAbsolute()); } else { host.setDefaultPath(directory.getParent().getAbsolute()); } if(input.hasOption(TerminalOptionsBuilder.Params.udt.name())) { host.setTransfer(Host.TransferType.udt); } if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", uri, host)); } return host; } }
CommandLineUriParser { public Host parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(input.hasOption(TerminalOptionsBuilder.Params.region.name())) { host.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name())); } final Path directory = new CommandLinePathParser(input, factory).parse(uri); if(directory.isDirectory()) { host.setDefaultPath(directory.getAbsolute()); } else { host.setDefaultPath(directory.getParent().getAbsolute()); } if(input.hasOption(TerminalOptionsBuilder.Params.udt.name())) { host.setTransfer(Host.TransferType.udt); } if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", uri, host)); } return host; } CommandLineUriParser(final CommandLine input);  CommandLineUriParser(final CommandLine input, final ProtocolFactory factory); }
CommandLineUriParser { public Host parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(input.hasOption(TerminalOptionsBuilder.Params.region.name())) { host.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name())); } final Path directory = new CommandLinePathParser(input, factory).parse(uri); if(directory.isDirectory()) { host.setDefaultPath(directory.getAbsolute()); } else { host.setDefaultPath(directory.getParent().getAbsolute()); } if(input.hasOption(TerminalOptionsBuilder.Params.udt.name())) { host.setTransfer(Host.TransferType.udt); } if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", uri, host)); } return host; } CommandLineUriParser(final CommandLine input);  CommandLineUriParser(final CommandLine input, final ProtocolFactory factory); Host parse(final String uri); }
CommandLineUriParser { public Host parse(final String uri) throws HostParserException { final Host host = new HostParser(factory).get(uri); if(input.hasOption(TerminalOptionsBuilder.Params.region.name())) { host.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name())); } final Path directory = new CommandLinePathParser(input, factory).parse(uri); if(directory.isDirectory()) { host.setDefaultPath(directory.getAbsolute()); } else { host.setDefaultPath(directory.getParent().getAbsolute()); } if(input.hasOption(TerminalOptionsBuilder.Params.udt.name())) { host.setTransfer(Host.TransferType.udt); } if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", uri, host)); } return host; } CommandLineUriParser(final CommandLine input);  CommandLineUriParser(final CommandLine input, final ProtocolFactory factory); Host parse(final String uri);  }