本文整理汇总了Java中org.apache.commons.vfs.provider.sftp.SftpFileNameParser类的典型用法代码示例。如果您正苦于以下问题:Java SftpFileNameParser类的具体用法?Java SftpFileNameParser怎么用?Java SftpFileNameParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SftpFileNameParser类属于org.apache.commons.vfs.provider.sftp包,在下文中一共展示了SftpFileNameParser类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setParameter
import org.apache.commons.vfs.provider.sftp.SftpFileNameParser; //导入依赖的package包/类
/**
* Publicly expose a generic way to set parameters
*/
@Override
public void setParameter(FileSystemOptions opts, String name, String value, String fullParameterName, String vfsUrl) throws IOException {
if(!fullParameterName.startsWith("vfs.sftp")) { //$NON-NLS-1$
// This is not an SFTP parameter. Delegate to the generic handler
super.setParameter(opts, name, value, fullParameterName, vfsUrl);
} else {
// Check for the presence of a host in the full variable name
try {
// Parse server name from vfsFilename
FileNameParser sftpFilenameParser = SftpFileNameParser.getInstance();
URLFileName file = (URLFileName)sftpFilenameParser.parseUri(null, null, vfsUrl);
if(!parameterContainsHost(fullParameterName) || fullParameterName.endsWith(file.getHostName())) {
// Match special cases for parameter names
if(name.equalsIgnoreCase("AuthKeyPassphrase")) { //$NON-NLS-1$
setParam(opts, UserInfo.class.getName(), new PentahoUserInfo((String)value));
} else if (name.equals("identity")) { //$NON-NLS-1$
File[] identities = (File[])this.getParam(opts, "identities"); //$NON-NLS-1$
if(identities == null) {
identities = new File[] {new File((String)value)};
} else {
// Copy, in a Java 5 friendly manner, identities into a larger array
File[] temp = new File[identities.length + 1];
System.arraycopy(identities, 0, temp, 0, identities.length);
identities = temp;
identities[identities.length - 1] = new File((String)value);
}
setParam(opts, "identities", identities); //$NON-NLS-1$
} else {
setParam(opts, name, value);
}
} else {
// No host match found
log.logDebug("No host match found for: " + fullParameterName); //$NON-NLS-1$
}
} catch (FileSystemException e) {
log.logError("Failed to set VFS parameter: [" + fullParameterName + "] " + value, e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}