All Packages Class Hierarchy This Package Previous Next Index

Class org.jfouffa.jslider.template.TemplateLoader

java.lang.Object
   |
   +----org.jfouffa.jslider.template.TemplateLoader

public class TemplateLoader
extends Object
implements TemplateLoaderConstants

Constructor index

 o TemplateLoader()
Creates a new default TemplateLoader
 o TemplateLoader(InputStream)
Creates a new default TemplateLoader and adds templates from a stream.
 o TemplateLoader(TemplateLoader)
Creates a new TemplateLoader with default values from a TemplateLoader.

Method index

 o addAttribute(String, String)
Adds an attribute.
 o addMacro(String, String)
Adds a macro.
 o addPositionAttribute(String, String, String)
Adds a position attribute.
 o getAttribute(String)
Gets an attribute from the template.
 o getExpandedText(String)
Expand recursively all macros in the given text.
 o getMacro(String)
Returns the value of a specified macro, null otherwise.
 o getPositionAttribute(String, String)
Gets a value for a given position and a given name.
 o main(String[])
Test me
 o save(OutputStream)
Output the template into a stream

Constructors

 o TemplateLoader
 public TemplateLoader()
Creates a new default TemplateLoader

 o 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
 o 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

 o getMacro
 public String getMacro(String name)
Returns the value of a specified macro, null otherwise.

Parameters:
name - the name of the macro.
 o 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
 o 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
 o 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)
 o 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
 o 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
 o 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
 o 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
 o main
 public static void main(String args[]) throws Exception
Test me

Throws: Exception
any exception