This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push: new 9fc4a66 Javadoc fixes (fails mvn site.) 9fc4a66 is described below commit 9fc4a666cd14b099f8a3b0c5f4f9e612c08d10b6 Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Fri Apr 19 10:41:48 2019 -0400 Javadoc fixes (fails mvn site.) --- .../vfs2/provider/bzip2/Bzip2FileObject.java | 148 +++++----- .../commons/vfs2/provider/gzip/GzipFileObject.java | 136 ++++----- .../commons/vfs2/provider/tar/TarFileObject.java | 306 +++++++++++---------- 3 files changed, 300 insertions(+), 290 deletions(-) diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/bzip2/Bzip2FileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/bzip2/Bzip2FileObject.java index 0b80bbc..cd0043f 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/bzip2/Bzip2FileObject.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/bzip2/Bzip2FileObject.java @@ -1,72 +1,76 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.commons.vfs2.provider.bzip2; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; -import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; -import org.apache.commons.vfs2.FileObject; -import org.apache.commons.vfs2.provider.AbstractFileName; -import org.apache.commons.vfs2.provider.compressed.CompressedFileFileObject; -import org.apache.commons.vfs2.provider.compressed.CompressedFileFileSystem; - -/** - * the bzip2 file. - */ -public class Bzip2FileObject extends CompressedFileFileObject<Bzip2FileSystem> { - /** - * Deprecated since 2.1. - * - * @deprecated Use {@link #Bzip2FileObject(AbstractFileName, FileObject, Bzip2FileSystem)} instead. - */ - @Deprecated - protected Bzip2FileObject(final AbstractFileName name, final FileObject container, - final CompressedFileFileSystem fs) { - super(name, container, cast(fs)); - } - - protected Bzip2FileObject(final AbstractFileName name, final FileObject container, final Bzip2FileSystem fs) { - super(name, container, fs); - } - - @Override - protected InputStream doGetInputStream() throws Exception { - // check file - final InputStream is = getContainer().getContent().getInputStream(); - return wrapInputStream(getName().getURI(), is); - } - - public static InputStream wrapInputStream(final String name, final InputStream is) throws IOException { - return new BZip2CompressorInputStream(is); - } - - @Override - protected OutputStream doGetOutputStream(final boolean bAppend) throws Exception { - final OutputStream os = getContainer().getContent().getOutputStream(false); - return new BZip2CompressorOutputStream(os); - } - - private static Bzip2FileSystem cast(final CompressedFileFileSystem fs) { - if (fs instanceof Bzip2FileSystem) { - return (Bzip2FileSystem) fs; - } - throw new IllegalArgumentException("Bzip2FileObject requires a Bzip2FileSystem implementation"); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.commons.vfs2.provider.bzip2; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; +import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; +import org.apache.commons.vfs2.FileObject; +import org.apache.commons.vfs2.provider.AbstractFileName; +import org.apache.commons.vfs2.provider.compressed.CompressedFileFileObject; +import org.apache.commons.vfs2.provider.compressed.CompressedFileFileSystem; + +/** + * the bzip2 file. + */ +public class Bzip2FileObject extends CompressedFileFileObject<Bzip2FileSystem> { + + /** + * Deprecated since 2.1. + * + * @param name Abstract file name. + * @param container My container. + * + * @deprecated Use {@link #Bzip2FileObject(AbstractFileName, FileObject, Bzip2FileSystem)} instead. + */ + @Deprecated + protected Bzip2FileObject(final AbstractFileName name, final FileObject container, + final CompressedFileFileSystem fs) { + super(name, container, cast(fs)); + } + + protected Bzip2FileObject(final AbstractFileName name, final FileObject container, final Bzip2FileSystem fs) { + super(name, container, fs); + } + + @Override + protected InputStream doGetInputStream() throws Exception { + // check file + final InputStream is = getContainer().getContent().getInputStream(); + return wrapInputStream(getName().getURI(), is); + } + + public static InputStream wrapInputStream(final String name, final InputStream is) throws IOException { + return new BZip2CompressorInputStream(is); + } + + @Override + protected OutputStream doGetOutputStream(final boolean bAppend) throws Exception { + final OutputStream os = getContainer().getContent().getOutputStream(false); + return new BZip2CompressorOutputStream(os); + } + + private static Bzip2FileSystem cast(final CompressedFileFileSystem fs) { + if (fs instanceof Bzip2FileSystem) { + return (Bzip2FileSystem) fs; + } + throw new IllegalArgumentException("Bzip2FileObject requires a Bzip2FileSystem implementation"); + } +} diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/gzip/GzipFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/gzip/GzipFileObject.java index 52e9b18..ec1b623 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/gzip/GzipFileObject.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/gzip/GzipFileObject.java @@ -1,66 +1,70 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.commons.vfs2.provider.gzip; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - -import org.apache.commons.vfs2.FileObject; -import org.apache.commons.vfs2.provider.AbstractFileName; -import org.apache.commons.vfs2.provider.compressed.CompressedFileFileObject; -import org.apache.commons.vfs2.provider.compressed.CompressedFileFileSystem; - -/** - * the gzip file. - */ -public class GzipFileObject extends CompressedFileFileObject<GzipFileSystem> { - /** - * Deprecated since 2.1. - * - * @deprecated Use {@link #GzipFileObject(AbstractFileName, FileObject, GzipFileSystem)} instead. - */ - @Deprecated - protected GzipFileObject(final AbstractFileName name, final FileObject container, - final CompressedFileFileSystem fs) { - super(name, container, cast(fs)); - } - - protected GzipFileObject(final AbstractFileName name, final FileObject container, final GzipFileSystem fs) { - super(name, container, fs); - } - - @Override - protected InputStream doGetInputStream() throws Exception { - final InputStream is = getContainer().getContent().getInputStream(); - return new GZIPInputStream(is); - } - - @Override - protected OutputStream doGetOutputStream(final boolean bAppend) throws Exception { - final OutputStream os = getContainer().getContent().getOutputStream(false); - return new GZIPOutputStream(os); - } - - private static GzipFileSystem cast(final CompressedFileFileSystem fs) { - if (fs instanceof GzipFileSystem) { - return (GzipFileSystem) fs; - } - throw new IllegalArgumentException("GzipFileObject expects an instance of GzipFileSystem"); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.commons.vfs2.provider.gzip; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +import org.apache.commons.vfs2.FileObject; +import org.apache.commons.vfs2.provider.AbstractFileName; +import org.apache.commons.vfs2.provider.compressed.CompressedFileFileObject; +import org.apache.commons.vfs2.provider.compressed.CompressedFileFileSystem; + +/** + * the gzip file. + */ +public class GzipFileObject extends CompressedFileFileObject<GzipFileSystem> { + + /** + * Deprecated since 2.1. + * + * @param name Abstract file name. + * @param container My container. + * + * @deprecated Use {@link #GzipFileObject(AbstractFileName, FileObject, GzipFileSystem)} instead. + */ + @Deprecated + protected GzipFileObject(final AbstractFileName name, final FileObject container, + final CompressedFileFileSystem fs) { + super(name, container, cast(fs)); + } + + protected GzipFileObject(final AbstractFileName name, final FileObject container, final GzipFileSystem fs) { + super(name, container, fs); + } + + @Override + protected InputStream doGetInputStream() throws Exception { + final InputStream is = getContainer().getContent().getInputStream(); + return new GZIPInputStream(is); + } + + @Override + protected OutputStream doGetOutputStream(final boolean bAppend) throws Exception { + final OutputStream os = getContainer().getContent().getOutputStream(false); + return new GZIPOutputStream(os); + } + + private static GzipFileSystem cast(final CompressedFileFileSystem fs) { + if (fs instanceof GzipFileSystem) { + return (GzipFileSystem) fs; + } + throw new IllegalArgumentException("GzipFileObject expects an instance of GzipFileSystem"); + } +} diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/tar/TarFileObject.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/tar/TarFileObject.java index 6f6b9ed..aa43659 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/tar/TarFileObject.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/tar/TarFileObject.java @@ -1,152 +1,154 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.commons.vfs2.provider.tar; - -import java.io.InputStream; -import java.util.HashSet; - -import org.apache.commons.compress.archivers.tar.TarArchiveEntry; -import org.apache.commons.vfs2.FileName; -import org.apache.commons.vfs2.FileSystemException; -import org.apache.commons.vfs2.FileType; -import org.apache.commons.vfs2.provider.AbstractFileName; -import org.apache.commons.vfs2.provider.AbstractFileObject; - -/** - * A file in a Tar file system. - */ -public class TarFileObject extends AbstractFileObject<TarFileSystem> { - /** The TarArchiveEntry */ - private TarArchiveEntry entry; - private final HashSet<String> children = new HashSet<>(); - private FileType type; - - protected TarFileObject(final AbstractFileName name, final TarArchiveEntry entry, final TarFileSystem fs, - final boolean tarExists) throws FileSystemException { - super(name, fs); - setTarEntry(entry); - if (!tarExists) { - type = FileType.IMAGINARY; - } - } - - /** - * Sets the details for this file object. - * - * Consider this method package private. TODO Might be made package private in the next major version. - */ - protected void setTarEntry(final TarArchiveEntry entry) { - if (this.entry != null) { - return; - } - - if (entry == null || entry.isDirectory()) { - type = FileType.FOLDER; - } else { - type = FileType.FILE; - } - - this.entry = entry; - } - - /** - * Attaches a child. - * - * @param childName Name of child to remember. - */ - protected void attachChild(final FileName childName) { - children.add(childName.getBaseName()); - } - - /** - * Determines if this file can be written to. - * - * @return {@code true} if this file is writeable, {@code false} if not. - * @throws FileSystemException if an error occurs. - */ - @Override - public boolean isWriteable() throws FileSystemException { - return false; - } - - /** - * Returns the file's type. - */ - @Override - protected FileType doGetType() { - return type; - } - - /** - * Lists the children of the file. - */ - @Override - protected String[] doListChildren() { - try { - if (!getType().hasChildren()) { - return null; - } - } catch (final FileSystemException e) { - // should not happen as the type has already been cached. - throw new RuntimeException(e); - } - - return children.toArray(new String[children.size()]); - } - - /** - * Returns the size of the file content (in bytes). Is only called if {@link #doGetType} returns - * {@link FileType#FILE}. - */ - @Override - protected long doGetContentSize() { - if (entry == null) { - return 0; - } - - return entry.getSize(); - } - - /** - * Returns the last modified time of this file. - */ - @Override - protected long doGetLastModifiedTime() throws Exception { - if (entry == null) { - return 0; - } - - return entry.getModTime().getTime(); - } - - /** - * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns - * {@link FileType#FILE}. The input stream returned by this method is guaranteed to be closed before this method is - * called again. - */ - @Override - protected InputStream doGetInputStream() throws Exception { - // VFS-210: zip allows to gather an input stream even from a directory and will - // return -1 on the first read. getType should not be expensive and keeps the tests - // running - if (!getType().hasContent()) { - throw new FileSystemException("vfs.provider/read-not-file.error", getName()); - } - - return getAbstractFileSystem().getInputStream(entry); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.commons.vfs2.provider.tar; + +import java.io.InputStream; +import java.util.HashSet; + +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.vfs2.FileName; +import org.apache.commons.vfs2.FileSystemException; +import org.apache.commons.vfs2.FileType; +import org.apache.commons.vfs2.provider.AbstractFileName; +import org.apache.commons.vfs2.provider.AbstractFileObject; + +/** + * A file in a Tar file system. + */ +public class TarFileObject extends AbstractFileObject<TarFileSystem> { + /** The TarArchiveEntry */ + private TarArchiveEntry entry; + private final HashSet<String> children = new HashSet<>(); + private FileType type; + + protected TarFileObject(final AbstractFileName name, final TarArchiveEntry entry, final TarFileSystem fs, + final boolean tarExists) throws FileSystemException { + super(name, fs); + setTarEntry(entry); + if (!tarExists) { + type = FileType.IMAGINARY; + } + } + + /** + * Sets the details for this file object. + * + * Consider this method package private. TODO Might be made package private in the next major version. + * + * @param entry Tar archive entry. + */ + protected void setTarEntry(final TarArchiveEntry entry) { + if (this.entry != null) { + return; + } + + if (entry == null || entry.isDirectory()) { + type = FileType.FOLDER; + } else { + type = FileType.FILE; + } + + this.entry = entry; + } + + /** + * Attaches a child. + * + * @param childName Name of child to remember. + */ + protected void attachChild(final FileName childName) { + children.add(childName.getBaseName()); + } + + /** + * Determines if this file can be written to. + * + * @return {@code true} if this file is writeable, {@code false} if not. + * @throws FileSystemException if an error occurs. + */ + @Override + public boolean isWriteable() throws FileSystemException { + return false; + } + + /** + * Returns the file's type. + */ + @Override + protected FileType doGetType() { + return type; + } + + /** + * Lists the children of the file. + */ + @Override + protected String[] doListChildren() { + try { + if (!getType().hasChildren()) { + return null; + } + } catch (final FileSystemException e) { + // should not happen as the type has already been cached. + throw new RuntimeException(e); + } + + return children.toArray(new String[children.size()]); + } + + /** + * Returns the size of the file content (in bytes). Is only called if {@link #doGetType} returns + * {@link FileType#FILE}. + */ + @Override + protected long doGetContentSize() { + if (entry == null) { + return 0; + } + + return entry.getSize(); + } + + /** + * Returns the last modified time of this file. + */ + @Override + protected long doGetLastModifiedTime() throws Exception { + if (entry == null) { + return 0; + } + + return entry.getModTime().getTime(); + } + + /** + * Creates an input stream to read the file content from. Is only called if {@link #doGetType} returns + * {@link FileType#FILE}. The input stream returned by this method is guaranteed to be closed before this method is + * called again. + */ + @Override + protected InputStream doGetInputStream() throws Exception { + // VFS-210: zip allows to gather an input stream even from a directory and will + // return -1 on the first read. getType should not be expensive and keeps the tests + // running + if (!getType().hasContent()) { + throw new FileSystemException("vfs.provider/read-not-file.error", getName()); + } + + return getAbstractFileSystem().getInputStream(entry); + } +}