Class org.jfouffa.jslider.template.TemplateLoader
java.lang.Object
|
+----org.jfouffa.jslider.template.TemplateLoader
- public class TemplateLoader
- extends Object
- implements TemplateLoaderConstants
Constructor index
-
TemplateLoader()
- Creates a new default TemplateLoader
-
TemplateLoader(InputStream)
- Creates a new default TemplateLoader and adds templates from
a stream.
-
TemplateLoader(TemplateLoader)
- Creates a new TemplateLoader with default values from a TemplateLoader.
Method index
-
addAttribute(String, String)
- Adds an attribute.
-
addMacro(String, String)
- Adds a macro.
-
addPositionAttribute(String, String, String)
- Adds a position attribute.
-
getAttribute(String)
- Gets an attribute from the template.
-
getExpandedText(String)
- Expand recursively all macros in the given text.
-
getMacro(String)
- Returns the value of a specified macro, null otherwise.
-
getPositionAttribute(String, String)
- Gets a value for a given position and a given name.
-
main(String[])
- Test me
-
save(OutputStream)
- Output the template into a stream
Constructors
TemplateLoader
public TemplateLoader()
- Creates a new default TemplateLoader
TemplateLoader
public TemplateLoader(InputStream input) throws IOException
- Creates a new default TemplateLoader and adds templates from
a stream.
- Parameters:
- input - the stream
- Throws: IOException
- an I/O exception occurs during the operation
TemplateLoader
public TemplateLoader(TemplateLoader template)
- Creates a new TemplateLoader with default values from a TemplateLoader.
- Parameters:
- template - where to find default values
- Throws: IOException
- an I/O exception occurs during the operation
Methods
getMacro
public String getMacro(String name)
- Returns the value of a specified macro, null otherwise.
- Parameters:
- name - the name of the macro.
addMacro
public TemplateLoader addMacro(String name,
String value)
- Adds a macro.
- Parameters:
- name - the name of the macro
- value - the value of the macro. if value is null or with no
content, remove the macro.
- Returns:
- in any case, return
this
getExpandedText
public String getExpandedText(String text)
- Expand recursively all macros in the given text.
- Parameters:
- text - the text to be expand
- Returns:
- the expanded text
getPositionAttribute
public String getPositionAttribute(String position,
String name)
- Gets a value for a given position and a given name.
- Parameters:
- position - the position (if null, invoke getAttribute)
- name - the name of the attribute
- Returns:
- the value of the attribute. (never return null)
addPositionAttribute
public TemplateLoader addPositionAttribute(String position,
String name,
String value)
- Adds a position attribute.
- Parameters:
- position - the position (if null, invoke addAttribute)
- name - the name of the attribute
- value - the value of the attribute. if value is null (or empty),
remove the attribute.
- Returns:
- in any case, return
this
getAttribute
public String getAttribute(String name)
- Gets an attribute from the template.
- Parameters:
- name - the name of the attribute
- Returns:
- the value of the attribute or null
addAttribute
public TemplateLoader addAttribute(String name,
String value)
- Adds an attribute.
- Parameters:
- name - the name of the attribute
- value - the value of the attribute. if value is null, remove the
attribute.
- Returns:
- in any case, return
this
save
public OutputStream save(OutputStream out) throws IOException
- Output the template into a stream
- Parameters:
- value - the value of the attribute
- Returns:
- in any case, return the output stream
- Throws: IOException
- an I/O exception occurs during the operation
main
public static void main(String args[]) throws Exception
- Test me
- Throws: Exception
- any exception