001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.commons.vfs2;
018    
019    /**
020     * An enumerated type to deal with the various cache strategies.
021     *
022     * @author <a href="http://commons.apache.org/vfs/team-list.html">Commons VFS team</a>
023     */
024    public enum CacheStrategy
025    {
026        /**
027         * Deal with cached data manually. Call {@link FileObject#refresh()} to refresh the object data.
028         */
029        MANUAL("manual"),
030    
031        /**
032         * Refresh the data every time you request a file from {@link FileSystemManager#resolveFile}.
033         */
034        ON_RESOLVE("onresolve"),
035    
036        /**
037         * Refresh the data every time you call a method on the fileObject.
038         * You'll use this only if you really need the latest info as this setting is a major performance
039         * loss.
040         */
041        ON_CALL("oncall");
042    
043        /**
044         * Cache strategy name
045         */
046        private final String realName;
047    
048        private CacheStrategy(final String name)
049        {
050            this.realName = name;
051        }
052    
053        /**
054         * Returns the name of the scope.
055         * @return the name of the scope.
056         */
057        @Override
058        public String toString()
059        {
060            return realName;
061        }
062    
063        /**
064         * Returns the name of the scope.
065         * @return the name of the scope.
066         */
067        public String getName()
068        {
069            return realName;
070        }
071    }