org.clearsilver
Interface HDF

All Superinterfaces:
Closeable
All Known Implementing Classes:
DelegatedHdf, JHdf, JniHdf

public interface HDF
extends Closeable

This interface establishes the API for an HDF data structure used by Clearsilver templates when rendering content.


Method Summary
 boolean belongsToSameRoot(HDF hdf)
          Checks if the given hdf object belongs to the same root HDF object as this one.
 void close()
          Clean up CS object state.
 void copy(String hdfpath, HDF src)
          Deep copy of the contents of the source HDF structure to this HDF starting at the specified HDF path node.
 String dump()
          Generates a string representing the content of the HDF tree rooted at this node.
 void exportDate(String hdfName, String tz, int tt)
          Export a date to a clearsilver tree using a specified timezone
 void exportDate(String hdfName, TimeZone timeZone, Date date)
          Export a date to a clearsilver tree using a specified timezone
 HDF getChild(String hdfpath)
          Retrieves the HDF for the first child of the root of the subtree at hdfpath, or null if no child exists of that path or if the path doesn't exist.
 CSFileLoader getFileLoader()
          Get the file loader in use, if any.
 int getIntValue(String hdfName, int defaultValue)
          Retrieves the integer value at the specified path in this HDF node's subtree.
 HDF getObj(String hdfpath)
          Retrieves the HDF object that is the root of the subtree at hdfpath, or null if no object exists at that path.
 HDF getOrCreateObj(String hdfpath)
          Retrieves the HDF object that is the root of the subtree at hdfpath, create the subtree if it doesn't exist
 HDF getRootObj()
          Return the root of the tree where the current node lies.
 String getValue(String hdfName, String defaultValue)
          Retrieves the value at the specified path in this HDF node's subtree.
 HDF objChild()
          Returns the child of this HDF node, or null if there is no child.
 String objName()
          Returns the name of this HDF node.
 HDF objNext()
          Returns the child of this HDF node, or null if there is no child.
 String objValue()
          Returns the value of this HDF node, or null if this node has no value.
 boolean readFile(String filename)
          Loads the contents of the specified HDF file from disk into the current HDF object.
 boolean readString(String data)
          Parses/loads the contents of the given string as HDF into the current HDF object.
 void removeTree(String hdfName)
          Remove the specified subtree.
 void setFileLoader(CSFileLoader fileLoader)
          Set the CS file loader to use
 void setSymLink(String hdfNameSrc, String hdfNameDest)
          Links the src hdf name to the dest.
 void setValue(String hdfName, String value)
          Sets the value at the specified path in this HDF node's subtree.
 boolean writeFile(String filename)
          Serializes HDF contents to a file (readable by readFile)
 String writeString()
          Serializes HDF contents to a string (readable by readString)
 

Method Detail

close

void close()
Clean up CS object state.

Specified by:
close in interface Closeable

readFile

boolean readFile(String filename)
                 throws IOException
Loads the contents of the specified HDF file from disk into the current HDF object. The loaded contents are merged with the existing contents.

Throws:
IOException

getFileLoader

CSFileLoader getFileLoader()
Get the file loader in use, if any.

Returns:
the file loader in use.

setFileLoader

void setFileLoader(CSFileLoader fileLoader)
Set the CS file loader to use

Parameters:
fileLoader - the file loader that should be used.

writeFile

boolean writeFile(String filename)
                  throws IOException
Serializes HDF contents to a file (readable by readFile)

Throws:
IOException

readString

boolean readString(String data)
Parses/loads the contents of the given string as HDF into the current HDF object. The loaded contents are merged with the existing contents.


writeString

String writeString()
Serializes HDF contents to a string (readable by readString)


getIntValue

int getIntValue(String hdfName,
                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.


getValue

String getValue(String hdfName,
                String defaultValue)
Retrieves the value at the specified path in this HDF node's subtree.


setValue

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


removeTree

void removeTree(String hdfName)
Remove the specified subtree.


setSymLink

void setSymLink(String hdfNameSrc,
                String hdfNameDest)
Links the src hdf name to the dest.


exportDate

void exportDate(String hdfName,
                TimeZone timeZone,
                Date date)
Export a date to a clearsilver tree using a specified timezone


exportDate

void exportDate(String hdfName,
                String tz,
                int tt)
Export a date to a clearsilver tree using a specified timezone


getObj

HDF getObj(String hdfpath)
Retrieves the HDF object that is the root of the subtree at hdfpath, or null if no object exists at that path.


getChild

HDF getChild(String hdfpath)
Retrieves the HDF for the first child of the root of the subtree at hdfpath, or null if no child exists of that path or if the path doesn't exist.


getRootObj

HDF getRootObj()
Return the root of the tree where the current node lies. If the current node is the root, return this. Implementations may not necessarily return the same instance of HDF every time. Use belongsToSameRoot(HDF) to check if two HDFs belong to the same root.


belongsToSameRoot

boolean belongsToSameRoot(HDF hdf)
Checks if the given hdf object belongs to the same root HDF object as this one.

Parameters:
hdf - The hdf object to compare to.
Throws:
IllegalArgumentException - If the supplied hdf object is from a different implementation (e.g. mixing JNI and jsilver).

getOrCreateObj

HDF getOrCreateObj(String hdfpath)
Retrieves the HDF object that is the root of the subtree at hdfpath, create the subtree if it doesn't exist


objName

String objName()
Returns the name of this HDF node. The root node has no name, so calling this on the root node will return null.


objValue

String objValue()
Returns the value of this HDF node, or null if this node has no value. Every node in the tree can have a value, a child, and a next peer.


objChild

HDF objChild()
Returns the child of this HDF node, or null if there is no child. Use this in conjunction with objNext to walk the HDF tree. Every node in the tree can have a value, a child, and a next peer.


objNext

HDF objNext()
Returns the child of this HDF node, or null if there is no child. Use this in conjunction with objNext to walk the HDF tree. Every node in the tree can have a value, a child, and a next peer.


copy

void copy(String hdfpath,
          HDF src)
Deep copy of the contents of the source HDF structure to this HDF starting at the specified HDF path node.

This method copies over the attributes and value of the node and recurses through all the children of the source node. Any symlink in the source node becomes a symlink in the copy.

Parameters:
hdfpath - the node within this HDF where the source structure should be copied to.
src - the source HDF to copy over.

dump

String dump()
Generates a string representing the content of the HDF tree rooted at this node.



Copyright © 2010-2012 Google. All Rights Reserved.