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

项目: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);
}
项目: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());
}
项目: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);
}
项目:filesystem    文件:LocalFileSystemProvider.java   
@Override
protected LocalPath toCachePath( Path path )
{
    Objects.requireNonNull( path );
    if( !(path instanceof LocalPath) ) {
        throw new ProviderMismatchException();
    }
    return (LocalPath) path.toAbsolutePath();
}
项目:filesystem    文件:AbstractPath.java   
private P checkPath( Path path )
{
    if( path == null ) {
        throw new NullPointerException();
    }
    if( !(path instanceof AbstractPath) ) {
        throw new ProviderMismatchException();
    }
    return (P) path;
}
项目:filesystem    文件:CacheFileSystemProvider.java   
@Override
protected CachePath toCachePath( Path path )
{
    Objects.requireNonNull( path );
    if( !(path instanceof CachePath) ) {
        throw new ProviderMismatchException();
    }
    return (CachePath) path.toAbsolutePath();
}
项目:filesystem    文件:MemoryFileSystemProvider.java   
protected MemoryPath toPath( Path path )
{
    Objects.requireNonNull( path );
    if( !(path instanceof MemoryPath) ) {
        throw new ProviderMismatchException();
    }
    return (MemoryPath) path.toAbsolutePath();
}
项目: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;
}
项目: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;
}
项目: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));
}
项目: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;
}
项目: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;
}
项目: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);
}
项目:ephemeralfs    文件:EphemeralFsPath.java   
private EphemeralFsPath toEfsPath(Path other) {
    if(other == null) {
        throw new NullPointerException();
    }
    try
    {
        return (EphemeralFsPath) other;
    } catch(ClassCastException e) {
        throw new ProviderMismatchException();
    }
}
项目:archive-fs    文件:AbstractTarFileSystemProvider.java   
static final TarPath toTarPath(Path path) {
    if (path == null) {
        throw new NullPointerException();
    }
    if (!(path instanceof TarPath)) {
        throw new ProviderMismatchException();
    }
    return (TarPath) path;
}
项目:archive-fs    文件:TarPath.java   
private static TarPath checkPath(Path path) {
    if (path == null) {
        throw new NullPointerException();
    }
    if (!(path instanceof TarPath)) {
        throw new ProviderMismatchException();
    }
    return (TarPath) path;
}
项目: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;
}
项目: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;
}
项目: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;
}
项目: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;
}
项目:jdk7-dxfs    文件:DxFileSystemProvider.java   
static final DxPath toDxPath(Path path) {
    if (path == null) {
        throw new NullPointerException();
    }

    if (!(path instanceof DxPath)) {
        throw new ProviderMismatchException();
    }

    return (DxPath)path;
}
项目: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");
}
项目: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");
}
项目:ParallelGit    文件:GfsUriUtils.java   
static void checkScheme(URI uri) throws ProviderMismatchException {
  if(!GitFileSystemProvider.GFS.equalsIgnoreCase(uri.getScheme()))
    throw new ProviderMismatchException(uri.getScheme());
}
项目: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);
}
项目:ParallelGit    文件:GfsUriUtilsTest.java   
@Test(expected = ProviderMismatchException.class)
public void checkSchemeTest() {
  GfsUriUtils.checkScheme(URI.create("/somepath"));
}
项目:ParallelGit    文件:GfsUriUtils.java   
static void checkScheme(URI uri) throws ProviderMismatchException {
  if(!GitFileSystemProvider.GFS.equalsIgnoreCase(uri.getScheme()))
    throw new ProviderMismatchException(uri.getScheme());
}
项目: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);
}
项目:ParallelGit    文件:GfsUriUtilsTest.java   
@Test(expected = ProviderMismatchException.class)
public void checkSchemeTest() {
  GfsUriUtils.checkScheme(URI.create("/somepath"));
}
项目:niotest    文件:Tests19HardLinks.java   
@Test
@Category( { HardLink.class, Writable.class } )
public void testHardLinkToOtherProviderThrows() throws IOException {
    assertThatThrownBy( () -> Files.createLink( link(), otherProviderFileA() ) ).isInstanceOf( ProviderMismatchException.class );
}
项目:niotest    文件:Tests12DifferentFS.java   
@Test
@Category( { SecondFileSystem.class } )
public void testRelativize() {
    assertThatThrownBy( () -> absAB().relativize( otherFSAbsA() )).isInstanceOf( ProviderMismatchException.class );
}
项目:niotest    文件:Tests09WrongProvider.java   
@Test
public void testNewByteChannelOtherProvider() throws IOException {
    assertThatThrownBy( () -> FS.provider().newByteChannel( otherProviderAbsA(), Collections.<OpenOption> emptySet() ) ).isInstanceOf( ProviderMismatchException.class );
}
项目:niotest    文件:Tests09WrongProvider.java   
@Test
public void testGetBasicFileAttributeViewProvider() throws IOException {
    assertThatThrownBy( () -> FS.provider().getFileAttributeView( otherProviderAbsA(), BasicFileAttributeView.class ) ).isInstanceOf( ProviderMismatchException.class );
}
项目:niotest    文件:Tests09WrongProvider.java   
@Test
@Category( { Writable.class } )
public void testCreateDirectoryOtherProvider() throws IOException {
    assertThatThrownBy( () -> FS.provider().createDirectory( otherProviderAbsA() ) ).isInstanceOf( ProviderMismatchException.class );
}
项目:niotest    文件:Tests09WrongProvider.java   
@Test
@Category( FileChannelT.class )
public void testNewFileChannelOtherProvider() throws IOException {
    assertThatThrownBy( () -> FS.provider().newFileChannel( otherProviderAbsA(), Collections.<OpenOption> emptySet() ) ).isInstanceOf( ProviderMismatchException.class );
}
项目:niotest    文件:Tests09WrongProvider.java   
@Test
public void testCheckAccessOtherProvider() throws IOException {
    assertThatThrownBy( () -> FS.provider().checkAccess( otherProviderAbsA() ) ).isInstanceOf( ProviderMismatchException.class );
}
项目:niotest    文件:Tests09WrongProvider.java   
@Test
@Category( { Copy.class, Writable.class } )
public void testCopyOtherProviderFrom() throws IOException {
    assertThatThrownBy( () -> FS.provider().copy( otherProviderAbsA(), absTA() ) ).isInstanceOf( ProviderMismatchException.class );
}
项目:niotest    文件:Tests09WrongProvider.java   
@Test
@Category( { Copy.class, Writable.class } )
public void testCopyOtherProviderTo() throws IOException {
    assertThatThrownBy( () -> FS.provider().copy( fileTA(), otherProviderAbsA() ) ).isInstanceOf( ProviderMismatchException.class );
}
项目:niotest    文件:Tests09WrongProvider.java   
@Test
@Category( { Move.class, Writable.class } )
public void testMoveOtherProviderFrom() throws IOException {
    assertThatThrownBy( () -> FS.provider().move( otherProviderAbsA(), absTA() ) ).isInstanceOf( ProviderMismatchException.class );
}
项目:niotest    文件:Tests09WrongProvider.java   
@Test
@Category( { Copy.class, Writable.class } )
public void testMoveOtherProviderTo() throws IOException {
    assertThatThrownBy( () -> FS.provider().move( fileTAB(), otherProviderAbsA() ) ).isInstanceOf( ProviderMismatchException.class );
}