Enum OfflineCache

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<OfflineCache>

    public enum OfflineCache
    extends java.lang.Enum<OfflineCache>
    Offline Cache functionality. The cache must be explicitly set to be active. If it is active, a call to a http or https resource is intercepted. If the reuslt of the same call is already stored in the local cache directory, it is returned without a further connect to the network. If it is not in the cache directory, a network request is made and the returned data is stored in the local cache directory. The cache is implemented as singleton. A list of regexp string s can be set with setNoCacheFilters(Collection). URLs that match any of these patterns will not be cached.
    Author:
    P.J. Meisch ([email protected]).
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      INSTANCE  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      deletes all files from the cache directory.
      java.nio.file.Path getCacheDirectory()  
      java.util.Collection<java.lang.String> getNoCacheFilters()  
      boolean isActive()  
      void setActive​(boolean active)
      sets the active state of the cache
      void setCacheDirectory​(java.lang.String cacheDirectory)
      sets the cacheDirectory.
      void setCacheDirectory​(java.nio.file.Path cacheDirectory)
      sets the cacheDirectory.
      void setNoCacheFilters​(java.util.Collection<java.lang.String> noCacheFilters)  
      static OfflineCache valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static OfflineCache[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

    • Method Detail

      • values

        public static OfflineCache[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (OfflineCache c : OfflineCache.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static OfflineCache valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getNoCacheFilters

        public java.util.Collection<java.lang.String> getNoCacheFilters()
      • setNoCacheFilters

        public void setNoCacheFilters​(java.util.Collection<java.lang.String> noCacheFilters)
      • getCacheDirectory

        public java.nio.file.Path getCacheDirectory()
      • setCacheDirectory

        public void setCacheDirectory​(java.nio.file.Path cacheDirectory)
        sets the cacheDirectory.
        Parameters:
        cacheDirectory - the new directory
        Throws:
        java.lang.NullPointerException - if cacheDirectory is null
        java.lang.IllegalArgumentException - if cacheDirectory does not exist or is not writeable
      • setCacheDirectory

        public void setCacheDirectory​(java.lang.String cacheDirectory)
        sets the cacheDirectory.
        Parameters:
        cacheDirectory - the new directory
        Throws:
        java.lang.NullPointerException - if cacheDirectory is null
        java.lang.IllegalArgumentException - if cacheDirectory does not exist or is not writeable
      • isActive

        public boolean isActive()
      • setActive

        public void setActive​(boolean active)
        sets the active state of the cache
        Parameters:
        active - new state
        Throws:
        java.lang.IllegalArgumentException - if active is true and no cacheDirectory has been set.
        java.lang.IllegalStateException - if the factory cannot be initialized.
      • clear

        public void clear()
                   throws java.io.IOException
        deletes all files from the cache directory. Make sure before calling this method, that the cache directory was set to a directory that only contains the cache's files and is not used for something else.
        Throws:
        java.io.IOException