/** * @param identifier Serialized protocol reference or scheme * @return Matching protocol or null if no match */ public Protocol forName(final String identifier) { return this.forName(identifier, null); }
/** * @param identifier Serialized protocol reference or scheme * @param provider Custom inherited protocol definition * @return Matching protocol or null if no match */ public Protocol forName(final String identifier, final String provider) { return this.forName(this.find(), identifier, provider); }
public HostParser(final ProtocolFactory factory) { this.factory = factory; this.defaultScheme = factory.forName(preferences.getProperty("connection.protocol.default")); }
/** * Parses URL in the format ftp://username:pass@hostname:portnumber/path/to/file * * @param url URL * @return Bookmark */ public static Host parse(final String url) { final Host parsed = parse(ProtocolFactory.get(), ProtocolFactory.get().forName( preferences.getProperty("connection.protocol.default")), url); if(log.isDebugEnabled()) { log.debug(String.format("Parsed %s as %s", url, parsed)); } return parsed; }
public Profile deserialize(Object serialized) { final Deserializer<String> dict = deserializer.create(serialized); final String protocol = dict.stringForKey("Protocol"); if(StringUtils.isNotBlank(protocol)) { final Protocol parent = protocols.forName(protocols.find(new Predicate<Protocol>() { @Override public boolean test(final Protocol protocol) { // Return default registered protocol specification as parent but not other profile return !(protocol.isEnabled() || protocol.isBundled()); } }), protocol, null); if(null == parent) { log.error(String.format("Unknown protocol %s in profile", protocol)); return null; } return new Profile(parent, dict); } log.error("Missing protocol in profile"); return null; } }
if(input.indexOf("://", begin) != -1) { cut = input.indexOf("://", begin); protocol = factory.forName(input.substring(begin, cut)); begin += cut - begin + 3;
public static ConnectionController create(final WindowController parent) { synchronized(NSApplication.sharedApplication()) { if(!open.containsKey(parent)) { final ConnectionController c = new ConnectionController( new Host(ProtocolFactory.get().forName(PreferencesFactory.get().getProperty("connection.protocol.default"))) ) { @Override public void invalidate() { open.remove(parent); super.invalidate(); } }; c.loadBundle(); open.put(parent, c); return c; } else { final ConnectionController c = open.get(parent); c.loadBundle(); return c; } } } }
final Protocol protocol = factory.forName(uri.substring(0, uri.indexOf("://", 0))); if(null == protocol) { console.printf("Unknown protocol in URI %s%n", uri);
break; default: protocol = protocols.forName(type);
@Action public void protocolComboboxClicked(NSPopUpButton sender) { final Protocol selected = ProtocolFactory.get().forName(sender.selectedItem().representedObject()); preferences.setProperty("connection.protocol.default", selected.getIdentifier()); preferences.setProperty("connection.port.default", selected.getDefaultPort()); }
protected static String getScheme(final Protocol protocol) { if(new BundledProtocolPredicate().test(protocol)) { for(String scheme : protocol.getSchemes()) { // Return first custom scheme registered return scheme; } // Return default name return protocol.getIdentifier(); } // Find parent protocol definition for profile final Protocol standard = ProtocolFactory.get().forName(protocol.getIdentifier()); if(Arrays.equals(protocol.getSchemes(), standard.getSchemes())) { // No custom scheme set in profile return protocol.getProvider(); } for(String scheme : protocol.getSchemes()) { // First custom scheme in profile return scheme; } // Default vendor string of third party profile return protocol.getProvider(); } }
@Action public void protocolSelectionChanged(final NSPopUpButton sender) { final Protocol selected = ProtocolFactory.get().forName(sender.selectedItem().representedObject()); if(log.isDebugEnabled()) { log.debug(String.format("Protocol selection changed to %s", selected));
= ProtocolFactory.get().forName(preferences.getProperty("connection.protocol.default")); this.protocolCombobox.selectItemAtIndex(this.protocolCombobox.indexOfItemWithRepresentedObject(String.valueOf(defaultProtocol.hashCode())));
@Action public void addBookmarkButtonClicked(final ID sender) { final Host bookmark; if(this.isMounted()) { Path selected = this.getSelectedPath(); if(null == selected || !selected.isDirectory()) { selected = this.workdir(); } bookmark = new HostDictionary().deserialize(pool.getHost().serialize(SerializerFactory.get())); // Make sure a new UUID is asssigned for duplicate bookmark.setUuid(null); bookmark.setDefaultPath(selected.getAbsolute()); } else { bookmark = new Host(ProtocolFactory.get().forName(preferences.getProperty("connection.protocol.default"))); } this.selectBookmarks(BookmarkSwitchSegement.bookmarks); this.addBookmark(bookmark); }