Package org.fastily.jwiki.core
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
-
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)
Appendso
to the end of the WikiText associated withk
void
drop()
Removes this WTemplate from its parent WikiText object, if applicable.WParser.WikiText
get(String k)
Gets the specified WikiText value associated with keyk
in this WTemplate.boolean
has(String k)
Test if the specified keyk
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 towiki
.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.
-
Field Details
-
title
This WTemplate's title
-
-
Constructor Details
-
WTemplate
public WTemplate()Creates a new, empty WTemplate object.
-
-
Method Details
-
normalizeTitle
Normalize the title of the WTemplate, according towiki
. In other words, remove the 'Template:' namespace, convert, capitalize the first letter, convert underscores to spaces.- Parameters:
wiki
- The Wiki to normalize against.
-
has
Test if the specified keyk
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
Gets the specified WikiText value associated with keyk
in this WTemplate.- Parameters:
k
- The key to get WikiText for.- Returns:
- The WikiText, or null if there is no mapping for
k
-
put
Puts a new parameter in this Template.- Parameters:
k
- The name of the parameterv
- The value of the parameter; acceptable types are WikiText, String, and WTemplate.
-
append
Appendso
to the end of the WikiText associated withk
- Parameters:
k
- The key to associate new text with.o
- The Object to append to the value keyed byk
in this WTemplate
-
remove
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
Re-map the a key to a new name.- Parameters:
oldK
- The old namenewK
- The new name
-
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
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
Renders this WTemplate as a String.
-