NodeList (SelekTOR Java Documentation)
Date: 2017-04-14

client

## Class NodeList

- java.lang.Object
- - client.NodeList

-     public class NodeList
      extends java.lang.Object

  Author:
    Alistair Neil

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `NODELIST_BUILDING`
    `static int` | `NODELIST_BUILT`
    `static int` | `NODELIST_FAILED`
    `static int` | `NODELIST_IDLE`
    `static int` | `NODELIST_TERMINATED`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NodeList(java.lang.String filepath, java.lang.String exitfavourites, java.lang.String guardfavouritesfile)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addBridge(java.lang.String bridgedata)` Add newly learned bridge to nodelist
    `void` | `clearBridges()` Clear any learned bridges
    `java.lang.String` | `filterRouterInfo(java.util.ArrayList<java.lang.String> alInfo, java.lang.String field)`
    `int` | `getCurrentStatus()` Get the process status
    `java.util.ArrayList<java.lang.String>` | `getExitNodes(boolean all, boolean omitfailednodes)` Get a list of exitnodes, if all is false then it returns only favourited nodes, if omitfailednodes is true then don't include nodes that failed testing
    `java.lang.String` | `getExitNodesAsString(boolean all, boolean omitfailednodes)` Get a string of comma separated exitnodes, if all is false then it returns only favourited nodes, if omitfailednodes is true then don't include nodes that failed testing
    `java.lang.String` | `getGuardFavouritesAsCSV()` Get guard favourites
    `java.util.ArrayList<java.lang.String>` | `getGuardNodes()` Get a list of all guard nodes guard nodes
    `NodeItem` | `getNode(java.lang.String key)` Get node item from its fingerprint
    `int` | `getNumberOfFavs()` Get the number of active favourites
    `java.util.ArrayList<java.lang.String>` | `getRouterDesc(java.lang.String finger)`
    `java.util.ArrayList<java.lang.String>` | `getRouterStatus(java.lang.String finger)`
    `java.lang.String[]` | `getValidatedCountries()` Gets validated countries, a valid country is any country with active exit nodes
    `java.lang.String[]` | `getValidatedCountryCodes()` Gets validated country codes, a valid country is any country with active exit nodes
    `void` | `refreshExitTableModel(java.lang.String isocountry)` Update the table model based on supplied country
    `void` | `refreshGuardTableModel()` Update the guard node table model
    `void` | `refreshNodelist(TorController tc)` Generate the nodelist
    `void` | `saveExitFavourites()` Save exit node whitelist
    `int` | `saveGuardWhitelist()` Save exit node blacklist
    `void` | `setExitNodeTableModel(ExitNodeTableModel entm)` Set the exit node view table model
    `void` | `setGuardNodeTableModel(GuardNodeTableModel gntm)` Set the guard node view table model
    `void` | `terminate()` Ensures any threaded actions will terminate themselves

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

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

- - ### Field Detail

    - #### NODELIST_IDLE

          public static final int NODELIST_IDLE

      See Also:
        Constant Field Values

    - #### NODELIST_BUILDING

          public static final int NODELIST_BUILDING

      See Also:
        Constant Field Values

    - #### NODELIST_BUILT

          public static final int NODELIST_BUILT

      See Also:
        Constant Field Values

    - #### NODELIST_FAILED

          public static final int NODELIST_FAILED

      See Also:
        Constant Field Values

    - #### NODELIST_TERMINATED

          public static final int NODELIST_TERMINATED

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### NodeList

          public NodeList(java.lang.String filepath,
                          java.lang.String exitfavourites,
                          java.lang.String guardfavouritesfile)

  - ### Method Detail

    - #### getNode

          public final NodeItem getNode(java.lang.String key)

      Get node item from its fingerprint
      Parameters:
        `key` - or fingerprint
      Returns:
        NodeItem

    - #### getRouterDesc

          public java.util.ArrayList<java.lang.String> getRouterDesc(java.lang.String finger)

    - #### getRouterStatus

          public java.util.ArrayList<java.lang.String> getRouterStatus(java.lang.String finger)

    - #### filterRouterInfo

          public java.lang.String filterRouterInfo(java.util.ArrayList<java.lang.String> alInfo,
                                                   java.lang.String field)

    - #### getCurrentStatus

          public final int getCurrentStatus()

      Get the process status
      Returns:
        status

    - #### refreshNodelist

          public final void refreshNodelist(TorController tc)

      Generate the nodelist
      Parameters:
        `tc` -

    - #### addBridge

          public void addBridge(java.lang.String bridgedata)

      Add newly learned bridge to nodelist
      Parameters:
        `bridgedata` -

    - #### clearBridges

          public void clearBridges()

      Clear any learned bridges

    - #### getValidatedCountries

          public final java.lang.String[] getValidatedCountries()

      Gets validated countries, a valid country is any country with active exit nodes
      Returns:
        String array of countries

    - #### getValidatedCountryCodes

          public final java.lang.String[] getValidatedCountryCodes()

      Gets validated country codes, a valid country is any country with active exit nodes
      Returns:
        String array of country abbreviations

    - #### setGuardNodeTableModel

          public final void setGuardNodeTableModel(GuardNodeTableModel gntm)

      Set the guard node view table model
      Parameters:
        `gntm` -

    - #### setExitNodeTableModel

          public final void setExitNodeTableModel(ExitNodeTableModel entm)

      Set the exit node view table model
      Parameters:
        `entm` -

    - #### getExitNodes

          public final java.util.ArrayList<java.lang.String> getExitNodes(boolean all,
                                                                          boolean omitfailednodes)

      Get a list of exitnodes, if all is false then it returns only favourited nodes, if omitfailednodes is true then don't include nodes that failed testing
      Parameters:
        `all` -
        `omitfailednodes` -
      Returns:
        ArrayList of exit nodes

    - #### getExitNodesAsString

          public final java.lang.String getExitNodesAsString(boolean all,
                                                             boolean omitfailednodes)

      Get a string of comma separated exitnodes, if all is false then it returns only favourited nodes, if omitfailednodes is true then don't include nodes that failed testing
      Parameters:
        `all` -
        `omitfailednodes` -
      Returns:
        String of exitnodes in csv format

    - #### getGuardNodes

          public final java.util.ArrayList<java.lang.String> getGuardNodes()

      Get a list of all guard nodes guard nodes
      Returns:
        ArrayList of guard nodes

    - #### getGuardFavouritesAsCSV

          public final java.lang.String getGuardFavouritesAsCSV()

      Get guard favourites
      Returns:
        CSV string of guard entry fingerprints

    - #### refreshGuardTableModel

          public final void refreshGuardTableModel()

      Update the guard node table model

    - #### refreshExitTableModel

          public final void refreshExitTableModel(java.lang.String isocountry)

      Update the table model based on supplied country
      Parameters:
        `isocountry` - in the format "GB,Great Britain"

    - #### getNumberOfFavs

          public int getNumberOfFavs()

      Get the number of active favourites
      Returns:
        number of favs as int

    - #### terminate

          public final void terminate()

      Ensures any threaded actions will terminate themselves

    - #### saveExitFavourites

          public void saveExitFavourites()

      Save exit node whitelist

    - #### saveGuardWhitelist

          public int saveGuardWhitelist()

      Save exit node blacklist
      Returns:
        number of active guards