Class Wiki.Builder

java.lang.Object
org.fastily.jwiki.core.Wiki.Builder
Enclosing class:
Wiki

public static class Wiki.Builder
extends Object
Builder used to create Wiki objects. All options are optional. If you're lazy and just want an anonymous Wiki pointing to en.wikipedia.org, use new Wiki.Builder().build()
Author:
Fastily
  • Constructor Details

    • Builder

      public Builder()
      Creates a new Wiki Builder.
  • Method Details

    • withUserAgent

      public Wiki.Builder withUserAgent​(String userAgent)
      Configures the Wiki to be created to use the specified User-Agent for HTTP requests.
      Parameters:
      userAgent - The User-Agent to use
      Returns:
      This Builder
    • withProxy

      public Wiki.Builder withProxy​(Proxy proxy)
      Configures the Wiki to be created with the specified Proxy.
      Parameters:
      proxy - The Proxy to use
      Returns:
      This Builder
    • withApiEndpoint

      public Wiki.Builder withApiEndpoint​(okhttp3.HttpUrl apiEndpoint)
      Configures the Wiki to be created with the specified api endpoint. This is the base endpoint of the MediaWiki instance you are targeting. Example: Wikipedia API.
      Parameters:
      apiEndpoint - The base api endpoint to target
      Returns:
      This Builder
    • withDomain

      public Wiki.Builder withDomain​(String domain)
      Configures the Wiki to be created with the specified domain. This method assumes that the target API endpoint is located at https://<YOUR_DOMAIN_HERE>/w/api.php; if this is not the case, then use withApiEndpoint(HttpUrl)
      Parameters:
      domain - The domain to target. Example: en.wikipedia.org.
      Returns:
      This Builder
    • withDefaultLogger

      public Wiki.Builder withDefaultLogger​(boolean enableLogging)
      Configures the Wiki to use the default jwiki logger. This is enabled by default.
      Parameters:
      enableLogging - Set false to disable jwiki's built-in logging.
      Returns:
      This Builder
    • withLogin

      public Wiki.Builder withLogin​(String username, String password)
      Configures the Wiki to be created with the specified username and password combination. Login will be attempted when build() is called.
      Parameters:
      username - The username to use
      password - The password to use
      Returns:
      This Builder
    • withDebug

      public Wiki.Builder withDebug​(boolean enableDebug)
      Configures the Wiki to be created to print *all* the messages.
      Parameters:
      enableDebug - Set true to enable debug mode.
      Returns:
      This Builder
    • build

      public Wiki build()
      Performs the task of creating the Wiki object as configured. If withApiEndpoint(HttpUrl) or withDomain(String) were not called, then the resulting Wiki will default to the Wikipedia API.
      Returns:
      A Wiki object