Author: rgoers Date: Mon Nov 15 08:01:58 2010 New Revision: 1035170 URL: http://svn.apache.org/viewvc?rev=1035170&view=rev Log: Convert more enum patterns to Java 5 enum
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/CacheStrategy.java commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/Capability.java commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/NameScope.java commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/CacheStrategy.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/CacheStrategy.java?rev=1035170&r1=1035169&r2=1035170&view=diff ============================================================================== --- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/CacheStrategy.java (original) +++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/CacheStrategy.java Mon Nov 15 08:01:58 2010 @@ -22,33 +22,33 @@ package org.apache.commons.vfs2; * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a> * @version $Revision$ $Date$ */ -public final class CacheStrategy +public enum CacheStrategy { /** * Deal with cached data manually. Call {...@link FileObject#refresh()} to refresh the object data. */ - public static final CacheStrategy MANUAL = new CacheStrategy("manual"); + MANUAL("manual"), /** * Refresh the data every time you request a file from {...@link FileSystemManager#resolveFile}. */ - public static final CacheStrategy ON_RESOLVE = new CacheStrategy("onresolve"); + ON_RESOLVE("onresolve"), /** * Refresh the data every time you call a method on the fileObject. * You'll use this only if you really need the latest info as this setting is a major performance * loss. */ - public static final CacheStrategy ON_CALL = new CacheStrategy("oncall"); + ON_CALL("oncall"); /** * Cache strategy name */ - private final String name; + private final String realName; private CacheStrategy(final String name) { - this.name = name; + this.realName = name; } /** @@ -58,7 +58,7 @@ public final class CacheStrategy @Override public String toString() { - return name; + return realName; } /** @@ -67,6 +67,6 @@ public final class CacheStrategy */ public String getName() { - return name; + return realName; } } Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/Capability.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/Capability.java?rev=1035170&r1=1035169&r2=1035170&view=diff ============================================================================== --- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/Capability.java (original) +++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/Capability.java Mon Nov 15 08:01:58 2010 @@ -22,109 +22,109 @@ package org.apache.commons.vfs2; * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a> * @version $Revision$ $Date$ */ -public final class Capability +public enum Capability { /** * File content can be read. */ - public static final Capability READ_CONTENT = new Capability("READ_CONTENT"); + READ_CONTENT, /** * File content can be written. */ - public static final Capability WRITE_CONTENT = new Capability("WRITE_CONTENT"); + WRITE_CONTENT, /** * File content can be read in random mode.<br> */ - public static final Capability RANDOM_ACCESS_READ = new Capability("RANDOM_ACCESS_READ"); + RANDOM_ACCESS_READ, /** * File content can be written in random mode.<br> */ - public static final Capability RANDOM_ACCESS_WRITE = new Capability("RANDOM_ACCESS_WRITE"); + RANDOM_ACCESS_WRITE, /** * File content can be appended. */ - public static final Capability APPEND_CONTENT = new Capability("APPEND_CONTENT"); + APPEND_CONTENT, /** * File attributes are supported. */ - public static final Capability ATTRIBUTES = new Capability("ATTRIBUTES"); + ATTRIBUTES, /** * File last-modified time is supported. */ - public static final Capability LAST_MODIFIED = new Capability("LAST_MODIFIED"); + LAST_MODIFIED, /** * File get last-modified time is supported. */ - public static final Capability GET_LAST_MODIFIED = new Capability("GET_LAST_MODIFIED"); + GET_LAST_MODIFIED, /** * File set last-modified time is supported. */ - public static final Capability SET_LAST_MODIFIED_FILE = new Capability("SET_LAST_MODIFIED_FILE"); + SET_LAST_MODIFIED_FILE, /** * folder set last-modified time is supported. */ - public static final Capability SET_LAST_MODIFIED_FOLDER = new Capability("SET_LAST_MODIFIED_FOLDER"); + SET_LAST_MODIFIED_FOLDER, /** * File content signing is supported. */ - public static final Capability SIGNING = new Capability("SIGNING"); + SIGNING, /** * Files can be created. */ - public static final Capability CREATE = new Capability("CREATE"); + CREATE, /** * Files can be deleted. */ - public static final Capability DELETE = new Capability("DELETE"); + DELETE, /** * Files can be renamed. */ - public static final Capability RENAME = new Capability("RENAME"); + RENAME, /** * The file type can be determined. */ - public static final Capability GET_TYPE = new Capability("GET_TYPE"); + GET_TYPE, /** * Children of files can be listed. */ - public static final Capability LIST_CHILDREN = new Capability("LIST_CHILDREN"); + LIST_CHILDREN, /** * URI are supported. Files without this capability use URI that do not * globally and uniquely identify the file. */ - public static final Capability URI = new Capability("URI"); + URI, /** * File system attributes are supported. */ - public static final Capability FS_ATTRIBUTES = new Capability("FS_ATTRIBUTE"); + FS_ATTRIBUTES, /** * Junctions are supported. */ - public static final Capability JUNCTIONS = new Capability("JUNCTIONS"); + JUNCTIONS, /** * The set of attributes defined by the Jar manifest specification are * supported. The attributes aren't necessarily stored in a manifest file. */ - public static final Capability MANIFEST_ATTRIBUTES = new Capability("MANIFEST_ATTRIBUTES"); + MANIFEST_ATTRIBUTES, /** * The provider itself do not provide a filesystem. It simply resolves a full name @@ -132,38 +132,22 @@ public final class Capability * A provider with this capability cant tell much about the capabilities about the * finally used filesystem in advance. */ - public static final Capability DISPATCHER = new Capability("DISPATCHER"); + DISPATCHER, /** * A compressed filesystem is a filesystem which use compression. */ - public static final Capability COMPRESS = new Capability("COMPRESS"); + COMPRESS, /** * A virtual filesystem can be an archive like tar or zip. */ - public static final Capability VIRTUAL = new Capability("VIRTUAL"); + VIRTUAL, /** * Provides directories which allows you to read its content through * {...@link org.apache.commons.vfs2.FileContent#getInputStream()}. * @since 2.0 */ - public static final Capability DIRECTORY_READ_CONTENT = new Capability("DIRECTORY_READ_CONTENT"); - - /** - * The Capability name - */ - private final String name; - - private Capability(final String name) - { - this.name = name; - } - - @Override - public String toString() - { - return name; - } + DIRECTORY_READ_CONTENT; } Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/NameScope.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/NameScope.java?rev=1035170&r1=1035169&r2=1035170&view=diff ============================================================================== --- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/NameScope.java (original) +++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/NameScope.java Mon Nov 15 08:01:58 2010 @@ -23,21 +23,21 @@ package org.apache.commons.vfs2; * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a> * @version $Revision$ $Date$ */ -public final class NameScope +public enum NameScope { /** * Resolve against the children of the base file. The name is resolved * as described by {...@link #FILE_SYSTEM}. However, an exception is * thrown if the resolved file is not a direct child of the base file. */ - public static final NameScope CHILD = new NameScope("child"); + CHILD("child"), /** * Resolve against the descendents of the base file. The name is resolved * as described by {...@link #FILE_SYSTEM}. However, an exception is thrown * if the resolved file is not a descendent of the base file. */ - public static final NameScope DESCENDENT = new NameScope("descendent"); + DESCENDENT("descendent"), /** * Resolve against the descendents of the base file. The name is resolved @@ -45,8 +45,7 @@ public final class NameScope * if the resolved file is not a descendent of the base file, or the base * files itself. */ - public static final NameScope DESCENDENT_OR_SELF = - new NameScope("descendent_or_self"); + DESCENDENT_OR_SELF("descendent_or_self"), /** * Resolve against files in the same file system as the base file. @@ -63,14 +62,14 @@ public final class NameScope * <p>A path is considered absolute if it starts with a separator character, * and relative if it does not. */ - public static final NameScope FILE_SYSTEM = new NameScope("filesystem"); + FILE_SYSTEM("filesystem"); /** The name */ - private final String name; + private final String realName; private NameScope(final String name) { - this.name = name; + this.realName = name; } /** @@ -80,7 +79,7 @@ public final class NameScope @Override public String toString() { - return name; + return realName; } /** @@ -89,6 +88,6 @@ public final class NameScope */ public String getName() { - return name; + return realName; } } Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java?rev=1035170&r1=1035169&r2=1035170&view=diff ============================================================================== --- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java (original) +++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java Mon Nov 15 08:01:58 2010 @@ -22,17 +22,17 @@ package org.apache.commons.vfs2.util; * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a> * @version $Revision$ $Date$ */ -public final class RandomAccessMode +public enum RandomAccessMode { /** * read. */ - public static final RandomAccessMode READ = new RandomAccessMode(true, false); + READ(true, false), /** * read/write. */ - public static final RandomAccessMode READWRITE = new RandomAccessMode(true, true); + READWRITE(true, true); private final boolean read;