You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/01/19 16:45:27 UTC

[commons-io] 01/03: Oops, did not meet to commit those as part of the Javadoc cleanup.

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-io.git

commit 8ca72fde228b8f78f39e7ca96e82d263a3141808
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jan 19 11:19:48 2021 -0500

    Oops, did not meet to commit those as part of the Javadoc cleanup.
---
 .../file/attribute/BasicFileAttributesPrinter.java | 124 -------------------
 .../apache/commons/io/file/attribute/package.html  |  22 ----
 .../io/filefilter/AbstractMethodFileFilter.java    |  56 ---------
 .../commons/io/filefilter/FileVisitorMethod.java   |  51 --------
 .../io/filefilter/PrintStreamFileFilter.java       | 135 ---------------------
 .../attribute/BasicFileAttributesPrinterTest.java  |  31 -----
 6 files changed, 419 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/file/attribute/BasicFileAttributesPrinter.java b/src/main/java/org/apache/commons/io/file/attribute/BasicFileAttributesPrinter.java
deleted file mode 100644
index eb63101..0000000
--- a/src/main/java/org/apache/commons/io/file/attribute/BasicFileAttributesPrinter.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.io.file.attribute;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.Objects;
-
-import org.apache.commons.io.file.PathUtils;
-
-/**
- * Prints {@link BasicFileAttributes} allowing for custom formats.
- * 
- * @since 2.9.0
- */
-public class BasicFileAttributesPrinter {
-
-    /**
-     * Prints the {@link BasicFileAttributes} for the given {@link Path} strings.
-     * 
-     * @param args {@link Path} strings.
-     */
-    public static void main(String[] args) {
-        for (String arg : args) {
-            try {
-                final Path path = Paths.get(arg);
-                System.out.print(path);
-                System.out.print(": ");
-                System.out.println(toString(readBasicFileAttributes(path)));
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private static BasicFileAttributes readBasicFileAttributes(final Path path) throws IOException {
-        return PathUtils.readBasicFileAttributes(path);
-    }
-
-    private static final String FORMAT_FULL = "D%s O%s F%s S%s %s %s %s %,9d %s";
-    private static final String FORMAT_FILE = "S%s %s %s %s %,9d %s";
-    private static final String FORMAT_DIR = "S%s %s %s %s %,9d %s";
-    private static final String EMPTY = "";
-
-    private static char toSign(final boolean value) {
-        return toSign(value, '+', '-');
-    }
-
-    private static char toSign(final boolean value, char trueChar, char falseChar) {
-        return value ? trueChar : falseChar;
-    }
-
-    public static String toDirString(final BasicFileAttributes attributes) {
-        if (attributes == null) {
-            return EMPTY;
-        }
-        // Convert FileTime to instant for constant-width formatting.
-        // @formatter:off
-        return String.format(FORMAT_DIR,
-            toSign(attributes.isSymbolicLink()),
-            attributes.creationTime().toInstant(),
-            attributes.lastAccessTime().toInstant(),
-            attributes.lastModifiedTime().toInstant(),
-            attributes.size(),
-            Objects.toString(attributes.fileKey(), EMPTY)
-        );
-        // @formatter:on
-    }
-
-    public static String toFileString(final BasicFileAttributes attributes) {
-        if (attributes == null) {
-            return EMPTY;
-        }
-        // Convert FileTime to instant for constant-width formatting.
-        // @formatter:off
-        return String.format(FORMAT_FILE,
-            toSign(attributes.isSymbolicLink()),
-            attributes.creationTime().toInstant(),
-            attributes.lastAccessTime().toInstant(),
-            attributes.lastModifiedTime().toInstant(),
-            attributes.size(),
-            Objects.toString(attributes.fileKey(), EMPTY)
-        );
-        // @formatter:on
-    }
-
-    public static String toString(final BasicFileAttributes attributes) {
-        if (attributes == null) {
-            return EMPTY;
-        }
-        // Convert FileTime to instant for constant-width formatting.
-        // @formatter:off
-        return String.format(FORMAT_FULL,
-            toSign(attributes.isDirectory()),
-            toSign(attributes.isOther()),
-            toSign(attributes.isRegularFile()),
-            toSign(attributes.isSymbolicLink()),
-            attributes.creationTime().toInstant(),
-            attributes.lastAccessTime().toInstant(),
-            attributes.lastModifiedTime().toInstant(),
-            attributes.size(),
-            Objects.toString(attributes.fileKey(), EMPTY)
-        );
-        // @formatter:on
-    }
-
-}
diff --git a/src/main/java/org/apache/commons/io/file/attribute/package.html b/src/main/java/org/apache/commons/io/file/attribute/package.html
deleted file mode 100644
index 10ef237..0000000
--- a/src/main/java/org/apache/commons/io/file/attribute/package.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<!--
-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.
--->
-<html>
-<body>
-	<p>This package provides extensions in the realm of java.nio.file.attribute.</p>
-</body>
-</html>
diff --git a/src/main/java/org/apache/commons/io/filefilter/AbstractMethodFileFilter.java b/src/main/java/org/apache/commons/io/filefilter/AbstractMethodFileFilter.java
deleted file mode 100644
index b3542ff..0000000
--- a/src/main/java/org/apache/commons/io/filefilter/AbstractMethodFileFilter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.io.filefilter;
-
-import java.util.Arrays;
-
-public abstract class AbstractMethodFileFilter extends AbstractFileFilter {
-
-    private final boolean checkDirPost;
-    private final boolean checkDirPre;
-    private final boolean checkFile;
-    private final boolean checkFileFailed;
-
-    public AbstractMethodFileFilter(final FileVisitorMethod... fileVisitorMethod) {
-        final FileVisitorMethod[] actual = (fileVisitorMethod == null || fileVisitorMethod.length == 0
-            ? FileVisitorMethod.values()
-            : fileVisitorMethod).clone();
-        Arrays.sort(actual);
-        this.checkFile = Arrays.binarySearch(actual, FileVisitorMethod.FILE) >= 0;
-        this.checkFileFailed = Arrays.binarySearch(actual, FileVisitorMethod.FILE_FAILED) >= 0;
-        this.checkDirPre = Arrays.binarySearch(actual, FileVisitorMethod.PRE_DIR) >= 0;
-        this.checkDirPost = Arrays.binarySearch(actual, FileVisitorMethod.POST_DIR) >= 0;
-
-    }
-
-    public boolean isCheckDirPost() {
-        return checkDirPost;
-    }
-
-    public boolean isCheckDirPre() {
-        return checkDirPre;
-    }
-
-    public boolean isCheckFile() {
-        return checkFile;
-    }
-
-    public boolean isCheckFileFailed() {
-        return checkFileFailed;
-    }
-}
diff --git a/src/main/java/org/apache/commons/io/filefilter/FileVisitorMethod.java b/src/main/java/org/apache/commons/io/filefilter/FileVisitorMethod.java
deleted file mode 100644
index e51d3e6..0000000
--- a/src/main/java/org/apache/commons/io/filefilter/FileVisitorMethod.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.io.filefilter;
-
-import java.io.IOException;
-import java.nio.file.FileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-
-/**
- * Enumerates visitation methods from {@link FileVisitor}.
- * 
- * @since 2.9.0
- * @see FileVisitor
- */
-public enum FileVisitorMethod {
-
-    /**
-     * Matches {@link FileVisitor#visitFile(Object, BasicFileAttributes)}.
-     */
-    FILE,
-
-    /**
-     * Matches {@link FileVisitor#visitFileFailed(Object, IOException)}.
-     */
-    FILE_FAILED,
-
-    /**
-     * Matches {@link FileVisitor#postVisitDirectory(Object, IOException)}.
-     */
-    POST_DIR,
-
-    /**
-     * Matches {@link FileVisitor#preVisitDirectory(Object, BasicFileAttributes)}.
-     */
-    PRE_DIR
-}
\ No newline at end of file
diff --git a/src/main/java/org/apache/commons/io/filefilter/PrintStreamFileFilter.java b/src/main/java/org/apache/commons/io/filefilter/PrintStreamFileFilter.java
deleted file mode 100644
index 1b98228..0000000
--- a/src/main/java/org/apache/commons/io/filefilter/PrintStreamFileFilter.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.io.filefilter;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.attribute.BasicFileAttributes;
-
-import org.apache.commons.io.file.PathUtils;
-import org.apache.commons.io.file.attribute.BasicFileAttributesPrinter;
-
-public class PrintStreamFileFilter extends AbstractMethodFileFilter {
-
-    public static void main(final String[] args) {
-        final Path directory = args.length == 0 ? PathUtils.current() : Paths.get(args[0]);
-        try {
-            PathUtils.visitFileTree(PrintStreamFileFilter.systemOut(), directory);
-        } catch (final IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static PrintStreamFileFilter systemOut() {
-        return new PrintStreamFileFilter(System.out, FileVisitorMethod.FILE, FileVisitorMethod.PRE_DIR);
-    }
-
-    private final String dirPostExFormat = "Post %s: %s%n";
-    private final String dirPostFormat = "Directory: %s%n";
-    private final String dirPreAttrFormat = "Directory: %s %s%n";
-    private final String dirPreFormat = "Pre %s%n";
-    private final String fileAttrFormat = "%s %s%n";
-    private final String fileFailFormat = "%s: %s%n";
-    private final String fileFormat = "%s%n";
-    private final boolean printAttributes;
-    private final PrintStream printStream;
-
-    public PrintStreamFileFilter(final PrintStream printStream, final FileVisitorMethod... fileVisitorMethod) {
-        super(fileVisitorMethod);
-        this.printStream = printStream;
-        this.printAttributes = true;
-    }
-
-    @Override
-    public boolean accept(final File file) {
-        if (isCheckFile()) {
-            printFile(file, null);
-        }
-        return true;
-    }
-
-    @Override
-    protected FileVisitResult handle(final Throwable t) {
-        printStream.println(t);
-        return FileVisitResult.TERMINATE;
-    }
-
-    @Override
-    public FileVisitResult accept(final Path file, final BasicFileAttributes attributes) {
-        if (isCheckFile()) {
-            printFile(file, attributes);
-        }
-        return FileVisitResult.CONTINUE;
-    }
-
-    @Override
-    public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
-        if (isCheckDirPost()) {
-            if (exc == null) {
-                printStream.printf(dirPostFormat, dir);
-            } else {
-                printStream.printf(dirPostExFormat, dir, exc);
-            }
-        }
-        return FileVisitResult.CONTINUE;
-    }
-
-    @Override
-    public FileVisitResult preVisitDirectory(final Path dir, final BasicFileAttributes attributes) throws IOException {
-        if (isCheckDirPre()) {
-            if (printAttributes(attributes)) {
-                printStream.printf(dirPreFormat, dir);
-            } else {
-                printStream.printf(dirPreAttrFormat, dir, BasicFileAttributesPrinter.toFileString(attributes));
-            }
-        }
-        return FileVisitResult.CONTINUE;
-    }
-
-    private boolean printAttributes(final BasicFileAttributes attributes) {
-        return attributes == null || !printAttributes;
-    }
-
-    private void printFile(final Object file, final BasicFileAttributes attributes) {
-        if (printAttributes(attributes)) {
-            printStream.printf(fileFormat, file);
-        } else {
-            printStream.printf(fileAttrFormat, BasicFileAttributesPrinter.toFileString(attributes), file);
-        }
-    }
-
-    @Override
-    public FileVisitResult visitFile(final Path file, final BasicFileAttributes attributes) throws IOException {
-        if (isCheckFile()) {
-            printFile(file, attributes);
-        }
-        return FileVisitResult.CONTINUE;
-    }
-
-    @Override
-    public FileVisitResult visitFileFailed(final Path file, final IOException exc) throws IOException {
-        if (isCheckFileFailed()) {
-            printStream.printf(fileFailFormat, file, exc);
-        }
-        return FileVisitResult.CONTINUE;
-    }
-}
diff --git a/src/test/java/org/apache/commons/io/file/attribute/BasicFileAttributesPrinterTest.java b/src/test/java/org/apache/commons/io/file/attribute/BasicFileAttributesPrinterTest.java
deleted file mode 100644
index 1ef4253..0000000
--- a/src/test/java/org/apache/commons/io/file/attribute/BasicFileAttributesPrinterTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.io.file.attribute;
-
-import org.junit.jupiter.api.Test;
-
-/**
- * Tests {@link BasicFileAttributesPrinter}.
- */
-public class BasicFileAttributesPrinterTest {
-
-    @Test
-    public void test() {
-        
-    }
-}