com.google.clearsilver.jsilver.data
Class AbstractData

java.lang.Object
  extended by com.google.clearsilver.jsilver.data.AbstractData
All Implemented Interfaces:
Data
Direct Known Subclasses:
NestedMapData

public abstract class AbstractData
extends Object
implements Data

This class is meant to hold implementation common to different instances of Data interface.


Field Summary
protected  EscapeMode escapeMode
           
 
Constructor Summary
AbstractData()
           
 
Method Summary
 boolean getBooleanValue()
          Returns the boolean value of this HDF node, or false if this node has no value.
 boolean getBooleanValue(String path)
          Retrieves the value at the specified path in this HDF node's subtree.
 EscapeMode getEscapeMode()
          Indicates the escaping, if any that was applied to this HDF node.
 int getIntValue()
          Returns the integer value of this HDF node, or 0 if this node has no value.
 int getIntValue(String path)
          Retrieves the value at the specified path in this HDF node's subtree.
 int getIntValue(String path, int defaultValue)
          Retrieves the integer value at the specified path in this HDF node's subtree.
 String getValue(String path)
          Retrieves the value at the specified path in this HDF node's subtree.
 String getValue(String path, String defaultValue)
          Retrieves the value at the specified path in this HDF node's subtree.
 void optimize()
          Optimizes the Data structure for performance.
 void setEscapeMode(EscapeMode mode)
          Set the escaping that was applied to this HDF node.
 void setValue(String path, String value)
          Sets the value at the specified path in this HDF node's subtree.
 String toString()
           
 void toString(StringBuilder out, int indent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.clearsilver.jsilver.data.Data
copy, copy, createChild, getAttribute, getAttributeCount, getAttributes, getChild, getChildCount, getChildren, getFullPath, getName, getNextSibling, getParent, getRoot, getSymlink, getValue, hasAttribute, isFirstSibling, isLastSibling, removeTree, setAttribute, setSymlink, setSymlink, setSymlink, setValue, write
 

Field Detail

escapeMode

protected EscapeMode escapeMode
Constructor Detail

AbstractData

public AbstractData()
Method Detail

getIntValue

public int getIntValue()
Description copied from interface: Data
Returns the integer value of this HDF node, or 0 if this node has no value. Note: The fact that this method returns a primitive type, rather than an Integer means that its value cannot be used to determine whether the data node exists or not. Note also that, when implementing a Data object that caches these values, care must be taken to ensure that a node with an integer value of '0' is not mistaken for a non-existent node.

Specified by:
getIntValue in interface Data

getBooleanValue

public boolean getBooleanValue()
Description copied from interface: Data
Returns the boolean value of this HDF node, or false if this node has no value. Note: The fact that this method returns a primitive type, rather than a Boolean means that its value cannot be used to determine whether the data node exists or not. Note also that, when implementing a Data object that caches these values, care must be taken to ensure that a node with a boolean value of 'false' is not mistaken for a non-existent node.

Specified by:
getBooleanValue in interface Data

getValue

public String getValue(String path,
                       String defaultValue)
Retrieves the value at the specified path in this HDF node's subtree. Use getValue(String) in preference to ensure ClearSilver compatibility.

Specified by:
getValue in interface Data

getIntValue

public int getIntValue(String path,
                       int defaultValue)
Retrieves the integer value at the specified path in this HDF node's subtree. If the value does not exist, or cannot be converted to an integer, default_value will be returned. Use getValue(String) in preference to ensure ClearSilver compatibility.

Specified by:
getIntValue in interface Data

getValue

public String getValue(String path)
Retrieves the value at the specified path in this HDF node's subtree. If not found, returns null.

Specified by:
getValue in interface Data

getIntValue

public int getIntValue(String path)
Retrieves the value at the specified path in this HDF node's subtree. If not found or invalid, returns 0.

Specified by:
getIntValue in interface Data

getBooleanValue

public boolean getBooleanValue(String path)
Retrieves the value at the specified path in this HDF node's subtree. If not found or invalid, returns false.

Specified by:
getBooleanValue in interface Data

setValue

public void setValue(String path,
                     String value)
Sets the value at the specified path in this HDF node's subtree.

Specified by:
setValue in interface Data

toString

public String toString()
Specified by:
toString in interface Data
Overrides:
toString in class Object

toString

public void toString(StringBuilder out,
                     int indent)
Specified by:
toString in interface Data

optimize

public void optimize()
Description copied from interface: Data
Optimizes the Data structure for performance. This is a somewhat expensive operation that should improve CPU and/or memory usage for long-lived Data objects. For example, it may internalize all Strings to reduce redundant copies.

Specified by:
optimize in interface Data

setEscapeMode

public void setEscapeMode(EscapeMode mode)
Description copied from interface: Data
Set the escaping that was applied to this HDF node. This method may be called by the template renderer, for instance, when a "set" command sets the node to a constant string. It may also be explicitly called if populating the HDF with pre-escaped or trusted values.

Specified by:
setEscapeMode in interface Data
See Also:
Data.getEscapeMode()

getEscapeMode

public EscapeMode getEscapeMode()
Description copied from interface: Data
Indicates the escaping, if any that was applied to this HDF node.

Specified by:
getEscapeMode in interface Data
Returns:
EscapeMode that was applied to this node's value. EscapeMode.ESCAPE_NONE if the value is not escaped. EscapeMode.ESCAPE_IS_CONSTANT if value is a string or numeric literal.
See Also:
Data.setEscapeMode(com.google.clearsilver.jsilver.autoescape.EscapeMode), EscapeMode


Copyright © 2010-2012 Google. All Rights Reserved.