Collaboration API Documentation

com.filenet.bso.api.collaboration
Class TextTemplate

java.lang.Object
  |
  +--com.filenet.bso.api.collaboration.TextTemplate
All Implemented Interfaces:
com.filenet.bso.api.collaboration.impl.templates.TemplateInclude

public class TextTemplate
extends java.lang.Object
implements com.filenet.bso.api.collaboration.impl.templates.TemplateInclude

The TextTemplate class uses a text template and a map of parameters, interprets the template looking for special template instructions, and returns either a resulting input stream or a string.

To use it, use code like this

      // set up parameters for template

      HashMap params = new HashMap();
      params.put("doc", doc);
      params.put("folder", folder);
      params.put("time", time());

      TextTemplate tt = new TextTemplate(store, null, null);

      // interpret the template

      InputStream in = tt.getStream("mytemplate", params);
 

The application ID and time zone information are not required; if not available, the application ID is determined from the store's session and the time zone from either the application ID, or, if not found, from the server. Normally, the application ID affects which localized template file is selected and both the locale and the time zone affect some formatting, but certain installations might all be in the same locale and time zone or the template might be written in such a way that this is not significant.


Constructor Summary
TextTemplate(com.filenet.wcm.api.ObjectStore store, java.lang.String applicationID, java.util.TimeZone timeZone)
          Construct a TextTemplate instance.
 
Method Summary
 java.lang.String getApplicationID()
          Return the current application ID.
 byte[] getInclude(java.lang.String name, java.lang.String applicationID)
          Return a byte array representing the text of a template include.
 boolean getIsDebug()
          Return whether debugging mode is currently set or not.
 com.filenet.wcm.api.TransportInputStream getStream(int templateCode, java.util.Map parameters)
          Return a JavaAPI TransportInputStream representing the interpretation of a template given its template code and parameters.
 com.filenet.wcm.api.TransportInputStream getStream(java.lang.String templateName, java.util.Map parameters)
           
 java.lang.String getString(int templateCode, java.util.Map parameters)
           
 java.lang.String getString(java.lang.String templateName, java.util.Map parameters)
           
 void setApplicationID(java.lang.String applicationID)
          Set the application ID, which is used in looking up the correct template and also to find "localized" versions of the same application for locale lookups.
 void setIsDebug(boolean isDebug)
          Set or clear debugging mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTemplate

public TextTemplate(com.filenet.wcm.api.ObjectStore store,
                    java.lang.String applicationID,
                    java.util.TimeZone timeZone)
Construct a TextTemplate instance.
Parameters:
store - the object store where collaboration email information can be found
applicationID - the name of the application. This will also be used to find different localized versions of the same application. This may be null, in which case the appID of the store's JavaAPI session is used instead.
Method Detail

getApplicationID

public java.lang.String getApplicationID()
Return the current application ID.
Returns:
the application ID

setApplicationID

public void setApplicationID(java.lang.String applicationID)
Set the application ID, which is used in looking up the correct template and also to find "localized" versions of the same application for locale lookups. This also gets the group of this appID as well as the default time zone. If the appID is null, then the appID of the object store's JavaAPI session is used instead.
Parameters:
applicationID - the new application ID to use

getIsDebug

public boolean getIsDebug()
Return whether debugging mode is currently set or not.
Returns:
true if in debugging mode, false otherwise

setIsDebug

public void setIsDebug(boolean isDebug)
Set or clear debugging mode.
Parameters:
isDebug - if true, sets debugging mode; if false, resets it

getInclude

public byte[] getInclude(java.lang.String name,
                         java.lang.String applicationID)
Return a byte array representing the text of a template include. This method is a callback, used whenever the template encounters an {$include:"xyz.txt"} command.
Specified by:
getInclude in interface com.filenet.bso.api.collaboration.impl.templates.TemplateInclude
Parameters:
name - the name of the include/template file
applicationID - the name of the application (used during template lookup)
Returns:
the byte array for the template include

getStream

public com.filenet.wcm.api.TransportInputStream getStream(int templateCode,
                                                          java.util.Map parameters)
                                                   throws TemplateException
Return a JavaAPI TransportInputStream representing the interpretation of a template given its template code and parameters.
Parameters:
templateCode - the code for this template
parameters - values to use when interpreting the template
Returns:
a stream generated by interpreting the template
Throws:
TemplateException -  

getStream

public com.filenet.wcm.api.TransportInputStream getStream(java.lang.String templateName,
                                                          java.util.Map parameters)
                                                   throws TemplateException

getString

public java.lang.String getString(int templateCode,
                                  java.util.Map parameters)

getString

public java.lang.String getString(java.lang.String templateName,
                                  java.util.Map parameters)

Collaboration API Documentation

Copyright © 2002 - 2004 FileNet Corporation. All rights reserved.