当前位置: 首页>>代码示例>>Java>>正文


Java SftpFileNameParser类代码示例

本文整理汇总了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$
    }
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:46,代码来源:KettleSftpFileSystemConfigBuilder.java


注:本文中的org.apache.commons.vfs.provider.sftp.SftpFileNameParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。