You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/12/12 16:17:03 UTC
svn commit: r1644927 - in /commons/proper/net/trunk/src/main/java:
examples/ftp/FTPClientExample.java org/apache/commons/net/ftp/FTPFile.java
Author: sebb
Date: Fri Dec 12 15:17:03 2014
New Revision: 1644927
URL: http://svn.apache.org/r1644927
Log:
Better handling of invalid entries; Javadoc
Modified:
commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java
commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPFile.java
Modified: commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java?rev=1644927&r1=1644926&r2=1644927&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java (original)
+++ commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java Fri Dec 12 15:17:03 2014
@@ -415,11 +415,7 @@ __main:
for (FTPFile f : ftp.listFiles(remote)) {
System.out.println(f.getRawListing());
- if (f.isValid()) {
- System.out.println(f.toFormattedString(displayTimeZoneId));
- } else {
- System.out.println("[Unparseable]");
- }
+ System.out.println(f.toFormattedString(displayTimeZoneId));
}
}
}
Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPFile.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPFile.java?rev=1644927&r1=1644926&r2=1644927&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPFile.java (original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/ftp/FTPFile.java Fri Dec 12 15:17:03 2014
@@ -178,6 +178,7 @@ public class FTPFile implements Serializ
* Other methods may fail.
*
* Used in conjunction with list parsing that preseverves entries that failed to parse.
+ * @see FTPClientConfig#setUnparseableEntries(boolean)
* @return true if the entry is valid
* @since 3.4
*/
@@ -399,9 +400,14 @@ public class FTPFile implements Serializ
* @param permission The access permission (one of the
* <code> _PERMISSION </code> constants)
* @throws ArrayIndexOutOfBoundsException if either of the parameters is out of range
+ * @return true if {@link #isValid()} is {@code true &&} the associated permission is set;
+ * {@code false} otherwise.
***/
public boolean hasPermission(int access, int permission)
{
+ if (_permissions == null) {
+ return false;
+ }
return _permissions[access][permission];
}
@@ -422,6 +428,10 @@ public class FTPFile implements Serializ
* This method uses the timezone of the Calendar entry, which is
* the server time zone (if one was provided) otherwise it is
* the local time zone.
+ * <p>
+ * Note: if the instance is not valid {@link #isValid()}, no useful
+ * information can be returned. In this case, use {@link #getRawListing()}
+ * instead.
*
* @return A string representation of the FTPFile information.
* @since 3.0
@@ -435,7 +445,10 @@ public class FTPFile implements Serializ
* Returns a string representation of the FTPFile information.
* This currently mimics the Unix listing format.
* This method allows the Calendar time zone to be overridden.
- *
+ * <p>
+ * Note: if the instance is not valid {@link #isValid()}, no useful
+ * information can be returned. In this case, use {@link #getRawListing()}
+ * instead.
* @param timezone the timezone to use for displaying the time stamp
* If {@code null}, then use the Calendar entry timezone
* @return A string representation of the FTPFile information.
@@ -445,7 +458,7 @@ public class FTPFile implements Serializ
{
if (!isValid()) {
- return getRawListing();
+ return "[Invalid: could not parse file entry]";
}
StringBuilder sb = new StringBuilder();
Formatter fmt = new Formatter(sb);