You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ec...@apache.org on 2014/12/20 02:17:50 UTC
svn commit: r1646908 - in
/commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2:
example/ libcheck/
Author: ecki
Date: Sat Dec 20 01:17:50 2014
New Revision: 1646908
URL: http://svn.apache.org/r1646908
Log:
Style Police for examples (remove all findbugs and most checkstyle errors)
Added:
commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/package.html
Modified:
commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/ChangeLastModificationTime.java
commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/Shell.java
commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/ShowProperties.java
commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/package.html
commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/FtpCheck.java
commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/SftpCheck.java
Modified: commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/ChangeLastModificationTime.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/ChangeLastModificationTime.java?rev=1646908&r1=1646907&r2=1646908&view=diff
==============================================================================
--- commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/ChangeLastModificationTime.java (original)
+++ commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/ChangeLastModificationTime.java Sat Dec 20 01:17:50 2014
@@ -20,10 +20,15 @@ import org.apache.commons.vfs2.FileObjec
import org.apache.commons.vfs2.VFS;
/**
- * Simply changed the last modification time of the given file.
+ * Example to change the last modification time of the given file.
*/
-public class ChangeLastModificationTime
+public final class ChangeLastModificationTime
{
+ private ChangeLastModificationTime()
+ {
+ /* main class not instantiated. */
+ }
+
public static void main(final String[] args) throws Exception
{
if (args.length == 0)
@@ -38,4 +43,5 @@ public class ChangeLastModificationTime
fo.getContent().setLastModifiedTime(setTo);
System.err.println("after set: " + fo.getContent().getLastModifiedTime());
}
+
}
Modified: commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/Shell.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/Shell.java?rev=1646908&r1=1646907&r2=1646908&view=diff
==============================================================================
--- commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/Shell.java (original)
+++ commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/Shell.java Sat Dec 20 01:17:50 2014
@@ -19,6 +19,7 @@ package org.apache.commons.vfs2.example;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.nio.charset.Charset;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -36,13 +37,19 @@ import org.apache.commons.vfs2.VFS;
/**
* A simple command-line shell for performing file operations.
*/
-public class Shell
+public final class Shell
{
- private static final String SVN_ID = "$Id$";
private final FileSystemManager mgr;
private FileObject cwd;
private final BufferedReader reader;
+ private Shell() throws FileSystemException
+ {
+ mgr = VFS.getManager();
+ cwd = mgr.resolveFile(System.getProperty("user.dir"));
+ reader = new BufferedReader(new InputStreamReader(System.in, Charset.defaultCharset()));
+ }
+
public static void main(final String[] args)
{
try
@@ -57,16 +64,9 @@ public class Shell
System.exit(0);
}
- private Shell() throws FileSystemException
- {
- mgr = VFS.getManager();
- cwd = mgr.resolveFile(System.getProperty("user.dir"));
- reader = new BufferedReader(new InputStreamReader(System.in));
- }
-
private void go() throws Exception
{
- System.out.println("VFS Shell [" + SVN_ID + "]");
+ System.out.println("VFS Shell");
while (true)
{
final String[] cmd = nextCommand();
Modified: commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/ShowProperties.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/ShowProperties.java?rev=1646908&r1=1646907&r2=1646908&view=diff
==============================================================================
--- commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/ShowProperties.java (original)
+++ commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/ShowProperties.java Sat Dec 20 01:17:50 2014
@@ -26,12 +26,18 @@ import org.apache.commons.vfs2.FileType;
import org.apache.commons.vfs2.VFS;
/**
- * A simple that prints the properties of the file passed as first parameter.
+ * Example which prints all properties of the file passed as first parameter.
*/
+public final class ShowProperties
+{
+ /** Maximum number of children to show. */
+ private static final int SHOW_MAX = 5;
+ private ShowProperties()
+ {
+ /* main class not instantiated. */
+ }
-public class ShowProperties
-{
public static void main(final String[] args)
{
if (args.length == 0)
@@ -75,7 +81,7 @@ public class ShowProperties
for (int iterChildren = 0; iterChildren < children.length; iterChildren++)
{
System.out.println("#" + iterChildren + ": " + children[iterChildren].getName());
- if (iterChildren > 5)
+ if (iterChildren > SHOW_MAX)
{
break;
}
@@ -96,5 +102,6 @@ public class ShowProperties
}
}
}
+
}
Modified: commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/package.html
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/package.html?rev=1646908&r1=1646907&r2=1646908&view=diff
==============================================================================
--- commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/package.html (original)
+++ commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/example/package.html Sat Dec 20 01:17:50 2014
@@ -15,5 +15,5 @@
limitations under the License.
-->
<body>
-<p>Examples classes.</p>
+<p>Apache Commons VFS Examples classes.</p>
</body>
Modified: commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/FtpCheck.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/FtpCheck.java?rev=1646908&r1=1646907&r2=1646908&view=diff
==============================================================================
--- commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/FtpCheck.java (original)
+++ commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/FtpCheck.java Sat Dec 20 01:17:50 2014
@@ -17,6 +17,7 @@
package org.apache.commons.vfs2.libcheck;
import java.io.OutputStream;
+import java.nio.charset.Charset;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
@@ -25,8 +26,13 @@ import org.apache.commons.net.ftp.FTPRep
/**
* Basic check for FTP.
*/
-public class FtpCheck
+public final class FtpCheck
{
+ private FtpCheck()
+ {
+ /* main class not instantiated. */
+ }
+
public static void main(final String[] args) throws Exception
{
if (args.length < 3)
@@ -60,16 +66,13 @@ public class FtpCheck
{
throw new IllegalStateException(client.getReplyString());
}
- os.write("test".getBytes());
+ os.write("test".getBytes(Charset.defaultCharset()));
os.close();
client.completePendingCommand();
- if (dir != null)
+ if (dir != null && !client.changeWorkingDirectory(dir))
{
- if (!client.changeWorkingDirectory(dir))
- {
- throw new IllegalArgumentException("change dir to '" + dir + "' failed");
- }
+ throw new IllegalArgumentException("change dir to '" + dir + "' failed");
}
System.err.println("System: " + client.getSystemType());
Modified: commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/SftpCheck.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/SftpCheck.java?rev=1646908&r1=1646907&r2=1646908&view=diff
==============================================================================
--- commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/SftpCheck.java (original)
+++ commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/SftpCheck.java Sat Dec 20 01:17:50 2014
@@ -28,8 +28,13 @@ import com.jcraft.jsch.UserInfo;
/**
* Basic check for SFTP.
*/
-public class SftpCheck
+public final class SftpCheck
{
+ private SftpCheck()
+ {
+ /* main class not instantiated. */
+ }
+
public static void main(final String[] args) throws Exception
{
if (args.length != 4)
Added: commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/package.html
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/package.html?rev=1646908&view=auto
==============================================================================
--- commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/package.html (added)
+++ commons/proper/vfs/trunk/examples/src/main/java/org/apache/commons/vfs2/libcheck/package.html Sat Dec 20 01:17:50 2014
@@ -0,0 +1,21 @@
+<!--
+ 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.
+-->
+<body>
+<p>Sample clients for commons-net.ftp and JSch libraries.</p>
+<p>The classes do not use the VFS library, but can be used to test the underlying
+libraries, if they can connect to a specified servicde.</p>
+</body>