
br.com.objectos.io.NotFoundJava6 Maven / Gradle / Ivy
/*
* Copyright (C) 2011-2021 Objectos Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package br.com.objectos.io;
import br.com.objectos.multirelease.Concrete;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.nio.channels.FileChannel;
@Concrete.Bridge
abstract class NotFoundJava6 extends AbstractNotFound {
private final File delegate;
@Concrete.Constructor
NotFoundJava6(File delegate) {
this.delegate = delegate;
}
@Override
public final Directory createDirectory() throws IOException {
if (!delegate.mkdirs()) {
throw new IOException("createDirectory operation failed");
}
return new Directory(delegate);
}
@Override
public final void createParents() throws IOException {
File parent;
parent = delegate.getParentFile();
if (parent == null) {
return;
}
if (parent.exists()) {
return;
}
if (!parent.mkdirs()) {
throw new IOException("createParents operation failed");
}
}
@Override
public final RegularFile createRegularFile() throws IOException {
if (!delegate.createNewFile()) {
throw new IOException("createRegularFile operation failed");
}
return new RegularFile(delegate);
}
@Override
public final boolean exists() {
return delegate.exists();
}
@Override
public final String getExtension() {
return Io.getExtension(getName());
}
@Override
public final String getName() {
return delegate.getName();
}
@Override
public final FsObject getParent() {
File parent;
parent = delegate.getParentFile();
return QueryBuilderJava6.refresh(parent);
}
@Override
public final OutputStream openOutputStream() throws IOException {
return new FileOutputStream(delegate);
}
@Override
public final FileChannel openWriteChannel() throws IOException {
return ComunsIoJava6.openWriteChannel(delegate);
}
@Override
public final FsObject refresh() {
return QueryBuilderJava6.refresh(delegate);
}
@Override
public final File toFile() {
return delegate;
}
@Override
public final URI toUri() {
URI uri;
uri = delegate.toURI();
return ComunsIoJava6.toUri(uri);
}
@Override
final File getDelegate() {
return delegate;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy