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 2017/09/14 19:26:44 UTC
svn commit: r1808381 [19/25] - in /commons/proper/vfs/trunk/commons-vfs2/src:
main/java/org/apache/commons/vfs2/ main/java/org/apache/commons/vfs2/auth/
main/java/org/apache/commons/vfs2/cache/
main/java/org/apache/commons/vfs2/events/ main/java/org/ap...
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilder.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilder.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/DelegatingFileSystemOptionsBuilder.java Thu Sep 14 19:26:39 2017
@@ -35,9 +35,10 @@ import org.apache.commons.vfs2.FileSyste
import org.apache.commons.vfs2.FileSystemOptions;
/**
- * This class use reflection to set a configuration value using the fileSystemConfigBuilder
- * associated the a scheme.<br><br>
+ * This class use reflection to set a configuration value using the fileSystemConfigBuilder associated the a scheme.<br>
+ * <br>
* Example:<br>
+ *
* <pre>
* FileSystemOptions fso = new FileSystemOptions();
* DelegatingFileSystemOptionsBuilder delegate = new DelegatingFileSystemOptionsBuilder(VFS.getManager());
@@ -46,18 +47,16 @@ import org.apache.commons.vfs2.FileSyste
* delegate.setConfigClass(fso, "sftp", "userinfo", TrustEveryoneUserInfo.class);
* </pre>
*/
-public class DelegatingFileSystemOptionsBuilder
-{
- @SuppressWarnings("unchecked") // OK, it is a String
- private static final Class<String>[] STRING_PARAM = new Class[]{String.class};
+public class DelegatingFileSystemOptionsBuilder {
+ @SuppressWarnings("unchecked") // OK, it is a String
+ private static final Class<String>[] STRING_PARAM = new Class[] { String.class };
private static final Map<String, Class<?>> PRIMATIVE_TO_OBJECT = new TreeMap<>();
private static final Log log = LogFactory.getLog(DelegatingFileSystemOptionsBuilder.class);
private final FileSystemManager manager;
private final Map<String, Map<String, List<Method>>> beanMethods = new TreeMap<>();
- static
- {
+ static {
PRIMATIVE_TO_OBJECT.put(Void.TYPE.getName(), Void.class);
PRIMATIVE_TO_OBJECT.put(Boolean.TYPE.getName(), Boolean.class);
PRIMATIVE_TO_OBJECT.put(Byte.TYPE.getName(), Byte.class);
@@ -72,8 +71,7 @@ public class DelegatingFileSystemOptions
/**
* Context.
*/
- private static final class Context
- {
+ private static final class Context {
private final FileSystemOptions fso;
private final String scheme;
private final String name;
@@ -82,8 +80,7 @@ public class DelegatingFileSystemOptions
private List<Method> configSetters;
private FileSystemConfigBuilder fileSystemConfigBuilder;
- private Context(final FileSystemOptions fso, final String scheme, final String name, final Object[] values)
- {
+ private Context(final FileSystemOptions fso, final String scheme, final String name, final Object[] values) {
this.fso = fso;
this.scheme = scheme;
this.name = name;
@@ -97,43 +94,39 @@ public class DelegatingFileSystemOptions
*
* @param manager the manager to use to get the fileSystemConfigBuilder assocated to a scheme
*/
- public DelegatingFileSystemOptionsBuilder(final FileSystemManager manager)
- {
+ public DelegatingFileSystemOptionsBuilder(final FileSystemManager manager) {
this.manager = manager;
}
- protected FileSystemManager getManager()
- {
+ protected FileSystemManager getManager() {
return manager;
}
/**
* Set a single string value.
*
- * @param fso FileSystemOptions
+ * @param fso FileSystemOptions
* @param scheme scheme
- * @param name name
- * @param value value
+ * @param name name
+ * @param value value
* @throws FileSystemException if an error occurs.
*/
- public void setConfigString(final FileSystemOptions fso, final String scheme, final String name,
- final String value) throws FileSystemException
- {
- setConfigStrings(fso, scheme, name, new String[]{value});
+ public void setConfigString(final FileSystemOptions fso, final String scheme, final String name, final String value)
+ throws FileSystemException {
+ setConfigStrings(fso, scheme, name, new String[] { value });
}
/**
* Set an array of string value.
*
- * @param fso FileSystemOptions
+ * @param fso FileSystemOptions
* @param scheme scheme
- * @param name name
+ * @param name name
* @param values values
* @throws FileSystemException if an error occurs.
*/
public void setConfigStrings(final FileSystemOptions fso, final String scheme, final String name,
- final String[] values) throws FileSystemException
- {
+ final String[] values) throws FileSystemException {
final Context ctx = new Context(fso, scheme, name, values);
setValues(ctx);
@@ -143,40 +136,35 @@ public class DelegatingFileSystemOptions
* Set a single class value.<br>
* The class has to implement a no-args constructor, else the instantiation might fail.
*
- * @param fso FileSystemOptions
- * @param scheme scheme
- * @param name name
+ * @param fso FileSystemOptions
+ * @param scheme scheme
+ * @param name name
* @param className className
* @throws FileSystemException if an error occurs.
* @throws IllegalAccessException if a class canoot be accessed.
* @throws InstantiationException if a class cannot be instantiated.
*/
public void setConfigClass(final FileSystemOptions fso, final String scheme, final String name,
- final Class<?> className)
- throws FileSystemException, IllegalAccessException, InstantiationException
- {
- setConfigClasses(fso, scheme, name, new Class[]{className});
+ final Class<?> className) throws FileSystemException, IllegalAccessException, InstantiationException {
+ setConfigClasses(fso, scheme, name, new Class[] { className });
}
/**
* Set an array of class values.<br>
* The class has to implement a no-args constructor, else the instantiation might fail.
*
- * @param fso FileSystemOptions
- * @param scheme scheme
- * @param name name
+ * @param fso FileSystemOptions
+ * @param scheme scheme
+ * @param name name
* @param classNames classNames
* @throws FileSystemException if an error occurs.
* @throws IllegalAccessException if a class canoot be accessed.
* @throws InstantiationException if a class cannot be instantiated.
*/
public void setConfigClasses(final FileSystemOptions fso, final String scheme, final String name,
- final Class<?>[] classNames)
- throws FileSystemException, IllegalAccessException, InstantiationException
- {
+ final Class<?>[] classNames) throws FileSystemException, IllegalAccessException, InstantiationException {
final Object[] values = new Object[classNames.length];
- for (int iterClassNames = 0; iterClassNames < values.length; iterClassNames++)
- {
+ for (int iterClassNames = 0; iterClassNames < values.length; iterClassNames++) {
values[iterClassNames] = classNames[iterClassNames].newInstance();
}
@@ -188,14 +176,10 @@ public class DelegatingFileSystemOptions
/**
* sets the values using the informations of the given context.<br>
*/
- private void setValues(final Context ctx) throws FileSystemException
- {
+ private void setValues(final Context ctx) throws FileSystemException {
// find all setter methods suitable for the given "name"
- if (!fillConfigSetters(ctx))
- {
- throw new FileSystemException("vfs.provider/config-key-invalid.error",
- ctx.scheme,
- ctx.name);
+ if (!fillConfigSetters(ctx)) {
+ throw new FileSystemException("vfs.provider/config-key-invalid.error", ctx.scheme, ctx.name);
}
// get the fileSystemConfigBuilder
@@ -203,57 +187,43 @@ public class DelegatingFileSystemOptions
// try to find a setter which could accept the value
final Iterator<Method> iterConfigSetters = ctx.configSetters.iterator();
- while (iterConfigSetters.hasNext())
- {
+ while (iterConfigSetters.hasNext()) {
final Method configSetter = iterConfigSetters.next();
- if (convertValuesAndInvoke(configSetter, ctx))
- {
+ if (convertValuesAndInvoke(configSetter, ctx)) {
return;
}
}
- throw new FileSystemException("vfs.provider/config-value-invalid.error",
- ctx.scheme,
- ctx.name,
- ctx.values);
+ throw new FileSystemException("vfs.provider/config-value-invalid.error", ctx.scheme, ctx.name, ctx.values);
}
/**
* tries to convert the value and pass it to the given method
*/
- private boolean convertValuesAndInvoke(final Method configSetter, final Context ctx) throws FileSystemException
- {
+ private boolean convertValuesAndInvoke(final Method configSetter, final Context ctx) throws FileSystemException {
final Class<?>[] parameters = configSetter.getParameterTypes();
- if (parameters.length < 2)
- {
+ if (parameters.length < 2) {
return false;
}
- if (!parameters[0].isAssignableFrom(FileSystemOptions.class))
- {
+ if (!parameters[0].isAssignableFrom(FileSystemOptions.class)) {
return false;
}
final Class<?> valueParameter = parameters[1];
Class<?> type;
- if (valueParameter.isArray())
- {
+ if (valueParameter.isArray()) {
type = valueParameter.getComponentType();
- }
- else
- {
- if (ctx.values.length > 1)
- {
+ } else {
+ if (ctx.values.length > 1) {
return false;
}
type = valueParameter;
}
- if (type.isPrimitive())
- {
+ if (type.isPrimitive()) {
final Class<?> objectType = PRIMATIVE_TO_OBJECT.get(type.getName());
- if (objectType == null)
- {
+ if (objectType == null) {
log.warn(Messages.getString("vfs.provider/config-unexpected-primitive.error", type.getName()));
return false;
}
@@ -261,53 +231,36 @@ public class DelegatingFileSystemOptions
}
final Class<? extends Object> valueClass = ctx.values[0].getClass();
- if (type.isAssignableFrom(valueClass))
- {
+ if (type.isAssignableFrom(valueClass)) {
// can set value directly
invokeSetter(valueParameter, ctx, configSetter, ctx.values);
return true;
}
- if (valueClass != String.class)
- {
- log.warn(Messages.getString("vfs.provider/config-unexpected-value-class.error",
- valueClass.getName(),
- ctx.scheme,
- ctx.name
- ));
+ if (valueClass != String.class) {
+ log.warn(Messages.getString("vfs.provider/config-unexpected-value-class.error", valueClass.getName(),
+ ctx.scheme, ctx.name));
return false;
}
final Object convertedValues = Array.newInstance(type, ctx.values.length);
Constructor<?> valueConstructor;
- try
- {
+ try {
valueConstructor = type.getConstructor(STRING_PARAM);
- }
- catch (final NoSuchMethodException e)
- {
+ } catch (final NoSuchMethodException e) {
valueConstructor = null;
}
- if (valueConstructor != null)
- {
+ if (valueConstructor != null) {
// can convert using constructor
- for (int iterValues = 0; iterValues < ctx.values.length; iterValues++)
- {
- try
- {
+ for (int iterValues = 0; iterValues < ctx.values.length; iterValues++) {
+ try {
Array.set(convertedValues, iterValues,
- valueConstructor.newInstance(new Object[]{ctx.values[iterValues]}));
- }
- catch (final InstantiationException e)
- {
+ valueConstructor.newInstance(new Object[] { ctx.values[iterValues] }));
+ } catch (final InstantiationException e) {
throw new FileSystemException(e);
- }
- catch (final IllegalAccessException e)
- {
+ } catch (final IllegalAccessException e) {
throw new FileSystemException(e);
- }
- catch (final InvocationTargetException e)
- {
+ } catch (final InvocationTargetException e) {
throw new FileSystemException(e);
}
}
@@ -317,35 +270,24 @@ public class DelegatingFileSystemOptions
}
Method valueFactory;
- try
- {
+ try {
valueFactory = type.getMethod("valueOf", STRING_PARAM);
- if (!Modifier.isStatic(valueFactory.getModifiers()))
- {
+ if (!Modifier.isStatic(valueFactory.getModifiers())) {
valueFactory = null;
}
- }
- catch (final NoSuchMethodException e)
- {
+ } catch (final NoSuchMethodException e) {
valueFactory = null;
}
- if (valueFactory != null)
- {
+ if (valueFactory != null) {
// can convert using factory method (valueOf)
- for (int iterValues = 0; iterValues < ctx.values.length; iterValues++)
- {
- try
- {
+ for (int iterValues = 0; iterValues < ctx.values.length; iterValues++) {
+ try {
Array.set(convertedValues, iterValues,
- valueFactory.invoke(null, new Object[]{ctx.values[iterValues]}));
- }
- catch (final IllegalAccessException e)
- {
+ valueFactory.invoke(null, new Object[] { ctx.values[iterValues] }));
+ } catch (final IllegalAccessException e) {
throw new FileSystemException(e);
- }
- catch (final InvocationTargetException e)
- {
+ } catch (final InvocationTargetException e) {
throw new FileSystemException(e);
}
}
@@ -361,36 +303,18 @@ public class DelegatingFileSystemOptions
* invokes the method with the converted values
*/
private void invokeSetter(final Class<?> valueParameter, final Context ctx, final Method configSetter,
- final Object values)
- throws FileSystemException
- {
+ final Object values) throws FileSystemException {
Object[] args;
- if (valueParameter.isArray())
- {
- args = new Object[]
- {
- ctx.fso,
- values
- };
- }
- else
- {
- args = new Object[]
- {
- ctx.fso,
- Array.get(values, 0)
- };
+ if (valueParameter.isArray()) {
+ args = new Object[] { ctx.fso, values };
+ } else {
+ args = new Object[] { ctx.fso, Array.get(values, 0) };
}
- try
- {
+ try {
configSetter.invoke(ctx.fileSystemConfigBuilder, args);
- }
- catch (final IllegalAccessException e)
- {
+ } catch (final IllegalAccessException e) {
throw new FileSystemException(e);
- }
- catch (final InvocationTargetException e)
- {
+ } catch (final InvocationTargetException e) {
throw new FileSystemException(e);
}
}
@@ -398,13 +322,10 @@ public class DelegatingFileSystemOptions
/**
* fills all available set*() methods for the context-scheme into the context.
*/
- private boolean fillConfigSetters(final Context ctx)
- throws FileSystemException
- {
+ private boolean fillConfigSetters(final Context ctx) throws FileSystemException {
final Map<String, List<Method>> schemeMethods = getSchemeMethods(ctx.scheme);
final List<Method> configSetters = schemeMethods.get(ctx.name.toLowerCase());
- if (configSetters == null)
- {
+ if (configSetters == null) {
return false;
}
@@ -415,11 +336,9 @@ public class DelegatingFileSystemOptions
/**
* get (cached) list of set*() methods for the given scheme
*/
- private Map<String, List<Method>> getSchemeMethods(final String scheme) throws FileSystemException
- {
+ private Map<String, List<Method>> getSchemeMethods(final String scheme) throws FileSystemException {
Map<String, List<Method>> schemeMethods = beanMethods.get(scheme);
- if (schemeMethods == null)
- {
+ if (schemeMethods == null) {
schemeMethods = createSchemeMethods(scheme);
beanMethods.put(scheme, schemeMethods);
}
@@ -430,27 +349,22 @@ public class DelegatingFileSystemOptions
/**
* create the list of all set*() methods for the given scheme
*/
- private Map<String, List<Method>> createSchemeMethods(final String scheme) throws FileSystemException
- {
+ private Map<String, List<Method>> createSchemeMethods(final String scheme) throws FileSystemException {
final FileSystemConfigBuilder fscb = getManager().getFileSystemConfigBuilder(scheme);
- if (fscb == null)
- {
+ if (fscb == null) {
throw new FileSystemException("vfs.provider/no-config-builder.error", scheme);
}
final Map<String, List<Method>> schemeMethods = new TreeMap<>();
final Method[] methods = fscb.getClass().getMethods();
- for (final Method method : methods)
- {
- if (!Modifier.isPublic(method.getModifiers()))
- {
+ for (final Method method : methods) {
+ if (!Modifier.isPublic(method.getModifiers())) {
continue;
}
final String methodName = method.getName();
- if (!methodName.startsWith("set"))
- {
+ if (!methodName.startsWith("set")) {
// not a setter
continue;
}
@@ -458,8 +372,7 @@ public class DelegatingFileSystemOptions
final String key = methodName.substring(3).toLowerCase();
List<Method> configSetter = schemeMethods.get(key);
- if (configSetter == null)
- {
+ if (configSetter == null) {
configSetter = new ArrayList<>(2);
schemeMethods.put(key, configSetter);
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/EncryptUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/EncryptUtil.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/EncryptUtil.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/EncryptUtil.java Thu Sep 14 19:26:39 2017
@@ -18,36 +18,32 @@ package org.apache.commons.vfs2.util;
/**
* Allows passwords to be encrypted and decrypted.
+ *
* @since 2.0
*/
-public final class EncryptUtil
-{
+public final class EncryptUtil {
/**
* Don't allow class instantiation.
*/
- private EncryptUtil()
- {
+ private EncryptUtil() {
}
/**
- * This class can be called with "encrypt" password as the arguments where encrypt is
- * a literal and password is replaced with the clear text password to be encrypted.
+ * This class can be called with "encrypt" password as the arguments where encrypt is a literal and password is
+ * replaced with the clear text password to be encrypted.
*
* @param args The arguments in the form "command" parm1, parm2.
* @throws Exception If an error occurs.
*/
- public static void main(final String[] args) throws Exception
- {
- if (args.length != 2 || !args[0].equals("encrypt"))
- {
+ public static void main(final String[] args) throws Exception {
+ if (args.length != 2 || !args[0].equals("encrypt")) {
System.err.println("Usage: \"EncryptUtil encrypt\" password");
System.err.println(" password : The clear text password to encrypt");
System.exit(0);
}
final Cryptor cryptor = CryptorFactory.getCryptor();
- if (args[0].equals("encrypt"))
- {
+ if (args[0].equals("encrypt")) {
System.out.println(cryptor.encrypt(args[1]));
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/FileObjectUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/FileObjectUtils.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/FileObjectUtils.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/FileObjectUtils.java Thu Sep 14 19:26:39 2017
@@ -24,31 +24,26 @@ import org.apache.commons.vfs2.provider.
/**
* Stuff to get some strange things from an FileObject.
*/
-public final class FileObjectUtils
-{
- private FileObjectUtils()
- {
+public final class FileObjectUtils {
+ private FileObjectUtils() {
}
/**
* Get access to the base object even if decorated.
+ *
* @param fileObject The FileObject.
* @return The decorated FileObject or null.
* @throws FileSystemException if an error occurs.
*/
- public static AbstractFileObject getAbstractFileObject(final FileObject fileObject) throws FileSystemException
- {
+ public static AbstractFileObject getAbstractFileObject(final FileObject fileObject) throws FileSystemException {
Object searchObject = fileObject;
- while (searchObject instanceof DecoratedFileObject)
- {
+ while (searchObject instanceof DecoratedFileObject) {
searchObject = ((DecoratedFileObject) searchObject).getDecoratedFileObject();
}
- if (searchObject instanceof AbstractFileObject)
- {
+ if (searchObject instanceof AbstractFileObject) {
return (AbstractFileObject) searchObject;
}
- if (searchObject == null)
- {
+ if (searchObject == null) {
return null;
}
@@ -58,27 +53,24 @@ public final class FileObjectUtils
/**
* Check if the given FileObject is instance of given class argument.
+ *
* @param fileObject The FileObject.
* @param wantedClass The Class to check.
* @return true if fileObject is an instance of the specified Class.
* @throws FileSystemException if an error occurs.
*/
public static boolean isInstanceOf(final FileObject fileObject, final Class<?> wantedClass)
- throws FileSystemException
- {
+ throws FileSystemException {
Object searchObject = fileObject;
- while (searchObject instanceof DecoratedFileObject)
- {
- if (wantedClass.isInstance(searchObject))
- {
+ while (searchObject instanceof DecoratedFileObject) {
+ if (wantedClass.isInstance(searchObject)) {
return true;
}
searchObject = ((DecoratedFileObject) searchObject).getDecoratedFileObject();
}
- if (wantedClass.isInstance(searchObject))
- {
+ if (wantedClass.isInstance(searchObject)) {
return true;
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Messages.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Messages.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Messages.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Messages.java Thu Sep 14 19:26:39 2017
@@ -25,16 +25,14 @@ import java.util.concurrent.ConcurrentMa
/**
* Formats messages.
*/
-public final class Messages
-{
+public final class Messages {
/**
* Map from message code to MessageFormat object for the message.
*/
private static ConcurrentMap<String, MessageFormat> messageMap = new ConcurrentHashMap<>();
private static final ResourceBundle RESOURCES = new CombinedResources("org.apache.commons.vfs2.Resources");
- private Messages()
- {
+ private Messages() {
}
/**
@@ -43,49 +41,40 @@ public final class Messages
* @param code The message code.
* @return The formatted message.
*/
- public static String getString(final String code)
- {
+ public static String getString(final String code) {
return getString(code, new Object[0]);
}
/**
* Formats a message.
*
- * @param code
- * The message code.
- * @param param
- * The message parameter.
+ * @param code The message code.
+ * @param param The message parameter.
* @return The formatted message.
* @deprecated Will be removed in 3.0 in favor of {@link #getString(String, Object[])} When removed, calls to this
* method will automatically recompile to {@link #getString(String, Object[])}
*/
@Deprecated
- public static String getString(final String code, final Object param)
- {
- return getString(code, new Object[]{param});
+ public static String getString(final String code, final Object param) {
+ return getString(code, new Object[] { param });
}
/**
* Formats a message.
*
- * @param code The message code.
+ * @param code The message code.
* @param params The message parameters.
* @return The formatted message.
*/
- public static String getString(final String code, final Object... params)
- {
- try
- {
- if (code == null)
- {
+ public static String getString(final String code, final Object... params) {
+ try {
+ if (code == null) {
return null;
}
final MessageFormat msg = findMessage(code);
return msg.format(params);
- }
- catch (final MissingResourceException mre)
- {
+ } catch (final MissingResourceException mre) {
return "Unknown message with code \"" + code + "\".";
}
}
@@ -93,13 +82,10 @@ public final class Messages
/**
* Locates a message by its code.
*/
- private static MessageFormat findMessage(final String code)
- throws MissingResourceException
- {
+ private static MessageFormat findMessage(final String code) throws MissingResourceException {
// Check if the message is cached
MessageFormat msg = messageMap.get(code);
- if (msg != null)
- {
+ if (msg != null) {
return msg;
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorInputStream.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorInputStream.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorInputStream.java Thu Sep 14 19:26:39 2017
@@ -25,30 +25,25 @@ import java.util.concurrent.atomic.Atomi
/**
* An InputStream that provides buffering and end-of-stream monitoring.
*/
-public class MonitorInputStream
- extends BufferedInputStream
-{
+public class MonitorInputStream extends BufferedInputStream {
private static final int EOF_CHAR = -1;
private final AtomicBoolean finished = new AtomicBoolean(false);
private final AtomicLong atomicCount = new AtomicLong(0);
- public MonitorInputStream(final InputStream in)
- {
+ public MonitorInputStream(final InputStream in) {
super(in);
}
-
/**
* Returns 0 if the stream is at EOF, else the underlying inputStream will be queried.
+ *
* @return The number of bytes that are available.
* @throws IOException if an error occurs.
* @since 2.0
*/
@Override
- public synchronized int available() throws IOException
- {
- if (finished.get())
- {
+ public synchronized int available() throws IOException {
+ if (finished.get()) {
return 0;
}
@@ -57,20 +52,18 @@ public class MonitorInputStream
/**
* Reads a character.
+ *
* @return The character that was read as an integer.
* @throws IOException if an error occurs.
*/
@Override
- public int read() throws IOException
- {
- if (finished.get())
- {
+ public int read() throws IOException {
+ if (finished.get()) {
return EOF_CHAR;
}
final int ch = super.read();
- if (ch != EOF_CHAR)
- {
+ if (ch != EOF_CHAR) {
atomicCount.incrementAndGet();
return ch;
}
@@ -82,6 +75,7 @@ public class MonitorInputStream
/**
* Reads bytes from this input stream.
+ *
* @param buffer A byte array in which to place the characters read.
* @param offset The offset at which to start reading.
* @param length The maximum number of bytes to read.
@@ -89,17 +83,13 @@ public class MonitorInputStream
* @throws IOException if an error occurs.
*/
@Override
- public int read(final byte[] buffer, final int offset, final int length)
- throws IOException
- {
- if (finished.get())
- {
+ public int read(final byte[] buffer, final int offset, final int length) throws IOException {
+ if (finished.get()) {
return EOF_CHAR;
}
final int nread = super.read(buffer, offset, length);
- if (nread != EOF_CHAR)
- {
+ if (nread != EOF_CHAR) {
atomicCount.addAndGet(nread);
return nread;
}
@@ -110,61 +100,51 @@ public class MonitorInputStream
}
/**
- * Closes this input stream and releases any system resources
- * associated with the stream.
+ * Closes this input stream and releases any system resources associated with the stream.
+ *
* @throws IOException if an error occurs.
*/
@Override
- public void close() throws IOException
- {
+ public void close() throws IOException {
final boolean closed = finished.getAndSet(true);
- if (closed)
- {
+ if (closed) {
return;
}
// Close the stream
IOException exc = null;
- try
- {
+ try {
super.close();
- }
- catch (final IOException ioe)
- {
+ } catch (final IOException ioe) {
exc = ioe;
}
// Notify that the stream has been closed
- try
- {
+ try {
onClose();
- }
- catch (final IOException ioe)
- {
+ } catch (final IOException ioe) {
exc = ioe;
}
- if (exc != null)
- {
+ if (exc != null) {
throw exc;
}
}
/**
- * Called after the stream has been closed. This implementation does
- * nothing.
+ * Called after the stream has been closed. This implementation does nothing.
+ *
* @throws IOException if an error occurs.
*/
- protected void onClose() throws IOException
- {
+ protected void onClose() throws IOException {
}
/**
* Get the number of bytes read by this input stream.
+ *
* @return The number of bytes read by this input stream.
*/
- public long getCount()
- {
+ public long getCount() {
return atomicCount.get();
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorOutputStream.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorOutputStream.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorOutputStream.java Thu Sep 14 19:26:39 2017
@@ -26,85 +26,67 @@ import org.apache.commons.vfs2.FileSyste
/**
* An OutputStream that provides buffering and end-of-stream monitoring.
*/
-public class MonitorOutputStream
- extends BufferedOutputStream
-{
+public class MonitorOutputStream extends BufferedOutputStream {
private final AtomicBoolean finished = new AtomicBoolean(false);
- public MonitorOutputStream(final OutputStream out)
- {
+ public MonitorOutputStream(final OutputStream out) {
super(out);
}
/**
* Closes this output stream.
* <p>
- * This makes sure the buffers are flushed, close the output
- * stream and it will call {@link #onClose()}
- * and re-throw last exception from any of the three.
+ * This makes sure the buffers are flushed, close the output stream and it will call {@link #onClose()} and re-throw
+ * last exception from any of the three.
* <p>
* This does nothing if the stream is closed already.
*
* @throws IOException if an error occurs.
*/
@Override
- public void close() throws IOException
- {
+ public void close() throws IOException {
// do not use super.close()
// on Java 8 it might throw self suppression, see JDK-8042377
// in older Java it silently ignores flush() errors
- if (finished.getAndSet(true))
- {
+ if (finished.getAndSet(true)) {
return;
}
IOException exc = null;
// flush the buffer and out stream
- try
- {
+ try {
super.flush();
- }
- catch (final IOException ioe)
- {
+ } catch (final IOException ioe) {
exc = ioe;
}
// close the out stream without using super.close()
- try
- {
+ try {
super.out.close();
- }
- catch (final IOException ioe)
- {
+ } catch (final IOException ioe) {
exc = ioe;
}
// Notify of end of output
- try
- {
+ try {
onClose();
- }
- catch (final IOException ioe)
- {
+ } catch (final IOException ioe) {
exc = ioe;
}
- if (exc != null)
- {
+ if (exc != null) {
throw exc;
}
}
-
/**
* @param b The character to write.
* @throws IOException if an error occurs.
* @since 2.0
*/
@Override
- public synchronized void write(final int b) throws IOException
- {
+ public synchronized void write(final int b) throws IOException {
assertOpen();
super.write(b);
}
@@ -117,8 +99,7 @@ public class MonitorOutputStream
* @since 2.0
*/
@Override
- public synchronized void write(final byte[] b, final int off, final int len) throws IOException
- {
+ public synchronized void write(final byte[] b, final int off, final int len) throws IOException {
assertOpen();
super.write(b, off, len);
}
@@ -128,8 +109,7 @@ public class MonitorOutputStream
* @since 2.0
*/
@Override
- public synchronized void flush() throws IOException
- {
+ public synchronized void flush() throws IOException {
assertOpen();
super.flush();
}
@@ -140,8 +120,7 @@ public class MonitorOutputStream
* @since 2.0
*/
@Override
- public void write(final byte[] b) throws IOException
- {
+ public void write(final byte[] b) throws IOException {
assertOpen();
super.write(b);
}
@@ -149,16 +128,14 @@ public class MonitorOutputStream
/**
* Check if file is still open.
* <p>
- * This is a workaround for an oddity with Java's BufferedOutputStream where you can write to
- * even if the stream has been closed.
+ * This is a workaround for an oddity with Java's BufferedOutputStream where you can write to even if the stream has
+ * been closed.
*
* @throws FileSystemException if already closed.
* @since 2.0
*/
- protected void assertOpen() throws FileSystemException
- {
- if (finished.get())
- {
+ protected void assertOpen() throws FileSystemException {
+ if (finished.get()) {
throw new FileSystemException("vfs.provider/closed.error");
}
}
@@ -171,7 +148,6 @@ public class MonitorOutputStream
* @throws IOException if an error occurs.
*/
// IOException is needed because subclasses may need to throw it
- protected void onClose() throws IOException
- {
+ protected void onClose() throws IOException {
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorRandomAccessContent.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorRandomAccessContent.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorRandomAccessContent.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/MonitorRandomAccessContent.java Thu Sep 14 19:26:39 2017
@@ -24,13 +24,11 @@ import org.apache.commons.vfs2.RandomAcc
/**
* A RandomAccessContent that provides end-of-stream monitoring.
*/
-public class MonitorRandomAccessContent implements RandomAccessContent
-{
+public class MonitorRandomAccessContent implements RandomAccessContent {
private final RandomAccessContent content;
private boolean finished;
- public MonitorRandomAccessContent(final RandomAccessContent content)
- {
+ public MonitorRandomAccessContent(final RandomAccessContent content) {
this.content = content;
}
@@ -40,253 +38,210 @@ public class MonitorRandomAccessContent
* @throws IOException if subclass throws it.
*/
@SuppressWarnings("unused") // IOException is needed because subclasses may need to throw it
- protected void onClose() throws IOException
- {
+ protected void onClose() throws IOException {
}
/**
* Closes this content.
+ *
* @throws IOException if an error occurs.
*/
@Override
- public void close() throws IOException
- {
- if (finished)
- {
+ public void close() throws IOException {
+ if (finished) {
return;
}
// Close the output stream
IOException exc = null;
- try
- {
+ try {
content.close();
- }
- catch (final IOException ioe)
- {
+ } catch (final IOException ioe) {
exc = ioe;
}
// Notify of end of output
exc = null;
- try
- {
+ try {
onClose();
- }
- catch (final IOException ioe)
- {
+ } catch (final IOException ioe) {
exc = ioe;
}
finished = true;
- if (exc != null)
- {
+ if (exc != null) {
throw exc;
}
}
@Override
- public long getFilePointer() throws IOException
- {
+ public long getFilePointer() throws IOException {
return content.getFilePointer();
}
@Override
- public void seek(final long pos) throws IOException
- {
+ public void seek(final long pos) throws IOException {
content.seek(pos);
}
@Override
- public long length() throws IOException
- {
+ public long length() throws IOException {
return content.length();
}
@Override
- public void write(final int b) throws IOException
- {
+ public void write(final int b) throws IOException {
content.write(b);
}
@Override
- public void write(final byte[] b) throws IOException
- {
+ public void write(final byte[] b) throws IOException {
content.write(b);
}
@Override
- public void write(final byte[] b, final int off, final int len) throws IOException
- {
+ public void write(final byte[] b, final int off, final int len) throws IOException {
content.write(b, off, len);
}
@Override
- public void writeBoolean(final boolean v) throws IOException
- {
+ public void writeBoolean(final boolean v) throws IOException {
content.writeBoolean(v);
}
@Override
- public void writeByte(final int v) throws IOException
- {
+ public void writeByte(final int v) throws IOException {
content.writeByte(v);
}
@Override
- public void writeShort(final int v) throws IOException
- {
+ public void writeShort(final int v) throws IOException {
content.writeShort(v);
}
@Override
- public void writeChar(final int v) throws IOException
- {
+ public void writeChar(final int v) throws IOException {
content.writeChar(v);
}
@Override
- public void writeInt(final int v) throws IOException
- {
+ public void writeInt(final int v) throws IOException {
content.writeInt(v);
}
@Override
- public void writeLong(final long v) throws IOException
- {
+ public void writeLong(final long v) throws IOException {
content.writeLong(v);
}
@Override
- public void writeFloat(final float v) throws IOException
- {
+ public void writeFloat(final float v) throws IOException {
content.writeFloat(v);
}
@Override
- public void writeDouble(final double v) throws IOException
- {
+ public void writeDouble(final double v) throws IOException {
content.writeDouble(v);
}
@Override
- public void writeBytes(final String s) throws IOException
- {
+ public void writeBytes(final String s) throws IOException {
content.writeBytes(s);
}
@Override
- public void writeChars(final String s) throws IOException
- {
+ public void writeChars(final String s) throws IOException {
content.writeChars(s);
}
@Override
- public void writeUTF(final String str) throws IOException
- {
+ public void writeUTF(final String str) throws IOException {
content.writeUTF(str);
}
@Override
- public void readFully(final byte[] b) throws IOException
- {
+ public void readFully(final byte[] b) throws IOException {
content.readFully(b);
}
@Override
- public void readFully(final byte[] b, final int off, final int len) throws IOException
- {
+ public void readFully(final byte[] b, final int off, final int len) throws IOException {
content.readFully(b, off, len);
}
@Override
- public int skipBytes(final int n) throws IOException
- {
+ public int skipBytes(final int n) throws IOException {
return content.skipBytes(n);
}
@Override
- public void setLength(final long newLength) throws IOException
- {
+ public void setLength(final long newLength) throws IOException {
content.setLength(newLength);
}
@Override
- public boolean readBoolean() throws IOException
- {
+ public boolean readBoolean() throws IOException {
return content.readBoolean();
}
@Override
- public byte readByte() throws IOException
- {
+ public byte readByte() throws IOException {
return content.readByte();
}
@Override
- public int readUnsignedByte() throws IOException
- {
+ public int readUnsignedByte() throws IOException {
return content.readUnsignedByte();
}
@Override
- public short readShort() throws IOException
- {
+ public short readShort() throws IOException {
return content.readShort();
}
@Override
- public int readUnsignedShort() throws IOException
- {
+ public int readUnsignedShort() throws IOException {
return content.readUnsignedShort();
}
@Override
- public char readChar() throws IOException
- {
+ public char readChar() throws IOException {
return content.readChar();
}
@Override
- public int readInt() throws IOException
- {
+ public int readInt() throws IOException {
return content.readInt();
}
@Override
- public long readLong() throws IOException
- {
+ public long readLong() throws IOException {
return content.readLong();
}
@Override
- public float readFloat() throws IOException
- {
+ public float readFloat() throws IOException {
return content.readFloat();
}
@Override
- public double readDouble() throws IOException
- {
+ public double readDouble() throws IOException {
return content.readDouble();
}
@Override
- public String readLine() throws IOException
- {
+ public String readLine() throws IOException {
return content.readLine();
}
@Override
- public String readUTF() throws IOException
- {
+ public String readUTF() throws IOException {
return content.readUTF();
}
@Override
- public InputStream getInputStream() throws IOException
- {
+ public InputStream getInputStream() throws IOException {
return content.getInputStream();
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Os.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Os.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Os.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/Os.java Thu Sep 14 19:26:39 2017
@@ -26,8 +26,7 @@ import java.util.Set;
/**
* Class to help determining the OS.
*/
-public final class Os
-{
+public final class Os {
/**
* All Windows based OSes.
*/
@@ -41,26 +40,23 @@ public final class Os
/**
* All Windows NT based OSes.
*/
- public static final OsFamily OS_FAMILY_WINNT =
- new OsFamily("nt", new OsFamily[]{OS_FAMILY_WINDOWS});
+ public static final OsFamily OS_FAMILY_WINNT = new OsFamily("nt", new OsFamily[] { OS_FAMILY_WINDOWS });
/**
* All Windows 9x based OSes.
*/
- public static final OsFamily OS_FAMILY_WIN9X =
- new OsFamily("win9x", new OsFamily[]{OS_FAMILY_WINDOWS, OS_FAMILY_DOS});
+ public static final OsFamily OS_FAMILY_WIN9X = new OsFamily("win9x",
+ new OsFamily[] { OS_FAMILY_WINDOWS, OS_FAMILY_DOS });
/**
* OS/2.
*/
- public static final OsFamily OS_FAMILY_OS2 =
- new OsFamily("os/2", new OsFamily[]{OS_FAMILY_DOS});
+ public static final OsFamily OS_FAMILY_OS2 = new OsFamily("os/2", new OsFamily[] { OS_FAMILY_DOS });
/**
* Netware.
*/
- public static final OsFamily OS_FAMILY_NETWARE =
- new OsFamily("netware");
+ public static final OsFamily OS_FAMILY_NETWARE = new OsFamily("netware");
/**
* All UNIX based OSes.
@@ -75,34 +71,19 @@ public final class Os
/**
* OSX.
*/
- public static final OsFamily OS_FAMILY_OSX =
- new OsFamily("osx", new OsFamily[]{OS_FAMILY_UNIX, OS_FAMILY_MAC});
+ public static final OsFamily OS_FAMILY_OSX = new OsFamily("osx", new OsFamily[] { OS_FAMILY_UNIX, OS_FAMILY_MAC });
- private static final String OS_NAME =
- System.getProperty("os.name").toLowerCase(Locale.US);
- private static final String OS_ARCH =
- System.getProperty("os.arch").toLowerCase(Locale.US);
- private static final String OS_VERSION =
- System.getProperty("os.version").toLowerCase(Locale.US);
+ private static final String OS_NAME = System.getProperty("os.name").toLowerCase(Locale.US);
+ private static final String OS_ARCH = System.getProperty("os.arch").toLowerCase(Locale.US);
+ private static final String OS_VERSION = System.getProperty("os.version").toLowerCase(Locale.US);
private static final String PATH_SEP = File.pathSeparator;
private static final OsFamily OS_FAMILY;
private static final OsFamily[] OS_ALL_FAMILIES;
- private static final OsFamily[] ALL_FAMILIES = new OsFamily[]
- {
- OS_FAMILY_DOS,
- OS_FAMILY_MAC,
- OS_FAMILY_NETWARE,
- OS_FAMILY_OS2,
- OS_FAMILY_OSX,
- OS_FAMILY_UNIX,
- OS_FAMILY_WINDOWS,
- OS_FAMILY_WINNT,
- OS_FAMILY_WIN9X
- };
+ private static final OsFamily[] ALL_FAMILIES = new OsFamily[] { OS_FAMILY_DOS, OS_FAMILY_MAC, OS_FAMILY_NETWARE,
+ OS_FAMILY_OS2, OS_FAMILY_OSX, OS_FAMILY_UNIX, OS_FAMILY_WINDOWS, OS_FAMILY_WINNT, OS_FAMILY_WIN9X };
- static
- {
+ static {
OS_FAMILY = determineOsFamily();
OS_ALL_FAMILIES = determineAllFamilies();
}
@@ -110,51 +91,46 @@ public final class Os
/**
* Private constructor to block instantiation.
*/
- private Os()
- {
+ private Os() {
}
/**
- * Determines if the OS on which Ant is executing matches the given OS
- * version.
+ * Determines if the OS on which Ant is executing matches the given OS version.
+ *
* @param version The version to check.
* @return true if the version matches.
*/
- public static boolean isVersion(final String version)
- {
+ public static boolean isVersion(final String version) {
return isOs((OsFamily) null, null, null, version);
}
/**
- * Determines if the OS on which Ant is executing matches the given OS
- * architecture.
+ * Determines if the OS on which Ant is executing matches the given OS architecture.
+ *
* @param arch The architecture to check.
* @return true if the architecture mataches.
*/
- public static boolean isArch(final String arch)
- {
+ public static boolean isArch(final String arch) {
return isOs((OsFamily) null, null, arch, null);
}
/**
- * Determines if the OS on which Ant is executing matches the given OS
- * family.
+ * Determines if the OS on which Ant is executing matches the given OS family.
+ *
* @param family The family to check.
* @return true if the family matches.
*/
- public static boolean isFamily(final String family)
- {
+ public static boolean isFamily(final String family) {
return isOs(family, null, null, null);
}
/**
- * Determines if the OS on which Ant is executing matches the given OS
- * family.
+ * Determines if the OS on which Ant is executing matches the given OS family.
+ *
* @param family The family to check.
* @return true if the family matches.
*/
- public static boolean isFamily(final OsFamily family)
- {
+ public static boolean isFamily(final OsFamily family) {
return isOs(family, null, null, null);
}
@@ -165,46 +141,34 @@ public final class Os
* @return The Name value
* @since 1.7
*/
- public static boolean isName(final String name)
- {
+ public static boolean isName(final String name) {
return isOs((OsFamily) null, name, null, null);
}
/**
- * Determines if the OS on which Ant is executing matches the given OS
- * family, name, architecture and version.
+ * Determines if the OS on which Ant is executing matches the given OS family, name, architecture and version.
*
- * @param family The OS family
- * @param name The OS name
- * @param arch The OS architecture
+ * @param family The OS family
+ * @param name The OS name
+ * @param arch The OS architecture
* @param version The OS version
* @return The Os value
*/
- public static boolean isOs(final String family,
- final String name,
- final String arch,
- final String version)
- {
+ public static boolean isOs(final String family, final String name, final String arch, final String version) {
return isOs(getFamily(family), name, arch, version);
}
/**
- * Determines if the OS on which Ant is executing matches the given OS
- * family, name, architecture and version.
+ * Determines if the OS on which Ant is executing matches the given OS family, name, architecture and version.
*
- * @param family The OS family
- * @param name The OS name
- * @param arch The OS architecture
+ * @param family The OS family
+ * @param name The OS name
+ * @param arch The OS architecture
* @param version The OS version
* @return The Os value
*/
- public static boolean isOs(final OsFamily family,
- final String name,
- final String arch,
- final String version)
- {
- if (family != null || name != null || arch != null || version != null)
- {
+ public static boolean isOs(final OsFamily family, final String name, final String arch, final String version) {
+ if (family != null || name != null || arch != null || version != null) {
final boolean isFamily = familyMatches(family);
final boolean isName = nameMatches(name);
final boolean isArch = archMatches(arch);
@@ -221,12 +185,9 @@ public final class Os
* @param name The family name to lookup.
* @return the OS family, or null if not found.
*/
- public static OsFamily getFamily(final String name)
- {
- for (final OsFamily osFamily : ALL_FAMILIES)
- {
- if (osFamily.getName().equalsIgnoreCase(name))
- {
+ public static OsFamily getFamily(final String name) {
+ for (final OsFamily osFamily : ALL_FAMILIES) {
+ if (osFamily.getName().equalsIgnoreCase(name)) {
return osFamily;
}
}
@@ -234,67 +195,53 @@ public final class Os
return null;
}
- private static boolean versionMatches(final String version)
- {
+ private static boolean versionMatches(final String version) {
boolean isVersion = true;
- if (version != null)
- {
+ if (version != null) {
isVersion = version.equalsIgnoreCase(OS_VERSION);
}
return isVersion;
}
- private static boolean archMatches(final String arch)
- {
+ private static boolean archMatches(final String arch) {
boolean isArch = true;
- if (arch != null)
- {
+ if (arch != null) {
isArch = arch.equalsIgnoreCase(OS_ARCH);
}
return isArch;
}
- private static boolean nameMatches(final String name)
- {
+ private static boolean nameMatches(final String name) {
boolean isName = true;
- if (name != null)
- {
+ if (name != null) {
isName = name.equalsIgnoreCase(OS_NAME);
}
return isName;
}
- private static boolean familyMatches(final OsFamily family)
- {
- if (family == null)
- {
+ private static boolean familyMatches(final OsFamily family) {
+ if (family == null) {
return false;
}
- for (final OsFamily osFamily : OS_ALL_FAMILIES)
- {
- if (family == osFamily)
- {
+ for (final OsFamily osFamily : OS_ALL_FAMILIES) {
+ if (family == osFamily) {
return true;
}
}
return false;
}
- private static OsFamily[] determineAllFamilies()
- {
+ private static OsFamily[] determineAllFamilies() {
// Determine all families the current OS belongs to
final Set<OsFamily> allFamilies = new HashSet<>();
- if (OS_FAMILY != null)
- {
+ if (OS_FAMILY != null) {
final List<OsFamily> queue = new ArrayList<>();
queue.add(OS_FAMILY);
- while (queue.size() > 0)
- {
+ while (queue.size() > 0) {
final OsFamily family = queue.remove(0);
allFamilies.add(family);
final OsFamily[] families = family.getFamilies();
- for (final OsFamily parent : families)
- {
+ for (final OsFamily parent : families) {
queue.add(parent);
}
}
@@ -302,41 +249,25 @@ public final class Os
return allFamilies.toArray(new OsFamily[allFamilies.size()]);
}
- private static OsFamily determineOsFamily()
- {
+ private static OsFamily determineOsFamily() {
// Determine the most specific OS family
- if (OS_NAME.indexOf("windows") > -1)
- {
- if (OS_NAME.indexOf("xp") > -1
- || OS_NAME.indexOf("2000") > -1
- || OS_NAME.indexOf("nt") > -1)
- {
+ if (OS_NAME.indexOf("windows") > -1) {
+ if (OS_NAME.indexOf("xp") > -1 || OS_NAME.indexOf("2000") > -1 || OS_NAME.indexOf("nt") > -1) {
return OS_FAMILY_WINNT;
}
return OS_FAMILY_WIN9X;
- }
- else if (OS_NAME.indexOf("os/2") > -1)
- {
+ } else if (OS_NAME.indexOf("os/2") > -1) {
return OS_FAMILY_OS2;
- }
- else if (OS_NAME.indexOf("netware") > -1)
- {
+ } else if (OS_NAME.indexOf("netware") > -1) {
return OS_FAMILY_NETWARE;
- }
- else if (OS_NAME.indexOf("mac") > -1)
- {
- if (OS_NAME.endsWith("x"))
- {
+ } else if (OS_NAME.indexOf("mac") > -1) {
+ if (OS_NAME.endsWith("x")) {
return OS_FAMILY_OSX;
}
return OS_FAMILY_MAC;
- }
- else if (PATH_SEP.equals(":"))
- {
+ } else if (PATH_SEP.equals(":")) {
return OS_FAMILY_UNIX;
- }
- else
- {
+ } else {
return null;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/OsFamily.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/OsFamily.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/OsFamily.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/OsFamily.java Thu Sep 14 19:26:39 2017
@@ -19,38 +19,35 @@ package org.apache.commons.vfs2.util;
/**
* An enumerated type, which represents an OS family.
*/
-public final class OsFamily
-{
+public final class OsFamily {
private final String name;
private final OsFamily[] families;
- OsFamily(final String name)
- {
+ OsFamily(final String name) {
this.name = name;
families = new OsFamily[0];
}
- OsFamily(final String name, final OsFamily[] families)
- {
+ OsFamily(final String name, final OsFamily[] families) {
this.name = name;
this.families = families;
}
/**
* Returns the name of this family.
+ *
* @return The name of this family.
*/
- public String getName()
- {
+ public String getName() {
return name;
}
/**
* Returns the OS families that this family belongs to.
+ *
* @return an array of OSFamily objects that this family belongs to.
*/
- public OsFamily[] getFamilies()
- {
+ public OsFamily[] getFamilies() {
return families;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/PosixPermissions.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/PosixPermissions.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/PosixPermissions.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/PosixPermissions.java Thu Sep 14 19:26:39 2017
@@ -25,14 +25,12 @@ import java.util.Map;
*
* @since 2.1
*/
-public class PosixPermissions
-{
+public class PosixPermissions {
/**
* Permission types.
*/
- public static enum Type
- {
+ public static enum Type {
/**
* User right readable.
*/
@@ -83,8 +81,7 @@ public class PosixPermissions
/**
* Initialize with the mask
*/
- private Type(final int mask)
- {
+ private Type(final int mask) {
this.mask = mask;
}
@@ -93,8 +90,7 @@ public class PosixPermissions
*
* @return the mask for this permission.
*/
- public int getMask()
- {
+ public int getMask() {
return this.mask;
}
@@ -118,15 +114,11 @@ public class PosixPermissions
/**
* Creates a new PosixPermissions object.
*
- * @param permissions
- * The permissions
- * @param isOwner
- * true if the user is the owner of the file
- * @param isInGroup
- * true if the user is a group owner of the file
+ * @param permissions The permissions
+ * @param isOwner true if the user is the owner of the file
+ * @param isInGroup true if the user is a group owner of the file
*/
- public PosixPermissions(final int permissions, final boolean isOwner, final boolean isInGroup)
- {
+ public PosixPermissions(final int permissions, final boolean isOwner, final boolean isInGroup) {
this.permissions = permissions;
this.isOwner = isOwner;
this.isInGroup = isInGroup;
@@ -135,22 +127,16 @@ public class PosixPermissions
/**
* Computes new permission from old ones.
*
- * @param values
- * The permissions to set.
+ * @param values The permissions to set.
* @return The new permissions.
*/
- private int computeNewPermissions(final Map<Type, Boolean> values)
- {
+ private int computeNewPermissions(final Map<Type, Boolean> values) {
int newPerms = this.permissions;
- for (final Map.Entry<Type, Boolean> entry : values.entrySet())
- {
+ for (final Map.Entry<Type, Boolean> entry : values.entrySet()) {
final Type type = entry.getKey();
- if (entry.getValue())
- {
+ if (entry.getValue()) {
newPerms |= type.getMask();
- }
- else
- {
+ } else {
newPerms &= ~type.getMask();
}
}
@@ -162,8 +148,7 @@ public class PosixPermissions
*
* @return whether the bit corresponding to the permission is set.
*/
- private boolean get(final Type type)
- {
+ private boolean get(final Type type) {
return (type.getMask() & this.permissions) != 0;
}
@@ -172,8 +157,7 @@ public class PosixPermissions
*
* @return permissions.
*/
- public int getPermissions()
- {
+ public int getPermissions() {
return this.permissions;
}
@@ -182,14 +166,11 @@ public class PosixPermissions
*
* @return whether the permissions are executable.
*/
- public boolean isExecutable()
- {
- if (this.isOwner)
- {
+ public boolean isExecutable() {
+ if (this.isOwner) {
return this.get(Type.UserExecutable);
}
- if (this.isInGroup)
- {
+ if (this.isInGroup) {
return this.get(Type.GroupExecutable);
}
return this.get(Type.OtherExecutable);
@@ -200,14 +181,11 @@ public class PosixPermissions
*
* @return whether the permissions are readable.
*/
- public boolean isReadable()
- {
- if (this.isOwner)
- {
+ public boolean isReadable() {
+ if (this.isOwner) {
return this.get(Type.UserReadable);
}
- if (this.isInGroup)
- {
+ if (this.isInGroup) {
return this.get(Type.GroupReadable);
}
return this.get(Type.OtherReadable);
@@ -218,14 +196,11 @@ public class PosixPermissions
*
* @return whether the permissions are writable.
*/
- public boolean isWritable()
- {
- if (this.isOwner)
- {
+ public boolean isWritable() {
+ if (this.isOwner) {
return this.get(Type.UserWritable);
}
- if (this.isInGroup)
- {
+ if (this.isInGroup) {
return this.get(Type.GroupWritable);
}
return this.get(Type.OtherWritable);
@@ -234,18 +209,14 @@ public class PosixPermissions
/**
* Creates new permissions based on these permissions.
*
- * @param executable
- * Whether the new permissions should be readable.
- * @param ownerOnly
- * Whether the new permissions are only for the owner.
+ * @param executable Whether the new permissions should be readable.
+ * @param ownerOnly Whether the new permissions are only for the owner.
* @return the new permissions.
*/
- public int makeExecutable(final boolean executable, final boolean ownerOnly)
- {
+ public int makeExecutable(final boolean executable, final boolean ownerOnly) {
final EnumMap<Type, Boolean> map = new EnumMap<>(Type.class);
map.put(Type.UserExecutable, executable);
- if (!ownerOnly)
- {
+ if (!ownerOnly) {
map.put(Type.GroupExecutable, executable);
map.put(Type.OtherExecutable, executable);
}
@@ -255,18 +226,14 @@ public class PosixPermissions
/**
* Creates new permissions based on these permissions.
*
- * @param readable
- * Whether the new permissions should be readable.
- * @param ownerOnly
- * Whether the new permissions are only for the owner.
+ * @param readable Whether the new permissions should be readable.
+ * @param ownerOnly Whether the new permissions are only for the owner.
* @return the new permissions.
*/
- public Integer makeReadable(final boolean readable, final boolean ownerOnly)
- {
+ public Integer makeReadable(final boolean readable, final boolean ownerOnly) {
final EnumMap<Type, Boolean> map = new EnumMap<>(Type.class);
map.put(Type.UserReadable, readable);
- if (!ownerOnly)
- {
+ if (!ownerOnly) {
map.put(Type.GroupReadable, readable);
map.put(Type.OtherReadable, readable);
}
@@ -276,18 +243,14 @@ public class PosixPermissions
/**
* Creates new permissions based on these permissions.
*
- * @param writable
- * Whether the new permissions should be readable.
- * @param ownerOnly
- * Whether the new permissions are only for the owner.
+ * @param writable Whether the new permissions should be readable.
+ * @param ownerOnly Whether the new permissions are only for the owner.
* @return the new permissions.
*/
- public Integer makeWritable(final boolean writable, final boolean ownerOnly)
- {
+ public Integer makeWritable(final boolean writable, final boolean ownerOnly) {
final EnumMap<Type, Boolean> map = new EnumMap<>(Type.class);
map.put(Type.UserWritable, writable);
- if (!ownerOnly)
- {
+ if (!ownerOnly) {
map.put(Type.GroupWritable, writable);
map.put(Type.OtherWritable, writable);
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java Thu Sep 14 19:26:39 2017
@@ -19,8 +19,7 @@ package org.apache.commons.vfs2.util;
/**
* An enumerated type representing the modes of a random access content.
*/
-public enum RandomAccessMode
-{
+public enum RandomAccessMode {
/**
* read.
*/
@@ -31,42 +30,33 @@ public enum RandomAccessMode
*/
READWRITE(true, true);
-
private final boolean read;
private final boolean write;
- private RandomAccessMode(final boolean read, final boolean write)
- {
+ private RandomAccessMode(final boolean read, final boolean write) {
this.read = read;
this.write = write;
}
- public boolean requestRead()
- {
+ public boolean requestRead() {
return read;
}
- public boolean requestWrite()
- {
+ public boolean requestWrite() {
return write;
}
/**
* @return The mode String.
* @since 2.0
- * */
- public String getModeString()
- {
- if (requestRead())
- {
- if (requestWrite())
- {
+ */
+ public String getModeString() {
+ if (requestRead()) {
+ if (requestWrite()) {
return "rw"; // NON-NLS
}
return "r"; // NON-NLS
- }
- else if (requestWrite())
- {
+ } else if (requestWrite()) {
return "w"; // NON-NLS
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/UserAuthenticatorUtils.java Thu Sep 14 19:26:39 2017
@@ -24,15 +24,13 @@ import org.apache.commons.vfs2.impl.Defa
/**
* Helps with authentication.
*/
-public final class UserAuthenticatorUtils
-{
- private UserAuthenticatorUtils()
- {
+public final class UserAuthenticatorUtils {
+ private UserAuthenticatorUtils() {
}
/**
- * Gets data of given type from the UserAuthenticationData or null if there is no data or data
- * of this type available.
+ * Gets data of given type from the UserAuthenticationData or null if there is no data or data of this type
+ * available.
*
* @param data The UserAuthenticationData.
* @param type The type of the element to retrieve.
@@ -40,15 +38,12 @@ public final class UserAuthenticatorUtil
* @return The data of the given type as a character array or null if the data is not available.
*/
public static char[] getData(final UserAuthenticationData data, final UserAuthenticationData.Type type,
- final char[] overriddenValue)
- {
- if (overriddenValue != null)
- {
+ final char[] overriddenValue) {
+ if (overriddenValue != null) {
return overriddenValue;
}
- if (data == null)
- {
+ if (data == null) {
return null;
}
@@ -63,8 +58,7 @@ public final class UserAuthenticatorUtil
* @return A UserAuthenticationData object containing the data requested.
*/
public static UserAuthenticationData authenticate(final FileSystemOptions opts,
- final UserAuthenticationData.Type[] authenticatorTypes)
- {
+ final UserAuthenticationData.Type[] authenticatorTypes) {
final UserAuthenticator auth = DefaultFileSystemConfigBuilder.getInstance().getUserAuthenticator(opts);
return authenticate(auth, authenticatorTypes);
}
@@ -77,10 +71,8 @@ public final class UserAuthenticatorUtil
* @return A UserAuthenticationData object containing the data requested.
*/
public static UserAuthenticationData authenticate(final UserAuthenticator auth,
- final UserAuthenticationData.Type[] authenticatorTypes)
- {
- if (auth == null)
- {
+ final UserAuthenticationData.Type[] authenticatorTypes) {
+ if (auth == null) {
return null;
}
@@ -93,10 +85,8 @@ public final class UserAuthenticatorUtil
* @param string The String to convert.
* @return The character array.
*/
- public static char[] toChar(final String string)
- {
- if (string == null)
- {
+ public static char[] toChar(final String string) {
+ if (string == null) {
return null;
}
@@ -108,10 +98,8 @@ public final class UserAuthenticatorUtil
*
* @param authData The UserAuthenticationDAta.
*/
- public static void cleanup(final UserAuthenticationData authData)
- {
- if (authData == null)
- {
+ public static void cleanup(final UserAuthenticationData authData) {
+ if (authData == null) {
return;
}
@@ -124,10 +112,8 @@ public final class UserAuthenticatorUtil
* @param data A character array containing the data to convert to a String.
* @return The String.
*/
- public static String toString(final char[] data)
- {
- if (data == null)
- {
+ public static String toString(final char[] data) {
+ if (data == null) {
return null;
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/WeakRefFileListener.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/WeakRefFileListener.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/WeakRefFileListener.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/WeakRefFileListener.java Thu Sep 14 19:26:39 2017
@@ -29,14 +29,12 @@ import org.apache.commons.vfs2.FileSyste
*
* @since 2.0
*/
-public class WeakRefFileListener implements FileListener
-{
+public class WeakRefFileListener implements FileListener {
private final FileSystem fs;
private final FileName name;
private final WeakReference<FileListener> listener;
- protected WeakRefFileListener(final FileObject file, final FileListener listener)
- {
+ protected WeakRefFileListener(final FileObject file, final FileListener listener) {
this.fs = file.getFileSystem();
this.name = file.getName();
this.listener = new WeakReference<>(listener);
@@ -44,27 +42,26 @@ public class WeakRefFileListener impleme
/**
* This will install the {@code listener} at the given {@code file}.
+ *
* @param file The FileObject to listen on.
* @param listener The FileListener
*/
- public static void installListener(final FileObject file, final FileListener listener)
- {
+ public static void installListener(final FileObject file, final FileListener listener) {
final WeakRefFileListener weakListener = new WeakRefFileListener(file, listener);
file.getFileSystem().addListener(file, new WeakRefFileListener(file, weakListener));
}
/**
- * returns the wrapped listener. If it is gone, the WeakRefFileListener wrapper will
- * remove itself from the list of listeners.
+ * returns the wrapped listener. If it is gone, the WeakRefFileListener wrapper will remove itself from the list of
+ * listeners.
+ *
* @return The FileListener.
* @throws Exception if an error occurs.
*/
- protected FileListener getListener() throws Exception
- {
+ protected FileListener getListener() throws Exception {
final FileListener listener = this.listener.get();
- if (listener == null)
- {
+ if (listener == null) {
final FileObject file = fs.resolveFile(name);
file.getFileSystem().removeListener(file, this);
}
@@ -73,15 +70,14 @@ public class WeakRefFileListener impleme
/**
* Called when a file is created.
+ *
* @param event The FileChangeEvent.
* @throws Exception if an error occurs.
*/
@Override
- public void fileCreated(final FileChangeEvent event) throws Exception
- {
+ public void fileCreated(final FileChangeEvent event) throws Exception {
final FileListener listener = getListener();
- if (listener == null)
- {
+ if (listener == null) {
return;
}
listener.fileCreated(event);
@@ -89,15 +85,14 @@ public class WeakRefFileListener impleme
/**
* Called when a file is deleted.
+ *
* @param event The FileChangeEvent.
* @throws Exception if an error occurs.
*/
@Override
- public void fileDeleted(final FileChangeEvent event) throws Exception
- {
+ public void fileDeleted(final FileChangeEvent event) throws Exception {
final FileListener listener = getListener();
- if (listener == null)
- {
+ if (listener == null) {
return;
}
listener.fileDeleted(event);
@@ -112,11 +107,9 @@ public class WeakRefFileListener impleme
* @throws Exception if an error occurs.
*/
@Override
- public void fileChanged(final FileChangeEvent event) throws Exception
- {
+ public void fileChanged(final FileChangeEvent event) throws Exception {
final FileListener listener = getListener();
- if (listener == null)
- {
+ if (listener == null) {
return;
}
listener.fileChanged(event);
Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/code/ClassToLoad.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/code/ClassToLoad.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/test/java/code/ClassToLoad.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/code/ClassToLoad.java Thu Sep 14 19:26:39 2017
@@ -19,13 +19,11 @@ package code;
/**
* The test class for the VFS classloader.
*/
-public class ClassToLoad
-{
+public class ClassToLoad {
private final String m_message = "**PRIVATE**";
@Override
- public String toString()
- {
+ public String toString() {
return m_message;
}
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/code/sealed/AnotherClass.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/code/sealed/AnotherClass.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/test/java/code/sealed/AnotherClass.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/code/sealed/AnotherClass.java Thu Sep 14 19:26:39 2017
@@ -19,6 +19,5 @@ package code.sealed;
/**
* A test class for the ClassLoader tests.
*/
-public class AnotherClass
-{
+public class AnotherClass {
}
Modified: commons/proper/vfs/trunk/commons-vfs2/src/test/java/com/jcraft/jsch/TestIdentityRepositoryFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/commons-vfs2/src/test/java/com/jcraft/jsch/TestIdentityRepositoryFactory.java?rev=1808381&r1=1808380&r2=1808381&view=diff
==============================================================================
--- commons/proper/vfs/trunk/commons-vfs2/src/test/java/com/jcraft/jsch/TestIdentityRepositoryFactory.java (original)
+++ commons/proper/vfs/trunk/commons-vfs2/src/test/java/com/jcraft/jsch/TestIdentityRepositoryFactory.java Thu Sep 14 19:26:39 2017
@@ -21,16 +21,14 @@ import org.apache.commons.vfs2.provider.
/**
* Simple JSch identity repository factory (that just returns the default factory).
*
- * This class is packaged in {@code com.jcraft.jsch} because {@code com.jcraft.jsch.LocalIdentityRepository} is
- * declared with default scope.
+ * This class is packaged in {@code com.jcraft.jsch} because {@code com.jcraft.jsch.LocalIdentityRepository} is declared
+ * with default scope.
*
* @version $Id$
*/
-public class TestIdentityRepositoryFactory implements IdentityRepositoryFactory
-{
+public class TestIdentityRepositoryFactory implements IdentityRepositoryFactory {
@Override
- public IdentityRepository create(final JSch jsch)
- {
+ public IdentityRepository create(final JSch jsch) {
return new LocalIdentityRepository(jsch);
}
}