PacFactory (SelekTOR Java Documentation)
Date: 2018-05-25

client

## Class PacFactory

- java.lang.Object
- - client.PacFactory

-     public class PacFactory
      extends java.lang.Object

  Author:
    Alistair Neil

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `FILEUSER`
    `static int` | `PROXY_ALL`
    `static int` | `PROXY_DISABLED`
    `static int` | `PROXY_PATTERN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PacFactory()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDirectMatchingRule(java.util.ArrayList<java.lang.String> rules, java.lang.String pattern)`
    `void` | `addProxyRule(java.util.ArrayList<java.lang.String> rules, java.lang.String proxy)`
    `void` | `addSocksMatchingRule(java.util.ArrayList<java.lang.String> rules, java.lang.String pattern, java.lang.String host, java.lang.String port)` Add socks pattern mayching rule to a supllied list
    `void` | `addSocksRule(java.util.ArrayList<java.lang.String> rules, java.lang.String host, java.lang.String port)` Add a socks rule to a supplied list
    `void` | `addToPatternFile(java.lang.String country, java.lang.String description, java.lang.String pattern)` Adds pattern to an existing pattern file
    `void` | `backupProxyPrefs()` Generic backup of proxy settings
    `void` | `createPacFile(java.lang.String isocountry, int port)` Create and/or activate a pacfile for a specific country
    `void` | `deleteAllPAC()` Delete all pac files
    `boolean` | `deletePAC(java.lang.String filename)` Delete specified pac file
    `void` | `deletePatternsFile(java.lang.String country, java.lang.String type)` Delete patterns file for a given country and type, where type is either "def" or "user"
    `void` | `deleteProxyPrefs()` Generic proxy prefs delete, for ease of use
    `void` | `exportUserPatterns(java.lang.String filename, java.io.File[] files)` Export user patterns
    `java.lang.String` | `getActiveCountry()` Get the active country code
    `java.lang.String` | `getDoNotProxy()` Get value of comma separated host or ip list
    `java.io.File[]` | `getPatternsFiles()` Get an array of user pattern files
    `boolean` | `importPatterns(java.lang.String filename)` Import patterns
    `void` | `loadPatternsList(java.lang.String country, java.util.ArrayList<java.lang.String> list)` Load a patterns list from a file
    `void` | `restoreProxyPrefs(boolean resetonfail)` Generic restore of proxy settings, for ease of use
    `void` | `savePatternsList(java.lang.String country, java.lang.String type, java.util.ArrayList<java.lang.String> list)` Save a patterns list by filename
    `void` | `setBackupFolder(java.lang.String folder)` Set folder where system proxy settings will be backed up
    `void` | `setDefaultProxy(java.lang.String proxyurl)` Set default proxy url
    `void` | `setDoNotProxy(java.lang.String hostcsv)` Set do not proxy
    `void` | `setPACFolder(java.lang.String folder)` Set folder where pac files will be generated
    `void` | `setPatternsFolder(java.lang.String folder)` Create folder in which pattern files will be stored
    `void` | `setProxyAutoConfigURL(java.lang.String url)` Generic set proxy config
    `void` | `setTempFolder(java.lang.String path)` Set the temp folder for file extractions

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### FILEUSER

          public static final java.lang.String FILEUSER

      See Also:
        Constant Field Values

    - #### PROXY_DISABLED

          public static final int PROXY_DISABLED

      See Also:
        Constant Field Values

    - #### PROXY_PATTERN

          public static final int PROXY_PATTERN

      See Also:
        Constant Field Values

    - #### PROXY_ALL

          public static final int PROXY_ALL

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PacFactory

          public PacFactory()

  - ### Method Detail

    - #### getActiveCountry

          public java.lang.String getActiveCountry()

      Get the active country code
      Returns:
        Active country

    - #### createPacFile

          public void createPacFile(java.lang.String isocountry,
                                    int port)

      Create and/or activate a pacfile for a specific country
      Parameters:
        `isocountry` -
        `port` -

    - #### addProxyRule

          public void addProxyRule(java.util.ArrayList<java.lang.String> rules,
                                   java.lang.String proxy)

      Parameters:
        `rules` -
        `proxy` -

    - #### addSocksRule

          public void addSocksRule(java.util.ArrayList<java.lang.String> rules,
                                   java.lang.String host,
                                   java.lang.String port)

      Add a socks rule to a supplied list
      Parameters:
        `rules` -
        `host` -
        `port` -

    - #### addDirectMatchingRule

          public void addDirectMatchingRule(java.util.ArrayList<java.lang.String> rules,
                                            java.lang.String pattern)

      Parameters:
        `rules` -
        `pattern` -

    - #### addSocksMatchingRule

          public void addSocksMatchingRule(java.util.ArrayList<java.lang.String> rules,
                                           java.lang.String pattern,
                                           java.lang.String host,
                                           java.lang.String port)

      Add socks pattern mayching rule to a supllied list
      Parameters:
        `rules` -
        `pattern` -
        `host` -
        `port` -

    - #### loadPatternsList

          public void loadPatternsList(java.lang.String country,
                                       java.util.ArrayList<java.lang.String> list)

      Load a patterns list from a file
      Parameters:
        `country` -
        `list` -

    - #### deletePatternsFile

          public void deletePatternsFile(java.lang.String country,
                                         java.lang.String type)

      Delete patterns file for a given country and type, where type is either "def" or "user"
      Parameters:
        `country` -
        `type` -

    - #### savePatternsList

          public void savePatternsList(java.lang.String country,
                                       java.lang.String type,
                                       java.util.ArrayList<java.lang.String> list)

      Save a patterns list by filename
      Parameters:
        `country` -
        `list` -
        `type` -

    - #### setPatternsFolder

          public final void setPatternsFolder(java.lang.String folder)

      Create folder in which pattern files will be stored
      Parameters:
        `folder` -

    - #### setPACFolder

          public final void setPACFolder(java.lang.String folder)

      Set folder where pac files will be generated
      Parameters:
        `folder` -

    - #### setBackupFolder

          public final void setBackupFolder(java.lang.String folder)

      Set folder where system proxy settings will be backed up
      Parameters:
        `folder` -

    - #### setTempFolder

          public final void setTempFolder(java.lang.String path)

      Set the temp folder for file extractions
      Parameters:
        `path` -

    - #### backupProxyPrefs

          public void backupProxyPrefs()

      Generic backup of proxy settings

    - #### restoreProxyPrefs

          public void restoreProxyPrefs(boolean resetonfail)

      Generic restore of proxy settings, for ease of use

    - #### deleteProxyPrefs

          public void deleteProxyPrefs()

      Generic proxy prefs delete, for ease of use

    - #### setProxyAutoConfigURL

          public void setProxyAutoConfigURL(java.lang.String url)

      Generic set proxy config
      Parameters:
        `url` -

    - #### deletePAC

          public boolean deletePAC(java.lang.String filename)

      Delete specified pac file
      Parameters:
        `filename` -
      Returns:
        boolean true if action successful

    - #### deleteAllPAC

          public void deleteAllPAC()

      Delete all pac files

    - #### setDefaultProxy

          public void setDefaultProxy(java.lang.String proxyurl)

      Set default proxy url
      Parameters:
        `proxyurl` -

    - #### setDoNotProxy

          public void setDoNotProxy(java.lang.String hostcsv)

      Set do not proxy
      Parameters:
        `hostcsv` -

    - #### getDoNotProxy

          public java.lang.String getDoNotProxy()

      Get value of comma separated host or ip list
      Returns:
        String value

    - #### addToPatternFile

          public void addToPatternFile(java.lang.String country,
                                       java.lang.String description,
                                       java.lang.String pattern)

      Adds pattern to an existing pattern file
      Parameters:
        `country` -
        `description` -
        `pattern` -

    - #### getPatternsFiles

          public java.io.File[] getPatternsFiles()

      Get an array of user pattern files
      Returns:
        array of files

    - #### exportUserPatterns

          public void exportUserPatterns(java.lang.String filename,
                                         java.io.File[] files)

      Export user patterns
      Parameters:
        `filename` -
        `files` -

    - #### importPatterns

          public boolean importPatterns(java.lang.String filename)

      Import patterns
      Parameters:
        `filename` -
      Returns:
        true if succesful