org.duelengine.duel
Class DuelView

java.lang.Object
  extended by org.duelengine.duel.DuelView
Direct Known Subclasses:
DuelPart

public abstract class DuelView
extends Object

The skeletal implementation of DUEL view runtime. Inherently thread-safe as contains no mutable instance data.


Constructor Summary
protected DuelView()
           
protected DuelView(DuelPart... parts)
           
 
Method Summary
protected  void addPart(DuelPart part)
          Sets the partial view for a named area
protected  boolean coerceEqual(Object a, Object b)
          Coerces objects before performing equality test
protected  void dataEncode(DuelContext context, Object data, int depth)
          Emits data object as a graph of JavaScript literals
protected  double echo(double value, double ignore)
          A work-around for dynamic post-inc/dec operator semantics
protected  boolean equal(Object a, Object b)
          Performs equality test
protected  Object getExtra(DuelContext context, String ident)
           
protected  Object getProperty(Object data, Object property)
          Retrieves the value of a property from the data object
protected  boolean hasExtras(DuelContext context, String... idents)
           
protected  void htmlEncode(DuelContext context, Object value)
          Ensures the value is properly encoded as HTML text
protected  void init()
          Initialization of parts and child-views
protected  Object LogicalAND(Object left, Object right)
           
protected  Object LogicalOR(Object left, Object right)
           
protected  String nextID(DuelContext context)
           
protected  void putExtra(DuelContext context, String ident, Object value)
           
 void render(Appendable output)
          Renders the view to the output
 void render(Appendable output, Object data)
          Binds the view to the data and renders the view to the output
 void render(DuelContext context)
          Binds the view to any data and renders the view to the output
protected abstract  void render(DuelContext context, Object data, int index, int count, String key)
          The entry point into the view tree
protected  void renderPart(DuelContext context, String partName, Object data, int index, int count, String key)
          Renders a named partial view
protected  void renderView(DuelContext context, DuelView view, Object data, int index, int count, String key)
          Allows one view to render another
protected  void setProperty(Object data, Object property, Object value)
          Stores the value for a property of the data object
protected  String transformURL(DuelContext context, String url)
          Allows view to intercept and transform URLs within element attributes
protected  void write(DuelContext context, char value)
          Writes the value to the output
protected  void write(DuelContext context, Object value)
          Writes the value to the output
protected  void write(DuelContext context, String value)
          Writes the value to the output
protected  void writeExtras(DuelContext context, boolean needsTags)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DuelView

protected DuelView()

DuelView

protected DuelView(DuelPart... parts)
Method Detail

init

protected void init()
Initialization of parts and child-views


render

public void render(Appendable output)
            throws IOException
Renders the view to the output

Parameters:
output -
Throws:
IOException

render

public void render(Appendable output,
                   Object data)
            throws IOException
Binds the view to the data and renders the view to the output

Parameters:
output -
data -
Throws:
IOException

render

public void render(DuelContext context)
            throws IOException
Binds the view to any data and renders the view to the output

Parameters:
context -
Throws:
IOException

render

protected abstract void render(DuelContext context,
                               Object data,
                               int index,
                               int count,
                               String key)
                        throws IOException
The entry point into the view tree

Parameters:
context -
data -
index -
count -
key -
Throws:
IOException

addPart

protected void addPart(DuelPart part)
Sets the partial view for a named area

Parameters:
part -

renderPart

protected void renderPart(DuelContext context,
                          String partName,
                          Object data,
                          int index,
                          int count,
                          String key)
                   throws IOException
Renders a named partial view

Parameters:
partName -
context -
data -
index -
count -
key -
Throws:
IOException

renderView

protected void renderView(DuelContext context,
                          DuelView view,
                          Object data,
                          int index,
                          int count,
                          String key)
                   throws IOException
Allows one view to render another

Parameters:
view -
context -
data -
index -
count -
key -
Throws:
IOException

write

protected void write(DuelContext context,
                     Object value)
              throws IOException
Writes the value to the output

Parameters:
context -
value -
Throws:
IOException

write

protected void write(DuelContext context,
                     char value)
              throws IOException
Writes the value to the output

Parameters:
context -
value -
Throws:
IOException

write

protected void write(DuelContext context,
                     String value)
              throws IOException
Writes the value to the output

Parameters:
context -
value -
Throws:
IOException

htmlEncode

protected void htmlEncode(DuelContext context,
                          Object value)
                   throws IOException
Ensures the value is properly encoded as HTML text

Parameters:
context -
value -
Throws:
IOException

dataEncode

protected void dataEncode(DuelContext context,
                          Object data,
                          int depth)
                   throws IOException
Emits data object as a graph of JavaScript literals

Parameters:
context -
data -
depth -
Throws:
IOException

getExtra

protected Object getExtra(DuelContext context,
                          String ident)

putExtra

protected void putExtra(DuelContext context,
                        String ident,
                        Object value)

hasExtras

protected boolean hasExtras(DuelContext context,
                            String... idents)

writeExtras

protected void writeExtras(DuelContext context,
                           boolean needsTags)
                    throws IOException
Throws:
IOException

nextID

protected String nextID(DuelContext context)

transformURL

protected String transformURL(DuelContext context,
                              String url)
Allows view to intercept and transform URLs within element attributes

Parameters:
url - URL
Returns:
transformed URL

getProperty

protected Object getProperty(Object data,
                             Object property)
Retrieves the value of a property from the data object

Parameters:
data -
Returns:

setProperty

protected void setProperty(Object data,
                           Object property,
                           Object value)
Stores the value for a property of the data object

Parameters:
data -

equal

protected boolean equal(Object a,
                        Object b)
Performs equality test

Parameters:
a -
b -
Returns:

coerceEqual

protected boolean coerceEqual(Object a,
                              Object b)
Coerces objects before performing equality test

Parameters:
a -
b -
Returns:

LogicalOR

protected Object LogicalOR(Object left,
                           Object right)

LogicalAND

protected Object LogicalAND(Object left,
                            Object right)

echo

protected double echo(double value,
                      double ignore)
A work-around for dynamic post-inc/dec operator semantics

Parameters:
value -
ignore -
Returns:


Copyright © 2011. All Rights Reserved.