Class WParser.WTemplate

java.lang.Object
org.fastily.jwiki.core.WParser.WTemplate
Enclosing class:
WParser

public static class WParser.WTemplate
extends Object
Mutable representation of a parsed wikitext template.
Author:
Fastily
  • Field Summary

    Fields 
    Modifier and Type Field Description
    String title
    This WTemplate's title
  • Constructor Summary

    Constructors 
    Constructor Description
    WTemplate()
    Creates a new, empty WTemplate object.
  • Method Summary

    Modifier and Type Method Description
    void append​(String k, Object o)
    Appends o to the end of the WikiText associated with k
    void drop()
    Removes this WTemplate from its parent WikiText object, if applicable.
    WParser.WikiText get​(String k)
    Gets the specified WikiText value associated with key k in this WTemplate.
    boolean has​(String k)
    Test if the specified key k exists in this WTemplate.
    HashSet<String> keySet()
    Get the keyset (all parameters) for this WTemplate.
    void normalizeTitle​(Wiki wiki)
    Normalize the title of the WTemplate, according to wiki.
    void put​(String k, Object v)
    Puts a new parameter in this Template.
    void remap​(String oldK, String newK)
    Re-map the a key to a new name.
    void remove​(String k)
    Removes the mapping for the specified key, k
    String toString()
    Renders this WTemplate as a String.
    String toString​(boolean indent)
    Generates a String (wikitext) representation of this Template.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • WTemplate

      public WTemplate()
      Creates a new, empty WTemplate object.
  • Method Details

    • normalizeTitle

      public void normalizeTitle​(Wiki wiki)
      Normalize the title of the WTemplate, according to wiki. In other words, remove the 'Template:' namespace, convert, capitalize the first letter, convert underscores to spaces.
      Parameters:
      wiki - The Wiki to normalize against.
    • has

      public boolean has​(String k)
      Test if the specified key k exists in this WTemplate. This does not check whether the parameter is empty or not.
      Parameters:
      k - The key to check
      Returns:
      True if there is a mapping for k in this WTemplate.
    • get

      public WParser.WikiText get​(String k)
      Gets the specified WikiText value associated with key k in this WTemplate.
      Parameters:
      k - The key to get WikiText for.
      Returns:
      The WikiText, or null if there is no mapping for k
    • put

      public void put​(String k, Object v)
      Puts a new parameter in this Template.
      Parameters:
      k - The name of the parameter
      v - The value of the parameter; acceptable types are WikiText, String, and WTemplate.
    • append

      public void append​(String k, Object o)
      Appends o to the end of the WikiText associated with k
      Parameters:
      k - The key to associate new text with.
      o - The Object to append to the value keyed by k in this WTemplate
    • remove

      public void remove​(String k)
      Removes the mapping for the specified key, k
      Parameters:
      k - Removes the mapping for this key, if possible
    • drop

      public void drop()
      Removes this WTemplate from its parent WikiText object, if applicable.
    • remap

      public void remap​(String oldK, String newK)
      Re-map the a key to a new name.
      Parameters:
      oldK - The old name
      newK - The new name
    • keySet

      public HashSet<String> keySet()
      Get the keyset (all parameters) for this WTemplate. The resulting keyset does not back the internal Map.
      Returns:
      The keyset for this WTemplate.
    • toString

      public String toString​(boolean indent)
      Generates a String (wikitext) representation of this Template.
      Parameters:
      indent - Set true to add a newline between each parameter.
      Returns:
      A String representation of this Template.
    • toString

      public String toString()
      Renders this WTemplate as a String.
      Overrides:
      toString in class Object