类java.nio.file.ProviderMismatchException源码实例Demo

下面列出了怎么用java.nio.file.ProviderMismatchException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: buck   文件: BuckUnixPath.java
private BuckUnixPath toUnixPath(Path obj) {
  if (obj == null) {
    throw new NullPointerException();
  }

  if (obj instanceof BuckUnixPath) {
    return (BuckUnixPath) obj;
  }

  FileSystem otherFs = obj.getFileSystem();
  if (!fs.equals(otherFs) && !fs.getDefaultFileSystem().equals(otherFs)) {
    throw new ProviderMismatchException(
        "Unable to convert Path to BuckUnixPath because file systems do not match");
  }
  return BuckUnixPath.of(fs, obj.toString());
}
 
源代码2 项目: jimfs   文件: JimfsSecureDirectoryStream.java
@Override
public void move(Path srcPath, SecureDirectoryStream<Path> targetDir, Path targetPath)
    throws IOException {
  checkOpen();
  JimfsPath checkedSrcPath = checkPath(srcPath);
  JimfsPath checkedTargetPath = checkPath(targetPath);

  if (!(targetDir instanceof JimfsSecureDirectoryStream)) {
    throw new ProviderMismatchException(
        "targetDir isn't a secure directory stream associated with this file system");
  }

  JimfsSecureDirectoryStream checkedTargetDir = (JimfsSecureDirectoryStream) targetDir;

  view.copy(
      checkedSrcPath,
      checkedTargetDir.view,
      checkedTargetPath,
      ImmutableSet.<CopyOption>of(),
      true);
}
 
源代码3 项目: jimfs   文件: JimfsPath.java
@Override
public JimfsPath resolve(Path other) {
  JimfsPath otherPath = checkPath(other);
  if (otherPath == null) {
    throw new ProviderMismatchException(other.toString());
  }

  if (isEmptyPath() || otherPath.isAbsolute()) {
    return otherPath;
  }
  if (otherPath.isEmptyPath()) {
    return this;
  }
  return pathService.createPath(
      root, ImmutableList.<Name>builder().addAll(names).addAll(otherPath.names).build());
}
 
源代码4 项目: jimfs   文件: JimfsPath.java
@Override
public JimfsPath resolveSibling(Path other) {
  JimfsPath otherPath = checkPath(other);
  if (otherPath == null) {
    throw new ProviderMismatchException(other.toString());
  }

  if (otherPath.isAbsolute()) {
    return otherPath;
  }
  JimfsPath parent = getParent();
  if (parent == null) {
    return otherPath;
  }
  return parent.resolve(other);
}
 
源代码5 项目: directory-watcher   文件: WatchablePath.java
@Override
public WatchKey register(
    WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers)
    throws IOException {
  if (watcher == null) {
    throw new NullPointerException();
  }
  if (!(watcher instanceof AbstractWatchService)) {
    throw new ProviderMismatchException();
  }
  return ((AbstractWatchService) watcher).register(this, Arrays.asList(events));
}
 
源代码6 项目: dremio-oss   文件: HadoopFileSystem.java
@Override
public Iterable<FileBlockLocation> getFileBlockLocations(FileAttributes file, long start, long len) throws IOException {
  if (!(file instanceof FileStatusWrapper)) {
    throw new ProviderMismatchException();
  }
  final FileStatus status = ((FileStatusWrapper) file).getFileStatus();
  try (WaitRecorder recorder = OperatorStats.getWaitRecorder(operatorStats)) {
    return toFileBlockLocations(() -> underlyingFs.getFileBlockLocations(status, start, len));
  } catch (FSError e) {
    throw propagateFSError(e);
  }
}
 
@Override
public Iterable<FileBlockLocation> getFileBlockLocations(FileAttributes file, long start, long len) throws IOException {
  if (!(file instanceof HadoopFileStatusWrapper)) {
    throw new ProviderMismatchException();
  }
  final FileStatus status = ((HadoopFileStatusWrapper) file).getFileStatus();
  try (WaitRecorder recorder = OperatorStats.getWaitRecorder(operatorStats)) {
    return toFileBlockLocations(() -> underlyingFs.getFileBlockLocations(status, start, len));
  } catch(FSError e) {
    throw propagateFSError(e);
  }
}
 
@Override
public Iterable<FileBlockLocation> getFileBlockLocations(FileAttributes file, long start, long len) throws IOException {
  if (!(file instanceof HadoopFileStatusWrapper)) {
    throw new ProviderMismatchException();
  }
  final FileStatus status = ((HadoopFileStatusWrapper) file).getFileStatus();
  try (WaitRecorder recorder = OperatorStats.getWaitRecorder(operatorStats)) {
    return toFileBlockLocations(() -> underlyingFs.getFileBlockLocations(status, start, len));
  } catch(FSError e) {
    throw propagateFSError(e);
  }
}
 
源代码9 项目: mycore   文件: MCRPath.java
public static MCRPath toMCRPath(final Path other) {
    if (other == null) {
        throw new NullPointerException();
    }
    if (!(other instanceof MCRPath)) {
        throw new ProviderMismatchException("other is not an instance of MCRPath: " + other.getClass());
    }
    return (MCRPath) other;
}
 
源代码10 项目: mycore   文件: MCRFileSystemUtils.java
static MCRPath checkPathAbsolute(Path path) {
    MCRPath mcrPath = MCRPath.toMCRPath(path);
    if (!(Objects.requireNonNull(mcrPath.getFileSystem(), "'path' requires a associated filesystem.")
        .provider() instanceof MCRFileSystemProvider)) {
        throw new ProviderMismatchException("Path does not match to this provider: " + path);
    }
    if (!mcrPath.isAbsolute()) {
        throw new InvalidPathException(mcrPath.toString(), "'path' must be absolute.");
    }
    return mcrPath;
}
 
源代码11 项目: mycore   文件: MCRFileSystemUtils.java
static MCRPath checkPathAbsolute(Path path) {
    MCRPath mcrPath = MCRPath.toMCRPath(path);
    if (!(Objects.requireNonNull(mcrPath.getFileSystem(), "'path' requires a associated filesystem.")
        .provider() instanceof MCRFileSystemProvider)) {
        throw new ProviderMismatchException("Path does not match to this provider: " + path);
    }
    if (!mcrPath.isAbsolute()) {
        throw new InvalidPathException(mcrPath.toString(), "'path' must be absolute.");
    }
    return mcrPath;
}
 
源代码12 项目: lucene-solr   文件: FilterPath.java
/** Override this to customize the unboxing of Path
 *  from various operations
 */
protected Path toDelegate(Path path) {
  if (path instanceof FilterPath) {
    FilterPath fp = (FilterPath) path;
    if (fp.fileSystem != fileSystem) {
      throw new ProviderMismatchException("mismatch, expected: " + fileSystem.provider().getClass() + ", got: " + fp.fileSystem.provider().getClass());
    }
    return fp.delegate;
  } else {
    throw new ProviderMismatchException("mismatch, expected: FilterPath, got: " + path.getClass());
  }
}
 
源代码13 项目: lucene-solr   文件: FilterFileSystemProvider.java
protected Path toDelegate(Path path) {
  if (path instanceof FilterPath) {
    FilterPath fp = (FilterPath) path;
    if (fp.fileSystem != fileSystem) {
      throw new ProviderMismatchException("mismatch, expected: " + fileSystem.provider().getClass() + ", got: " + fp.fileSystem.provider().getClass());
    }
    return fp.delegate;
  } else {
    throw new ProviderMismatchException("mismatch, expected: FilterPath, got: " + path.getClass());
  }
}
 
源代码14 项目: sftp-fs   文件: SFTPFileSystemProvider.java
private static SFTPPath toSFTPPath(Path path) {
    Objects.requireNonNull(path);
    if (path instanceof SFTPPath) {
        return (SFTPPath) path;
    }
    throw new ProviderMismatchException();
}
 
源代码15 项目: sftp-fs   文件: SFTPFileSystemProvider.java
/**
 * Send a keep-alive signal for an SFTP file system.
 *
 * @param fs The SFTP file system to send a keep-alive signal for.
 * @throws ProviderMismatchException If the given file system is not an SFTP file system (not created by an {@code SFTPFileSystemProvider}).
 * @throws IOException If an I/O error occurred.
 */
public static void keepAlive(FileSystem fs) throws IOException {
    if (fs instanceof SFTPFileSystem) {
        ((SFTPFileSystem) fs).keepAlive();
        return;
    }
    throw new ProviderMismatchException();
}
 
源代码16 项目: vespa   文件: NodeAgentContextImpl.java
private Path requireValidPath(Path path) {
    Objects.requireNonNull(path);

    Objects.requireNonNull(fileSystem); // to allow this method to be used in constructor.
    if (!path.getFileSystem().provider().equals(fileSystem.provider())) {
        throw new ProviderMismatchException("Expected file system provider " + fileSystem.provider() +
                " but " + path + " had " + path.getFileSystem().provider());
    }

    return path;
}
 
源代码17 项目: ParallelGit   文件: GfsUriUtils.java
@Nonnull
public static String getFile(URI uri) throws ProviderMismatchException {
  checkScheme(uri);
  String fragment = uri.getFragment();
  if(fragment == null)
    fragment = "";
  if(!fragment.startsWith("/"))
    fragment = "/" + fragment;
  if(fragment.length() > 1 && fragment.endsWith("/"))
    fragment = fragment.substring(0, fragment.length() - 1);
  return fragment;
}
 
源代码18 项目: encfs4j   文件: EncryptedFileSystem.java
static Path dismantle(Path mantle) {
	if (mantle == null)
		throw new NullPointerException();
	if (!(mantle instanceof EncryptedFileSystemPath))
		throw new ProviderMismatchException();
	return ((EncryptedFileSystemPath) mantle).subFSPath;
}
 
源代码19 项目: RxJavaFileUtils   文件: WatchableFile.java
@Override
public WatchKey register(WatchService watcher,
                         WatchEvent.Kind<?>[] events,
                         WatchEvent.Modifier... modifiers)
        throws IOException {
    if (watcher == null)
        throw new NullPointerException();
    if (!(watcher instanceof AbstractWatchService))
        throw new ProviderMismatchException();
    return ((AbstractWatchService) watcher).register(this, events, modifiers);
}
 
源代码20 项目: ParallelGit   文件: GfsUriUtils.java
@Nonnull
public static String getFile(URI uri) throws ProviderMismatchException {
  checkScheme(uri);
  String fragment = uri.getFragment();
  if(fragment == null)
    fragment = "";
  if(!fragment.startsWith("/"))
    fragment = "/" + fragment;
  if(fragment.length() > 1 && fragment.endsWith("/"))
    fragment = fragment.substring(0, fragment.length() - 1);
  return fragment;
}
 
源代码21 项目: encfs4j   文件: EncryptedFileSystem.java
static Path dismantle(Path mantle) {
	if (mantle == null)
		throw new NullPointerException();
	if (!(mantle instanceof EncryptedFileSystemPath))
		throw new ProviderMismatchException();
	return ((EncryptedFileSystemPath) mantle).subFSPath;
}
 
源代码22 项目: jsr203-hadoop   文件: HadoopPath.java
private HadoopPath checkPath(Path pathToCheck) {
  if (pathToCheck == null) {
    throw new NullPointerException();
  }
  if (!(pathToCheck instanceof HadoopPath)) {
    throw new ProviderMismatchException();
  }
  return (HadoopPath) pathToCheck;
}
 
源代码23 项目: jsr203-hadoop   文件: HadoopFileSystemProvider.java
private static final HadoopPath toHadoopPath(Path path) {
  if (path == null) {
    throw new NullPointerException();
  }
  if (!(path instanceof HadoopPath)) {
    throw new ProviderMismatchException();
  }
  return (HadoopPath) path;
}
 
源代码24 项目: jsch-nio   文件: UnixSshPath.java
/** {@inheritDoc} */
@Override
public WatchKey register( WatchService watcher, Kind<?>[] events, Modifier... modifiers ) throws IOException {
    if ( watcher == null ) {
        throw new NullPointerException();
    }
    if ( !(watcher instanceof UnixSshFileSystemWatchService) ) {
        throw new ProviderMismatchException();
    }
    if ( !getFileSystem().provider().readAttributes( this, BasicFileAttributes.class ).isDirectory() ) {
        throw new NotDirectoryException( this.toString() );
    }
    getFileSystem().provider().checkAccess( this, AccessMode.READ );
    return ((UnixSshFileSystemWatchService) watcher).register( this, events, modifiers );
}
 
源代码25 项目: jimfs   文件: JimfsFileSystemProvider.java
private static JimfsPath checkPath(Path path) {
  if (path instanceof JimfsPath) {
    return (JimfsPath) path;
  }
  throw new ProviderMismatchException(
      "path " + path + " is not associated with a Jimfs file system");
}
 
源代码26 项目: jimfs   文件: JimfsSecureDirectoryStream.java
private static JimfsPath checkPath(Path path) {
  if (path instanceof JimfsPath) {
    return (JimfsPath) path;
  }
  throw new ProviderMismatchException(
      "path " + path + " is not associated with a Jimfs file system");
}
 
源代码27 项目: sftp-fs   文件: SFTPFileSystemProviderTest.java
@Test
public void testKeepAliveWithNonFTPFileSystem() {
    @SuppressWarnings("resource")
    FileSystem defaultFileSystem = FileSystems.getDefault();
    assertThrows(ProviderMismatchException.class, () -> SFTPFileSystemProvider.keepAlive(defaultFileSystem));
}
 
源代码28 项目: sftp-fs   文件: SFTPFileSystemProviderTest.java
@Test
public void testKeepAliveWithNullFTPFileSystem() {
    assertThrows(ProviderMismatchException.class, () -> SFTPFileSystemProvider.keepAlive(null));
}
 
源代码29 项目: ParallelGit   文件: GfsUriUtils.java
static void checkScheme(URI uri) throws ProviderMismatchException {
  if(!GitFileSystemProvider.GFS.equalsIgnoreCase(uri.getScheme()))
    throw new ProviderMismatchException(uri.getScheme());
}
 
源代码30 项目: ParallelGit   文件: GfsUriUtils.java
@Nullable
public static String getSession(URI uri) throws ProviderMismatchException {
  checkScheme(uri);
  return parseQuery(uri.getQuery(), Collections.singleton(SID_KEY)).get(SID_KEY);
}
 
 类所在包
 类方法
 同包方法