org.melati.template
Class AbstractMarkupLanguage

Package class diagram package AbstractMarkupLanguage
java.lang.Object
  extended by org.melati.template.AbstractMarkupLanguage
All Implemented Interfaces:
MarkupLanguage
Direct Known Subclasses:
HTMLLikeMarkupLanguage

public abstract class AbstractMarkupLanguage
extends Object
implements MarkupLanguage

MarkupLanguage provides a variety of methods for rendering objects in a template. Each object to be rendered has 3 methods: 1 - String rendered(Object o) - this will render the object to a String 2 - void render(Object o) - renders the object to melati.getWriter() 3 - void render(Object o, MelatiWriter w) - render the object to w. When this class was written it was thought that for maximum efficiency one should render the object direct to the output stream using method (2) above. However now all but (1) is deprecated.


Field Summary
static int DATE_FIELD_POSSIBILITIES_LIMIT
          The maximum number of date field possibilities to render.
static int FIELD_POSSIBILITIES_LIMIT
          The maximum number of field possibilities to render.
protected  PoemLocale locale
           
protected  Melati melati
           
protected  TempletLoader templetLoader
           
 
Constructor Summary
protected AbstractMarkupLanguage(String name, AbstractMarkupLanguage other)
          Construct a new MarkupLanguage given a new name and an existing MarkupLanguage.
  AbstractMarkupLanguage(String name, Melati melati, TempletLoader templetLoader, PoemLocale locale)
          Construct a Markup Language object.
 
Method Summary
protected  void expandTemplet(Template templet, TemplateContext tc, MelatiWriter out)
          Interpolate a templet and write it out.
 String getName()
          Get the name of this Markup Language.
 String input(Field field)
          Get an input widget for this Field.
protected  String input(Field field, String templetName, String nullValue, boolean overrideNullable)
           
 String inputAs(Field field, String templetName)
          Get an input widget for this Field defined by name.
protected  void render(Field field, int style, int limit, MelatiWriter writer)
          Render a Field Object in a MarkupLanguage specific way, rendering to supplied MelatiWriter.
protected  void render(Field field, MelatiWriter writer)
          Render a Field Object in a MarkupLanguage specific way, rendering to supplied MelatiWriter.
protected  void render(Object o)
          Render an Object in a MarkupLanguage specific way, rendering to the MelatiWriter supplied by melati.getWriter().
protected  void render(Object o, MelatiWriter writer)
          Render an Object in a MarkupLanguage specific way, rendering to a supplied Writer.
protected  void render(String s, int limit, MelatiWriter writer)
          Render a String in a MarkupLanguage specific way, limiting it's length.
protected abstract  void render(String s, MelatiWriter writer)
          Render a String in a MarkupLanguage specific way to a supplied MelatiWriter.
 String rendered(Field field, int style)
          Render a Field Object in a MarkupLanguage specific way, returning a String.
 String rendered(Field field, int style, int limit)
          Render a Field Object in a MarkupLanguage specific way, returning a String.
 String rendered(Object o)
          Render an Object in a MarkupLanguage specific way, returning a String.
 String rendered(String s, int limit)
          Render a String in a MarkupLanguage specific way, limiting it's length.
 String renderedMarkup(String s)
          
 String renderedStart(Field field)
          Render a Date Field Object in a MarkupLanguage specific way, returning a START Date format String.
protected abstract  void renderMarkup(String s, MelatiWriter writer)
          Render a markup fragment in a MarkupLanguage specific way to a supplied MelatiWriter.
protected  void renderStart(Field field, MelatiWriter writer)
           
 String searchInput(Field field, String nullValue)
          Get an input widget for this Field specifying the null value.
 String toString()
          Name and locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.melati.template.MarkupLanguage
decoded, encoded, escaped, escaped, getAttr
 

Field Detail

templetLoader

protected TempletLoader templetLoader

melati

protected Melati melati

locale

protected PoemLocale locale

FIELD_POSSIBILITIES_LIMIT

public static final int FIELD_POSSIBILITIES_LIMIT
The maximum number of field possibilities to render.

See Also:
Constant Field Values

DATE_FIELD_POSSIBILITIES_LIMIT

public static final int DATE_FIELD_POSSIBILITIES_LIMIT
The maximum number of date field possibilities to render.

See Also:
Constant Field Values
Constructor Detail

AbstractMarkupLanguage

public AbstractMarkupLanguage(String name,
                              Melati melati,
                              TempletLoader templetLoader,
                              PoemLocale locale)
Construct a Markup Language object.

Parameters:
name - - the name associated with this markup language. This is used to determine where to load templates from ie 'html' templates are found in the 'html' directory.
melati - - the melati currently in use
templetLoader - - the template loader in use (taken from org.melati.MelatiConfig.properties)
locale - - the locale in use (taken from org.melati.MelatiConfig.properties)

AbstractMarkupLanguage

protected AbstractMarkupLanguage(String name,
                                 AbstractMarkupLanguage other)
Construct a new MarkupLanguage given a new name and an existing MarkupLanguage.

Parameters:
name - - the name of the new MarkupLanguage
other - - the Markup Language to base this one upon
Method Detail

getName

public String getName()
Get the name of this Markup Language.

Specified by:
getName in interface MarkupLanguage
Returns:
name - the name associated with this markup language. This is used to determine where to load templates from ie 'html' templates are found in the 'html' directory.
See Also:
MarkupLanguage.getName()

toString

public String toString()
Name and locale.

Overrides:
toString in class Object
See Also:
Object.toString()

rendered

public String rendered(String s,
                       int limit)
Render a String in a MarkupLanguage specific way, limiting it's length.

Specified by:
rendered in interface MarkupLanguage
Parameters:
s - - the string to be rendered
limit - - the lenght to trim the string to
Returns:
- the String having been rendered in a MarkupLanguage specific way.
See Also:
MarkupLanguage.rendered(java.lang.String, int)

rendered

public String rendered(Field field,
                       int style,
                       int limit)
                throws TemplateEngineException
Render a Field Object in a MarkupLanguage specific way, returning a String. see org.melati.poem.DatePoemType#_stringOfCooked (java.lang.Object,org.melati.poem.PoemLocale, int)

Specified by:
rendered in interface MarkupLanguage
Parameters:
field - - the Field to be rendered
style - - a DateFormat style to format this Field.
limit - - the length to trim the rendered string to
Returns:
- the Field rendered as a String in a MarkupLanguage specific way.
Throws:
TemplateEngineException - - if there is a problem with the ServletTemplateEngine
See Also:
MarkupLanguage.rendered(org.melati.poem.Field, int, int)

rendered

public String rendered(Field field,
                       int style)
                throws TemplateEngineException
Render a Field Object in a MarkupLanguage specific way, returning a String. Defaults to a limit of 10,000,000.

Specified by:
rendered in interface MarkupLanguage
Parameters:
field - - the Field to be rendered
style - - a style to format this Field.
Returns:
- the Field rendered as a String in a MarkupLanguage specific way.
Throws:
TemplateEngineException - - if there is a problem with the ServletTemplateEngine
See Also:
MarkupLanguage.rendered(org.melati.poem.Field, int)

rendered

public String rendered(Object o)
Render an Object in a MarkupLanguage specific way, returning a String.

Specified by:
rendered in interface MarkupLanguage
Parameters:
o - - the Object to be rendered
Returns:
- the object rendered as a String in a MarkupLanguage specific way.
See Also:
MarkupLanguage.rendered(java.lang.Object)

renderedMarkup

public String renderedMarkup(String s)

Specified by:
renderedMarkup in interface MarkupLanguage
Parameters:
s - markup fragment to render
Returns:
fragment rendered with markup unchanged
See Also:
MarkupLanguage.renderedMarkup(java.lang.String)

render

protected void render(String s,
                      int limit,
                      MelatiWriter writer)
Render a String in a MarkupLanguage specific way, limiting it's length. Render to a supplied MelatiWriter.

Parameters:
s - - the string to be rendered
writer - - the MelatiWriter to render this String to
limit - - the length to trim the string to

render

protected abstract void render(String s,
                               MelatiWriter writer)
Render a String in a MarkupLanguage specific way to a supplied MelatiWriter.

Parameters:
s - - the string to be rendered
writer - - the MelatiWriter to render this String to

renderMarkup

protected abstract void renderMarkup(String s,
                                     MelatiWriter writer)
Render a markup fragment in a MarkupLanguage specific way to a supplied MelatiWriter.

Parameters:
s - - the fragment to be rendered
writer - - the MelatiWriter to render this String to

render

protected void render(Field field,
                      MelatiWriter writer)
Render a Field Object in a MarkupLanguage specific way, rendering to supplied MelatiWriter.

Parameters:
field - - the Field to be rendered
writer - - the MelatiWriter to render this Object to

render

protected void render(Field field,
                      int style,
                      int limit,
                      MelatiWriter writer)
Render a Field Object in a MarkupLanguage specific way, rendering to supplied MelatiWriter.

Parameters:
field - - the Field to be rendered
style - - a style to format this Field.
limit - - the length to trim the rendered string to
writer - - the MelatiWriter to render this Object to
See Also:
(java.lang.Object,org.melati.poem.PoemLocale, int)

renderedStart

public String renderedStart(Field field)
Render a Date Field Object in a MarkupLanguage specific way, returning a START Date format String.

Specified by:
renderedStart in interface MarkupLanguage
Parameters:
field - - the Field to be rendered
Returns:
- the Field rendered as a String in a MarkupLanguage specific way.
See Also:
MarkupLanguage.renderedStart(org.melati.poem.Field)

renderStart

protected void renderStart(Field field,
                           MelatiWriter writer)

render

protected void render(Object o)
Render an Object in a MarkupLanguage specific way, rendering to the MelatiWriter supplied by melati.getWriter().

Parameters:
o - - the Object to be rendered
Throws:
TemplateEngineException - - if there is a problem with the ServletTemplateEngine

render

protected void render(Object o,
                      MelatiWriter writer)
Render an Object in a MarkupLanguage specific way, rendering to a supplied Writer. NOTE The context always contains objects with the names melati, object and ml

Parameters:
o - - the Object to be rendered
writer - - the MelatiWriter to render this Object to

input

public String input(Field field)
             throws TemplateEngineException,
                    NotFoundException
Get an input widget for this Field.

Specified by:
input in interface MarkupLanguage
Parameters:
field - The Field
Returns:
The default input widget for the Field type
Throws:
NotFoundException - if template not found
TemplateEngineException
See Also:
MarkupLanguage.input(org.melati.poem.Field)

inputAs

public String inputAs(Field field,
                      String templetName)
               throws TemplateEngineException,
                      NotFoundException
Get an input widget for this Field defined by name.

Specified by:
inputAs in interface MarkupLanguage
Parameters:
field - The Field
templetName - the templet to use instead of the default
Returns:
The specified input widget for the Field type
Throws:
NotFoundException - if template not found
TemplateEngineException
See Also:
MarkupLanguage.inputAs(org.melati.poem.Field, java.lang.String)

searchInput

public String searchInput(Field field,
                          String nullValue)
                   throws TemplateEngineException,
                          NotFoundException
Get an input widget for this Field specifying the null value.

Specified by:
searchInput in interface MarkupLanguage
Parameters:
field - The Field
nullValue - the value to use for null for example in a dropdown.
Returns:
The default input widget for the Field type with a specified null value
Throws:
NotFoundException - if template not found
TemplateEngineException
See Also:
MarkupLanguage.searchInput(org.melati.poem.Field, java.lang.String)

input

protected String input(Field field,
                       String templetName,
                       String nullValue,
                       boolean overrideNullable)
                throws NotFoundException
Throws:
NotFoundException

expandTemplet

protected void expandTemplet(Template templet,
                             TemplateContext tc,
                             MelatiWriter out)
Interpolate a templet and write it out.

Parameters:
templet - Template to interpolate
tc - TemplateContext against which to instantiate variables
out - MelatiWriter to write results to


Copyright © 2000-2010 PanEris. All Rights Reserved.